diff options
author | Ryan <fauxpark@gmail.com> | 2022-01-26 00:40:55 +1100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-01-25 13:40:55 +0000 |
commit | 3e0ee6fb74e125d14ac22c922d80def4649f6784 (patch) | |
tree | e661406000f2d0059d5983904462f515b15ed58c /quantum/process_keycode | |
parent | 6cc4e32e61a275a624061fd9be643973476cad9c (diff) |
Fix joystick button off-by-one error (#16037)
Diffstat (limited to 'quantum/process_keycode')
-rw-r--r-- | quantum/process_keycode/process_joystick.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/quantum/process_keycode/process_joystick.c b/quantum/process_keycode/process_joystick.c index 3ffaf42bf8..fa9c2c1dbc 100644 --- a/quantum/process_keycode/process_joystick.c +++ b/quantum/process_keycode/process_joystick.c @@ -28,10 +28,11 @@ bool process_joystick_buttons(uint16_t keycode, keyrecord_t *record) { if (keycode < JS_BUTTON0 || keycode > JS_BUTTON_MAX) { return true; } else { + uint8_t button_idx = (keycode - JS_BUTTON0); 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 { - 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; |