mirror of
https://github.com/spice2x/spice2x.github.io.git
synced 2026-08-01 22:30:42 -07:00
rawinput: reimplement analog relative mode and delay (#674)
## Link to GitHub Issue or related Pull Request, if one exists #181 ## Description of change Implement analog relative mode and delay option using a new millisecond-based algorithm. ## Testing WIP
This commit is contained in:
@@ -783,42 +783,7 @@ namespace games::iidx {
|
||||
}
|
||||
|
||||
// return higher 8 bit
|
||||
uint8_t result = (uint8_t) (ret_value >> 2);
|
||||
|
||||
// delay
|
||||
if ((player == 0 && TT_DELAY_P1 > 0) ||
|
||||
(player == 1 && TT_DELAY_P2 > 0)) {
|
||||
|
||||
static std::queue<std::pair<double, uint8_t>> delay_queue[2];
|
||||
auto &queue = delay_queue[player];
|
||||
|
||||
const auto max_delta_ms =
|
||||
static_cast<double>((player == 0) ? TT_DELAY_P1 : TT_DELAY_P2);
|
||||
|
||||
// always push a new value
|
||||
const auto now = get_performance_milliseconds();
|
||||
queue.push(std::make_pair(now, result));
|
||||
|
||||
// drain the queue down to reasonable length to prevent unconstrained growth
|
||||
// this would accommodate 1 second at ~1000Hz
|
||||
// (in reality all three iidx I/O emulation runs well under 500Hz)
|
||||
while (queue.size() > 1024) {
|
||||
queue.pop();
|
||||
}
|
||||
|
||||
// pop until we find one that falls just under the time threshold
|
||||
while (!queue.empty()) {
|
||||
const auto delta_t = now - queue.front().first;
|
||||
if (delta_t <= max_delta_ms) {
|
||||
break;
|
||||
}
|
||||
queue.pop();
|
||||
}
|
||||
|
||||
result = queue.front().second;
|
||||
}
|
||||
|
||||
return result;
|
||||
return (uint8_t)(ret_value >> 2);
|
||||
}
|
||||
|
||||
unsigned char get_slider(uint8_t slider) {
|
||||
|
||||
@@ -31,8 +31,6 @@ namespace games::iidx {
|
||||
extern bool NATIVE_TOUCH;
|
||||
extern std::optional<std::string> SOUND_OUTPUT_DEVICE;
|
||||
extern std::optional<std::string> ASIO_DRIVER;
|
||||
extern uint32_t TT_DELAY_P1;
|
||||
extern uint32_t TT_DELAY_P2;
|
||||
extern uint8_t DIGITAL_TT_SENS;
|
||||
extern std::optional<std::string> SUBSCREEN_OVERLAY_SIZE;
|
||||
extern std::optional<std::string> SCREEN_MODE;
|
||||
|
||||
Reference in New Issue
Block a user