]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
boot: Correctly handle shift keys
authorJan Janssen <medhefgo@web.de>
Wed, 24 Aug 2022 09:01:02 +0000 (11:01 +0200)
committerJan Janssen <medhefgo@web.de>
Wed, 7 Sep 2022 10:55:55 +0000 (12:55 +0200)
src/boot/efi/console.c

index f61199ccfd86c04ed0106d622ea8abbca765e499..14c0008afb47bf751a5d8644c196160a67cf5dd8 100644 (file)
@@ -132,14 +132,19 @@ EFI_STATUS console_key_read(uint64_t *key, uint64_t timeout_usec) {
 
                 if (FLAGS_SET(keydata.KeyState.KeyShiftState, EFI_SHIFT_STATE_VALID)) {
                         /* Do not distinguish between left and right keys (set both flags). */
-                        if (keydata.KeyState.KeyShiftState & EFI_SHIFT_PRESSED)
-                                shift |= EFI_SHIFT_PRESSED;
                         if (keydata.KeyState.KeyShiftState & EFI_CONTROL_PRESSED)
                                 shift |= EFI_CONTROL_PRESSED;
                         if (keydata.KeyState.KeyShiftState & EFI_ALT_PRESSED)
                                 shift |= EFI_ALT_PRESSED;
                         if (keydata.KeyState.KeyShiftState & EFI_LOGO_PRESSED)
                                 shift |= EFI_LOGO_PRESSED;
+
+                        /* Shift is not supposed to be reported for keys that can be represented as uppercase
+                         * unicode chars (Shift+f is reported as F instead). Some firmware does it anyway, so
+                         * filter those out. */
+                        if ((keydata.KeyState.KeyShiftState & EFI_SHIFT_PRESSED) &&
+                            keydata.Key.UnicodeChar == 0)
+                                shift |= EFI_SHIFT_PRESSED;
                 }
 
                 /* 32 bit modifier keys + 16 bit scan code + 16 bit unicode */