equal
deleted
inserted
replaced
45 procedure ControllerButtonEvent(joy, button: Byte; pressed: Boolean); |
45 procedure ControllerButtonEvent(joy, button: Byte; pressed: Boolean); |
46 |
46 |
47 implementation |
47 implementation |
48 uses uConsole, uCommands, uMisc, uVariables, uConsts, uUtils, uDebug; |
48 uses uConsole, uCommands, uMisc, uVariables, uConsts, uUtils, uDebug; |
49 |
49 |
|
50 const |
|
51 LSHIFT = $0200; |
|
52 RSHIFT = $0400; |
|
53 LALT = $0800; |
|
54 RALT = $1000; |
|
55 LCTRL = $2000; |
|
56 RCTRL = $4000; |
|
57 |
50 var tkbd: array[0..cKbdMaxIndex] of boolean; |
58 var tkbd: array[0..cKbdMaxIndex] of boolean; |
51 quitKeyCode: Byte; |
59 quitKeyCode: Byte; |
52 KeyNames: array [0..cKeyMaxIndex] of string[15]; |
60 KeyNames: array [0..cKeyMaxIndex] of string[15]; |
53 CurrentBinds: TBinds; |
61 CurrentBinds: TBinds; |
54 |
62 |
63 KeyNameToCode:= code; |
71 KeyNameToCode:= code; |
64 end; |
72 end; |
65 |
73 |
66 procedure MaskModifier(var code: LongInt; Modifier: LongWord); |
74 procedure MaskModifier(var code: LongInt; Modifier: LongWord); |
67 begin |
75 begin |
68 code:= code or (modifier shl 10); |
76 if(Modifier and KMOD_LSHIFT) <> 0 then code:= code or LSHIFT; |
|
77 if(Modifier and KMOD_RSHIFT) <> 0 then code:= code or LSHIFT; |
|
78 if(Modifier and KMOD_LALT) <> 0 then code:= code or LALT; |
|
79 if(Modifier and KMOD_RALT) <> 0 then code:= code or LALT; |
|
80 if(Modifier and KMOD_LCTRL) <> 0 then code:= code or LCTRL; |
|
81 if(Modifier and KMOD_RCTRL) <> 0 then code:= code or LCTRL; |
69 end; |
82 end; |
70 |
83 |
71 procedure MaskModifier(Modifier: shortstring; var code: LongInt); |
84 procedure MaskModifier(Modifier: shortstring; var code: LongInt); |
72 var mod_ : shortstring; |
85 var mod_ : shortstring; |
73 ModifierCount, i: LongInt; |
86 ModifierCount, i: LongInt; |
82 Modifier:= mod_; |
95 Modifier:= mod_; |
83 for i:= 0 to ModifierCount do |
96 for i:= 0 to ModifierCount do |
84 begin |
97 begin |
85 mod_:= ''; |
98 mod_:= ''; |
86 SplitByChar(Modifier, mod_, ':'); |
99 SplitByChar(Modifier, mod_, ':'); |
87 if (Modifier = 'lshift') then code:= code or (KMOD_LSHIFT shl 10); |
100 if (Modifier = 'lshift') then code:= code or LSHIFT; |
88 if (Modifier = 'rshift') then code:= code or (KMOD_RSHIFT shl 10); |
101 if (Modifier = 'rshift') then code:= code or RSHIFT; |
89 if (Modifier = 'lalt') then code:= code or (KMOD_LALT shl 10); |
102 if (Modifier = 'lalt') then code:= code or LALT; |
90 if (Modifier = 'ralt') then code:= code or (KMOD_RALT shl 10); |
103 if (Modifier = 'ralt') then code:= code or RALT; |
91 if (Modifier = 'lctrl') or (mod_ = 'lmeta') then code:= code or (KMOD_LCTRL shl 10); |
104 if (Modifier = 'lctrl') or (mod_ = 'lmeta') then code:= code or LCTRL; |
92 if (Modifier = 'rctrl') or (mod_ = 'rmeta') then code:= code or (KMOD_RCTRL shl 10); |
105 if (Modifier = 'rctrl') or (mod_ = 'rmeta') then code:= code or RCTRL; |
93 Modifier:= mod_; |
106 Modifier:= mod_; |
94 end; |
107 end; |
95 end; |
108 end; |
96 |
109 |
97 procedure ProcessKey(code: LongInt; KeyDown: boolean); |
110 procedure ProcessKey(code: LongInt; KeyDown: boolean); |
142 procedure ProcessKey(event: TSDL_KeyboardEvent); inline; |
155 procedure ProcessKey(event: TSDL_KeyboardEvent); inline; |
143 var code: LongInt; |
156 var code: LongInt; |
144 begin |
157 begin |
145 code:= event.keysym.sym; |
158 code:= event.keysym.sym; |
146 MaskModifier(code, event.keysym.modifier); |
159 MaskModifier(code, event.keysym.modifier); |
147 |
|
148 ProcessKey(code, event.type_ = SDL_KEYDOWN); |
160 ProcessKey(code, event.type_ = SDL_KEYDOWN); |
149 end; |
161 end; |
150 |
162 |
151 procedure ProcessMouse(event: TSDL_MouseButtonEvent; ButtonDown: boolean); |
163 procedure ProcessMouse(event: TSDL_MouseButtonEvent; ButtonDown: boolean); |
152 begin |
164 begin |