Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions platform/x11/joypad_linux.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -330,16 +330,16 @@ void JoypadLinux::open_joypad(const char *p_path) {
return;
}

//check if the device supports basic gamepad events, prevents certain keyboards from
//being detected as joypads
if (!(test_bit(EV_KEY, evbit) && test_bit(EV_ABS, evbit) &&
(test_bit(ABS_X, absbit) || test_bit(ABS_Y, absbit) || test_bit(ABS_HAT0X, absbit) ||
test_bit(ABS_GAS, absbit) || test_bit(ABS_RUDDER, absbit)) &&
(test_bit(BTN_A, keybit) || test_bit(BTN_THUMBL, keybit) ||
test_bit(BTN_TRIGGER, keybit) || test_bit(BTN_1, keybit))) &&
!(test_bit(EV_ABS, evbit) &&
test_bit(ABS_X, absbit) && test_bit(ABS_Y, absbit) &&
test_bit(ABS_RX, absbit) && test_bit(ABS_RY, absbit))) {
// Check if the device supports basic gamepad events and not non-joystick events
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// Check if the device supports basic gamepad events and not non-joystick events
// Check if the device supports basic gamepad events and not non-joystick events.

Per the comment style.

bool has_key = test_bit(EV_KEY, evbit);
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));
bool has_dpad = test_bit(ABS_HAT0X, absbit) || test_bit(BTN_DPAD_DOWN, keybit);
bool has_direction_input = has_abs_left || has_abs_right || has_dpad;
bool has_pointing_capability = test_bit(BTN_STYLUS, keybit) || test_bit(BTN_TOOL_PEN, keybit)
|| test_bit(BTN_TOOL_FINGER, keybit) || test_bit(BTN_LEFT, keybit) || test_bit(BTN_TOUCH, keybit);
bool is_gamepad = has_key && has_direction_input && !has_pointing_capability;
if (!is_gamepad) {
close(fd);
return;
}
Expand Down