From 1e93506f84e631e104cbe56ceab46073370bf337 Mon Sep 17 00:00:00 2001 From: Jorge Guzman Date: Thu, 30 Jul 2026 15:08:21 -0300 Subject: [PATCH] include/nuttx/input: define all four keyboard event types keyboard.h declares KEYBOARD_PRESS and KEYBOARD_RELEASE only, but the type field of struct keyboard_event_s has four values: the two special key types live in kbd_codec.h, under a different prefix. Somebody writing a keyboard driver reads keyboard.h, sees two types, and implements two types. Six of the nine drivers that register a keyboard never report a special key at all, and the failure is silent: the build is clean and the symptom is a key that does nothing. Define all four here, as aliases of the kbd_decode() return values so that a driver can feed both this interface and the byte stream codec from a single source. Signed-off-by: Jorge Guzman --- include/nuttx/input/keyboard.h | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/include/nuttx/input/keyboard.h b/include/nuttx/input/keyboard.h index 98b408a4d64..694f13daf8a 100644 --- a/include/nuttx/input/keyboard.h +++ b/include/nuttx/input/keyboard.h @@ -31,6 +31,7 @@ #include +#include #include #include @@ -38,8 +39,22 @@ * Pre-processor Definitions ****************************************************************************/ -#define KEYBOARD_PRESS 0 /* Key press event */ -#define KEYBOARD_RELEASE 1 /* Key release event */ +/* Values for the type field of struct keyboard_event_s. + * + * A normal key carries its character in the code field. A special key + * carries a value from enum kbd_keycode_e instead, and must be reported + * with one of the SPEC types: the two ranges overlap, so the type is the + * only way a consumer can tell an arrow key from the character that shares + * its value. + * + * These are aliases of the kbd_decode() return values so that a driver can + * feed both this interface and the byte stream codec from a single source. + */ + +#define KEYBOARD_PRESS KBD_PRESS /* Normal key press event */ +#define KEYBOARD_RELEASE KBD_RELEASE /* Normal key release event */ +#define KEYBOARD_SPECPRESS KBD_SPECPRESS /* Special key press event */ +#define KEYBOARD_SPECREL KBD_SPECREL /* Special key release event */ /**************************************************************************** * Public Types