1
0
Fork 0

Fix joystick button off-by-one error (#16037)

This commit is contained in:
Ryan 2022-01-26 00:40:55 +11:00 committed by GitHub
parent 6cc4e32e61
commit 3e0ee6fb74
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -28,10 +28,11 @@ bool process_joystick_buttons(uint16_t keycode, keyrecord_t *record) {
if (keycode < JS_BUTTON0 || keycode > JS_BUTTON_MAX) { if (keycode < JS_BUTTON0 || keycode > JS_BUTTON_MAX) {
return true; return true;
} else { } else {
uint8_t button_idx = (keycode - JS_BUTTON0);
if (record->event.pressed) { if (record->event.pressed) {
joystick_status.buttons[(keycode - JS_BUTTON0) / 8] |= 1 << (keycode % 8); joystick_status.buttons[button_idx / 8] |= 1 << (button_idx % 8);
} else { } else {
joystick_status.buttons[(keycode - JS_BUTTON0) / 8] &= ~(1 << (keycode % 8)); joystick_status.buttons[button_idx / 8] &= ~(1 << (button_idx % 8));
} }
joystick_status.status |= JS_UPDATED; joystick_status.status |= JS_UPDATED;