2020-12-02 14:22:26 +00:00
|
|
|
# pylint: skip-file
|
2018-07-10 09:29:02 +00:00
|
|
|
# generate keys.h file
|
2010-05-29 07:25:38 +00:00
|
|
|
f = file("src/engine/keys.h", "w")
|
2007-08-22 07:52:33 +00:00
|
|
|
|
2008-10-23 16:18:33 +00:00
|
|
|
keynames = []
|
2008-10-20 17:47:42 +00:00
|
|
|
for i in range(0, 512):
|
2008-10-23 16:18:33 +00:00
|
|
|
keynames += ["&%d"%i]
|
2007-08-22 07:52:33 +00:00
|
|
|
|
|
|
|
print >>f, "#ifndef ENGINE_KEYS_H"
|
|
|
|
print >>f, "#define ENGINE_KEYS_H"
|
2015-08-24 20:46:28 +00:00
|
|
|
|
|
|
|
# KEY_EXECUTE already exists on windows platforms
|
|
|
|
print >>f, "#if defined(CONF_FAMILY_WINDOWS)"
|
|
|
|
print >>f, " #undef KEY_EXECUTE"
|
|
|
|
print >>f, "#endif"
|
|
|
|
|
2007-08-22 07:52:33 +00:00
|
|
|
print >>f, '/* AUTO GENERATED! DO NOT EDIT MANUALLY! */'
|
|
|
|
print >>f, "enum"
|
|
|
|
print >>f, "{"
|
2008-10-20 17:47:42 +00:00
|
|
|
|
2015-08-24 20:46:28 +00:00
|
|
|
print >>f, "\tKEY_FIRST = 0,"
|
|
|
|
|
2008-10-20 17:47:42 +00:00
|
|
|
highestid = 0
|
2015-08-24 20:46:28 +00:00
|
|
|
for line in open("scripts/SDL_scancode.h"):
|
2008-10-20 17:47:42 +00:00
|
|
|
l = line.strip().split("=")
|
2015-08-24 20:46:28 +00:00
|
|
|
if len(l) == 2 and "SDL_SCANCODE_" in line:
|
|
|
|
key = l[0].strip().replace("SDL_SCANCODE_", "KEY_")
|
2008-10-20 17:47:42 +00:00
|
|
|
value = int(l[1].split(",")[0].strip())
|
2015-08-24 20:46:28 +00:00
|
|
|
if key[0:2] == "/*":
|
|
|
|
continue
|
2008-10-20 17:47:42 +00:00
|
|
|
print >>f, "\t%s = %d,"%(key, value)
|
2015-08-24 20:46:28 +00:00
|
|
|
|
2008-10-23 16:18:33 +00:00
|
|
|
keynames[value] = key.replace("KEY_", "").lower()
|
2015-08-24 20:46:28 +00:00
|
|
|
|
2008-10-20 17:47:42 +00:00
|
|
|
if value > highestid:
|
|
|
|
highestid =value
|
|
|
|
|
2008-10-23 16:18:33 +00:00
|
|
|
print >>f, "\tKEY_MOUSE_1 = %d,"%(highestid+1); keynames[highestid+1] = "mouse1"
|
|
|
|
print >>f, "\tKEY_MOUSE_2 = %d,"%(highestid+2); keynames[highestid+2] = "mouse2"
|
|
|
|
print >>f, "\tKEY_MOUSE_3 = %d,"%(highestid+3); keynames[highestid+3] = "mouse3"
|
|
|
|
print >>f, "\tKEY_MOUSE_4 = %d,"%(highestid+4); keynames[highestid+4] = "mouse4"
|
|
|
|
print >>f, "\tKEY_MOUSE_5 = %d,"%(highestid+5); keynames[highestid+5] = "mouse5"
|
|
|
|
print >>f, "\tKEY_MOUSE_6 = %d,"%(highestid+6); keynames[highestid+6] = "mouse6"
|
|
|
|
print >>f, "\tKEY_MOUSE_7 = %d,"%(highestid+7); keynames[highestid+7] = "mouse7"
|
|
|
|
print >>f, "\tKEY_MOUSE_8 = %d,"%(highestid+8); keynames[highestid+8] = "mouse8"
|
2017-07-21 17:53:49 +00:00
|
|
|
print >>f, "\tKEY_MOUSE_9 = %d,"%(highestid+9); keynames[highestid+9] = "mouse9"
|
|
|
|
print >>f, "\tKEY_MOUSE_WHEEL_UP = %d,"%(highestid+10); keynames[highestid+10] = "mousewheelup"
|
|
|
|
print >>f, "\tKEY_MOUSE_WHEEL_DOWN = %d,"%(highestid+11); keynames[highestid+11] = "mousewheeldown"
|
|
|
|
print >>f, "\tKEY_MOUSE_WHEEL_LEFT = %d,"%(highestid+12); keynames[highestid+12] = "mousewheelleft"
|
|
|
|
print >>f, "\tKEY_MOUSE_WHEEL_RIGHT = %d,"%(highestid+13); keynames[highestid+13] = "mousewheelright"
|
2015-08-26 15:21:47 +00:00
|
|
|
print >>f, "\tKEY_LAST = 512,"
|
2008-10-20 17:47:42 +00:00
|
|
|
|
2007-08-22 07:52:33 +00:00
|
|
|
print >>f, "};"
|
|
|
|
print >>f, ""
|
|
|
|
print >>f, "#endif"
|
|
|
|
|
|
|
|
# generate keynames.c file
|
2010-05-29 07:25:38 +00:00
|
|
|
f = file("src/engine/client/keynames.h", "w")
|
2007-08-22 07:52:33 +00:00
|
|
|
print >>f, '/* AUTO GENERATED! DO NOT EDIT MANUALLY! */'
|
|
|
|
print >>f, ''
|
2010-05-29 07:25:38 +00:00
|
|
|
print >>f, '#ifndef KEYS_INCLUDE'
|
|
|
|
print >>f, '#error do not include this header!'
|
|
|
|
print >>f, '#endif'
|
|
|
|
print >>f, ''
|
2007-08-22 07:52:33 +00:00
|
|
|
print >>f, "#include <string.h>"
|
|
|
|
print >>f, ""
|
2015-08-24 20:46:28 +00:00
|
|
|
print >>f, "const char g_aaKeyStrings[512][20] ="
|
2007-08-22 07:52:33 +00:00
|
|
|
print >>f, "{"
|
2008-10-23 16:18:33 +00:00
|
|
|
for n in keynames:
|
2008-10-20 17:47:42 +00:00
|
|
|
print >>f, '\t"%s",'%n
|
2007-08-22 07:52:33 +00:00
|
|
|
|
|
|
|
print >>f, "};"
|
|
|
|
print >>f, ""
|
|
|
|
|
|
|
|
f.close()
|