mirror of
https://github.com/godotengine/godot.git
synced 2026-01-08 00:25:01 +03:00
[3.x] Prevent double input events on gamepad when running through steam input #79706
Co-authored-by: Eoin O'Neill <eoinoneill1991@gmail.com>
This commit is contained in:
@@ -858,6 +858,27 @@ InputDefault::InputDefault() {
|
||||
parse_mapping(entries[i]);
|
||||
}
|
||||
}
|
||||
|
||||
String env_ignore_devices = OS::get_singleton()->get_environment("SDL_GAMECONTROLLER_IGNORE_DEVICES");
|
||||
if (!env_ignore_devices.empty()) {
|
||||
Vector<String> entries = env_ignore_devices.split(",");
|
||||
for (int i = 0; i < entries.size(); i++) {
|
||||
Vector<String> vid_pid = entries[i].split("/");
|
||||
|
||||
if (vid_pid.size() < 2) {
|
||||
continue;
|
||||
}
|
||||
|
||||
print_verbose(vformat("Device Ignored -- Vendor: %s Product: %s", vid_pid[0], vid_pid[1]));
|
||||
const uint16_t vid_unswapped = vid_pid[0].hex_to_int();
|
||||
const uint16_t pid_unswapped = vid_pid[1].hex_to_int();
|
||||
const uint16_t vid = BSWAP16(vid_unswapped);
|
||||
const uint16_t pid = BSWAP16(pid_unswapped);
|
||||
|
||||
uint32_t full_id = (((uint32_t)vid) << 16) | ((uint16_t)pid);
|
||||
ignored_device_ids.insert(full_id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void InputDefault::joy_button(int p_device, int p_button, bool p_pressed) {
|
||||
@@ -1350,6 +1371,11 @@ String InputDefault::get_joy_guid(int p_device) const {
|
||||
return OS::get_singleton()->get_joy_guid(p_device);
|
||||
}
|
||||
|
||||
bool InputDefault::should_ignore_device(int p_vendor_id, int p_product_id) const {
|
||||
uint32_t full_id = (((uint32_t)p_vendor_id) << 16) | ((uint16_t)p_product_id);
|
||||
return ignored_device_ids.has(full_id);
|
||||
}
|
||||
|
||||
//platforms that use the remapping system can override and call to these ones
|
||||
bool InputDefault::is_joy_mapped(int p_device) {
|
||||
if (joy_names.has(p_device)) {
|
||||
|
||||
Reference in New Issue
Block a user