hedgewars/uKeyNames.pas
author Simon McVittie <smcv@debian.org>
Mon, 12 Sep 2022 10:40:53 -0400
branch1.0.0
changeset 15881 7b1d6dfa3173
parent 14865 9e8c201eae9d
permissions -rw-r--r--
Remove FindSDL2 find-module, use sdl2-config.cmake instead This requires SDL >= 2.0.4. Since <https://bugzilla.libsdl.org/show_bug.cgi?id=2464> was fixed in SDL 2.0.4, SDL behaves as a CMake "config-file package", even if it was not itself built using CMake: it installs a sdl2-config.cmake file to ${libdir}/cmake/SDL2, which tells CMake where to find SDL's headers and library, analogous to a pkg-config .pc file. As a result, we no longer need to copy/paste a "find-module package" to be able to find a system copy of SDL >= 2.0.4 with find_package(SDL2). Find-module packages are now discouraged by the CMake developers, in favour of having upstream projects behave as config-file packages. This results in a small API change: FindSDL2 used to set SDL2_INCLUDE_DIR and SDL2_LIBRARY, but the standard behaviour for config-file packages is to set <name>_INCLUDE_DIRS and <name>_LIBRARIES. Use the CONFIG keyword to make sure we search in config-file package mode, and will not find a FindSDL2.cmake in some other directory that implements the old interface. In addition to deleting redundant code, this avoids some assumptions in FindSDL2 about the layout of a SDL installation. The current libsdl2-dev package in Debian breaks those assumptions; this is considered a bug and will hopefully be fixed soon, but it illustrates how fragile these assumptions can be. We can be more robust against different installation layouts by relying on SDL's own CMake integration. When linking to a copy of CMake in a non-standard location, users can now set the SDL2_DIR or CMAKE_PREFIX_PATH environment variable to point to it; previously, these users would have used the SDL2DIR environment variable. This continues to be unnecessary if using matching system-wide installations of CMake and SDL2, for example both from Debian.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
14853
769189675b6c Add lookup table for Hedgewars key IDs instead of generating IDs on the fly
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
     1
(*
769189675b6c Add lookup table for Hedgewars key IDs instead of generating IDs on the fly
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
     2
 * Hedgewars, a free turn based strategy game
769189675b6c Add lookup table for Hedgewars key IDs instead of generating IDs on the fly
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
     3
 * Copyright (c) 2004-2019 Andrey Korotaev <unC0Rr@gmail.com>
769189675b6c Add lookup table for Hedgewars key IDs instead of generating IDs on the fly
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
     4
 *
769189675b6c Add lookup table for Hedgewars key IDs instead of generating IDs on the fly
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
     5
 * This program is free software; you can redistribute it and/or modify
769189675b6c Add lookup table for Hedgewars key IDs instead of generating IDs on the fly
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
     6
 * it under the terms of the GNU General Public License as published by
769189675b6c Add lookup table for Hedgewars key IDs instead of generating IDs on the fly
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
     7
 * the Free Software Foundation; version 2 of the License
769189675b6c Add lookup table for Hedgewars key IDs instead of generating IDs on the fly
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
     8
 *
769189675b6c Add lookup table for Hedgewars key IDs instead of generating IDs on the fly
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
     9
 * This program is distributed in the hope that it will be useful,
769189675b6c Add lookup table for Hedgewars key IDs instead of generating IDs on the fly
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
769189675b6c Add lookup table for Hedgewars key IDs instead of generating IDs on the fly
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
769189675b6c Add lookup table for Hedgewars key IDs instead of generating IDs on the fly
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    12
 * GNU General Public License for more details.
769189675b6c Add lookup table for Hedgewars key IDs instead of generating IDs on the fly
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    13
 *
769189675b6c Add lookup table for Hedgewars key IDs instead of generating IDs on the fly
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    14
 * You should have received a copy of the GNU General Public License
769189675b6c Add lookup table for Hedgewars key IDs instead of generating IDs on the fly
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    15
 * along with this program; if not, write to the Free Software
769189675b6c Add lookup table for Hedgewars key IDs instead of generating IDs on the fly
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    16
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
769189675b6c Add lookup table for Hedgewars key IDs instead of generating IDs on the fly
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    17
 *)
