Mercurial > sdl-ios-xcode
annotate src/video/cybergfx/SDL_amigaevents.c @ 1338:604d73db6802
Removed uses of stdlib.h and string.h
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Tue, 07 Feb 2006 09:29:18 +0000 |
parents | c9b51268668f |
children | 19418e4422cb |
rev | line source |
---|---|
0 | 1 /* |
2 SDL - Simple DirectMedia Layer | |
1312
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
3 Copyright (C) 1997-2006 Sam Lantinga |
0 | 4 |
5 This library is free software; you can redistribute it and/or | |
1312
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
6 modify it under the terms of the GNU Lesser General Public |
0 | 7 License as published by the Free Software Foundation; either |
1312
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
8 version 2.1 of the License, or (at your option) any later version. |
0 | 9 |
10 This library is distributed in the hope that it will be useful, | |
11 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
1312
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
13 Lesser General Public License for more details. |
0 | 14 |
1312
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
15 You should have received a copy of the GNU Lesser General Public |
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
16 License along with this library; if not, write to the Free Software |
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
0 | 18 |
19 Sam Lantinga | |
252
e8157fcb3114
Updated the source with the correct e-mail address
Sam Lantinga <slouken@libsdl.org>
parents:
21
diff
changeset
|
20 slouken@libsdl.org |
0 | 21 */ |
22 | |
23 /* Handle the event stream, converting Amiga events into SDL events */ | |
24 #include "SDL.h" | |
25 | |
26 #include "SDL_syswm.h" | |
27 #include "SDL_sysevents.h" | |
28 #include "SDL_sysvideo.h" | |
29 #include "SDL_events_c.h" | |
30 #include "SDL_cgxvideo.h" | |
31 #include "SDL_cgxmodes_c.h" | |
32 #include "SDL_cgximage_c.h" | |
33 #include "SDL_cgxwm_c.h" | |
34 #include "SDL_amigaevents_c.h" | |
35 | |
36 | |
37 /* The translation tables from an Amiga keysym to a SDL keysym */ | |
38 static SDLKey MISC_keymap[256]; | |
39 SDL_keysym *amiga_TranslateKey(int code, SDL_keysym *keysym); | |
40 struct IOStdReq *ConReq=NULL; | |
41 struct MsgPort *ConPort=NULL; | |
42 | |
43 /* Note: The X server buffers and accumulates mouse motion events, so | |
44 the motion event generated by the warp may not appear exactly as we | |
45 expect it to. We work around this (and improve performance) by only | |
46 warping the pointer when it reaches the edge, and then wait for it. | |
47 */ | |
48 #define MOUSE_FUDGE_FACTOR 8 | |
49 | |
50 #if 0 | |
51 | |
52 static inline int amiga_WarpedMotion(_THIS, struct IntuiMessage *m) | |
53 { | |
54 int w, h, i; | |
55 int deltax, deltay; | |
56 int posted; | |
57 | |
58 w = SDL_VideoSurface->w; | |
59 h = SDL_VideoSurface->h; | |
60 deltax = xevent->xmotion.x - mouse_last.x; | |
61 deltay = xevent->xmotion.y - mouse_last.y; | |
62 #ifdef DEBUG_MOTION | |
63 printf("Warped mouse motion: %d,%d\n", deltax, deltay); | |
64 #endif | |
65 mouse_last.x = xevent->xmotion.x; | |
66 mouse_last.y = xevent->xmotion.y; | |
67 posted = SDL_PrivateMouseMotion(0, 1, deltax, deltay); | |
68 | |
69 if ( (xevent->xmotion.x < MOUSE_FUDGE_FACTOR) || | |
70 (xevent->xmotion.x > (w-MOUSE_FUDGE_FACTOR)) || | |
71 (xevent->xmotion.y < MOUSE_FUDGE_FACTOR) || | |
72 (xevent->xmotion.y > (h-MOUSE_FUDGE_FACTOR)) ) { | |
73 /* Get the events that have accumulated */ | |
74 while ( XCheckTypedEvent(SDL_Display, MotionNotify, xevent) ) { | |
75 deltax = xevent->xmotion.x - mouse_last.x; | |
76 deltay = xevent->xmotion.y - mouse_last.y; | |
77 #ifdef DEBUG_MOTION | |
78 printf("Extra mouse motion: %d,%d\n", deltax, deltay); | |
79 #endif | |
80 mouse_last.x = xevent->xmotion.x; | |
81 mouse_last.y = xevent->xmotion.y; | |
82 posted += SDL_PrivateMouseMotion(0, 1, deltax, deltay); | |
83 } | |
84 mouse_last.x = w/2; | |
85 mouse_last.y = h/2; | |
86 XWarpPointer(SDL_Display, None, SDL_Window, 0, 0, 0, 0, | |
87 mouse_last.x, mouse_last.y); | |
88 for ( i=0; i<10; ++i ) { | |
89 XMaskEvent(SDL_Display, PointerMotionMask, xevent); | |
90 if ( (xevent->xmotion.x > | |
91 (mouse_last.x-MOUSE_FUDGE_FACTOR)) && | |
92 (xevent->xmotion.x < | |
93 (mouse_last.x+MOUSE_FUDGE_FACTOR)) && | |
94 (xevent->xmotion.y > | |
95 (mouse_last.y-MOUSE_FUDGE_FACTOR)) && | |
96 (xevent->xmotion.y < | |
97 (mouse_last.y+MOUSE_FUDGE_FACTOR)) ) { | |
98 break; | |
99 } | |
100 #ifdef DEBUG_XEVENTS | |
101 printf("Lost mouse motion: %d,%d\n", xevent->xmotion.x, xevent->xmotion.y); | |
102 #endif | |
103 } | |
104 #ifdef DEBUG_XEVENTS | |
105 if ( i == 10 ) { | |
106 printf("Warning: didn't detect mouse warp motion\n"); | |
107 } | |
108 #endif | |
109 } | |
110 return(posted); | |
111 } | |
112 | |
113 #endif | |
114 | |
115 static int amiga_GetButton(int code) | |
116 { | |
117 switch(code) | |
118 { | |
119 case IECODE_MBUTTON: | |
120 return SDL_BUTTON_MIDDLE; | |
121 case IECODE_RBUTTON: | |
122 return SDL_BUTTON_RIGHT; | |
123 default: | |
124 return SDL_BUTTON_LEFT; | |
125 } | |
126 } | |
127 | |
128 static int amiga_DispatchEvent(_THIS,struct IntuiMessage *msg) | |
129 { | |
130 int class=msg->Class,code=msg->Code; | |
131 int posted; | |
132 | |
133 posted = 0; | |
134 switch (class) { | |
135 /* Gaining mouse coverage? */ | |
136 case IDCMP_ACTIVEWINDOW: | |
137 posted = SDL_PrivateAppActive(1, SDL_APPMOUSEFOCUS); | |
138 break; | |
139 | |
140 /* Losing mouse coverage? */ | |
141 case IDCMP_INACTIVEWINDOW: | |
142 posted = SDL_PrivateAppActive(0, SDL_APPMOUSEFOCUS); | |
143 break; | |
144 #if 0 | |
145 /* Gaining input focus? */ | |
255
dcb5e869f8b5
Updated Amiga port by Gabriele Greco
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
146 case IDCMP_ACTIVEWINDOW: |
0 | 147 posted = SDL_PrivateAppActive(1, SDL_APPINPUTFOCUS); |
148 | |
149 /* Queue entry into fullscreen mode */ | |
150 switch_waiting = 0x01 | SDL_FULLSCREEN; | |
151 switch_time = SDL_GetTicks() + 1500; | |
152 break; | |
153 | |
154 /* Losing input focus? */ | |
155 case IDCMP_INACTIVEWINDOW: | |
156 posted = SDL_PrivateAppActive(0, SDL_APPINPUTFOCUS); | |
157 | |
158 /* Queue leaving fullscreen mode */ | |
159 switch_waiting = 0x01; | |
160 switch_time = SDL_GetTicks() + 200; | |
161 break; | |
162 #endif | |
163 /* Mouse motion? */ | |
255
dcb5e869f8b5
Updated Amiga port by Gabriele Greco
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
164 case IDCMP_MOUSEMOVE: |
0 | 165 if ( SDL_VideoSurface ) { |
166 posted = SDL_PrivateMouseMotion(0, 0, | |
167 msg->MouseX-SDL_Window->BorderLeft, | |
168 msg->MouseY-SDL_Window->BorderTop); | |
169 } | |
170 break; | |
171 | |
172 /* Mouse button press? */ | |
173 case IDCMP_MOUSEBUTTONS: | |
174 | |
175 if(!(code&IECODE_UP_PREFIX)) | |
176 { | |
255
dcb5e869f8b5
Updated Amiga port by Gabriele Greco
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
177 posted = SDL_PrivateMouseButton(SDL_PRESSED, |
0 | 178 amiga_GetButton(code), 0, 0); |
179 } | |
180 /* Mouse button release? */ | |
181 else | |
182 { | |
183 code&=~IECODE_UP_PREFIX; | |
255
dcb5e869f8b5
Updated Amiga port by Gabriele Greco
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
184 posted = SDL_PrivateMouseButton(SDL_RELEASED, |
0 | 185 amiga_GetButton(code), 0, 0); |
186 } | |
187 break; | |
188 | |
189 case IDCMP_RAWKEY: | |
190 | |
191 /* Key press? */ | |
192 | |
193 if( !(code&IECODE_UP_PREFIX) ) | |
194 { | |
195 SDL_keysym keysym; | |
196 posted = SDL_PrivateKeyboard(SDL_PRESSED, | |
197 amiga_TranslateKey(code, &keysym)); | |
198 } | |
199 else | |
200 { | |
201 /* Key release? */ | |
202 | |
203 SDL_keysym keysym; | |
204 code&=~IECODE_UP_PREFIX; | |
205 | |
206 /* Check to see if this is a repeated key */ | |
207 /* if ( ! X11_KeyRepeat(SDL_Display, &xevent) ) */ | |
208 | |
255
dcb5e869f8b5
Updated Amiga port by Gabriele Greco
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
209 posted = SDL_PrivateKeyboard(SDL_RELEASED, |
0 | 210 amiga_TranslateKey(code, &keysym)); |
211 } | |
212 break; | |
213 /* Have we been iconified? */ | |
214 #if 0 | |
215 case UnmapNotify: { | |
216 #ifdef DEBUG_XEVENTS | |
217 printf("UnmapNotify!\n"); | |
218 #endif | |
219 posted=SDL_PrivateAppActive(0, SDL_APPACTIVE|SDL_APPINPUTFOCUS); | |
220 } | |
221 break; | |
222 | |
223 /* Have we been restored? */ | |
224 | |
225 case MapNotify: { | |
226 #ifdef DEBUG_XEVENTS | |
227 printf("MapNotify!\n"); | |
228 #endif | |
229 | |
230 posted = SDL_PrivateAppActive(1, SDL_APPACTIVE); | |
231 | |
232 if ( SDL_VideoSurface && | |
255
dcb5e869f8b5
Updated Amiga port by Gabriele Greco
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
233 (SDL_VideoSurface->flags & SDL_FULLSCREEN) ) |
0 | 234 { |
235 CGX_EnterFullScreen(this); | |
236 } else { | |
237 X11_GrabInputNoLock(this, this->input_grab); | |
238 } | |
239 if ( SDL_VideoSurface ) { | |
240 CGX_RefreshDisplay(this); | |
241 } | |
242 } | |
243 break; | |
244 case Expose: | |
245 if ( SDL_VideoSurface && (xevent.xexpose.count == 0) ) { | |
246 CGX_RefreshDisplay(this); | |
247 } | |
248 break; | |
249 #endif | |
250 | |
251 /* Have we been resized? */ | |
255
dcb5e869f8b5
Updated Amiga port by Gabriele Greco
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
252 case IDCMP_NEWSIZE: |
21
75a95f82bc1f
Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
253 SDL_PrivateResize(SDL_Window->Width-SDL_Window->BorderLeft-SDL_Window->BorderRight, |
75a95f82bc1f
Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
254 SDL_Window->Height-SDL_Window->BorderTop-SDL_Window->BorderBottom); |
255
dcb5e869f8b5
Updated Amiga port by Gabriele Greco
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
255 |
0 | 256 break; |
257 | |
258 /* Have we been requested to quit? */ | |
259 case IDCMP_CLOSEWINDOW: | |
260 posted = SDL_PrivateQuit(); | |
261 break; | |
262 | |
263 /* Do we need to refresh ourselves? */ | |
264 | |
265 default: { | |
266 /* Only post the event if we're watching for it */ | |
267 if ( SDL_ProcessEvents[SDL_SYSWMEVENT] == SDL_ENABLE ) { | |
268 SDL_SysWMmsg wmmsg; | |
269 | |
270 SDL_VERSION(&wmmsg.version); | |
271 #if 0 | |
272 wmmsg.subsystem = SDL_SYSWM_CGX; | |
273 wmmsg.event.xevent = xevent; | |
274 #endif | |
275 posted = SDL_PrivateSysWMEvent(&wmmsg); | |
276 } | |
277 } | |
278 break; | |
279 } | |
280 ReplyMsg((struct Message *)msg); | |
281 | |
282 | |
283 return(posted); | |
284 } | |
285 | |
286 void amiga_PumpEvents(_THIS) | |
287 { | |
288 int pending; | |
289 struct IntuiMessage *m; | |
290 | |
291 /* Keep processing pending events */ | |
292 pending = 0; | |
293 while ( m=(struct IntuiMessage *)GetMsg(SDL_Window->UserPort) ) { | |
294 amiga_DispatchEvent(this,m); | |
295 ++pending; | |
296 } | |
297 } | |
298 | |
299 void amiga_InitKeymap(void) | |
300 { | |
301 int i; | |
302 | |
303 /* Map the miscellaneous keys */ | |
304 for ( i=0; i<SDL_TABLESIZE(MISC_keymap); ++i ) | |
305 MISC_keymap[i] = SDLK_UNKNOWN; | |
306 | |
307 /* These X keysyms have 0xFF as the high byte */ | |
308 MISC_keymap[65] = SDLK_BACKSPACE; | |
309 MISC_keymap[66] = SDLK_TAB; | |
310 MISC_keymap[70] = SDLK_CLEAR; | |
311 MISC_keymap[70] = SDLK_DELETE; | |
312 MISC_keymap[68] = SDLK_RETURN; | |
313 // MISC_keymap[XK_Pause&0xFF] = SDLK_PAUSE; | |
314 MISC_keymap[69] = SDLK_ESCAPE; | |
315 MISC_keymap[70] = SDLK_DELETE; | |
316 /* | |
317 SDLK_SPACE = 32, | |
318 SDLK_MINUS = 45, | |
319 SDLK_LESS = 60, | |
320 SDLK_COMMA = 44, | |
321 SDLK_PERIOD = 46, | |
322 SDLK_0 = 48, | |
323 SDLK_1 = 49, | |
324 SDLK_2 = 50, | |
325 SDLK_3 = 51, | |
326 SDLK_4 = 52, | |
327 SDLK_5 = 53, | |
328 SDLK_6 = 54, | |
329 SDLK_7 = 55, | |
330 SDLK_8 = 56, | |
331 SDLK_9 = 57, | |
332 SDLK_BACKQUOTE = 96, | |
333 SDLK_BACKSLASH = 92, | |
334 SDLK_a = 97, | |
335 SDLK_b = 98, | |
336 SDLK_c = 99, | |
337 SDLK_d = 100, | |
338 SDLK_e = 101, | |
339 SDLK_f = 102, | |
340 SDLK_g = 103, | |
341 SDLK_h = 104, | |
342 SDLK_i = 105, | |
343 SDLK_j = 106, | |
344 SDLK_k = 107, | |
345 SDLK_l = 108, | |
346 SDLK_m = 109, | |
347 SDLK_n = 110, | |
348 SDLK_o = 111, | |
349 SDLK_p = 112, | |
350 SDLK_q = 113, | |
351 SDLK_r = 114, | |
352 SDLK_s = 115, | |
353 SDLK_t = 116, | |
354 SDLK_u = 117, | |
355 SDLK_v = 118, | |
356 SDLK_w = 119, | |
357 SDLK_x = 120, | |
358 SDLK_y = 121, | |
359 SDLK_z = 122, | |
360 */ | |
361 MISC_keymap[15] = SDLK_KP0; /* Keypad 0-9 */ | |
362 MISC_keymap[29] = SDLK_KP1; | |
363 MISC_keymap[30] = SDLK_KP2; | |
364 MISC_keymap[31] = SDLK_KP3; | |
365 MISC_keymap[45] = SDLK_KP4; | |
366 MISC_keymap[46] = SDLK_KP5; | |
367 MISC_keymap[47] = SDLK_KP6; | |
368 MISC_keymap[61] = SDLK_KP7; | |
369 MISC_keymap[62] = SDLK_KP8; | |
370 MISC_keymap[63] = SDLK_KP9; | |
371 MISC_keymap[60] = SDLK_KP_PERIOD; | |
372 MISC_keymap[92] = SDLK_KP_DIVIDE; | |
373 MISC_keymap[93] = SDLK_KP_MULTIPLY; | |
374 MISC_keymap[74] = SDLK_KP_MINUS; | |
375 MISC_keymap[94] = SDLK_KP_PLUS; | |
376 MISC_keymap[67] = SDLK_KP_ENTER; | |
377 // MISC_keymap[XK_KP_Equal&0xFF] = SDLK_KP_EQUALS; | |
378 | |
379 MISC_keymap[76] = SDLK_UP; | |
380 MISC_keymap[77] = SDLK_DOWN; | |
381 MISC_keymap[78] = SDLK_RIGHT; | |
382 MISC_keymap[79] = SDLK_LEFT; | |
383 /* | |
384 MISC_keymap[XK_Insert&0xFF] = SDLK_INSERT; | |
385 MISC_keymap[XK_Home&0xFF] = SDLK_HOME; | |
386 MISC_keymap[XK_End&0xFF] = SDLK_END; | |
387 */ | |
388 // Mappati sulle parentesi del taastierino | |
389 MISC_keymap[90] = SDLK_PAGEUP; | |
390 MISC_keymap[91] = SDLK_PAGEDOWN; | |
391 | |
392 MISC_keymap[80] = SDLK_F1; | |
393 MISC_keymap[81] = SDLK_F2; | |
394 MISC_keymap[82] = SDLK_F3; | |
395 MISC_keymap[83] = SDLK_F4; | |
396 MISC_keymap[84] = SDLK_F5; | |
397 MISC_keymap[85] = SDLK_F6; | |
398 MISC_keymap[86] = SDLK_F7; | |
399 MISC_keymap[87] = SDLK_F8; | |
400 MISC_keymap[88] = SDLK_F9; | |
401 MISC_keymap[89] = SDLK_F10; | |
402 // MISC_keymap[XK_F11&0xFF] = SDLK_F11; | |
403 // MISC_keymap[XK_F12&0xFF] = SDLK_F12; | |
404 // MISC_keymap[XK_F13&0xFF] = SDLK_F13; | |
405 // MISC_keymap[XK_F14&0xFF] = SDLK_F14; | |
406 // MISC_keymap[XK_F15&0xFF] = SDLK_F15; | |
407 | |
408 // MISC_keymap[XK_Num_Lock&0xFF] = SDLK_NUMLOCK; | |
409 MISC_keymap[98] = SDLK_CAPSLOCK; | |
410 // MISC_keymap[XK_Scroll_Lock&0xFF] = SDLK_SCROLLOCK; | |
411 MISC_keymap[97] = SDLK_RSHIFT; | |
412 MISC_keymap[96] = SDLK_LSHIFT; | |
413 MISC_keymap[99] = SDLK_LCTRL; | |
414 MISC_keymap[99] = SDLK_LCTRL; | |
415 MISC_keymap[101] = SDLK_RALT; | |
416 MISC_keymap[100] = SDLK_LALT; | |
417 // MISC_keymap[XK_Meta_R&0xFF] = SDLK_RMETA; | |
418 // MISC_keymap[XK_Meta_L&0xFF] = SDLK_LMETA; | |
419 MISC_keymap[103] = SDLK_LSUPER; /* Left "Windows" */ | |
420 MISC_keymap[102] = SDLK_RSUPER; /* Right "Windows */ | |
421 | |
422 MISC_keymap[95] = SDLK_HELP; | |
423 } | |
424 | |
425 SDL_keysym *amiga_TranslateKey(int code, SDL_keysym *keysym) | |
426 { | |
255
dcb5e869f8b5
Updated Amiga port by Gabriele Greco
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
427 #ifdef STORMC4_WOS |
dcb5e869f8b5
Updated Amiga port by Gabriele Greco
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
428 static struct Library *KeymapBase=NULL; /* Linking failed in WOS version if ConsoleDevice was used */ |
dcb5e869f8b5
Updated Amiga port by Gabriele Greco
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
429 #else |
0 | 430 static struct Library *ConsoleDevice=NULL; |
255
dcb5e869f8b5
Updated Amiga port by Gabriele Greco
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
431 #endif |
0 | 432 |
433 /* Get the raw keyboard scancode */ | |
434 keysym->scancode = code; | |
435 keysym->sym = MISC_keymap[code]; | |
436 | |
437 #ifdef DEBUG_KEYS | |
438 fprintf(stderr, "Translating key 0x%.4x (%d)\n", xsym, xkey->keycode); | |
439 #endif | |
440 /* Get the translated SDL virtual keysym */ | |
255
dcb5e869f8b5
Updated Amiga port by Gabriele Greco
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
441 if ( keysym->sym==SDLK_UNKNOWN ) |
0 | 442 { |
255
dcb5e869f8b5
Updated Amiga port by Gabriele Greco
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
443 #ifdef STORMC4_WOS |
dcb5e869f8b5
Updated Amiga port by Gabriele Greco
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
444 if(!KeymapBase) |
dcb5e869f8b5
Updated Amiga port by Gabriele Greco
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
445 #else |
0 | 446 if(!ConsoleDevice) |
255
dcb5e869f8b5
Updated Amiga port by Gabriele Greco
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
447 #endif |
0 | 448 { |
255
dcb5e869f8b5
Updated Amiga port by Gabriele Greco
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
449 #ifdef STORMC4_WOS |
dcb5e869f8b5
Updated Amiga port by Gabriele Greco
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
450 KeymapBase=OpenLibrary("keymap.library", 0L); |
dcb5e869f8b5
Updated Amiga port by Gabriele Greco
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
451 #else |
0 | 452 if(ConPort=CreateMsgPort()) |
453 { | |
454 if(ConReq=CreateIORequest(ConPort,sizeof(struct IOStdReq))) | |
455 { | |
456 if(!OpenDevice("console.device",-1,(struct IORequest *)ConReq,0)) | |
457 ConsoleDevice=(struct Library *)ConReq->io_Device; | |
458 else | |
459 { | |
460 DeleteIORequest(ConReq); | |
461 ConReq=NULL; | |
462 } | |
463 } | |
464 else | |
465 { | |
466 DeleteMsgPort(ConPort); | |
467 ConPort=NULL; | |
468 } | |
469 } | |
255
dcb5e869f8b5
Updated Amiga port by Gabriele Greco
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
470 #endif |
0 | 471 } |
472 | |
255
dcb5e869f8b5
Updated Amiga port by Gabriele Greco
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
473 #ifdef STORMC4_WOS |
dcb5e869f8b5
Updated Amiga port by Gabriele Greco
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
474 if(KeymapBase) |
dcb5e869f8b5
Updated Amiga port by Gabriele Greco
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
475 #else |
0 | 476 if(ConsoleDevice) |
255
dcb5e869f8b5
Updated Amiga port by Gabriele Greco
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
477 #endif |
0 | 478 { |
479 struct InputEvent event; | |
480 long actual; | |
481 char buffer[5]; | |
482 | |
483 event.ie_Qualifier=0; | |
484 event.ie_Class=IECLASS_RAWKEY; | |
485 event.ie_SubClass=0L; | |
486 event.ie_Code=code; | |
487 event.ie_X=event.ie_Y=0; | |
488 event.ie_EventAddress=NULL; | |
489 event.ie_NextEvent=NULL; | |
490 event.ie_Prev1DownCode=event.ie_Prev1DownQual=event.ie_Prev2DownCode=event.ie_Prev2DownQual=0; | |
491 | |
255
dcb5e869f8b5
Updated Amiga port by Gabriele Greco
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
492 #ifdef STORMC4_WOS |
dcb5e869f8b5
Updated Amiga port by Gabriele Greco
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
493 if( (actual=MapRawKey(&event,buffer,5,NULL))>=0) |
dcb5e869f8b5
Updated Amiga port by Gabriele Greco
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
494 #else |
0 | 495 if( (actual=RawKeyConvert(&event,buffer,5,NULL))>=0) |
255
dcb5e869f8b5
Updated Amiga port by Gabriele Greco
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
496 #endif |
0 | 497 { |
498 if(actual>1) | |
499 { | |
500 D(bug("Warning (%ld) character conversion!\n",actual)); | |
501 } | |
502 else if(actual==1) | |
503 { | |
504 keysym->sym=*buffer; | |
505 D(bug("Converted rawcode %ld to <%lc>\n",code,*buffer)); | |
506 // Bufferizzo x le successive chiamate! | |
507 MISC_keymap[code]=*buffer; | |
508 } | |
509 } | |
510 } | |
511 | |
512 } | |
513 keysym->mod = KMOD_NONE; | |
514 | |
515 /* If UNICODE is on, get the UNICODE value for the key */ | |
516 keysym->unicode = 0; | |
517 if ( SDL_TranslateUNICODE ) { | |
518 #if 0 | |
519 static XComposeStatus state; | |
520 /* Until we handle the IM protocol, use XLookupString() */ | |
521 unsigned char keybuf[32]; | |
522 if ( XLookupString(xkey, (char *)keybuf, sizeof(keybuf), | |
523 NULL, &state) ) { | |
524 keysym->unicode = keybuf[0]; | |
525 } | |
526 #endif | |
527 } | |
528 return(keysym); | |
529 } | |
530 | |
531 void amiga_InitOSKeymap(_THIS) | |
532 { | |
533 amiga_InitKeymap(); | |
534 } |