mirror of
https://github.com/mofeng-git/One-KVM.git
synced 2026-01-29 09:01:54 +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:
|
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("#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)):
|
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\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__":
|
if __name__ == "__main__":
|
||||||
|
|||||||
@@ -16,4 +16,4 @@ upload_port = /dev/ttyACM0
|
|||||||
monitor_baud = 115200
|
monitor_baud = 115200
|
||||||
|
|
||||||
lib_deps =
|
lib_deps =
|
||||||
HID-Project
|
HID-Project@2.4.4
|
||||||
|
|||||||
@@ -1 +1,3 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
#define INLINE inline __attribute__((always_inline))
|
#define INLINE inline __attribute__((always_inline))
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
#include "inline.h"
|
#include "inline.h"
|
||||||
|
|
||||||
|
|
||||||
INLINE uint8_t keymap(uint8_t code) {
|
INLINE KeyboardKeycode keymap(uint8_t code) {
|
||||||
switch(code) {
|
switch(code) {
|
||||||
case 36: return KEY_0;
|
case 36: return KEY_0;
|
||||||
case 27: return KEY_1;
|
case 27: return KEY_1;
|
||||||
@@ -91,4 +91,4 @@ INLINE uint8_t keymap(uint8_t code) {
|
|||||||
case 26: return KEY_Z;
|
case 26: return KEY_Z;
|
||||||
default: return 0;
|
default: return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ INLINE void cmdResetHid() {
|
|||||||
|
|
||||||
INLINE void cmdKeyEvent() {
|
INLINE void cmdKeyEvent() {
|
||||||
uint8_t state = CMD_SERIAL.read();
|
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
|
CMD_SERIAL.read(); // unused now
|
||||||
if (code) {
|
if (code) {
|
||||||
if (state) {
|
if (state) {
|
||||||
|
|||||||
Reference in New Issue
Block a user