FrameworkComputer / EmbeddedController

Embedded Controller firmware for the Framework Laptop
BSD 3-Clause "New" or "Revised" License
957 stars 64 forks source link

hx20: Fn key rollover can trigger incorrect break codes, resulting in infinite key repeat #15

Closed DHowett closed 2 years ago

DHowett commented 2 years ago

The easiest way I've found to reproduce this is by:

  1. Pressing Vol Down
  2. Pressing Vol Up
  3. Releasing Vol Down

If done properly, releasing Vol Up will result in a break code for F3 being generated. This can also be accomplished with some combination of Fn and the arrow/page keys.

It appears that the state-tracking variables keep_fn_* aren't transitioning through their state graph correctly.

https://github.com/FrameworkComputer/EmbeddedController/blob/8109392adb17a2cd7d30a74eee8613a0cb72ee7d/board/hx20/keyboard_customization.c#L238-L240

Step Action Call Final State
1 Press Vol Down hotkey_F1_F12(&0x0006, 0, 1) keep_fn_key_F1F12 == 1
Set to 1 because the key was pressed
2 Press Vol Up hotkey_F1_F12(&0x0004, 0, 1) keep_fn_key_F1F12 == 1
Set to 1 because the key was pressed
3 Release Vol Down hotkey_F1_F12(&0x0006, 0, 0) keep_fn_key_F1F12 == 0
Cleared because the key was released
4 Release Vol Up hotkey_F1_F12(&0x0004, 0, 0) keep_fn_key_F1F12 == 0
We exit early (see code below) because this is 0

https://github.com/FrameworkComputer/EmbeddedController/blob/8109392adb17a2cd7d30a74eee8613a0cb72ee7d/board/hx20/keyboard_customization.c#L296-L297

kiram9 commented 2 years ago

@DHowett see https://github.com/FrameworkComputer/EmbeddedController/commit/fa8982056aa0ad6267029cf3ea20dc5c59cba282

DHowett commented 2 years ago

Ah, that looks perfect!

DHowett commented 2 years ago

Yep, confirming fixed as of 9450caa