Add a throttling setting to button/key (not axis) inputs #12205
Replies: 1 comment 2 replies
-
5 ms is non-negligible for many types of games (that's almost 1/3rd of a frame at 60 FPS), so I'd prefer not. Input lag in modern games is high enough as it is 🙁 However, for this use case, wouldn't throttling instead of debouncing resolve the issue? With throttling, you acknowledge the first input but discard the second one that occurs at nearly the same time. A throttle interval of 5 ms is perfectly acceptable here, as humans can only press buttons so many times in a second. (This wouldn't affect anyone unless they manage to press a button 200 times a second, which is completely impossible.) |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
The Problem
I have set
ui_*
input actions to both keyboard and gamepad main axis as well as d-pad buttons:See image: Input map settings
I noticed I'm having a controller-specific bouncing issue e.g. when navigating the UI focus through d-pad buttons.
Analog works fine, but D-pad works in one controller but another has bouncing - it moves twice. The d-pad on this controller (it's actually a generic-brand GameCube adapter) sends both button inputs and 7th/8th axes, but as you see these axes aren't assigned, so it can't be this. It seems to be a bouncing issue.
I always get 2 inputs consistently, it's not random. Delay in my case seems to be about 1ms or less:
Example output of
prints(direction, Time.get_ticks_usec())
when alternating left/right and up/downWhy not a GDScript solution?
While I could try to implement a throttling scripting solution for specific code handling input, it wouldn't help with things like the inbuilt way of navigating the UI focus through buttons. Unless there is a way I'm unaware of to intercept every input event and de-duplicate it in a way that affects native UI controls as well?
In any case, even if I can do it though some Autoload node, this is generic enough that all projects would benefit from it, so I think it should be in core, handled at a more low-level code in the engine.
Proposed Solution
I'm aware of #11267, but this is different; I'd like a throttling solution on the input level.
For example, it could be implemented as:
In either case you would set the amount of milliseconds or microseconds to ignore repeated input. And (1) and (2) should be configurable from script too, of course, so games can have UI for it if desired.
I'd suggest some sensible non-zero default for it of a humanly impossible low value (e.g. 5000μs = 5ms seems fine?), so it doesn't impact games much. Or if the per-action default is zero, there should be at least a global minimum setting as well.
EDIT: Btw, I'm not even sure "bouncing" is the proper term here, as I'm not even getting release events between both presses:
Bouncing/throttling intervals aside, it's already weird that a controller button can at all send 2 identical non-echo consecutive press events without requiring a release event in-between (and 2 release without a press in-between). So another option is blocking those repeated ones that don't change "state" anyway even without a setting, at least for short repeated intervals of exact duplicate button actions.
I'm opening this as discussion, sorry if it should've been an issue instead.
Beta Was this translation helpful? Give feedback.
All reactions