2020-12-02 14:22:26 +00:00
|
|
|
# pylint: skip-file
|
2018-07-10 09:29:02 +00:00
|
|
|
# generate keys.h file
|
2022-06-06 19:07:21 +00:00
|
|
|
f = open("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
|
|
|
|
2022-06-06 19:07:21 +00:00
|
|
|
print("#ifndef ENGINE_KEYS_H", file=f)
|
|
|
|
print("#define ENGINE_KEYS_H", file=f)
|
2015-08-24 20:46:28 +00:00
|
|
|
|
|
|
|
# KEY_EXECUTE already exists on windows platforms
|
2022-06-06 19:07:21 +00:00
|
|
|
print("#if defined(CONF_FAMILY_WINDOWS)", file=f)
|
|
|
|
print(" #undef KEY_EXECUTE", file=f)
|
|
|
|
print("#endif", file=f)
|
2015-08-24 20:46:28 +00:00
|
|
|
|
2022-06-06 19:07:21 +00:00
|
|
|
print('/* AUTO GENERATED! DO NOT EDIT MANUALLY! */', file=f)
|
|
|
|
print("enum", file=f)
|
|
|
|
print("{", file=f)
|
2008-10-20 17:47:42 +00:00
|
|
|
|
2022-06-06 19:07:21 +00:00
|
|
|
print("\tKEY_FIRST = 0,", file=f)
|
2015-08-24 20:46:28 +00:00
|
|
|
|
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
|
2022-06-06 19:07:21 +00:00
|
|
|
print("\t%s = %d,"%(key, value), file=f)
|
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:
|
2022-06-06 19:07:21 +00:00
|
|
|
highestid = value
|
2008-10-20 17:47:42 +00:00
|
|
|
|
2022-06-06 19:07:21 +00:00
|
|
|
highestid += 1
|
|
|
|
print("\tKEY_MOUSE_1 = %d,"%(highestid), file=f); keynames[highestid] = "mouse1"; highestid += 1
|
|
|
|
print("\tKEY_MOUSE_2 = %d,"%(highestid), file=f); keynames[highestid] = "mouse2"; highestid += 1
|
|
|
|
print("\tKEY_MOUSE_3 = %d,"%(highestid), file=f); keynames[highestid] = "mouse3"; highestid += 1
|
|
|
|
print("\tKEY_MOUSE_4 = %d,"%(highestid), file=f); keynames[highestid] = "mouse4"; highestid += 1
|
|
|
|
print("\tKEY_MOUSE_5 = %d,"%(highestid), file=f); keynames[highestid] = "mouse5"; highestid += 1
|
|
|
|
print("\tKEY_MOUSE_6 = %d,"%(highestid), file=f); keynames[highestid] = "mouse6"; highestid += 1
|
|
|
|
print("\tKEY_MOUSE_7 = %d,"%(highestid), file=f); keynames[highestid] = "mouse7"; highestid += 1
|
|
|
|
print("\tKEY_MOUSE_8 = %d,"%(highestid), file=f); keynames[highestid] = "mouse8"; highestid += 1
|
|
|
|
print("\tKEY_MOUSE_9 = %d,"%(highestid), file=f); keynames[highestid] = "mouse9"; highestid += 1
|
|
|
|
print("\tKEY_MOUSE_WHEEL_UP = %d,"%(highestid), file=f); keynames[highestid] = "mousewheelup"; highestid += 1
|
|
|
|
print("\tKEY_MOUSE_WHEEL_DOWN = %d,"%(highestid), file=f); keynames[highestid] = "mousewheeldown"; highestid += 1
|
|
|
|
print("\tKEY_MOUSE_WHEEL_LEFT = %d,"%(highestid), file=f); keynames[highestid] = "mousewheelleft"; highestid += 1
|
|
|
|
print("\tKEY_MOUSE_WHEEL_RIGHT = %d,"%(highestid), file=f); keynames[highestid] = "mousewheelright"; highestid += 1
|
|
|
|
print("\tKEY_LAST = 512,", file=f)
|
2008-10-20 17:47:42 +00:00
|
|
|
|
2022-06-06 19:07:21 +00:00
|
|
|
print("};", file=f)
|
|
|
|
print("", file=f)
|
|
|
|
print("#endif", file=f)
|
2007-08-22 07:52:33 +00:00
|
|
|
|
|
|
|
# generate keynames.c file
|
2022-06-06 19:07:21 +00:00
|
|
|
f = open("src/engine/client/keynames.h", "w")
|
|
|
|
print('/* AUTO GENERATED! DO NOT EDIT MANUALLY! */', file=f)
|
|
|
|
print('', file=f)
|
|
|
|
print('#ifndef KEYS_INCLUDE', file=f)
|
|
|
|
print('#error do not include this header!', file=f)
|
|
|
|
print('#endif', file=f)
|
|
|
|
print('', file=f)
|
|
|
|
print("#include <string.h>", file=f)
|
|
|
|
print("", file=f)
|
|
|
|
print("const char g_aaKeyStrings[512][20] = // NOLINT(misc-definitions-in-headers)", file=f)
|
|
|
|
print("{", file=f)
|
2008-10-23 16:18:33 +00:00
|
|
|
for n in keynames:
|
2022-06-06 19:07:21 +00:00
|
|
|
print('\t"%s",'%n, file=f)
|
2007-08-22 07:52:33 +00:00
|
|
|
|
2022-06-06 19:07:21 +00:00
|
|
|
print("};", file=f)
|
|
|
|
print("", file=f)
|
2007-08-22 07:52:33 +00:00
|
|
|
|
|
|
|
f.close()
|