23 uses SDLh, uTypes; |
23 uses SDLh, uTypes; |
24 |
24 |
25 procedure initModule; |
25 procedure initModule; |
26 procedure freeModule; |
26 procedure freeModule; |
27 |
27 |
28 function KeyNameToCode(name: shortstring; Modifier: shortstring = ''): LongInt; |
28 function KeyNameToCode(name: shortstring): LongInt; inline; |
29 procedure MaskModifier(var code: LongInt; modifier: LongWord); |
29 function KeyNameToCode(name: shortstring; Modifier: shortstring): LongInt; |
|
30 //procedure MaskModifier(var code: LongInt; modifier: LongWord); |
30 procedure MaskModifier(Modifier: shortstring; var code: LongInt); |
31 procedure MaskModifier(Modifier: shortstring; var code: LongInt); |
31 procedure ProcessMouse(event: TSDL_MouseButtonEvent; ButtonDown: boolean); |
32 procedure ProcessMouse(event: TSDL_MouseButtonEvent; ButtonDown: boolean); |
32 procedure ProcessKey(event: TSDL_KeyboardEvent); inline; |
33 procedure ProcessKey(event: TSDL_KeyboardEvent); inline; |
33 procedure ProcessKey(code: LongInt; KeyDown: boolean); |
34 procedure ProcessKey(code: LongInt; KeyDown: boolean); |
34 |
35 |
58 var tkbd: array[0..cKbdMaxIndex] of boolean; |
59 var tkbd: array[0..cKbdMaxIndex] of boolean; |
59 quitKeyCode: Byte; |
60 quitKeyCode: Byte; |
60 KeyNames: array [0..cKeyMaxIndex] of string[15]; |
61 KeyNames: array [0..cKeyMaxIndex] of string[15]; |
61 CurrentBinds: TBinds; |
62 CurrentBinds: TBinds; |
62 |
63 |
|
64 function KeyNameToCode(name: shortstring): LongInt; inline; |
|
65 begin |
|
66 KeyNameToCode:= KeyNameToCode(name, ''); |
|
67 end; |
|
68 |
63 function KeyNameToCode(name: shortstring; Modifier: shortstring): LongInt; |
69 function KeyNameToCode(name: shortstring; Modifier: shortstring): LongInt; |
64 var code: LongInt; |
70 var code: LongInt; |
65 begin |
71 begin |
66 name:= LowerCase(name); |
72 name:= LowerCase(name); |
67 code:= cKeyMaxIndex; |
73 code:= cKeyMaxIndex; |
68 while (code > 0) and (KeyNames[code] <> name) do dec(code); |
74 while (code > 0) and (KeyNames[code] <> name) do dec(code); |
69 |
75 |
70 MaskModifier(Modifier, code); |
76 MaskModifier(Modifier, code); |
71 KeyNameToCode:= code; |
77 KeyNameToCode:= code; |
72 end; |
78 end; |
73 |
79 (* |
74 procedure MaskModifier(var code: LongInt; Modifier: LongWord); |
80 procedure MaskModifier(var code: LongInt; Modifier: LongWord); |
75 begin |
81 begin |
76 if(Modifier and KMOD_LSHIFT) <> 0 then code:= code or LSHIFT; |
82 if(Modifier and KMOD_LSHIFT) <> 0 then code:= code or LSHIFT; |
77 if(Modifier and KMOD_RSHIFT) <> 0 then code:= code or LSHIFT; |
83 if(Modifier and KMOD_RSHIFT) <> 0 then code:= code or LSHIFT; |
78 if(Modifier and KMOD_LALT) <> 0 then code:= code or LALT; |
84 if(Modifier and KMOD_LALT) <> 0 then code:= code or LALT; |
79 if(Modifier and KMOD_RALT) <> 0 then code:= code or LALT; |
85 if(Modifier and KMOD_RALT) <> 0 then code:= code or LALT; |
80 if(Modifier and KMOD_LCTRL) <> 0 then code:= code or LCTRL; |
86 if(Modifier and KMOD_LCTRL) <> 0 then code:= code or LCTRL; |
81 if(Modifier and KMOD_RCTRL) <> 0 then code:= code or LCTRL; |
87 if(Modifier and KMOD_RCTRL) <> 0 then code:= code or LCTRL; |
82 end; |
88 end; |
83 |
89 *) |
84 procedure MaskModifier(Modifier: shortstring; var code: LongInt); |
90 procedure MaskModifier(Modifier: shortstring; var code: LongInt); |
85 var mod_ : shortstring; |
91 var mod_ : shortstring; |
86 ModifierCount, i: LongInt; |
92 ModifierCount, i: LongInt; |
87 begin |
93 begin |
88 if Modifier = '' then exit; |
94 if Modifier = '' then exit; |
131 ParseCommand('halt', true); |
137 ParseCommand('halt', true); |
132 end; |
138 end; |
133 |
139 |
134 if CurrentBinds[code][0] <> #0 then |
140 if CurrentBinds[code][0] <> #0 then |
135 begin |
141 begin |
136 if (code > 3) and KeyDown and not ((CurrentBinds[code] = 'put') or (CurrentBinds[code] = 'ammomenu') or (CurrentBinds[code] = '+cur_u') or (CurrentBinds[code] = '+cur_d') or (CurrentBinds[code] = '+cur_l') or (CurrentBinds[code] = '+cur_r')) then hideAmmoMenu:= true; |
142 if (code > 3) and KeyDown and (not ((CurrentBinds[code] = 'put')) or (CurrentBinds[code] = 'ammomenu') or (CurrentBinds[code] = '+cur_u') or (CurrentBinds[code] = '+cur_d') or (CurrentBinds[code] = '+cur_l') or (CurrentBinds[code] = '+cur_r')) then hideAmmoMenu:= true; |
137 |
143 |
138 if KeyDown then |
144 if KeyDown then |
139 begin |
145 begin |
140 ParseCommand(CurrentBinds[code], Trusted); |
146 ParseCommand(CurrentBinds[code], Trusted); |
141 if (CurrentTeam <> nil) and (not CurrentTeam^.ExtDriven) and (ReadyTimeLeft > 1) then |
147 if (CurrentTeam <> nil) and (not CurrentTeam^.ExtDriven) and (ReadyTimeLeft > 1) then |