Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@gsora
Created March 28, 2017 13:16
Show Gist options
  • Star 11 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gsora/45ba7b98d31929e75317908a97488ef1 to your computer and use it in GitHub Desktop.
Save gsora/45ba7b98d31929e75317908a97488ef1 to your computer and use it in GitHub Desktop.
file = open("usb_hid_keys.h", "r")
for line in file:
goodline = line[8:].split(" ")
if line.startswith("#define ") and len(goodline)>1:
key = goodline[0]
value = ""
for i in range(1, len(goodline)):
if goodline[i] == "":
continue
else:
value = goodline[i].rsplit()[0]
break
# do whatever you wanna do with the scancode name, and its hex value
print("\"{}\": \"{}\",".format(key, value))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment