瀏覽代碼

Improve detection of gamepads on Linux

Some devices (Nintendo Switch Right Joy-Con) report only a right stick.
Mai Lavelle 3 年之前
父節點
當前提交
b966ca6167
共有 1 個文件被更改,包括 3 次插入2 次删除
  1. 3 2
      platform/linuxbsd/joypad_linux.cpp

+ 3 - 2
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;
 		}