hedgewars/uInputHandler.pas
changeset 13343 93325e13d329
parent 13132 52178e8ffdfc
child 13412 236cc4cf2448
child 13546 46ee00a7526a
equal deleted inserted replaced
13342:774dd8762607 13343:93325e13d329
    27 
    27 
    28 function  KeyNameToCode(name: shortstring): LongInt; inline;
    28 function  KeyNameToCode(name: shortstring): LongInt; inline;
    29 function  KeyNameToCode(name: shortstring; Modifier: shortstring): LongInt;
    29 function  KeyNameToCode(name: shortstring; Modifier: shortstring): LongInt;
    30 
    30 
    31 function  KeyBindToCode(bind: shortstring): LongInt;
    31 function  KeyBindToCode(bind: shortstring): LongInt;
    32 function  KeyBindToName(bind: shortstring): ansistring;
    32 function  KeyBindToName(bind: shortstring): shortstring;
    33 //procedure MaskModifier(var code: LongInt; modifier: LongWord);
    33 //procedure MaskModifier(var code: LongInt; modifier: LongWord);
    34 procedure MaskModifier(Modifier: shortstring; var code: LongInt);
    34 procedure MaskModifier(Modifier: shortstring; var code: LongInt);
    35 procedure ProcessMouse(event: TSDL_MouseButtonEvent; ButtonDown: boolean);
    35 procedure ProcessMouse(event: TSDL_MouseButtonEvent; ButtonDown: boolean);
    36 //procedure ProcessMouseWheel(x, y: LongInt);
    36 //procedure ProcessMouseWheel(x, y: LongInt);
    37 procedure ProcessMouseWheel(y: LongInt);
    37 procedure ProcessMouseWheel(y: LongInt);
   117 // Takes a control name (e.g. 'quit') and returns the corresponding
   117 // Takes a control name (e.g. 'quit') and returns the corresponding
   118 // human-readable key name from SDL.
   118 // human-readable key name from SDL.
   119 // FIXME: Does not work 100% for all keys yet, but at least it no
   119 // FIXME: Does not work 100% for all keys yet, but at least it no
   120 //        longer hardcodes any key name.
   120 //        longer hardcodes any key name.
   121 // TODO: Localize
   121 // TODO: Localize
   122 function KeyBindToName(bind: shortstring): ansistring;
   122 function KeyBindToName(bind: shortstring): shortstring;
   123 var code: LongInt;
   123 var code: LongInt;
   124     name: ansistring;
   124     name: shortstring;
   125 begin
   125 begin
   126     code:= KeyBindToCode(bind);
   126     code:= KeyBindToCode(bind);
   127     if code = -1 then
   127     if code = -1 then
   128         KeyBindToName:= trmsg[sidUnknownKey]
   128         KeyBindToName:= trmsg[sidUnknownKey]
   129     else
   129     else
   130         begin
   130         begin
   131         name:= SDL_GetKeyName(SDL_GetKeyFromScancode(code));
   131         name:= SDL_GetKeyName(SDL_GetKeyFromScancode(code));
   132         if (name = 'Escape') then
   132         if (name = 'Escape') then
   133             // Let's shorten the name “Escape” for the quit menu
   133             // Let's shorten the name “Escape” for the quit menu
   134             KeyBindToName:= 'Esc'
   134             KeyBindToName:= 'Esc'
   135         else if (name <> '') then
   135         else if (length(name) <> 0) then
   136             KeyBindToName:= name
   136             KeyBindToName:= name
   137         else
   137         else
   138             begin
   138             begin
   139             WriteLnToConsole('Error: KeyBindToName('+bind+') failed to find SDL key name!');
   139             WriteLnToConsole('Error: KeyBindToName('+bind+') failed to find SDL key name!');
   140             KeyBindToName:= trmsg[sidUnknownKey];
   140             KeyBindToName:= trmsg[sidUnknownKey];