769189675b6c Add lookup table for Hedgewars key IDs instead of generating IDs on the fly
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    18
769189675b6c Add lookup table for Hedgewars key IDs instead of generating IDs on the fly
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    19
unit uKeyNames;
769189675b6c Add lookup table for Hedgewars key IDs instead of generating IDs on the fly
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    20
interface
769189675b6c Add lookup table for Hedgewars key IDs instead of generating IDs on the fly
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    21
uses uConsts;
769189675b6c Add lookup table for Hedgewars key IDs instead of generating IDs on the fly
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    22
769189675b6c Add lookup table for Hedgewars key IDs instead of generating IDs on the fly
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    23
type TKeyNames = array [0..cKeyMaxIndex] of string[15];
769189675b6c Add lookup table for Hedgewars key IDs instead of generating IDs on the fly
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    24
769189675b6c Add lookup table for Hedgewars key IDs instead of generating IDs on the fly
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    25
procedure populateKeyNames(var KeyArray: TKeyNames);
14864
9f6b650a6812 Make key ID generation algorithm more useful
Wuzzy <Wuzzy2@mail.ru>
parents: 14853
diff changeset
    26
// procedure generateKeyNames(); // DEBUG (see below)
14853
769189675b6c Add lookup table for Hedgewars key IDs instead of generating IDs on the fly
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    27
769189675b6c Add lookup table for Hedgewars key IDs instead of generating IDs on the fly
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    28
implementation
769189675b6c Add lookup table for Hedgewars key IDs instead of generating IDs on the fly
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    29
14865
9e8c201eae9d Move Hedgewars key IDs to CSV file
Wuzzy <Wuzzy2@mail.ru>
parents: 14864
diff changeset
    30
uses uPhysFSLayer, uUtils, uVariables, uTypes, uConsole;
9e8c201eae9d Move Hedgewars key IDs to CSV file
Wuzzy <Wuzzy2@mail.ru>
parents: 14864
diff changeset
    31
14853
769189675b6c Add lookup table for Hedgewars key IDs instead of generating IDs on the fly
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    32
procedure populateKeyNames(var KeyArray: TKeyNames);
14865
9e8c201eae9d Move Hedgewars key IDs to CSV file
Wuzzy <Wuzzy2@mail.ru>
parents: 14864
diff changeset
    33
var f: PfsFile;
9e8c201eae9d Move Hedgewars key IDs to CSV file
Wuzzy <Wuzzy2@mail.ru>
parents: 14864
diff changeset
    34
    l, keyname, tmp: shortstring;
9e8c201eae9d Move Hedgewars key IDs to CSV file
Wuzzy <Wuzzy2@mail.ru>
parents: 14864
diff changeset
    35
    i, scancode: LongInt;
14853
769189675b6c Add lookup table for Hedgewars key IDs instead of generating IDs on the fly
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    36
begin
769189675b6c Add lookup table for Hedgewars key IDs instead of generating IDs on the fly
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    37
(*
14865
9e8c201eae9d Move Hedgewars key IDs to CSV file
Wuzzy <Wuzzy2@mail.ru>
parents: 14864
diff changeset
    38
 KeyArray is a mapping from SDL scancodes to Hedgewars key identifiers.
14853
769189675b6c Add lookup table for Hedgewars key IDs instead of generating IDs on the fly
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    39
 Hedgewars key identifiers are strings with a maximum length of 15
769189675b6c Add lookup table for Hedgewars key IDs instead of generating IDs on the fly
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    40
 and are used internally to identify keys in the engine and in settings.ini.
769189675b6c Add lookup table for Hedgewars key IDs instead of generating IDs on the fly
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    41
*)
14865
9e8c201eae9d Move Hedgewars key IDs to CSV file
Wuzzy <Wuzzy2@mail.ru>
parents: 14864
diff changeset
    42
