equal
deleted
inserted
replaced
21 uses uConsts; |
21 uses uConsts; |
22 |
22 |
23 type TKeyNames = array [0..cKeyMaxIndex] of string[15]; |
23 type TKeyNames = array [0..cKeyMaxIndex] of string[15]; |
24 |
24 |
25 procedure populateKeyNames(var KeyArray: TKeyNames); |
25 procedure populateKeyNames(var KeyArray: TKeyNames); |
|
26 // procedure generateKeyNames(); // DEBUG (see below) |
26 |
27 |
27 implementation |
28 implementation |
28 |
29 |
29 procedure populateKeyNames(var KeyArray: TKeyNames); |
30 procedure populateKeyNames(var KeyArray: TKeyNames); |
30 begin |
31 begin |
255 KeyArray[283] := 'app1'; |
256 KeyArray[283] := 'app1'; |
256 KeyArray[284] := 'app2'; |
257 KeyArray[284] := 'app2'; |
257 KeyArray[285] := 'audiorewind'; |
258 KeyArray[285] := 'audiorewind'; |
258 KeyArray[286] := 'audiofastforwar'; |
259 KeyArray[286] := 'audiofastforwar'; |
259 |
260 |
|
261 // generateKeyNames(); // DEBUG (see below) |
260 end; |
262 end; |
261 |
263 |
262 (* |
264 (* |
263 The Hedgewars key identifiers were obtained with the following algorithm: |
265 The Hedgewars key identifiers were obtained with the following algorithm: |
264 |
266 |
275 https://wiki.libsdl.org/SDLScancodeLookup |
277 https://wiki.libsdl.org/SDLScancodeLookup |
276 https://wiki.libsdl.org/SDL_Scancode |
278 https://wiki.libsdl.org/SDL_Scancode |
277 |
279 |
278 NOTE: For compability reasons, existing identifiers should not be renamed. |
280 NOTE: For compability reasons, existing identifiers should not be renamed. |
279 |
281 |
280 Old code snippet: |
282 *) |
281 |
283 |
|
284 (* DEBUG |
|
285 Uncomment this to generate a list of key names in |
|
286 CSV format (RFC 4180) and print it out on console. |
|
287 Don't forget to fix duplicates! *) |
|
288 (* |
|
289 procedure generateKeyNames(); |
|
290 var i, t: LongInt; |
|
291 s, s2: shortstring; |
|
292 begin |
282 for i := 0 to cKeyMaxIndex - 5 do |
293 for i := 0 to cKeyMaxIndex - 5 do |
283 begin |
294 begin |
284 s := shortstring(SDL_GetScancodeName(TSDL_Scancode(i))); |
295 s := shortstring(SDL_GetScancodeName(TSDL_Scancode(i))); |
285 |
|
286 for t := 1 to Length(s) do |
296 for t := 1 to Length(s) do |
287 if s[t] = ' ' then |
297 if s[t] = ' ' then |
288 s[t] := '_'; |
298 s[t] := '_'; |
289 KeyArray[i] := LowerCase(s); |
299 s2:= copy(s, 1, 15); |
290 if s = '''' then |
300 if s2 = '"' then |
291 WriteLnToConsole(' KeyArray['+IntToStr(i)+']'+' := '';') |
301 WriteLnToConsole(IntToStr(i)+',"\""') |
292 else if s <> '' then |
302 else if s2 <> '' then |
293 WriteLnToConsole(' KeyArray[SDL_SCANCODE_'+KeyArray[i]+']'+' := '''+KeyArray[i]+''';'); |
303 WriteLnToConsole(IntToStr(i)+',"'+LowerCase(s2)+'"'); |
294 end; |
304 end; |
|
305 end; |
295 *) |
306 *) |
296 |
307 |
297 end. |
308 end. |