comparison docs/html/sdlkeysym.html @ 0:74212992fb08

Initial revision
author Sam Lantinga <slouken@lokigames.com>
date Thu, 26 Apr 2001 16:45:43 +0000
parents
children 55f1f1b3e27d
comparison
equal deleted inserted replaced
-1:000000000000 0:74212992fb08
1 <HTML
2 ><HEAD
3 ><TITLE
4 >SDL_keysym</TITLE
5 ><META
6 NAME="GENERATOR"
7 CONTENT="Modular DocBook HTML Stylesheet Version 1.61
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_QuitEvent"
17 HREF="sdlquitevent.html"><LINK
18 REL="NEXT"
19 TITLE="SDLKey"
20 HREF="sdlkey.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
31 WIDTH="100%"
32 BORDER="0"
33 CELLPADDING="0"
34 CELLSPACING="0"
35 ><TR
36 ><TH
37 COLSPAN="3"
38 ALIGN="center"
39 >SDL Library Documentation</TH
40 ></TR
41 ><TR
42 ><TD
43 WIDTH="10%"
44 ALIGN="left"
45 VALIGN="bottom"
46 ><A
47 HREF="sdlquitevent.html"
48 >Prev</A
49 ></TD
50 ><TD
51 WIDTH="80%"
52 ALIGN="center"
53 VALIGN="bottom"
54 ></TD
55 ><TD
56 WIDTH="10%"
57 ALIGN="right"
58 VALIGN="bottom"
59 ><A
60 HREF="sdlkey.html"
61 >Next</A
62 ></TD
63 ></TR
64 ></TABLE
65 ><HR
66 ALIGN="LEFT"
67 WIDTH="100%"></DIV
68 ><H1
69 ><A
70 NAME="SDLKEYSYM"
71 >SDL_keysym</A
72 ></H1
73 ><DIV
74 CLASS="REFNAMEDIV"
75 ><A
76 NAME="AEN4116"
77 ></A
78 ><H2
79 >Name</H2
80 >SDL_keysym&nbsp;--&nbsp;Keysym structure</DIV
81 ><DIV
82 CLASS="REFSECT1"
83 ><A
84 NAME="AEN4119"
85 ></A
86 ><H2
87 >Structure Definition</H2
88 ><PRE
89 CLASS="PROGRAMLISTING"
90 >typedef struct{
91 Uint8 scancode;
92 SDLKey sym;
93 SDLMod mod;
94 Uint16 unicode;
95 } SDL_keysym;</PRE
96 ></DIV
97 ><DIV
98 CLASS="REFSECT1"
99 ><A
100 NAME="AEN4122"
101 ></A
102 ><H2
103 >Structure Data</H2
104 ><DIV
105 CLASS="INFORMALTABLE"
106 ><A
107 NAME="AEN4124"
108 ></A
109 ><P
110 ></P
111 ><TABLE
112 BORDER="0"
113 CLASS="CALSTABLE"
114 ><TBODY
115 ><TR
116 ><TD
117 ALIGN="LEFT"
118 VALIGN="TOP"
119 ><TT
120 CLASS="STRUCTFIELD"
121 ><I
122 >scancode</I
123 ></TT
124 ></TD
125 ><TD
126 ALIGN="LEFT"
127 VALIGN="TOP"
128 >Hardware specific scancode</TD
129 ></TR
130 ><TR
131 ><TD
132 ALIGN="LEFT"
133 VALIGN="TOP"
134 ><TT
135 CLASS="STRUCTFIELD"
136 ><I
137 >sym</I
138 ></TT
139 ></TD
140 ><TD
141 ALIGN="LEFT"
142 VALIGN="TOP"
143 >SDL virtual keysym</TD
144 ></TR
145 ><TR
146 ><TD
147 ALIGN="LEFT"
148 VALIGN="TOP"
149 ><TT
150 CLASS="STRUCTFIELD"
151 ><I
152 >mod</I
153 ></TT
154 ></TD
155 ><TD
156 ALIGN="LEFT"
157 VALIGN="TOP"
158 >Current key modifiers</TD
159 ></TR
160 ><TR
161 ><TD
162 ALIGN="LEFT"
163 VALIGN="TOP"
164 ><TT
165 CLASS="STRUCTFIELD"
166 ><I
167 >unicode</I
168 ></TT
169 ></TD
170 ><TD
171 ALIGN="LEFT"
172 VALIGN="TOP"
173 >Translated character</TD
174 ></TR
175 ></TBODY
176 ></TABLE
177 ><P
178 ></P
179 ></DIV
180 ></DIV
181 ><DIV
182 CLASS="REFSECT1"
183 ><A
184 NAME="AEN4143"
185 ></A
186 ><H2
187 >Description</H2
188 ><P
189 >The <SPAN
190 CLASS="STRUCTNAME"
191 >SDL_keysym</SPAN
192 > structure is used by reporting key presses and releases since it is a part of the <A
193 HREF="sdlkeyboardevent.html"
194 ><SPAN
195 CLASS="STRUCTNAME"
196 >SDL_KeyboardEvent</SPAN
197 ></A
198 >.</P
199 ><P
200 >The <TT
201 CLASS="STRUCTFIELD"
202 ><I
203 >scancode</I
204 ></TT
205 > field should generally be left alone, it is the hardware dependent scancode returned by the keyboard. The <TT
206 CLASS="STRUCTFIELD"
207 ><I
208 >sym</I
209 ></TT
210 > field is extremely useful. It is the SDL-defined value of the key (see <A
211 HREF="sdlkey.html"
212 >SDL Key Syms</A
213 >. This field is very useful when you are checking for certain key presses, like so:
214 <PRE
215 CLASS="PROGRAMLISTING"
216 >.
217 .
218 while(SDL_PollEvent(&#38;event)){
219 switch(event.type){
220 case SDL_KEYDOWN:
221 if(event.key.keysym.sym==SDLK_LEFT)
222 move_left();
223 break;
224 .
225 .
226 .
227 }
228 }
229 .
230 .</PRE
231 >
232 <TT
233 CLASS="STRUCTFIELD"
234 ><I
235 >mod</I
236 ></TT
237 > stores the current state of the keyboard modifiers as explained in <A
238 HREF="sdlgetmodstate.html"
239 ><TT
240 CLASS="FUNCTION"
241 >SDL_GetModState</TT
242 ></A
243 >. The <TT
244 CLASS="STRUCTFIELD"
245 ><I
246 >unicode</I
247 ></TT
248 > is only used when UNICODE translation is enabled with <A
249 HREF="sdlenableunicode.html"
250 ><TT
251 CLASS="FUNCTION"
252 >SDL_EnableUNICODE</TT
253 ></A
254 >. If <TT
255 CLASS="STRUCTFIELD"
256 ><I
257 >unicode</I
258 ></TT
259 > is non-zero then this a the UNICODE character corresponding to the keypress. If the high 9 bits of the character are 0, then this maps to the equivalent ASCII character:
260 <PRE
261 CLASS="PROGRAMLISTING"
262 >char ch;
263 if ( (keysym.unicode &#38; 0xFF80) == 0 ) {
264 ch = keysym.unicode &#38; 0x7F;
265 }
266 else {
267 printf("An International Character.\n");
268 }</PRE
269 >
270 UNICODE translation does have a slight overhead so don't enable it unless its needed.</P
271 ></DIV
272 ><DIV
273 CLASS="REFSECT1"
274 ><A
275 NAME="AEN4162"
276 ></A
277 ><H2
278 >See Also</H2
279 ><P
280 ><A
281 HREF="sdlkey.html"
282 ><SPAN
283 CLASS="STRUCTNAME"
284 >SDLKey</SPAN
285 ></A
286 ></P
287 ></DIV
288 ><DIV
289 CLASS="NAVFOOTER"
290 ><HR
291 ALIGN="LEFT"
292 WIDTH="100%"><TABLE
293 WIDTH="100%"
294 BORDER="0"
295 CELLPADDING="0"
296 CELLSPACING="0"
297 ><TR
298 ><TD
299 WIDTH="33%"
300 ALIGN="left"
301 VALIGN="top"
302 ><A
303 HREF="sdlquitevent.html"
304 >Prev</A
305 ></TD
306 ><TD
307 WIDTH="34%"
308 ALIGN="center"
309 VALIGN="top"
310 ><A
311 HREF="index.html"
312 >Home</A
313 ></TD
314 ><TD
315 WIDTH="33%"
316 ALIGN="right"
317 VALIGN="top"
318 ><A
319 HREF="sdlkey.html"
320 >Next</A
321 ></TD
322 ></TR
323 ><TR
324 ><TD
325 WIDTH="33%"
326 ALIGN="left"
327 VALIGN="top"
328 >SDL_QuitEvent</TD
329 ><TD
330 WIDTH="34%"
331 ALIGN="center"
332 VALIGN="top"
333 ><A
334 HREF="eventstructures.html"
335 >Up</A
336 ></TD
337 ><TD
338 WIDTH="33%"
339 ALIGN="right"
340 VALIGN="top"
341 >SDLKey</TD
342 ></TR
343 ></TABLE
344 ></DIV
345 ></BODY
346 ></HTML
347 >