mirror of
https://github.com/mofeng-git/One-KVM.git
synced 2026-01-29 00:51:53 +08:00
fixed keymapping
This commit is contained in:
@@ -26,10 +26,10 @@ def main() -> None:
|
||||
|
||||
with open("src/keymap.h", "w") as hid_header_file:
|
||||
hid_header_file.write("#include <HID-Project.h>\n\n#include \"inline.h\"\n\n\n")
|
||||
hid_header_file.write("INLINE uint8_t keymap(uint8_t code) {\n\tswitch(code) {\n")
|
||||
hid_header_file.write("INLINE KeyboardKeycode keymap(uint8_t code) {\n\tswitch(code) {\n")
|
||||
for (code, hid_key, _) in sorted(keymap, key=operator.itemgetter(1)):
|
||||
hid_header_file.write("\t\tcase %d: return %s;\n" % (code, hid_key))
|
||||
hid_header_file.write("\t\tdefault: return 0;\n\t}\n}")
|
||||
hid_header_file.write("\t\tdefault: return 0;\n\t}\n}\n")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
@@ -16,4 +16,4 @@ upload_port = /dev/ttyACM0
|
||||
monitor_baud = 115200
|
||||
|
||||
lib_deps =
|
||||
HID-Project
|
||||
HID-Project@2.4.4
|
||||
|
||||
@@ -1 +1,3 @@
|
||||
#pragma once
|
||||
|
||||
#define INLINE inline __attribute__((always_inline))
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
#include "inline.h"
|
||||
|
||||
|
||||
INLINE uint8_t keymap(uint8_t code) {
|
||||
INLINE KeyboardKeycode keymap(uint8_t code) {
|
||||
switch(code) {
|
||||
case 36: return KEY_0;
|
||||
case 27: return KEY_1;
|
||||
@@ -91,4 +91,4 @@ INLINE uint8_t keymap(uint8_t code) {
|
||||
case 26: return KEY_Z;
|
||||
default: return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ INLINE void cmdResetHid() {
|
||||
|
||||
INLINE void cmdKeyEvent() {
|
||||
uint8_t state = CMD_SERIAL.read();
|
||||
uint8_t code = keymap(CMD_SERIAL.read());
|
||||
KeyboardKeycode code = keymap((uint8_t)CMD_SERIAL.read());
|
||||
CMD_SERIAL.read(); // unused now
|
||||
if (code) {
|
||||
if (state) {
|
||||
|
||||
Reference in New Issue
Block a user