9e8c201eae9d Move Hedgewars key IDs to CSV file
Wuzzy <Wuzzy2@mail.ru>
parents: 14864
diff changeset
    43
(* Key identifiers are read from an RFC 4180-compliant CSV file.
9e8c201eae9d Move Hedgewars key IDs to CSV file
Wuzzy <Wuzzy2@mail.ru>
parents: 14864
diff changeset
    44
- 1st column: SDL scancode
9e8c201eae9d Move Hedgewars key IDs to CSV file
Wuzzy <Wuzzy2@mail.ru>
parents: 14864
diff changeset
    45
- 2nd column: Hedgewars key ID *)
9e8c201eae9d Move Hedgewars key IDs to CSV file
Wuzzy <Wuzzy2@mail.ru>
parents: 14864
diff changeset
    46
if pfsExists(cPathz[ptMisc]+'/keys.csv') then
9e8c201eae9d Move Hedgewars key IDs to CSV file
Wuzzy <Wuzzy2@mail.ru>
parents: 14864
diff changeset
    47
    begin
9e8c201eae9d Move Hedgewars key IDs to CSV file
Wuzzy <Wuzzy2@mail.ru>
parents: 14864
diff changeset
    48
    f:= pfsOpenRead(cPathz[ptMisc]+'/keys.csv');
9e8c201eae9d Move Hedgewars key IDs to CSV file
Wuzzy <Wuzzy2@mail.ru>
parents: 14864
diff changeset
    49
    l:= '';
9e8c201eae9d Move Hedgewars key IDs to CSV file
Wuzzy <Wuzzy2@mail.ru>
parents: 14864
diff changeset
    50
    pfsReadLn(f, l);
9e8c201eae9d Move Hedgewars key IDs to CSV file
Wuzzy <Wuzzy2@mail.ru>
parents: 14864
diff changeset
    51
    while (not pfsEOF(f)) and (l <> '') do
9e8c201eae9d Move Hedgewars key IDs to CSV file
Wuzzy <Wuzzy2@mail.ru>
parents: 14864
diff changeset
    52
        begin
9e8c201eae9d Move Hedgewars key IDs to CSV file
Wuzzy <Wuzzy2@mail.ru>
parents: 14864
diff changeset
    53
        tmp:= '';
9e8c201eae9d Move Hedgewars key IDs to CSV file
Wuzzy <Wuzzy2@mail.ru>
parents: 14864
diff changeset
    54
        i:= 1;
9e8c201eae9d Move Hedgewars key IDs to CSV file
Wuzzy <Wuzzy2@mail.ru>
parents: 14864
diff changeset
    55
        while (i <= length(l)) and (l[i] <> ',') do
9e8c201eae9d Move Hedgewars key IDs to CSV file
Wuzzy <Wuzzy2@mail.ru>
parents: 14864
diff changeset
    56
            begin
9e8c201eae9d Move Hedgewars key IDs to CSV file
Wuzzy <Wuzzy2@mail.ru>
parents: 14864
diff changeset
    57
            tmp:= tmp + l[i];
9e8c201eae9d Move Hedgewars key IDs to CSV file
Wuzzy <Wuzzy2@mail.ru>
parents: 14864
diff changeset
    58
            inc(i)
9e8c201eae9d Move Hedgewars key IDs to CSV file
Wuzzy <Wuzzy2@mail.ru>
parents: 14864
diff changeset
    59
            end;
9e8c201eae9d Move Hedgewars key IDs to CSV file
Wuzzy <Wuzzy2@mail.ru>
parents: 14864
diff changeset
    60
        scancode:= StrToInt(tmp);
