From b966ca6167beefc470c3469665200b542b1ea58a Mon Sep 17 00:00:00 2001 From: Mai Lavelle Date: Thu, 3 Feb 2022 22:56:43 -0500 Subject: Improve detection of gamepads on Linux Some devices (Nintendo Switch Right Joy-Con) report only a right stick. --- platform/linuxbsd/joypad_linux.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/platform/linuxbsd/joypad_linux.cpp b/platform/linuxbsd/joypad_linux.cpp index 5eda42fea6..8e963238e3 100644 --- a/platform/linuxbsd/joypad_linux.cpp +++ b/platform/linuxbsd/joypad_linux.cpp @@ -333,8 +333,9 @@ void JoypadLinux::open_joypad(const char *p_path) { } // Check if the device supports basic gamepad events - if (!(test_bit(EV_KEY, evbit) && test_bit(EV_ABS, evbit) && - test_bit(ABS_X, absbit) && test_bit(ABS_Y, absbit))) { + bool has_abs_left = (test_bit(ABS_X, absbit) && test_bit(ABS_Y, absbit)); + bool has_abs_right = (test_bit(ABS_RX, absbit) && test_bit(ABS_RY, absbit)); + if (!(test_bit(EV_KEY, evbit) && test_bit(EV_ABS, evbit) && (has_abs_left || has_abs_right))) { close(fd); return; } -- cgit v1.2.3