This is an automated email from the ASF dual-hosted git repository.

acassis pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git

commit 1e93506f84e631e104cbe56ceab46073370bf337
Author: Jorge Guzman <[email protected]>
AuthorDate: Thu Jul 30 15:08:21 2026 -0300

    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 <[email protected]>
---
 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 <nuttx/config.h>
 
+#include <nuttx/input/kbd_codec.h>
 #include <nuttx/input/x11_keysym.h>
 #include <nuttx/input/x11_xf86keysym.h>
 
@@ -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

Reply via email to