Created
March 28, 2017 13:16
-
-
Save gsora/45ba7b98d31929e75317908a97488ef1 to your computer and use it in GitHub Desktop.
Python script to parse https://gist.github.com/MightyPork/6da26e382a7ad91b5496ee55fdc73db2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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