You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-10 13:00:37 +00:00
Prevent double input events on gamepad when running through steam input
During GDC and general testing on Steam Deck units, we found that single gamepads would often register inputs twice under certain circumstances. This was caused by SteamInput creating a new virtual device, which Godot registers as a second gamepad. This resulted in two gamepad devices reporting the same button presses, often leading to buggy input response on games with no multi-device logic and other-wise could cause intended Steam rebindings to not work as intended (for example, swapping o and x on a playstation pad if that feature isn't supported by the game.) SDL gets around this by taking in a list of devices that are to be ignored. When valve sees a controller that wants to be rebound via SteamInput, they push a new VID/PID entry onto the environment variable `SDL_GAMECONTROLLER_IGNORE_DEVICES` for the original gamepad so that all game inputs can be read from the virtual gamepad instead. This leverages the same logic as we are already using SDL gamepad related HID mappings.
This commit is contained in:
@@ -391,6 +391,16 @@ void JoypadLinux::open_joypad(const char *p_path) {
|
||||
return;
|
||||
}
|
||||
|
||||
uint16_t vendor = BSWAP16(inpid.vendor);
|
||||
uint16_t product = BSWAP16(inpid.product);
|
||||
uint16_t version = BSWAP16(inpid.version);
|
||||
|
||||
if (input->should_ignore_device(vendor, product)) {
|
||||
// This can be true in cases where Steam is passing information into the game to ignore
|
||||
// original gamepads when using virtual rebindings (See SteamInput).
|
||||
return;
|
||||
}
|
||||
|
||||
MutexLock lock(joypads_mutex[joy_num]);
|
||||
Joypad &joypad = joypads[joy_num];
|
||||
joypad.reset();
|
||||
@@ -399,10 +409,6 @@ void JoypadLinux::open_joypad(const char *p_path) {
|
||||
setup_joypad_properties(joypad);
|
||||
sprintf(uid, "%04x%04x", BSWAP16(inpid.bustype), 0);
|
||||
if (inpid.vendor && inpid.product && inpid.version) {
|
||||
uint16_t vendor = BSWAP16(inpid.vendor);
|
||||
uint16_t product = BSWAP16(inpid.product);
|
||||
uint16_t version = BSWAP16(inpid.version);
|
||||
|
||||
sprintf(uid + String(uid).length(), "%04x%04x%04x%04x%04x%04x", vendor, 0, product, 0, version, 0);
|
||||
input->joy_connection_changed(joy_num, true, name, uid);
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user