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