无法捕获0x01-0x1F的所有值

问题描述 投票:0回答:1

我正在编写一个受 DOS 启发的 EFI 操作系统。我已经把捕获关键部分放下了,你可以在这里看到:

#include "uefi/uefi.h"

int main(int argc, char **argv) {
    efi_input_key_t ch; // define ch as an efi input key
    char command[1024] = ""; // define the command variable as a buffer stored in memory with a size of 1024 bytes
    int len = 0; // define the length of the command

    while (1) {
        ST->BootServices->WaitForEvent(1, &(ST->ConIn->WaitForKey), NULL); // wait for key so keys arent printed forever
        ST->ConIn->ReadKeyStroke(ST->ConIn, &ch); // define ch as pressed key

        if (ch.ScanCode == 0x01) {
            // Check for Escape key and break the loop
            break;
        }

        printf("%c", ch.UnicodeChar); // print the character

        if (len < (sizeof(command) - 1)) {
            command[len] = ch.UnicodeChar; // add the character to the back
            command[len + 1] = '\0';  // Null-terminate the string
            len++;
        }
    }

    return 0; // after pressing ESC, exit the program and go to the UEFI shell
}

当我按 ESC 时,它将先前键入的字符复制到当前光标位置,当我将其设置为 ENTER 而不是 ESC 时,按 ENTER 时,它将光标移动到开头。我该如何解决这个问题?

c posix uefi
1个回答
0
投票

您使用了错误的扫描码,ESC扫描码是0x17。

© www.soinside.com 2019 - 2024. All rights reserved.