diff --git a/include/squirrel_keyboard.h b/include/squirrel_keyboard.h index c5365d6..dd71d7b 100644 --- a/include/squirrel_keyboard.h +++ b/include/squirrel_keyboard.h @@ -14,8 +14,9 @@ void keyboard_activate_keycode(uint8_t keycode); void keyboard_deactivate_keycode(uint8_t keycode); // keyboard_get_keycodes populates the provided array with the first 6 active // keycodes. 6 is the maximum number of keycodes that -// can be sent over USB HID. -void keyboard_get_keycodes(uint8_t (*active_keycodes)[6]); +// can be sent over USB HID. It also returns true if there are any active +// keycodes. +bool keyboard_get_keycodes(uint8_t (*active_keycodes)[6]); // keyboard_activate_modifier marks the provided modifier as active. void keyboard_activate_modifier(uint8_t modifier); diff --git a/src/squirrel_keyboard.c b/src/squirrel_keyboard.c index a5f0249..56a28e5 100644 --- a/src/squirrel_keyboard.c +++ b/src/squirrel_keyboard.c @@ -11,7 +11,7 @@ void keyboard_activate_keycode(uint8_t keycode) { void keyboard_deactivate_keycode(uint8_t keycode) { keyboard_keycodes[keycode] = false; } -void keyboard_get_keycodes(uint8_t (*active_keycodes)[6]) { +bool keyboard_get_keycodes(uint8_t (*active_keycodes)[6]) { uint8_t active_keycodes_index = 0; for (int i = 0; (i <= 0xFF) && active_keycodes_index < 6; i++) { if (!keyboard_keycodes[i]) { @@ -20,6 +20,7 @@ void keyboard_get_keycodes(uint8_t (*active_keycodes)[6]) { (*active_keycodes)[active_keycodes_index] = i; active_keycodes_index++; } + return active_keycodes_index > 0; } void keyboard_activate_modifier(uint8_t modifier) {