equal
deleted
inserted
replaced
52 LSHIFT = $0200; |
52 LSHIFT = $0200; |
53 RSHIFT = $0400; |
53 RSHIFT = $0400; |
54 LALT = $0800; |
54 LALT = $0800; |
55 RALT = $1000; |
55 RALT = $1000; |
56 LCTRL = $2000; |
56 LCTRL = $2000; |
57 RCTRL = $4000; |
57 RCTRL = $4000; |
58 |
58 |
59 var tkbd: array[0..cKbdMaxIndex] of boolean; |
59 var tkbd: array[0..cKbdMaxIndex] of boolean; |
60 quitKeyCode, closeKeyCode: Byte; |
60 quitKeyCode, closeKeyCode: Byte; |
61 KeyNames: array [0..cKeyMaxIndex] of string[15]; |
61 KeyNames: array [0..cKeyMaxIndex] of string[15]; |
62 CurrentBinds: TBinds; |
62 CurrentBinds: TBinds; |
|
63 ControllerNumControllers: Integer; |
|
64 ControllerEnabled: Integer; |
|
65 ControllerNumAxes: array[0..5] of Integer; |
|
66 //ControllerNumBalls: array[0..5] of Integer; |
|
67 ControllerNumHats: array[0..5] of Integer; |
|
68 ControllerNumButtons: array[0..5] of Integer; |
|
69 ControllerAxes: array[0..5] of array[0..19] of Integer; |
|
70 //ControllerBalls: array[0..5] of array[0..19] of array[0..1] of Integer; |
|
71 ControllerHats: array[0..5] of array[0..19] of Byte; |
|
72 ControllerButtons: array[0..5] of array[0..19] of Byte; |
63 |
73 |
64 function KeyNameToCode(name: shortstring): LongInt; inline; |
74 function KeyNameToCode(name: shortstring): LongInt; inline; |
65 begin |
75 begin |
66 KeyNameToCode:= KeyNameToCode(name, ''); |
76 KeyNameToCode:= KeyNameToCode(name, ''); |
67 end; |
77 end; |
77 KeyNameToCode:= code; |
87 KeyNameToCode:= code; |
78 end; |
88 end; |
79 (* |
89 (* |
80 procedure MaskModifier(var code: LongInt; Modifier: LongWord); |
90 procedure MaskModifier(var code: LongInt; Modifier: LongWord); |
81 begin |
91 begin |
82 if(Modifier and KMOD_LSHIFT) <> 0 then code:= code or LSHIFT; |
92 if(Modifier and KMOD_LSHIFT) <> 0 then code:= code or LSHIFT; |
83 if(Modifier and KMOD_RSHIFT) <> 0 then code:= code or LSHIFT; |
93 if(Modifier and KMOD_RSHIFT) <> 0 then code:= code or LSHIFT; |
84 if(Modifier and KMOD_LALT) <> 0 then code:= code or LALT; |
94 if(Modifier and KMOD_LALT) <> 0 then code:= code or LALT; |
85 if(Modifier and KMOD_RALT) <> 0 then code:= code or LALT; |
95 if(Modifier and KMOD_RALT) <> 0 then code:= code or LALT; |
86 if(Modifier and KMOD_LCTRL) <> 0 then code:= code or LCTRL; |
96 if(Modifier and KMOD_LCTRL) <> 0 then code:= code or LCTRL; |
87 if(Modifier and KMOD_RCTRL) <> 0 then code:= code or LCTRL; |
97 if(Modifier and KMOD_RCTRL) <> 0 then code:= code or LCTRL; |
88 end; |
98 end; |
89 *) |
99 *) |
90 procedure MaskModifier(Modifier: shortstring; var code: LongInt); |
100 procedure MaskModifier(Modifier: shortstring; var code: LongInt); |
91 var mod_ : shortstring; |
101 var mod_ : shortstring; |
92 ModifierCount, i: LongInt; |
102 ModifierCount, i: LongInt; |
98 if(Modifier[i] = ':') then inc(ModifierCount); |
108 if(Modifier[i] = ':') then inc(ModifierCount); |
99 |
109 |
100 SplitByChar(Modifier, mod_, ':');//remove the first mod: part |
110 SplitByChar(Modifier, mod_, ':');//remove the first mod: part |
101 Modifier:= mod_; |
111 Modifier:= mod_; |
102 for i:= 0 to ModifierCount do |
112 for i:= 0 to ModifierCount do |
103 begin |
113 begin |
104 mod_:= ''; |
114 mod_:= ''; |
105 SplitByChar(Modifier, mod_, ':'); |
115 SplitByChar(Modifier, mod_, ':'); |
106 if (Modifier = 'lshift') then code:= code or LSHIFT; |
116 if (Modifier = 'lshift') then code:= code or LSHIFT; |
107 if (Modifier = 'rshift') then code:= code or RSHIFT; |
117 if (Modifier = 'rshift') then code:= code or RSHIFT; |
108 if (Modifier = 'lalt') then code:= code or LALT; |
118 if (Modifier = 'lalt') then code:= code or LALT; |
219 for i:= 6 to cKeyMaxIndex do |
229 for i:= 6 to cKeyMaxIndex do |
220 begin |
230 begin |
221 s:= shortstring(sdl_getkeyname(i)); |
231 s:= shortstring(sdl_getkeyname(i)); |
222 //WriteLnToConsole('uInputHandler - ' + IntToStr(i) + ': ' + s + ' ' + IntToStr(cKeyMaxIndex)); |
232 //WriteLnToConsole('uInputHandler - ' + IntToStr(i) + ': ' + s + ' ' + IntToStr(cKeyMaxIndex)); |
223 if s = 'unknown key' then KeyNames[i]:= '' |
233 if s = 'unknown key' then KeyNames[i]:= '' |
224 else |
234 else |
225 begin |
235 begin |
226 for t:= 1 to Length(s) do |
236 for t:= 1 to Length(s) do |
227 if s[t] = ' ' then |
237 if s[t] = ' ' then |
228 s[t]:= '_'; |
238 s[t]:= '_'; |
229 KeyNames[i]:= LowerCase(s) |
239 KeyNames[i]:= LowerCase(s) |
379 ControllerEnabled:= 1; |
389 ControllerEnabled:= 1; |
380 |
390 |
381 if ControllerNumAxes[j] > 20 then |
391 if ControllerNumAxes[j] > 20 then |
382 ControllerNumAxes[j]:= 20; |
392 ControllerNumAxes[j]:= 20; |
383 //if ControllerNumBalls[j] > 20 then ControllerNumBalls[j]:= 20; |
393 //if ControllerNumBalls[j] > 20 then ControllerNumBalls[j]:= 20; |
384 |
394 |
385 if ControllerNumHats[j] > 20 then |
395 if ControllerNumHats[j] > 20 then |
386 ControllerNumHats[j]:= 20; |
396 ControllerNumHats[j]:= 20; |
387 |
397 |
388 if ControllerNumButtons[j] > 20 then |
398 if ControllerNumButtons[j] > 20 then |
389 ControllerNumButtons[j]:= 20; |
399 ControllerNumButtons[j]:= 20; |
390 |
400 |
391 // reset all buttons/axes |
401 // reset all buttons/axes |
392 for i:= 0 to pred(ControllerNumAxes[j]) do |
402 for i:= 0 to pred(ControllerNumAxes[j]) do |