From cc07ed7c7ede8dfc79643ccabb32285c74d6bff5 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Tue, 4 Jul 2023 14:17:48 +0100 Subject: [console] Avoid overlap between remapping flags and character values The keyboard remapping flags currently occupy bits 8 and upwards of the to-be-mapped character value. This overlaps the range used for special keys (KEY_MIN and upwards) and also overlaps the valid Unicode character range. No conflict is created by this overlap, since by design only ASCII character values (as generated by an ASCII-only keyboard driver) are subject to remapping, and so the to-be-remapped character values exist in a conceptually separate namespace from either special keys or non-ASCII Unicode characters. However, the overlap is potentially confusing for readers of the code. Minimise cognitive load by using bits 24 and upwards for the keyboard remapping flags. Signed-off-by: Michael Brown --- src/include/ipxe/keymap.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/include/ipxe/keymap.h b/src/include/ipxe/keymap.h index 8bfbe07..49a8915 100644 --- a/src/include/ipxe/keymap.h +++ b/src/include/ipxe/keymap.h @@ -52,10 +52,10 @@ struct keymap { #define KEYMAP_PSEUDO 0x80 /** Ctrl key flag */ -#define KEYMAP_CTRL 0x0100 +#define KEYMAP_CTRL 0x01000000 /** CapsLock key flag */ -#define KEYMAP_CAPSLOCK 0x0200 +#define KEYMAP_CAPSLOCK 0x02000000 /** Undo CapsLock key flag * @@ -64,13 +64,13 @@ struct keymap { * in order to correctly handle keyboard mappings that swap alphabetic * and non-alphabetic keys. */ -#define KEYMAP_CAPSLOCK_UNDO 0x0400 +#define KEYMAP_CAPSLOCK_UNDO 0x04000000 /** Undo and redo CapsLock key flags */ #define KEYMAP_CAPSLOCK_REDO ( KEYMAP_CAPSLOCK | KEYMAP_CAPSLOCK_UNDO ) /** AltGr key flag */ -#define KEYMAP_ALTGR 0x0800 +#define KEYMAP_ALTGR 0x08000000 extern unsigned int key_remap ( unsigned int character ); extern struct keymap * keymap_find ( const char *name ); -- cgit v1.1