14853
769189675b6c Add lookup table for Hedgewars key IDs instead of generating IDs on the fly
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    61
14865
9e8c201eae9d Move Hedgewars key IDs to CSV file
Wuzzy <Wuzzy2@mail.ru>
parents: 14864
diff changeset
    62
        if i < length(l) then
9e8c201eae9d Move Hedgewars key IDs to CSV file
Wuzzy <Wuzzy2@mail.ru>
parents: 14864
diff changeset
    63
            begin
9e8c201eae9d Move Hedgewars key IDs to CSV file
Wuzzy <Wuzzy2@mail.ru>
parents: 14864
diff changeset
    64
            keyname:= copy(l, i + 1, length(l) - i);
9e8c201eae9d Move Hedgewars key IDs to CSV file
Wuzzy <Wuzzy2@mail.ru>
parents: 14864
diff changeset
    65
            if (keyname[1] = '"') and (keyname[length(keyname)] = '"') then
9e8c201eae9d Move Hedgewars key IDs to CSV file
Wuzzy <Wuzzy2@mail.ru>
parents: 14864
diff changeset
    66
                keyname:= copy(keyname, 2, length(keyname) - 2)
9e8c201eae9d Move Hedgewars key IDs to CSV file
Wuzzy <Wuzzy2@mail.ru>
parents: 14864
diff changeset
    67
            else
9e8c201eae9d Move Hedgewars key IDs to CSV file
Wuzzy <Wuzzy2@mail.ru>
parents: 14864
diff changeset
    68
                keyname:= copy(keyname, 1, length(keyname) - 1);
9e8c201eae9d Move Hedgewars key IDs to CSV file
Wuzzy <Wuzzy2@mail.ru>
parents: 14864
diff changeset
    69
            end;
9e8c201eae9d Move Hedgewars key IDs to CSV file
Wuzzy <Wuzzy2@mail.ru>
parents: 14864
diff changeset
    70
9e8c201eae9d Move Hedgewars key IDs to CSV file
Wuzzy <Wuzzy2@mail.ru>
parents: 14864
diff changeset
    71
        pfsReadLn(f, l);
9e8c201eae9d Move Hedgewars key IDs to CSV file
Wuzzy <Wuzzy2@mail.ru>
parents: 14864
diff changeset
    72
        KeyArray[scancode]:= keyname;
9e8c201eae9d Move Hedgewars key IDs to CSV file
Wuzzy <Wuzzy2@mail.ru>
parents: 14864
diff changeset
    73
        end;
9e8c201eae9d Move Hedgewars key IDs to CSV file
Wuzzy <Wuzzy2@mail.ru>
parents: 14864
diff changeset
    74
9e8c201eae9d Move Hedgewars key IDs to CSV file
Wuzzy <Wuzzy2@mail.ru>
parents: 14864
diff changeset
    75
    pfsClose(f)
9e8c201eae9d Move Hedgewars key IDs to CSV file
Wuzzy <Wuzzy2@mail.ru>
parents: 14864
diff changeset
    76
    end
9e8c201eae9d Move Hedgewars key IDs to CSV file
Wuzzy <Wuzzy2@mail.ru>
parents: 14864
diff changeset
    77
else
9e8c201eae9d Move Hedgewars key IDs to CSV file
Wuzzy <Wuzzy2@mail.ru>
parents: 14864
diff changeset
    78
    begin
9e8c201eae9d Move Hedgewars key IDs to CSV file
Wuzzy <Wuzzy2@mail.ru>
parents: 14864
diff changeset
    79
    WriteLnToConsole('misc/keys.csv file not found');
9e8c201eae9d Move Hedgewars key IDs to CSV file
Wuzzy <Wuzzy2@mail.ru>
parents: 14864
diff changeset
    80
    AddFileLog('misc/keys.csv file not found');
