commit 33337f1c8bb8ad07fb9f0f17907210d7fa518333 parent 01d754f09a1cbffd00a89c9b10b1226c6b013b68 Author: René Wagner <rwa@clttr.info> Date: Tue, 19 Dec 2023 13:48:54 +0100 reduce logic overhead when disabling modifier display Diffstat:
M | reform2-keyboard-fw/keyboard.c | | | 30 | ++++++++++++++++-------------- |
1 file changed, 16 insertions(+), 14 deletions(-)
diff --git a/reform2-keyboard-fw/keyboard.c b/reform2-keyboard-fw/keyboard.c @@ -282,20 +282,22 @@ int process_keyboard(uint8_t* resulting_scancodes) { circle = 0; } // disable active keymod for OLED display - if (keycode == HID_KEYBOARD_SC_LEFT_CONTROL) { - left_ctrl_pressed = 0; - } else if (keycode == HID_KEYBOARD_SC_LEFT_SHIFT) { - left_shift_pressed = 0; - } else if (!left_ctrl_pressed && keycode == HID_KEYBOARD_SC_RIGHT_CONTROL) { - active_keymods &= ~ CONTROL; - } else if (!left_shift_pressed && keycode == HID_KEYBOARD_SC_RIGHT_SHIFT) { - active_keymods &= ~ SHIFT; - } else if (keycode == HID_KEYBOARD_SC_RIGHT_ALT) { - active_keymods &= ~ AGR; - } else if (keycode == HID_KEYBOARD_SC_LEFT_ALT) { - active_keymods &= ~ ALT; - } else if (keycode == HID_KEYBOARD_SC_LEFT_GUI) { - active_keymods &= ~ SUPER; + if (active_keymods) { + if (keycode == HID_KEYBOARD_SC_LEFT_CONTROL) { + left_ctrl_pressed = 0; + } else if (keycode == HID_KEYBOARD_SC_LEFT_SHIFT) { + left_shift_pressed = 0; + } else if (!left_ctrl_pressed && keycode == HID_KEYBOARD_SC_RIGHT_CONTROL) { + active_keymods &= ~ CONTROL; + } else if (!left_shift_pressed && keycode == HID_KEYBOARD_SC_RIGHT_SHIFT) { + active_keymods &= ~ SHIFT; + } else if (keycode == HID_KEYBOARD_SC_RIGHT_ALT) { + active_keymods &= ~ AGR; + } else if (keycode == HID_KEYBOARD_SC_LEFT_ALT) { + active_keymods &= ~ ALT; + } else if (keycode == HID_KEYBOARD_SC_LEFT_GUI) { + active_keymods &= ~ SUPER; + } } } }