From 3e0ee6fb74e125d14ac22c922d80def4649f6784 Mon Sep 17 00:00:00 2001 From: Ryan Date: Wed, 26 Jan 2022 00:40:55 +1100 Subject: Fix joystick button off-by-one error (#16037) --- quantum/process_keycode/process_joystick.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'quantum/process_keycode/process_joystick.c') 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; -- cgit v1.2.3 From 63646e8906e062d1c1de3925cba70c4e3426a855 Mon Sep 17 00:00:00 2001 From: QMK Bot Date: Sat, 12 Feb 2022 10:29:31 -0800 Subject: Format code according to conventions (#16322) --- quantum/process_keycode/process_joystick.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'quantum/process_keycode/process_joystick.c') diff --git a/quantum/process_keycode/process_joystick.c b/quantum/process_keycode/process_joystick.c index fa9c2c1dbc..2fb092c573 100644 --- a/quantum/process_keycode/process_joystick.c +++ b/quantum/process_keycode/process_joystick.c @@ -74,7 +74,9 @@ void restorePinState(pin_t pin, uint16_t restoreState) { #endif } -__attribute__((weak)) bool process_joystick_analogread() { return process_joystick_analogread_quantum(); } +__attribute__((weak)) bool process_joystick_analogread() { + return process_joystick_analogread_quantum(); +} bool process_joystick_analogread_quantum() { #if JOYSTICK_AXES_COUNT > 0 -- cgit v1.2.3