initial commit
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
from evdev import InputDevice, ecodes
|
||||
import json
|
||||
|
||||
DEVICE_PATH = "/dev/input/event8"
|
||||
|
||||
device = InputDevice(DEVICE_PATH)
|
||||
|
||||
print("Press keys... Ctrl+C to stop")
|
||||
print("Generating keymap from live input...\n")
|
||||
|
||||
keymap = {}
|
||||
|
||||
try:
|
||||
for event in device.read_loop():
|
||||
|
||||
if event.type != ecodes.EV_KEY:
|
||||
continue
|
||||
|
||||
if event.value != 1:
|
||||
continue
|
||||
|
||||
key_name = ecodes.KEY.get(event.code, f"UNKNOWN_{event.code}")
|
||||
|
||||
clean = key_name.replace("KEY_", "").title()
|
||||
|
||||
print(f"{event.code} -> {clean}")
|
||||
|
||||
keymap[event.code] = clean
|
||||
|
||||
except KeyboardInterrupt:
|
||||
pass
|
||||
|
||||
with open("keymap.json", "w") as f:
|
||||
json.dump(keymap, f, indent=4)
|
||||
|
||||
print("\nSaved to keymap.json")
|
||||
Reference in New Issue
Block a user