Mercurial > sdl-ios-xcode
annotate docs/html/sdlkeyboardevent.html @ 934:af585d6efec8
Date: Thu, 17 Jun 2004 11:38:51 -0700 (PDT)
From: Eric Wing <ewing2121@yahoo.com>
Subject: New OS X patch (was Re: [SDL] Bug with inverted mouse coordinates in
I have a new patch for OS X I would like to submit.
First, it appears no further action has been taken on
my fix from Apple on the OpenGL windowed mode mouse
inversion problem. The fix would reunify the code, and
no longer require case checking for which version of
the OS you are running. This is probably a good fix
because the behavior with the old code could change
again with future versions of the OS, so those fixes
are included in this new patch.
But in addition, when I was at Apple, I asked them
about the ability to distinguish between the modifier
keys on the left and right sides of the keyboard (e.g.
Left Shift, Right Shift, Left/Right Alt, L/R Cmd, L/R
Ctrl). They told me that starting with Panther, the OS
began supporting this feature. This has always been a
source of annoyance for me when bringing a program
that comes from Windows or Linux to OS X when the
keybindings happened to need distinguishable left-side
and right-side keys. So the rest of the patch I am
submitting contains new code to support this feature
on Panther (and presumably later versions of the OS).
So after removing the OS version checks for the mouse
inversion problem, I reused the OS version checks to
activate the Left/Right detection of modifier keys. If
you are running Panther (or above), the new code will
attempt to distinguish between sides. For the older
OS's, the code path reverts to the original code.
I've tested with Panther on a G4 Cube, G5 dual
processor, and Powerbook Rev C. The Cube and G5
keyboards demonstrated the ability to distinguish
between sides. The Powerbook seems to only have
left-side keys, but the patch was still able to handle
it by producing the same results as before the patch.
I also wanted to test a non-Apple keyboard.
Unfortunately, I don't have any PC USB keyboards.
However, I was able to borrow a Sun Microsystems USB
keyboard, so I tried that out on the G5, and I got the
correct behavior for left and right sides. I'm
expecting that if it worked with a Sun keyboard, most
other keyboards should work with no problems.
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Fri, 20 Aug 2004 22:35:23 +0000 |
parents | 355632dca928 |
children |
rev | line source |
---|---|
0 | 1 <HTML |
2 ><HEAD | |
3 ><TITLE | |
4 >SDL_KeyboardEvent</TITLE | |
5 ><META | |
6 NAME="GENERATOR" | |
803
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
181
diff
changeset
|
7 CONTENT="Modular DocBook HTML Stylesheet Version 1.76b+ |
0 | 8 "><LINK |
9 REL="HOME" | |
10 TITLE="SDL Library Documentation" | |
11 HREF="index.html"><LINK | |
12 REL="UP" | |
13 TITLE="SDL Event Structures." | |
14 HREF="eventstructures.html"><LINK | |
15 REL="PREVIOUS" | |
16 TITLE="SDL_ActiveEvent" | |
17 HREF="sdlactiveevent.html"><LINK | |
18 REL="NEXT" | |
19 TITLE="SDL_MouseMotionEvent" | |
20 HREF="sdlmousemotionevent.html"></HEAD | |
21 ><BODY | |
22 CLASS="REFENTRY" | |
23 BGCOLOR="#FFF8DC" | |
24 TEXT="#000000" | |
25 LINK="#0000ee" | |
26 VLINK="#551a8b" | |
27 ALINK="#ff0000" | |
28 ><DIV | |
29 CLASS="NAVHEADER" | |
30 ><TABLE | |
803
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
181
diff
changeset
|
31 SUMMARY="Header navigation table" |
0 | 32 WIDTH="100%" |
33 BORDER="0" | |
34 CELLPADDING="0" | |
35 CELLSPACING="0" | |
36 ><TR | |
37 ><TH | |
38 COLSPAN="3" | |
39 ALIGN="center" | |
40 >SDL Library Documentation</TH | |
41 ></TR | |
42 ><TR | |
43 ><TD | |
44 WIDTH="10%" | |
45 ALIGN="left" | |
46 VALIGN="bottom" | |
47 ><A | |
48 HREF="sdlactiveevent.html" | |
803
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
181
diff
changeset
|
49 ACCESSKEY="P" |
0 | 50 >Prev</A |
51 ></TD | |
52 ><TD | |
53 WIDTH="80%" | |
54 ALIGN="center" | |
55 VALIGN="bottom" | |
56 ></TD | |
57 ><TD | |
58 WIDTH="10%" | |
59 ALIGN="right" | |
60 VALIGN="bottom" | |
61 ><A | |
62 HREF="sdlmousemotionevent.html" | |
803
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
181
diff
changeset
|
63 ACCESSKEY="N" |
0 | 64 >Next</A |
65 ></TD | |
66 ></TR | |
67 ></TABLE | |
68 ><HR | |
69 ALIGN="LEFT" | |
70 WIDTH="100%"></DIV | |
71 ><H1 | |
72 ><A | |
73 NAME="SDLKEYBOARDEVENT" | |
803
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
181
diff
changeset
|
74 ></A |
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
181
diff
changeset
|
75 >SDL_KeyboardEvent</H1 |
0 | 76 ><DIV |
77 CLASS="REFNAMEDIV" | |
78 ><A | |
803
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
181
diff
changeset
|
79 NAME="AEN4011" |
0 | 80 ></A |
81 ><H2 | |
82 >Name</H2 | |
83 >SDL_KeyboardEvent -- Keyboard event structure</DIV | |
84 ><DIV | |
85 CLASS="REFSECT1" | |
86 ><A | |
803
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
181
diff
changeset
|
87 NAME="AEN4014" |
0 | 88 ></A |
89 ><H2 | |
90 >Structure Definition</H2 | |
91 ><PRE | |
92 CLASS="PROGRAMLISTING" | |
93 >typedef struct{ | |
94 Uint8 type; | |
95 Uint8 state; | |
96 SDL_keysym keysym; | |
97 } SDL_KeyboardEvent;</PRE | |
98 ></DIV | |
99 ><DIV | |
100 CLASS="REFSECT1" | |
101 ><A | |
803
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
181
diff
changeset
|
102 NAME="AEN4017" |
0 | 103 ></A |
104 ><H2 | |
105 >Structure Data</H2 | |
106 ><DIV | |
107 CLASS="INFORMALTABLE" | |
108 ><A | |
803
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
181
diff
changeset
|
109 NAME="AEN4019" |
0 | 110 ></A |
111 ><P | |
112 ></P | |
113 ><TABLE | |
114 BORDER="0" | |
115 CLASS="CALSTABLE" | |
116 ><TBODY | |
117 ><TR | |
118 ><TD | |
119 ALIGN="LEFT" | |
120 VALIGN="TOP" | |
121 ><TT | |
122 CLASS="STRUCTFIELD" | |
123 ><I | |
124 >type</I | |
125 ></TT | |
126 ></TD | |
127 ><TD | |
128 ALIGN="LEFT" | |
129 VALIGN="TOP" | |
130 ><TT | |
131 CLASS="LITERAL" | |
132 >SDL_KEYDOWN</TT | |
133 > or <TT | |
134 CLASS="LITERAL" | |
135 >SDL_KEYUP</TT | |
136 ></TD | |
137 ></TR | |
138 ><TR | |
139 ><TD | |
140 ALIGN="LEFT" | |
141 VALIGN="TOP" | |
142 ><TT | |
143 CLASS="STRUCTFIELD" | |
144 ><I | |
145 >state</I | |
146 ></TT | |
147 ></TD | |
148 ><TD | |
149 ALIGN="LEFT" | |
150 VALIGN="TOP" | |
151 ><TT | |
152 CLASS="LITERAL" | |
153 >SDL_PRESSED</TT | |
154 > or <TT | |
155 CLASS="LITERAL" | |
156 >SDL_RELEASED</TT | |
157 ></TD | |
158 ></TR | |
159 ><TR | |
160 ><TD | |
161 ALIGN="LEFT" | |
162 VALIGN="TOP" | |
163 ><TT | |
164 CLASS="STRUCTFIELD" | |
165 ><I | |
166 >keysym</I | |
167 ></TT | |
168 ></TD | |
169 ><TD | |
170 ALIGN="LEFT" | |
171 VALIGN="TOP" | |
172 >Contains key press information</TD | |
173 ></TR | |
174 ></TBODY | |
175 ></TABLE | |
176 ><P | |
177 ></P | |
178 ></DIV | |
179 ></DIV | |
180 ><DIV | |
181 CLASS="REFSECT1" | |
182 ><A | |
803
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
181
diff
changeset
|
183 NAME="AEN4038" |
0 | 184 ></A |
185 ><H2 | |
186 >Description</H2 | |
187 ><P | |
188 ><SPAN | |
189 CLASS="STRUCTNAME" | |
190 >SDL_KeyboardEvent</SPAN | |
191 > is a member of the <A | |
192 HREF="sdlevent.html" | |
193 ><SPAN | |
194 CLASS="STRUCTNAME" | |
195 >SDL_Event</SPAN | |
196 ></A | |
197 > union and is used when an event of type <TT | |
198 CLASS="LITERAL" | |
199 >SDL_KEYDOWN</TT | |
200 > or <TT | |
201 CLASS="LITERAL" | |
202 >SDL_KEYUP</TT | |
203 > is reported.</P | |
204 ><P | |
205 >The <TT | |
206 CLASS="STRUCTFIELD" | |
207 ><I | |
208 >type</I | |
209 ></TT | |
210 > and <TT | |
211 CLASS="STRUCTFIELD" | |
212 ><I | |
213 >state</I | |
214 ></TT | |
215 > actually report the same information, they just use different values to do it! A keyboard event occurs when a key is released (<TT | |
216 CLASS="STRUCTFIELD" | |
217 ><I | |
218 >type</I | |
219 ></TT | |
220 >=<TT | |
221 CLASS="LITERAL" | |
222 >SDK_KEYUP</TT | |
223 > or <TT | |
224 CLASS="STRUCTFIELD" | |
225 ><I | |
226 >state</I | |
227 ></TT | |
228 >=<TT | |
229 CLASS="LITERAL" | |
230 >SDL_RELEASED</TT | |
231 >) and when a key is pressed (<TT | |
232 CLASS="STRUCTFIELD" | |
233 ><I | |
234 >type</I | |
235 ></TT | |
236 >=<TT | |
237 CLASS="LITERAL" | |
238 >SDL_KEYDOWN</TT | |
239 > or <TT | |
240 CLASS="STRUCTFIELD" | |
241 ><I | |
242 >state</I | |
243 ></TT | |
244 >=<TT | |
245 CLASS="LITERAL" | |
246 >SDL_PRESSED</TT | |
247 >). The information on what key was pressed or released is in the <A | |
248 HREF="sdlkeysym.html" | |
249 ><SPAN | |
250 CLASS="STRUCTNAME" | |
251 >keysym</SPAN | |
252 ></A | |
253 > structure.</P | |
254 ><DIV | |
255 CLASS="NOTE" | |
256 ><BLOCKQUOTE | |
257 CLASS="NOTE" | |
258 ><P | |
259 ><B | |
260 >Note: </B | |
261 >Repeating <TT | |
262 CLASS="LITERAL" | |
263 >SDL_KEYDOWN</TT | |
264 > events will occur if key repeat is enabled (see <A | |
265 HREF="sdlenablekeyrepeat.html" | |
266 ><TT | |
267 CLASS="FUNCTION" | |
268 >SDL_EnableKeyRepeat</TT | |
269 ></A | |
270 >).</P | |
271 ></BLOCKQUOTE | |
272 ></DIV | |
273 ></DIV | |
274 ><DIV | |
275 CLASS="REFSECT1" | |
276 ><A | |
803
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
181
diff
changeset
|
277 NAME="AEN4064" |
0 | 278 ></A |
279 ><H2 | |
280 >See Also</H2 | |
281 ><P | |
282 ><A | |
283 HREF="sdlevent.html" | |
284 ><SPAN | |
285 CLASS="STRUCTNAME" | |
286 >SDL_Event</SPAN | |
287 ></A | |
288 >, | |
289 <A | |
290 HREF="sdlkeysym.html" | |
291 ><SPAN | |
292 CLASS="STRUCTNAME" | |
293 >SDL_keysym</SPAN | |
294 ></A | |
295 >, | |
296 <A | |
297 HREF="sdlenablekeyrepeat.html" | |
298 ><TT | |
299 CLASS="FUNCTION" | |
300 >SDL_EnableKeyRepeat</TT | |
301 ></A | |
302 >, | |
303 <A | |
304 HREF="sdlenableunicode.html" | |
305 ><TT | |
306 CLASS="FUNCTION" | |
307 >SDL_EnableUNICODE</TT | |
308 ></A | |
309 ></P | |
310 ></DIV | |
311 ><DIV | |
312 CLASS="NAVFOOTER" | |
313 ><HR | |
314 ALIGN="LEFT" | |
315 WIDTH="100%"><TABLE | |
803
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
181
diff
changeset
|
316 SUMMARY="Footer navigation table" |
0 | 317 WIDTH="100%" |
318 BORDER="0" | |
319 CELLPADDING="0" | |
320 CELLSPACING="0" | |
321 ><TR | |
322 ><TD | |
323 WIDTH="33%" | |
324 ALIGN="left" | |
325 VALIGN="top" | |
326 ><A | |
327 HREF="sdlactiveevent.html" | |
803
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
181
diff
changeset
|
328 ACCESSKEY="P" |
0 | 329 >Prev</A |
330 ></TD | |
331 ><TD | |
332 WIDTH="34%" | |
333 ALIGN="center" | |
334 VALIGN="top" | |
335 ><A | |
336 HREF="index.html" | |
803
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
181
diff
changeset
|
337 ACCESSKEY="H" |
0 | 338 >Home</A |
339 ></TD | |
340 ><TD | |
341 WIDTH="33%" | |
342 ALIGN="right" | |
343 VALIGN="top" | |
344 ><A | |
345 HREF="sdlmousemotionevent.html" | |
803
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
181
diff
changeset
|
346 ACCESSKEY="N" |
0 | 347 >Next</A |
348 ></TD | |
349 ></TR | |
350 ><TR | |
351 ><TD | |
352 WIDTH="33%" | |
353 ALIGN="left" | |
354 VALIGN="top" | |
355 >SDL_ActiveEvent</TD | |
356 ><TD | |
357 WIDTH="34%" | |
358 ALIGN="center" | |
359 VALIGN="top" | |
360 ><A | |
361 HREF="eventstructures.html" | |
803
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
181
diff
changeset
|
362 ACCESSKEY="U" |
0 | 363 >Up</A |
364 ></TD | |
365 ><TD | |
366 WIDTH="33%" | |
367 ALIGN="right" | |
368 VALIGN="top" | |
369 >SDL_MouseMotionEvent</TD | |
370 ></TR | |
371 ></TABLE | |
372 ></DIV | |
373 ></BODY | |
374 ></HTML | |
375 > |