31 |
31 |
32 procedure SetBinds(var binds: TBinds); |
32 procedure SetBinds(var binds: TBinds); |
33 procedure SetDefaultBinds; |
33 procedure SetDefaultBinds; |
34 |
34 |
35 var KbdKeyPressed: boolean; |
35 var KbdKeyPressed: boolean; |
|
36 wheelUp: boolean = false; |
|
37 wheelDown: boolean = false; |
36 |
38 |
37 implementation |
39 implementation |
38 uses SDLh, uTeams, uConsole, uMisc, uStore; |
40 uses SDLh, uTeams, uConsole, uMisc, uStore; |
39 const KeyNumber = 1024; |
41 const KeyNumber = 1024; |
40 type TKeyboardState = array[0..cKeyMaxIndex] of Byte; |
42 type TKeyboardState = array[0..cKeyMaxIndex] of Byte; |
68 {$ELSE} |
70 {$ELSE} |
69 pkbd := SDL_GetKeyState(nil); |
71 pkbd := SDL_GetKeyState(nil); |
70 i := SDL_GetMouseState(nil, nil); |
72 i := SDL_GetMouseState(nil, nil); |
71 {$ENDIF} |
73 {$ENDIF} |
72 |
74 |
73 |
75 // mouse buttons |
74 {$IFDEF DARWIN} |
76 {$IFDEF DARWIN} |
75 pkbd^[1]:= ((i and 1) and not (pkbd^[306] or pkbd^[305])); |
77 pkbd^[1]:= ((i and 1) and not (pkbd^[306] or pkbd^[305])); |
76 pkbd^[3]:= ((i and 1) and (pkbd^[306] or pkbd^[305])) or (i and 4); |
78 pkbd^[3]:= ((i and 1) and (pkbd^[306] or pkbd^[305])) or (i and 4); |
77 {$ELSE} |
79 {$ELSE} |
78 pkbd^[1]:= (i and 1); |
80 pkbd^[1]:= (i and 1); |
79 pkbd^[3]:= ((i shr 2) and 1); |
81 pkbd^[3]:= ((i shr 2) and 1); |
80 {$ENDIF} |
82 {$ENDIF} |
81 pkbd^[2]:= ((i shr 1) and 1); |
83 pkbd^[2]:= ((i shr 1) and 1); |
82 |
84 |
|
85 // mouse wheels (see event loop in project file) |
|
86 pkbd^[4]:= ord(wheelDown); |
|
87 pkbd^[5]:= ord(wheelUp); |
|
88 wheelUp:= false; |
|
89 wheelDown:= false; |
83 |
90 |
|
91 // now process strokes |
84 for i:= 1 to cKeyMaxIndex do |
92 for i:= 1 to cKeyMaxIndex do |
85 if CurrentBinds[i][0] <> #0 then |
93 if CurrentBinds[i][0] <> #0 then |
86 begin |
94 begin |
87 if (i > 3) and (pkbd^[i] <> 0) then KbdKeyPressed:= true; |
95 if (i > 3) and (pkbd^[i] <> 0) then KbdKeyPressed:= true; |
88 if (tkbd[i] = 0) and (pkbd^[i] <> 0) then ParseCommand(CurrentBinds[i], Trusted) |
96 if (tkbd[i] = 0) and (pkbd^[i] <> 0) then ParseCommand(CurrentBinds[i], Trusted) |
119 s: string[15]; |
127 s: string[15]; |
120 begin |
128 begin |
121 KeyNames[1]:= 'mousel'; |
129 KeyNames[1]:= 'mousel'; |
122 KeyNames[2]:= 'mousem'; |
130 KeyNames[2]:= 'mousem'; |
123 KeyNames[3]:= 'mouser'; |
131 KeyNames[3]:= 'mouser'; |
124 for i:= 4 to cKeyMaxIndex do |
132 KeyNames[4]:= 'wheelup'; |
|
133 KeyNames[5]:= 'wheeldown'; |
|
134 |
|
135 for i:= 6 to cKeyMaxIndex do |
125 begin |
136 begin |
126 s:= SDL_GetKeyName(i); |
137 s:= SDL_GetKeyName(i); |
|
138 //addfilelog(inttostr(i) + ' ' + s); |
127 if s = 'unknown key' then KeyNames[i]:= '' |
139 if s = 'unknown key' then KeyNames[i]:= '' |
128 else begin |
140 else begin |
129 for t:= 1 to Length(s) do |
141 for t:= 1 to Length(s) do |
130 if s[t] = ' ' then s[t]:= '_'; |
142 if s[t] = ' ' then s[t]:= '_'; |
131 KeyNames[i]:= s |
143 KeyNames[i]:= s |
132 end; |
144 end; |
133 end; |
145 end; |
134 |
146 |
135 DefaultBinds[ 27]:= 'quit'; // esc |
147 DefaultBinds[ 27]:= 'quit'; |
136 DefaultBinds[ 48]:= '+volup'; // 0 |
148 DefaultBinds[ 96]:= 'history'; |
137 DefaultBinds[ 57]:= '+voldown'; // 9 |
149 DefaultBinds[127]:= 'rotmask'; |
138 DefaultBinds[ 96]:= 'history'; // ` |
150 |
139 DefaultBinds[ 99]:= 'capture'; // c |
151 DefaultBinds[KeyNameToCode('0')]:= '+volup'; |
140 DefaultBinds[104]:= 'findhh'; // h |
152 DefaultBinds[KeyNameToCode('9')]:= '+voldown'; |
141 DefaultBinds[112]:= 'pause'; // p |
153 DefaultBinds[KeyNameToCode('c')]:= 'capture'; |
142 DefaultBinds[115]:= '+speedup'; // s |
154 DefaultBinds[KeyNameToCode('h')]:= 'findhh'; |
143 DefaultBinds[116]:= 'chat'; // t |
155 DefaultBinds[KeyNameToCode('p')]:= 'pause'; |
144 DefaultBinds[121]:= 'confirm'; // y |
156 DefaultBinds[KeyNameToCode('s')]:= '+speedup'; |
145 DefaultBinds[127]:= 'rotmask'; // canc |
157 DefaultBinds[KeyNameToCode('t')]:= 'chat'; |
|
158 DefaultBinds[KeyNameToCode('y')]:= 'confirm'; |
146 |
159 |
147 DefaultBinds[KeyNameToCode('f12')]:= 'fullscr'; |
160 DefaultBinds[KeyNameToCode('f12')]:= 'fullscr'; |
148 |
161 |
149 SetDefaultBinds |
162 SetDefaultBinds |
150 end; |
163 end; |