zmk icon indicating copy to clipboard operation
zmk copied to clipboard

Periodic "stuck" keys from peripheral sides of splits

Open petejohanson opened this issue 6 years ago • 9 comments

Periodically, we are encountering issues w/ keys being stuck in a "held" state and not being released. This seems to only be from keys on the peripheral side of split keyboards. The suspicion is something along the lines of:

  • Peripheral side notifies key position state pressed.
  • HID report sent by central to host w/ keycode held.
  • Peripheral side notifies of key position released, but that is dropped/lost by the central side.
  • The HID report is never updated to release the keycode, so the host starts repeating the key infinitely, until the connection to the keyboard is lost.

The suggested fix would be to switch the peripheral to send "full state" updates, not just release/press events. If a certain notification was dropped, the next one would end up releasing the key position in question.

petejohanson avatar Oct 14 '20 20:10 petejohanson

I haven't checked if ZMK supports more than 256 keys, but assuming it does, https://en.wikipedia.org/wiki/Variable-length_quantity would be a good way to keep most reasonable keyboards' key positions down to one byte without limiting the number of keys you support.

joelspadin avatar Oct 14 '20 20:10 joelspadin

@joelspadin, it's an interesting idea! I'm not sure if we'll ever need to support nodes with more than 256 keys tho?

@petejohanson, were you initially thinking of bit flags or an integer array?

It might also need to handle outlier scenarios such as when the final key the user types is the one that gets lost. That might require a timeout on the central combined with either: a) requesting an update, or b) mandating repeat/regular state updates for held keys

It reminds me of some of the strategies discussed in the ZeroMQ guide.

Of course, without nailing down the series of events, I guess we're prodding in the dark.

innovaker avatar Oct 14 '20 21:10 innovaker

I would guess that an integer array would result in the smaller average packet size, but bit flags would work well if there's any benefit to having a fixed packet size. Still, either way the packets are going to be tiny unless you're using an integer array and manage to hold down every key on a full-size split keyboard.

joelspadin avatar Oct 14 '20 22:10 joelspadin

I have noticed that the keyboard inputs lag/stutter for a few seconds before this happens. Sometimes both halves of my keyboard will stop inputting at all after some lag/stutter as well. Not clear if the two are related or separate issues. This is on win10 with an Intel bluetooth stack with a big antenna.

Slusho64 avatar Oct 16 '20 23:10 Slusho64

There could be overlap with #221, since the symptoms look comparable (keys stuck held indefinitely until reset) and because I've personally found that #221 only happens on the peripheral side, similar to this issue.

leejunseok avatar Nov 03 '20 22:11 leejunseok

While this does usually happen on the peripheral side for me, I have had it happen on the left/primary as well.

Slusho64 avatar Dec 01 '20 19:12 Slusho64

Another idea: what about attaching a monotonically increasing sequence number to each keypress/release notification, and then do some kind of gap detection in the sequence, and if this happens then ask for the messages to be sent again starting from the last known sequence number?

meln1k avatar Jan 01 '22 21:01 meln1k

Is this issue still current on latest ZMK?

moergo-sc avatar Apr 23 '22 04:04 moergo-sc

Is this issue still current on latest ZMK?

For me, the stuck key issue was solved a while ago and the latest big update has solved the lagging as well. Unless others have reported these problems recently, this issue should be ready to close.

Slusho64 avatar Apr 23 '22 04:04 Slusho64