9e8c201eae9d Move Hedgewars key IDs to CSV file
Wuzzy <Wuzzy2@mail.ru>
parents: 14864
diff changeset
    81
    halt(haltStartupError);
9e8c201eae9d Move Hedgewars key IDs to CSV file
Wuzzy <Wuzzy2@mail.ru>
parents: 14864
diff changeset
    82
    end;
9e8c201eae9d Move Hedgewars key IDs to CSV file
Wuzzy <Wuzzy2@mail.ru>
parents: 14864
diff changeset
    83
9e8c201eae9d Move Hedgewars key IDs to CSV file
Wuzzy <Wuzzy2@mail.ru>
parents: 14864
diff changeset
    84
// generateKeyNames(); // DEBUG (see below)
14853
769189675b6c Add lookup table for Hedgewars key IDs instead of generating IDs on the fly
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    85
end;
769189675b6c Add lookup table for Hedgewars key IDs instead of generating IDs on the fly
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    86
769189675b6c Add lookup table for Hedgewars key IDs instead of generating IDs on the fly
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    87
(*
769189675b6c Add lookup table for Hedgewars key IDs instead of generating IDs on the fly
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    88
The Hedgewars key identifiers were obtained with the following algorithm:
769189675b6c Add lookup table for Hedgewars key IDs instead of generating IDs on the fly
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    89
769189675b6c Add lookup table for Hedgewars key IDs instead of generating IDs on the fly
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    90
Basically:
769189675b6c Add lookup table for Hedgewars key IDs instead of generating IDs on the fly
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    91
- For each SDL scancode, do:
769189675b6c Add lookup table for Hedgewars key IDs instead of generating IDs on the fly
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    92
   - Take the printable SDL scancode key name (with SDL_GetScancodeName)
769189675b6c Add lookup table for Hedgewars key IDs instead of generating IDs on the fly
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    93
   - Replace spaces with underscores
769189675b6c Add lookup table for Hedgewars key IDs instead of generating IDs on the fly
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    94
   - Lowercase it
769189675b6c Add lookup table for Hedgewars key IDs instead of generating IDs on the fly
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    95
   - Cap string length to 15 characters
769189675b6c Add lookup table for Hedgewars key IDs instead of generating IDs on the fly
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    96
- Manually fix duplicates
769189675b6c Add lookup table for Hedgewars key IDs instead of generating IDs on the fly
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    97
769189675b6c Add lookup table for Hedgewars key IDs instead of generating IDs on the fly
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    98
See also:
769189675b6c Add lookup table for Hedgewars key IDs instead of generating IDs on the fly
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    99
769189675b6c Add lookup table for Hedgewars key IDs instead of generating IDs on the fly
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   100
https://wiki.libsdl.org/SDLScancodeLookup
769189675b6c Add lookup table for Hedgewars key IDs instead of generating IDs on the fly
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   101
https://wiki.libsdl.org/SDL_Scancode
769189675b6c Add lookup table for Hedgewars key IDs instead of generating IDs on the fly
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   102
769189675b6c Add lookup table for Hedgewars key IDs instead of generating IDs on the fly
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   103
NOTE: For compability reasons, existing identifiers should not be renamed.
769189675b6c Add lookup table for Hedgewars key IDs instead of generating IDs on the fly
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   104
14864
9f6b650a6812 Make key ID generation algorithm more useful
Wuzzy <Wuzzy2@mail.ru>
parents: 14853
diff changeset
   105
*)
14853
769189675b6c Add lookup table for Hedgewars key IDs instead of generating IDs on the fly
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   106
14864
9f6b650a6812 Make key ID generation algorithm more useful
Wuzzy <Wuzzy2@mail.ru>
parents: 14853
diff changeset
   107
