hedgewars/uInputHandler.pas
changeset 14837 769189675b6c
parent 14813 9443dc6663ba
child 14850 6c51f74d80a8
--- a/hedgewars/uInputHandler.pas	Tue Apr 23 15:54:06 2019 +0200
+++ b/hedgewars/uInputHandler.pas	Thu Apr 25 19:42:19 2019 +0200
@@ -60,7 +60,7 @@
 procedure ControllerButtonEvent(joy, button: Byte; pressed: Boolean);
 
 implementation
-uses uConsole, uCommands, uVariables, uConsts, uUtils, uDebug, uPhysFSLayer, uCursor;
+uses uKeyNames, uConsole, uCommands, uVariables, uConsts, uUtils, uDebug, uPhysFSLayer, uCursor;
 
 const
     LSHIFT = $0200;
@@ -71,7 +71,7 @@
     RCTRL  = $4000;
 
 var tkbd: array[0..cKbdMaxIndex] of boolean;
-    KeyNames: array [0..cKeyMaxIndex] of string[15];
+    KeyNames: TKeyNames;
     CurrentBinds: TBinds;
     ControllerNumControllers: Integer;
     ControllerEnabled: Integer;
@@ -446,9 +446,9 @@
 
 
 procedure InitKbdKeyTable;
-var i, j, k, t: LongInt;
-    s: string[15];
+var i, j, k: LongInt;
 begin
+    // Mouse buttons and mouse wheel
     KeyNames[cKeyMaxIndex    ]:= 'mousel';
     KeyNames[cKeyMaxIndex - 1]:= 'mousem';
     KeyNames[cKeyMaxIndex - 2]:= 'mouser';
@@ -457,16 +457,8 @@
     mwheeldownCode:= cKeyMaxIndex - 4;
     KeyNames[mwheeldownCode]:= 'wheeldown';
 
-    for i:= 0 to cKeyMaxIndex - 5 do
-        begin
-        s:= shortstring(SDL_GetScancodeName(TSDL_Scancode(i)));
-
-        for t:= 1 to Length(s) do
-            if s[t] = ' ' then
-                s[t]:= '_';
-        KeyNames[i]:= LowerCase(s)
-        end;
-
+    // Keyboard keys
+    uKeyNames.populateKeyNames(KeyNames);
 
     // get the size of keyboard array
     SDL_GetKeyboardState(@k);