Skip to content

Commit

Permalink
applespi: Handle key rollover overflow.
Browse files Browse the repository at this point in the history
The keyboard sends an all keys = 1 keyboard event when an overflow is
detected, which we need to detect and ignore.

This fixes cb22#53.
  • Loading branch information
roadrunner2 committed Mar 4, 2018
1 parent c98c672 commit 02ccb27
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions applespi.c
Original file line number Diff line number Diff line change
Expand Up @@ -1183,6 +1183,20 @@ static void applespi_handle_keyboard_event(struct applespi_data *applespi,
int i, j;
unsigned int key;
bool still_pressed;
bool is_overflow;

/* check for rollover overflow, which is signalled by all keys == 1 */
is_overflow = true;

for (i = 0; i < MAX_ROLLOVER; i++) {
if (keyboard_protocol->keys_pressed[i] != 1) {
is_overflow = false;
break;
}
}

if (is_overflow)
return;

/* check released keys */
for (i = 0; i < MAX_ROLLOVER; i++) {
Expand Down

0 comments on commit 02ccb27

Please sign in to comment.