(* DEBUG
9f6b650a6812 Make key ID generation algorithm more useful
Wuzzy <Wuzzy2@mail.ru>
parents: 14853
diff changeset
   108
   Uncomment this to generate a list of key names in
9f6b650a6812 Make key ID generation algorithm more useful
Wuzzy <Wuzzy2@mail.ru>
parents: 14853
diff changeset
   109
   CSV format (RFC 4180) and print it out on console.
9f6b650a6812 Make key ID generation algorithm more useful
Wuzzy <Wuzzy2@mail.ru>
parents: 14853
diff changeset
   110
   Don't forget to fix duplicates! *)
9f6b650a6812 Make key ID generation algorithm more useful
Wuzzy <Wuzzy2@mail.ru>
parents: 14853
diff changeset
   111
(*
9f6b650a6812 Make key ID generation algorithm more useful
Wuzzy <Wuzzy2@mail.ru>
parents: 14853
diff changeset
   112
procedure generateKeyNames();
9f6b650a6812 Make key ID generation algorithm more useful
Wuzzy <Wuzzy2@mail.ru>
parents: 14853
diff changeset
   113
var i, t: LongInt;
9f6b650a6812 Make key ID generation algorithm more useful
Wuzzy <Wuzzy2@mail.ru>
parents: 14853
diff changeset
   114
s, s2: shortstring;
9f6b650a6812 Make key ID generation algorithm more useful
Wuzzy <Wuzzy2@mail.ru>
parents: 14853
diff changeset
   115
begin
14853
769189675b6c Add lookup table for Hedgewars key IDs instead of generating IDs on the fly
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   116
    for i := 0 to cKeyMaxIndex - 5 do
769189675b6c Add lookup table for Hedgewars key IDs instead of generating IDs on the fly
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   117
        begin
769189675b6c Add lookup table for Hedgewars key IDs instead of generating IDs on the fly
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   118
        s := shortstring(SDL_GetScancodeName(TSDL_Scancode(i)));
769189675b6c Add lookup table for Hedgewars key IDs instead of generating IDs on the fly
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   119
        for t := 1 to Length(s) do
769189675b6c Add lookup table for Hedgewars key IDs instead of generating IDs on the fly
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   120
            if s[t] = ' ' then
769189675b6c Add lookup table for Hedgewars key IDs instead of generating IDs on the fly
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   121
                s[t] := '_';
14864
9f6b650a6812 Make key ID generation algorithm more useful
Wuzzy <Wuzzy2@mail.ru>
parents: 14853
diff changeset
   122
        s2:= copy(s, 1, 15);
9f6b650a6812 Make key ID generation algorithm more useful
Wuzzy <Wuzzy2@mail.ru>
parents: 14853
diff changeset
   123
        if s2 = '"' then
9f6b650a6812 Make key ID generation algorithm more useful
Wuzzy <Wuzzy2@mail.ru>
parents: 14853
diff changeset
   124
            WriteLnToConsole(IntToStr(i)+',"\""')
9f6b650a6812 Make key ID generation algorithm more useful
Wuzzy <Wuzzy2@mail.ru>
parents: 14853
diff changeset
   125
        else if s2 <> '' then
9f6b650a6812 Make key ID generation algorithm more useful
Wuzzy <Wuzzy2@mail.ru>
parents: 14853
diff changeset
   126
            WriteLnToConsole(IntToStr(i)+',"'+LowerCase(s2)+'"');
14853
769189675b6c Add lookup table for Hedgewars key IDs instead of generating IDs on the fly
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   127
        end;
14864
9f6b650a6812 Make key ID generation algorithm more useful
Wuzzy <Wuzzy2@mail.ru>
parents: 14853
diff changeset
   128
end;
14853
769189675b6c Add lookup table for Hedgewars key IDs instead of generating IDs on the fly
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   129
*)
769189675b6c Add lookup table for Hedgewars key IDs instead of generating IDs on the fly
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   130
769189675b6c Add lookup table for Hedgewars key IDs instead of generating IDs on the fly
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   131
end.