3 # genereate keys.h file
4 f
= file("src/engine/keys.h", "w")
7 for i
in range(0, 512):
10 print >>f
, "#ifndef ENGINE_KEYS_H"
11 print >>f
, "#define ENGINE_KEYS_H"
12 print >>f
, '/* AUTO GENERATED! DO NOT EDIT MANUALLY! */'
17 for line
in open("scripts/SDL_keysym.h"):
18 l
= line
.strip().split("=")
19 if len(l
) == 2 and "SDLK_" in line
:
20 key
= l
[0].strip().replace("SDLK_", "KEY_")
21 value
= int(l
[1].split(",")[0].strip())
22 print >>f
, "\t%s = %d,"%(key
, value
)
24 keynames
[value
] = key
.replace("KEY_", "").lower()
29 print >>f
, "\tKEY_MOUSE_1 = %d,"%(highestid
+1); keynames
[highestid
+1] = "mouse1"
30 print >>f
, "\tKEY_MOUSE_2 = %d,"%(highestid
+2); keynames
[highestid
+2] = "mouse2"
31 print >>f
, "\tKEY_MOUSE_3 = %d,"%(highestid
+3); keynames
[highestid
+3] = "mouse3"
32 print >>f
, "\tKEY_MOUSE_4 = %d,"%(highestid
+4); keynames
[highestid
+4] = "mouse4"
33 print >>f
, "\tKEY_MOUSE_5 = %d,"%(highestid
+5); keynames
[highestid
+5] = "mouse5"
34 print >>f
, "\tKEY_MOUSE_6 = %d,"%(highestid
+6); keynames
[highestid
+6] = "mouse6"
35 print >>f
, "\tKEY_MOUSE_7 = %d,"%(highestid
+7); keynames
[highestid
+7] = "mouse7"
36 print >>f
, "\tKEY_MOUSE_8 = %d,"%(highestid
+8); keynames
[highestid
+8] = "mouse8"
37 print >>f
, "\tKEY_MOUSE_WHEEL_UP = %d,"%(highestid
+9); keynames
[highestid
+9] = "mousewheelup"
38 print >>f
, "\tKEY_MOUSE_WHEEL_DOWN = %d,"%(highestid
+10); keynames
[highestid
+10] = "mousewheeldown"
39 print >>f
, "\tKEY_LAST,"
45 # generate keynames.c file
46 f
= file("src/engine/client/keynames.h", "w")
47 print >>f
, '/* AUTO GENERATED! DO NOT EDIT MANUALLY! */'
49 print >>f
, '#ifndef KEYS_INCLUDE'
50 print >>f
, '#error do not include this header!'
53 print >>f
, "#include <string.h>"
55 print >>f
, "const char g_aaKeyStrings[512][16] ="
58 print >>f
, '\t"%s",'%n