diff -r aa8d68817c32 -r 9419294e5f33 hedgewars/uInputHandler.pas --- a/hedgewars/uInputHandler.pas Wed Jun 06 17:56:39 2012 -0400 +++ b/hedgewars/uInputHandler.pas Thu Jun 07 01:10:57 2012 +0200 @@ -25,7 +25,9 @@ procedure initModule; procedure freeModule; -function KeyNameToCode(name: shortstring): word; +function KeyNameToCode(name: shortstring; Modifier: shortstring = ''): LongInt; +procedure MaskModifier(var code: LongInt; modifier: LongWord); +procedure MaskModifier(Modifier: shortstring; var code: LongInt); procedure ProcessMouse(event: TSDL_MouseButtonEvent; ButtonDown: boolean); procedure ProcessKey(event: TSDL_KeyboardEvent); inline; procedure ProcessKey(code: LongInt; KeyDown: boolean); @@ -45,37 +47,73 @@ implementation uses uConsole, uCommands, uMisc, uVariables, uConsts, uUtils, uDebug; -var tkbd: array[0..cKeyMaxIndex] of boolean; +var tkbd: array[0..cKbdMaxIndex] of boolean; quitKeyCode: Byte; KeyNames: array [0..cKeyMaxIndex] of string[15]; CurrentBinds: TBinds; -function KeyNameToCode(name: shortstring): word; -var code: Word; +function KeyNameToCode(name: shortstring; Modifier: shortstring): LongInt; +var code: LongInt; begin name:= LowerCase(name); code:= cKeyMaxIndex; while (code > 0) and (KeyNames[code] <> name) do dec(code); + + + MaskModifier(Modifier, code); + WriteLnToConsole(inttostr(code)); + KeyNameToCode:= code; end; +procedure MaskModifier(var code: LongInt; Modifier: LongWord); +begin + WriteLnToConsole(inttostr(code)); + code:= code or (modifier shl 10); + WriteLnToConsole(inttostr(code)); +end; + +procedure MaskModifier(Modifier: shortstring; var code: LongInt); +var mod_ : shortstring; + ModifierCount, i: LongInt; + c : char; +begin +if Modifier = '' then exit; +ModifierCount:= 0; +for c in Modifier do + if(c = ':') then inc(ModifierCount); + +SplitByChar(Modifier, mod_, ':');//remove the first mod: part +Modifier:= mod_; +for i:= 0 to ModifierCount do + begin + mod_:= ''; + SplitByChar(Modifier, mod_, ':'); + WriteLnToConsole(Modifier + ' baaaaa' ); + if (Modifier = 'lshift') then code:= code or (KMOD_LSHIFT shl 10); + if (Modifier = 'rshift') then code:= code or (KMOD_RSHIFT shl 10); + if (Modifier = 'lalt') then code:= code or (KMOD_LALT shl 10); + if (Modifier = 'ralt') then code:= code or (KMOD_RALT shl 10); + if (Modifier = 'lctrl') or (mod_ = 'lmeta') then code:= code or (KMOD_LCTRL shl 10); + if (Modifier = 'rctrl') or (mod_ = 'rmeta') then code:= code or (KMOD_RCTRL shl 10); + Modifier:= mod_; + end; +end; + procedure ProcessKey(code: LongInt; KeyDown: boolean); var Trusted: boolean; s : string; begin - +WriteLnToConsole(inttostr(code) + ' KeyDown:' + inttostr(ord(keydown)) + CurrentBinds[code]) ; if not(tkbd[code] xor KeyDown) then exit; tkbd[code]:= KeyDown; - hideAmmoMenu:= false; Trusted:= (CurrentTeam <> nil) and (not CurrentTeam^.ExtDriven) and (CurrentHedgehog^.BotLevel = 0); - - // ctrl/cmd + q to close engine and frontend if(KeyDown and (code = quitKeyCode)) then begin @@ -109,8 +147,12 @@ end; procedure ProcessKey(event: TSDL_KeyboardEvent); inline; +var code: LongInt; begin - ProcessKey(event.keysym.sym, event.type_ = SDL_KEYDOWN); + code:= event.keysym.sym; + MaskModifier(code, event.keysym.modifier); + + ProcessKey(code, event.type_ = SDL_KEYDOWN); end; procedure ProcessMouse(event: TSDL_MouseButtonEvent; ButtonDown: boolean); @@ -132,7 +174,7 @@ procedure ResetKbd; var t: LongInt; begin -for t:= 0 to cKeyMaxIndex do +for t:= 0 to cKbdMaxIndex do if tkbd[t] then ProcessKey(t, False); end; @@ -248,7 +290,7 @@ binds:= binds; // avoid hint CurrentBinds:= DefaultBinds; {$ELSE} -for t:= 0 to cKeyMaxIndex do +for t:= 0 to cKbdMaxIndex do if (CurrentBinds[t] <> binds[t]) and tkbd[t] then ProcessKey(t, False);