Mercurial > sdl-ios-xcode
comparison src/video/cybergfx/SDL_amigaevents.c @ 1662:782fd950bd46 SDL-1.3
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
WARNING: None of the video drivers have been updated for the new API yet! The API is still under design and very fluid.
The code is now run through a consistent indent format:
indent -i4 -nut -nsc -br -ce
The headers are being converted to automatically generate doxygen documentation.
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Sun, 28 May 2006 13:04:16 +0000 |
parents | d910939febfa |
children | 4da1ee79c9af |
comparison
equal
deleted
inserted
replaced
1661:281d3f4870e5 | 1662:782fd950bd46 |
---|---|
35 #include "SDL_amigaevents_c.h" | 35 #include "SDL_amigaevents_c.h" |
36 | 36 |
37 | 37 |
38 /* The translation tables from an Amiga keysym to a SDL keysym */ | 38 /* The translation tables from an Amiga keysym to a SDL keysym */ |
39 static SDLKey MISC_keymap[256]; | 39 static SDLKey MISC_keymap[256]; |
40 SDL_keysym *amiga_TranslateKey(int code, SDL_keysym *keysym); | 40 SDL_keysym *amiga_TranslateKey (int code, SDL_keysym * keysym); |
41 struct IOStdReq *ConReq=NULL; | 41 struct IOStdReq *ConReq = NULL; |
42 struct MsgPort *ConPort=NULL; | 42 struct MsgPort *ConPort = NULL; |
43 | 43 |
44 /* Note: The X server buffers and accumulates mouse motion events, so | 44 /* Note: The X server buffers and accumulates mouse motion events, so |
45 the motion event generated by the warp may not appear exactly as we | 45 the motion event generated by the warp may not appear exactly as we |
46 expect it to. We work around this (and improve performance) by only | 46 expect it to. We work around this (and improve performance) by only |
47 warping the pointer when it reaches the edge, and then wait for it. | 47 warping the pointer when it reaches the edge, and then wait for it. |
48 */ | 48 */ |
49 #define MOUSE_FUDGE_FACTOR 8 | 49 #define MOUSE_FUDGE_FACTOR 8 |
50 | 50 |
51 #if 0 | 51 #if 0 |
52 | 52 |
53 static inline int amiga_WarpedMotion(_THIS, struct IntuiMessage *m) | 53 static inline int |
54 { | 54 amiga_WarpedMotion (_THIS, struct IntuiMessage *m) |
55 int w, h, i; | 55 { |
56 int deltax, deltay; | 56 int w, h, i; |
57 int posted; | 57 int deltax, deltay; |
58 | 58 int posted; |
59 w = SDL_VideoSurface->w; | 59 |
60 h = SDL_VideoSurface->h; | 60 w = SDL_VideoSurface->w; |
61 deltax = xevent->xmotion.x - mouse_last.x; | 61 h = SDL_VideoSurface->h; |
62 deltay = xevent->xmotion.y - mouse_last.y; | 62 deltax = xevent->xmotion.x - mouse_last.x; |
63 deltay = xevent->xmotion.y - mouse_last.y; | |
63 #ifdef DEBUG_MOTION | 64 #ifdef DEBUG_MOTION |
64 printf("Warped mouse motion: %d,%d\n", deltax, deltay); | 65 printf ("Warped mouse motion: %d,%d\n", deltax, deltay); |
65 #endif | 66 #endif |
66 mouse_last.x = xevent->xmotion.x; | 67 mouse_last.x = xevent->xmotion.x; |
67 mouse_last.y = xevent->xmotion.y; | 68 mouse_last.y = xevent->xmotion.y; |
68 posted = SDL_PrivateMouseMotion(0, 1, deltax, deltay); | 69 posted = SDL_PrivateMouseMotion (0, 1, deltax, deltay); |
69 | 70 |
70 if ( (xevent->xmotion.x < MOUSE_FUDGE_FACTOR) || | 71 if ((xevent->xmotion.x < MOUSE_FUDGE_FACTOR) || |
71 (xevent->xmotion.x > (w-MOUSE_FUDGE_FACTOR)) || | 72 (xevent->xmotion.x > (w - MOUSE_FUDGE_FACTOR)) || |
72 (xevent->xmotion.y < MOUSE_FUDGE_FACTOR) || | 73 (xevent->xmotion.y < MOUSE_FUDGE_FACTOR) || |
73 (xevent->xmotion.y > (h-MOUSE_FUDGE_FACTOR)) ) { | 74 (xevent->xmotion.y > (h - MOUSE_FUDGE_FACTOR))) { |
74 /* Get the events that have accumulated */ | 75 /* Get the events that have accumulated */ |
75 while ( XCheckTypedEvent(SDL_Display, MotionNotify, xevent) ) { | 76 while (XCheckTypedEvent (SDL_Display, MotionNotify, xevent)) { |
76 deltax = xevent->xmotion.x - mouse_last.x; | 77 deltax = xevent->xmotion.x - mouse_last.x; |
77 deltay = xevent->xmotion.y - mouse_last.y; | 78 deltay = xevent->xmotion.y - mouse_last.y; |
78 #ifdef DEBUG_MOTION | 79 #ifdef DEBUG_MOTION |
79 printf("Extra mouse motion: %d,%d\n", deltax, deltay); | 80 printf ("Extra mouse motion: %d,%d\n", deltax, deltay); |
80 #endif | 81 #endif |
81 mouse_last.x = xevent->xmotion.x; | 82 mouse_last.x = xevent->xmotion.x; |
82 mouse_last.y = xevent->xmotion.y; | 83 mouse_last.y = xevent->xmotion.y; |
83 posted += SDL_PrivateMouseMotion(0, 1, deltax, deltay); | 84 posted += SDL_PrivateMouseMotion (0, 1, deltax, deltay); |
84 } | 85 } |
85 mouse_last.x = w/2; | 86 mouse_last.x = w / 2; |
86 mouse_last.y = h/2; | 87 mouse_last.y = h / 2; |
87 XWarpPointer(SDL_Display, None, SDL_Window, 0, 0, 0, 0, | 88 XWarpPointer (SDL_Display, None, SDL_Window, 0, 0, 0, 0, |
88 mouse_last.x, mouse_last.y); | 89 mouse_last.x, mouse_last.y); |
89 for ( i=0; i<10; ++i ) { | 90 for (i = 0; i < 10; ++i) { |
90 XMaskEvent(SDL_Display, PointerMotionMask, xevent); | 91 XMaskEvent (SDL_Display, PointerMotionMask, xevent); |
91 if ( (xevent->xmotion.x > | 92 if ((xevent->xmotion.x > |
92 (mouse_last.x-MOUSE_FUDGE_FACTOR)) && | 93 (mouse_last.x - MOUSE_FUDGE_FACTOR)) && |
93 (xevent->xmotion.x < | 94 (xevent->xmotion.x < |
94 (mouse_last.x+MOUSE_FUDGE_FACTOR)) && | 95 (mouse_last.x + MOUSE_FUDGE_FACTOR)) && |
95 (xevent->xmotion.y > | 96 (xevent->xmotion.y > |
96 (mouse_last.y-MOUSE_FUDGE_FACTOR)) && | 97 (mouse_last.y - MOUSE_FUDGE_FACTOR)) && |
97 (xevent->xmotion.y < | 98 (xevent->xmotion.y < (mouse_last.y + MOUSE_FUDGE_FACTOR))) { |
98 (mouse_last.y+MOUSE_FUDGE_FACTOR)) ) { | 99 break; |
99 break; | 100 } |
100 } | |
101 #ifdef DEBUG_XEVENTS | 101 #ifdef DEBUG_XEVENTS |
102 printf("Lost mouse motion: %d,%d\n", xevent->xmotion.x, xevent->xmotion.y); | 102 printf ("Lost mouse motion: %d,%d\n", xevent->xmotion.x, |
103 #endif | 103 xevent->xmotion.y); |
104 } | 104 #endif |
105 } | |
105 #ifdef DEBUG_XEVENTS | 106 #ifdef DEBUG_XEVENTS |
106 if ( i == 10 ) { | 107 if (i == 10) { |
107 printf("Warning: didn't detect mouse warp motion\n"); | 108 printf ("Warning: didn't detect mouse warp motion\n"); |
108 } | 109 } |
109 #endif | 110 #endif |
110 } | 111 } |
111 return(posted); | 112 return (posted); |
112 } | 113 } |
113 | 114 |
114 #endif | 115 #endif |
115 | 116 |
116 static int amiga_GetButton(int code) | 117 static int |
117 { | 118 amiga_GetButton (int code) |
118 switch(code) | 119 { |
119 { | 120 switch (code) { |
120 case IECODE_MBUTTON: | 121 case IECODE_MBUTTON: |
121 return SDL_BUTTON_MIDDLE; | 122 return SDL_BUTTON_MIDDLE; |
122 case IECODE_RBUTTON: | 123 case IECODE_RBUTTON: |
123 return SDL_BUTTON_RIGHT; | 124 return SDL_BUTTON_RIGHT; |
124 default: | 125 default: |
125 return SDL_BUTTON_LEFT; | 126 return SDL_BUTTON_LEFT; |
126 } | 127 } |
127 } | 128 } |
128 | 129 |
129 static int amiga_DispatchEvent(_THIS,struct IntuiMessage *msg) | 130 static int |
130 { | 131 amiga_DispatchEvent (_THIS, struct IntuiMessage *msg) |
131 int class=msg->Class,code=msg->Code; | 132 { |
132 int posted; | 133 int class = msg->Class, code = msg->Code; |
133 | 134 int posted; |
134 posted = 0; | 135 |
135 switch (class) { | 136 posted = 0; |
136 /* Gaining mouse coverage? */ | 137 switch (class) { |
137 case IDCMP_ACTIVEWINDOW: | 138 /* Gaining mouse coverage? */ |
138 posted = SDL_PrivateAppActive(1, SDL_APPMOUSEFOCUS); | 139 case IDCMP_ACTIVEWINDOW: |
139 break; | 140 posted = SDL_PrivateAppActive (1, SDL_APPMOUSEFOCUS); |
140 | 141 break; |
141 /* Losing mouse coverage? */ | 142 |
142 case IDCMP_INACTIVEWINDOW: | 143 /* Losing mouse coverage? */ |
143 posted = SDL_PrivateAppActive(0, SDL_APPMOUSEFOCUS); | 144 case IDCMP_INACTIVEWINDOW: |
144 break; | 145 posted = SDL_PrivateAppActive (0, SDL_APPMOUSEFOCUS); |
146 break; | |
145 #if 0 | 147 #if 0 |
146 /* Gaining input focus? */ | 148 /* Gaining input focus? */ |
147 case IDCMP_ACTIVEWINDOW: | 149 case IDCMP_ACTIVEWINDOW: |
148 posted = SDL_PrivateAppActive(1, SDL_APPINPUTFOCUS); | 150 posted = SDL_PrivateAppActive (1, SDL_APPINPUTFOCUS); |
149 | 151 |
150 /* Queue entry into fullscreen mode */ | 152 /* Queue entry into fullscreen mode */ |
151 switch_waiting = 0x01 | SDL_FULLSCREEN; | 153 switch_waiting = 0x01 | SDL_FULLSCREEN; |
152 switch_time = SDL_GetTicks() + 1500; | 154 switch_time = SDL_GetTicks () + 1500; |
153 break; | 155 break; |
154 | 156 |
155 /* Losing input focus? */ | 157 /* Losing input focus? */ |
156 case IDCMP_INACTIVEWINDOW: | 158 case IDCMP_INACTIVEWINDOW: |
157 posted = SDL_PrivateAppActive(0, SDL_APPINPUTFOCUS); | 159 posted = SDL_PrivateAppActive (0, SDL_APPINPUTFOCUS); |
158 | 160 |
159 /* Queue leaving fullscreen mode */ | 161 /* Queue leaving fullscreen mode */ |
160 switch_waiting = 0x01; | 162 switch_waiting = 0x01; |
161 switch_time = SDL_GetTicks() + 200; | 163 switch_time = SDL_GetTicks () + 200; |
162 break; | 164 break; |
163 #endif | 165 #endif |
164 /* Mouse motion? */ | 166 /* Mouse motion? */ |
165 case IDCMP_MOUSEMOVE: | 167 case IDCMP_MOUSEMOVE: |
166 if ( SDL_VideoSurface ) { | 168 if (SDL_VideoSurface) { |
167 posted = SDL_PrivateMouseMotion(0, 0, | 169 posted = SDL_PrivateMouseMotion (0, 0, |
168 msg->MouseX-SDL_Window->BorderLeft, | 170 msg->MouseX - |
169 msg->MouseY-SDL_Window->BorderTop); | 171 SDL_Window->BorderLeft, |
170 } | 172 msg->MouseY - |
171 break; | 173 SDL_Window->BorderTop); |
172 | 174 } |
173 /* Mouse button press? */ | 175 break; |
174 case IDCMP_MOUSEBUTTONS: | 176 |
175 | 177 /* Mouse button press? */ |
176 if(!(code&IECODE_UP_PREFIX)) | 178 case IDCMP_MOUSEBUTTONS: |
177 { | 179 |
178 posted = SDL_PrivateMouseButton(SDL_PRESSED, | 180 if (!(code & IECODE_UP_PREFIX)) { |
179 amiga_GetButton(code), 0, 0); | 181 posted = SDL_PrivateMouseButton (SDL_PRESSED, |
180 } | 182 amiga_GetButton (code), 0, 0); |
181 /* Mouse button release? */ | 183 } |
182 else | 184 /* Mouse button release? */ |
183 { | 185 else { |
184 code&=~IECODE_UP_PREFIX; | 186 code &= ~IECODE_UP_PREFIX; |
185 posted = SDL_PrivateMouseButton(SDL_RELEASED, | 187 posted = SDL_PrivateMouseButton (SDL_RELEASED, |
186 amiga_GetButton(code), 0, 0); | 188 amiga_GetButton (code), 0, 0); |
187 } | 189 } |
188 break; | 190 break; |
189 | 191 |
190 case IDCMP_RAWKEY: | 192 case IDCMP_RAWKEY: |
191 | 193 |
192 /* Key press? */ | 194 /* Key press? */ |
193 | 195 |
194 if( !(code&IECODE_UP_PREFIX) ) | 196 if (!(code & IECODE_UP_PREFIX)) { |
195 { | 197 SDL_keysym keysym; |
196 SDL_keysym keysym; | 198 posted = SDL_PrivateKeyboard (SDL_PRESSED, |
197 posted = SDL_PrivateKeyboard(SDL_PRESSED, | 199 amiga_TranslateKey (code, &keysym)); |
198 amiga_TranslateKey(code, &keysym)); | 200 } else { |
199 } | 201 /* Key release? */ |
200 else | 202 |
201 { | 203 SDL_keysym keysym; |
202 /* Key release? */ | 204 code &= ~IECODE_UP_PREFIX; |
203 | 205 |
204 SDL_keysym keysym; | 206 /* Check to see if this is a repeated key */ |
205 code&=~IECODE_UP_PREFIX; | |
206 | |
207 /* Check to see if this is a repeated key */ | |
208 /* if ( ! X11_KeyRepeat(SDL_Display, &xevent) ) */ | 207 /* if ( ! X11_KeyRepeat(SDL_Display, &xevent) ) */ |
209 | 208 |
210 posted = SDL_PrivateKeyboard(SDL_RELEASED, | 209 posted = SDL_PrivateKeyboard (SDL_RELEASED, |
211 amiga_TranslateKey(code, &keysym)); | 210 amiga_TranslateKey (code, &keysym)); |
212 } | 211 } |
213 break; | 212 break; |
214 /* Have we been iconified? */ | 213 /* Have we been iconified? */ |
215 #if 0 | 214 #if 0 |
216 case UnmapNotify: { | 215 case UnmapNotify: |
216 { | |
217 #ifdef DEBUG_XEVENTS | 217 #ifdef DEBUG_XEVENTS |
218 printf("UnmapNotify!\n"); | 218 printf ("UnmapNotify!\n"); |
219 #endif | 219 #endif |
220 posted=SDL_PrivateAppActive(0, SDL_APPACTIVE|SDL_APPINPUTFOCUS); | 220 posted = |
221 } | 221 SDL_PrivateAppActive (0, SDL_APPACTIVE | SDL_APPINPUTFOCUS); |
222 break; | 222 } |
223 | 223 break; |
224 /* Have we been restored? */ | 224 |
225 | 225 /* Have we been restored? */ |
226 case MapNotify: { | 226 |
227 case MapNotify: | |
228 { | |
227 #ifdef DEBUG_XEVENTS | 229 #ifdef DEBUG_XEVENTS |
228 printf("MapNotify!\n"); | 230 printf ("MapNotify!\n"); |
229 #endif | 231 #endif |
230 | 232 |
231 posted = SDL_PrivateAppActive(1, SDL_APPACTIVE); | 233 posted = SDL_PrivateAppActive (1, SDL_APPACTIVE); |
232 | 234 |
233 if ( SDL_VideoSurface && | 235 if (SDL_VideoSurface && |
234 (SDL_VideoSurface->flags & SDL_FULLSCREEN) ) | 236 (SDL_VideoSurface->flags & SDL_FULLSCREEN)) { |
235 { | 237 CGX_EnterFullScreen (this); |
236 CGX_EnterFullScreen(this); | 238 } else { |
237 } else { | 239 X11_GrabInputNoLock (this, this->input_grab); |
238 X11_GrabInputNoLock(this, this->input_grab); | 240 } |
239 } | 241 if (SDL_VideoSurface) { |
240 if ( SDL_VideoSurface ) { | 242 CGX_RefreshDisplay (this); |
241 CGX_RefreshDisplay(this); | 243 } |
242 } | 244 } |
243 } | 245 break; |
244 break; | 246 case Expose: |
245 case Expose: | 247 if (SDL_VideoSurface && (xevent.xexpose.count == 0)) { |
246 if ( SDL_VideoSurface && (xevent.xexpose.count == 0) ) { | 248 CGX_RefreshDisplay (this); |
247 CGX_RefreshDisplay(this); | 249 } |
248 } | 250 break; |
249 break; | 251 #endif |
250 #endif | 252 |
251 | 253 /* Have we been resized? */ |
252 /* Have we been resized? */ | 254 case IDCMP_NEWSIZE: |
253 case IDCMP_NEWSIZE: | 255 SDL_PrivateResize (SDL_Window->Width - SDL_Window->BorderLeft - |
254 SDL_PrivateResize(SDL_Window->Width-SDL_Window->BorderLeft-SDL_Window->BorderRight, | 256 SDL_Window->BorderRight, |
255 SDL_Window->Height-SDL_Window->BorderTop-SDL_Window->BorderBottom); | 257 SDL_Window->Height - SDL_Window->BorderTop - |
256 | 258 SDL_Window->BorderBottom); |
257 break; | 259 |
258 | 260 break; |
259 /* Have we been requested to quit? */ | 261 |
260 case IDCMP_CLOSEWINDOW: | 262 /* Have we been requested to quit? */ |
261 posted = SDL_PrivateQuit(); | 263 case IDCMP_CLOSEWINDOW: |
262 break; | 264 posted = SDL_PrivateQuit (); |
263 | 265 break; |
264 /* Do we need to refresh ourselves? */ | 266 |
265 | 267 /* Do we need to refresh ourselves? */ |
266 default: { | 268 |
267 /* Only post the event if we're watching for it */ | 269 default: |
268 if ( SDL_ProcessEvents[SDL_SYSWMEVENT] == SDL_ENABLE ) { | 270 { |
269 SDL_SysWMmsg wmmsg; | 271 /* Only post the event if we're watching for it */ |
270 | 272 if (SDL_ProcessEvents[SDL_SYSWMEVENT] == SDL_ENABLE) { |
271 SDL_VERSION(&wmmsg.version); | 273 SDL_SysWMmsg wmmsg; |
274 | |
275 SDL_VERSION (&wmmsg.version); | |
272 #if 0 | 276 #if 0 |
273 wmmsg.subsystem = SDL_SYSWM_CGX; | 277 wmmsg.subsystem = SDL_SYSWM_CGX; |
274 wmmsg.event.xevent = xevent; | 278 wmmsg.event.xevent = xevent; |
275 #endif | 279 #endif |
276 posted = SDL_PrivateSysWMEvent(&wmmsg); | 280 posted = SDL_PrivateSysWMEvent (&wmmsg); |
277 } | 281 } |
278 } | 282 } |
279 break; | 283 break; |
280 } | 284 } |
281 ReplyMsg((struct Message *)msg); | 285 ReplyMsg ((struct Message *) msg); |
282 | 286 |
283 | 287 |
284 return(posted); | 288 return (posted); |
285 } | 289 } |
286 | 290 |
287 void amiga_PumpEvents(_THIS) | 291 void |
288 { | 292 amiga_PumpEvents (_THIS) |
289 int pending; | 293 { |
290 struct IntuiMessage *m; | 294 int pending; |
291 | 295 struct IntuiMessage *m; |
292 /* Keep processing pending events */ | 296 |
293 pending = 0; | 297 /* Keep processing pending events */ |
294 while ( m=(struct IntuiMessage *)GetMsg(SDL_Window->UserPort) ) { | 298 pending = 0; |
295 amiga_DispatchEvent(this,m); | 299 while (m = (struct IntuiMessage *) GetMsg (SDL_Window->UserPort)) { |
296 ++pending; | 300 amiga_DispatchEvent (this, m); |
297 } | 301 ++pending; |
298 } | 302 } |
299 | 303 } |
300 void amiga_InitKeymap(void) | 304 |
301 { | 305 void |
302 int i; | 306 amiga_InitKeymap (void) |
303 | 307 { |
304 /* Map the miscellaneous keys */ | 308 int i; |
305 for ( i=0; i<SDL_arraysize(MISC_keymap); ++i ) | 309 |
306 MISC_keymap[i] = SDLK_UNKNOWN; | 310 /* Map the miscellaneous keys */ |
307 | 311 for (i = 0; i < SDL_arraysize (MISC_keymap); ++i) |
308 /* These X keysyms have 0xFF as the high byte */ | 312 MISC_keymap[i] = SDLK_UNKNOWN; |
309 MISC_keymap[65] = SDLK_BACKSPACE; | 313 |
310 MISC_keymap[66] = SDLK_TAB; | 314 /* These X keysyms have 0xFF as the high byte */ |
311 MISC_keymap[70] = SDLK_CLEAR; | 315 MISC_keymap[65] = SDLK_BACKSPACE; |
312 MISC_keymap[70] = SDLK_DELETE; | 316 MISC_keymap[66] = SDLK_TAB; |
313 MISC_keymap[68] = SDLK_RETURN; | 317 MISC_keymap[70] = SDLK_CLEAR; |
314 // MISC_keymap[XK_Pause&0xFF] = SDLK_PAUSE; | 318 MISC_keymap[70] = SDLK_DELETE; |
315 MISC_keymap[69] = SDLK_ESCAPE; | 319 MISC_keymap[68] = SDLK_RETURN; |
316 MISC_keymap[70] = SDLK_DELETE; | 320 // MISC_keymap[XK_Pause&0xFF] = SDLK_PAUSE; |
321 MISC_keymap[69] = SDLK_ESCAPE; | |
322 MISC_keymap[70] = SDLK_DELETE; | |
317 /* | 323 /* |
318 SDLK_SPACE = 32, | 324 SDLK_SPACE = 32, |
319 SDLK_MINUS = 45, | 325 SDLK_MINUS = 45, |
320 SDLK_LESS = 60, | 326 SDLK_LESS = 60, |
321 SDLK_COMMA = 44, | 327 SDLK_COMMA = 44, |
357 SDLK_w = 119, | 363 SDLK_w = 119, |
358 SDLK_x = 120, | 364 SDLK_x = 120, |
359 SDLK_y = 121, | 365 SDLK_y = 121, |
360 SDLK_z = 122, | 366 SDLK_z = 122, |
361 */ | 367 */ |
362 MISC_keymap[15] = SDLK_KP0; /* Keypad 0-9 */ | 368 MISC_keymap[15] = SDLK_KP0; /* Keypad 0-9 */ |
363 MISC_keymap[29] = SDLK_KP1; | 369 MISC_keymap[29] = SDLK_KP1; |
364 MISC_keymap[30] = SDLK_KP2; | 370 MISC_keymap[30] = SDLK_KP2; |
365 MISC_keymap[31] = SDLK_KP3; | 371 MISC_keymap[31] = SDLK_KP3; |
366 MISC_keymap[45] = SDLK_KP4; | 372 MISC_keymap[45] = SDLK_KP4; |
367 MISC_keymap[46] = SDLK_KP5; | 373 MISC_keymap[46] = SDLK_KP5; |
368 MISC_keymap[47] = SDLK_KP6; | 374 MISC_keymap[47] = SDLK_KP6; |
369 MISC_keymap[61] = SDLK_KP7; | 375 MISC_keymap[61] = SDLK_KP7; |
370 MISC_keymap[62] = SDLK_KP8; | 376 MISC_keymap[62] = SDLK_KP8; |
371 MISC_keymap[63] = SDLK_KP9; | 377 MISC_keymap[63] = SDLK_KP9; |
372 MISC_keymap[60] = SDLK_KP_PERIOD; | 378 MISC_keymap[60] = SDLK_KP_PERIOD; |
373 MISC_keymap[92] = SDLK_KP_DIVIDE; | 379 MISC_keymap[92] = SDLK_KP_DIVIDE; |
374 MISC_keymap[93] = SDLK_KP_MULTIPLY; | 380 MISC_keymap[93] = SDLK_KP_MULTIPLY; |
375 MISC_keymap[74] = SDLK_KP_MINUS; | 381 MISC_keymap[74] = SDLK_KP_MINUS; |
376 MISC_keymap[94] = SDLK_KP_PLUS; | 382 MISC_keymap[94] = SDLK_KP_PLUS; |
377 MISC_keymap[67] = SDLK_KP_ENTER; | 383 MISC_keymap[67] = SDLK_KP_ENTER; |
378 // MISC_keymap[XK_KP_Equal&0xFF] = SDLK_KP_EQUALS; | 384 // MISC_keymap[XK_KP_Equal&0xFF] = SDLK_KP_EQUALS; |
379 | 385 |
380 MISC_keymap[76] = SDLK_UP; | 386 MISC_keymap[76] = SDLK_UP; |
381 MISC_keymap[77] = SDLK_DOWN; | 387 MISC_keymap[77] = SDLK_DOWN; |
382 MISC_keymap[78] = SDLK_RIGHT; | 388 MISC_keymap[78] = SDLK_RIGHT; |
383 MISC_keymap[79] = SDLK_LEFT; | 389 MISC_keymap[79] = SDLK_LEFT; |
384 /* | 390 /* |
385 MISC_keymap[XK_Insert&0xFF] = SDLK_INSERT; | 391 MISC_keymap[XK_Insert&0xFF] = SDLK_INSERT; |
386 MISC_keymap[XK_Home&0xFF] = SDLK_HOME; | 392 MISC_keymap[XK_Home&0xFF] = SDLK_HOME; |
387 MISC_keymap[XK_End&0xFF] = SDLK_END; | 393 MISC_keymap[XK_End&0xFF] = SDLK_END; |
388 */ | 394 */ |
389 // Mappati sulle parentesi del taastierino | 395 // Mappati sulle parentesi del taastierino |
390 MISC_keymap[90] = SDLK_PAGEUP; | 396 MISC_keymap[90] = SDLK_PAGEUP; |
391 MISC_keymap[91] = SDLK_PAGEDOWN; | 397 MISC_keymap[91] = SDLK_PAGEDOWN; |
392 | 398 |
393 MISC_keymap[80] = SDLK_F1; | 399 MISC_keymap[80] = SDLK_F1; |
394 MISC_keymap[81] = SDLK_F2; | 400 MISC_keymap[81] = SDLK_F2; |
395 MISC_keymap[82] = SDLK_F3; | 401 MISC_keymap[82] = SDLK_F3; |
396 MISC_keymap[83] = SDLK_F4; | 402 MISC_keymap[83] = SDLK_F4; |
397 MISC_keymap[84] = SDLK_F5; | 403 MISC_keymap[84] = SDLK_F5; |
398 MISC_keymap[85] = SDLK_F6; | 404 MISC_keymap[85] = SDLK_F6; |
399 MISC_keymap[86] = SDLK_F7; | 405 MISC_keymap[86] = SDLK_F7; |
400 MISC_keymap[87] = SDLK_F8; | 406 MISC_keymap[87] = SDLK_F8; |
401 MISC_keymap[88] = SDLK_F9; | 407 MISC_keymap[88] = SDLK_F9; |
402 MISC_keymap[89] = SDLK_F10; | 408 MISC_keymap[89] = SDLK_F10; |
403 // MISC_keymap[XK_F11&0xFF] = SDLK_F11; | 409 // MISC_keymap[XK_F11&0xFF] = SDLK_F11; |
404 // MISC_keymap[XK_F12&0xFF] = SDLK_F12; | 410 // MISC_keymap[XK_F12&0xFF] = SDLK_F12; |
405 // MISC_keymap[XK_F13&0xFF] = SDLK_F13; | 411 // MISC_keymap[XK_F13&0xFF] = SDLK_F13; |
406 // MISC_keymap[XK_F14&0xFF] = SDLK_F14; | 412 // MISC_keymap[XK_F14&0xFF] = SDLK_F14; |
407 // MISC_keymap[XK_F15&0xFF] = SDLK_F15; | 413 // MISC_keymap[XK_F15&0xFF] = SDLK_F15; |
408 | 414 |
409 // MISC_keymap[XK_Num_Lock&0xFF] = SDLK_NUMLOCK; | 415 // MISC_keymap[XK_Num_Lock&0xFF] = SDLK_NUMLOCK; |
410 MISC_keymap[98] = SDLK_CAPSLOCK; | 416 MISC_keymap[98] = SDLK_CAPSLOCK; |
411 // MISC_keymap[XK_Scroll_Lock&0xFF] = SDLK_SCROLLOCK; | 417 // MISC_keymap[XK_Scroll_Lock&0xFF] = SDLK_SCROLLOCK; |
412 MISC_keymap[97] = SDLK_RSHIFT; | 418 MISC_keymap[97] = SDLK_RSHIFT; |
413 MISC_keymap[96] = SDLK_LSHIFT; | 419 MISC_keymap[96] = SDLK_LSHIFT; |
414 MISC_keymap[99] = SDLK_LCTRL; | 420 MISC_keymap[99] = SDLK_LCTRL; |
415 MISC_keymap[99] = SDLK_LCTRL; | 421 MISC_keymap[99] = SDLK_LCTRL; |
416 MISC_keymap[101] = SDLK_RALT; | 422 MISC_keymap[101] = SDLK_RALT; |
417 MISC_keymap[100] = SDLK_LALT; | 423 MISC_keymap[100] = SDLK_LALT; |
418 // MISC_keymap[XK_Meta_R&0xFF] = SDLK_RMETA; | 424 // MISC_keymap[XK_Meta_R&0xFF] = SDLK_RMETA; |
419 // MISC_keymap[XK_Meta_L&0xFF] = SDLK_LMETA; | 425 // MISC_keymap[XK_Meta_L&0xFF] = SDLK_LMETA; |
420 MISC_keymap[103] = SDLK_LSUPER; /* Left "Windows" */ | 426 MISC_keymap[103] = SDLK_LSUPER; /* Left "Windows" */ |
421 MISC_keymap[102] = SDLK_RSUPER; /* Right "Windows */ | 427 MISC_keymap[102] = SDLK_RSUPER; /* Right "Windows */ |
422 | 428 |
423 MISC_keymap[95] = SDLK_HELP; | 429 MISC_keymap[95] = SDLK_HELP; |
424 } | 430 } |
425 | 431 |
426 SDL_keysym *amiga_TranslateKey(int code, SDL_keysym *keysym) | 432 SDL_keysym * |
427 { | 433 amiga_TranslateKey (int code, SDL_keysym * keysym) |
428 #ifdef STORMC4_WOS | 434 { |
429 static struct Library *KeymapBase=NULL; /* Linking failed in WOS version if ConsoleDevice was used */ | 435 #ifdef STORMC4_WOS |
430 #else | 436 static struct Library *KeymapBase = NULL; /* Linking failed in WOS version if ConsoleDevice was used */ |
431 static struct Library *ConsoleDevice=NULL; | 437 #else |
432 #endif | 438 static struct Library *ConsoleDevice = NULL; |
433 | 439 #endif |
434 /* Get the raw keyboard scancode */ | 440 |
435 keysym->scancode = code; | 441 /* Get the raw keyboard scancode */ |
436 keysym->sym = MISC_keymap[code]; | 442 keysym->scancode = code; |
443 keysym->sym = MISC_keymap[code]; | |
437 | 444 |
438 #ifdef DEBUG_KEYS | 445 #ifdef DEBUG_KEYS |
439 fprintf(stderr, "Translating key 0x%.4x (%d)\n", xsym, xkey->keycode); | 446 fprintf (stderr, "Translating key 0x%.4x (%d)\n", xsym, xkey->keycode); |
440 #endif | 447 #endif |
441 /* Get the translated SDL virtual keysym */ | 448 /* Get the translated SDL virtual keysym */ |
442 if ( keysym->sym==SDLK_UNKNOWN ) | 449 if (keysym->sym == SDLK_UNKNOWN) { |
443 { | 450 #ifdef STORMC4_WOS |
444 #ifdef STORMC4_WOS | 451 if (!KeymapBase) |
445 if(!KeymapBase) | 452 #else |
446 #else | 453 if (!ConsoleDevice) |
447 if(!ConsoleDevice) | 454 #endif |
448 #endif | 455 { |
449 { | 456 #ifdef STORMC4_WOS |
450 #ifdef STORMC4_WOS | 457 KeymapBase = OpenLibrary ("keymap.library", 0L); |
451 KeymapBase=OpenLibrary("keymap.library", 0L); | 458 #else |
452 #else | 459 if (ConPort = CreateMsgPort ()) { |
453 if(ConPort=CreateMsgPort()) | 460 if (ConReq = |
454 { | 461 CreateIORequest (ConPort, sizeof (struct IOStdReq))) { |
455 if(ConReq=CreateIORequest(ConPort,sizeof(struct IOStdReq))) | 462 if (!OpenDevice |
456 { | 463 ("console.device", -1, |
457 if(!OpenDevice("console.device",-1,(struct IORequest *)ConReq,0)) | 464 (struct IORequest *) ConReq, 0)) |
458 ConsoleDevice=(struct Library *)ConReq->io_Device; | 465 ConsoleDevice = (struct Library *) ConReq->io_Device; |
459 else | 466 else { |
460 { | 467 DeleteIORequest (ConReq); |
461 DeleteIORequest(ConReq); | 468 ConReq = NULL; |
462 ConReq=NULL; | 469 } |
463 } | 470 } else { |
464 } | 471 DeleteMsgPort (ConPort); |
465 else | 472 ConPort = NULL; |
466 { | 473 } |
467 DeleteMsgPort(ConPort); | 474 } |
468 ConPort=NULL; | 475 #endif |
469 } | 476 } |
470 } | 477 #ifdef STORMC4_WOS |
471 #endif | 478 if (KeymapBase) |
472 } | 479 #else |
473 | 480 if (ConsoleDevice) |
474 #ifdef STORMC4_WOS | 481 #endif |
475 if(KeymapBase) | 482 { |
476 #else | 483 struct InputEvent event; |
477 if(ConsoleDevice) | 484 long actual; |
478 #endif | 485 char buffer[5]; |
479 { | 486 |
480 struct InputEvent event; | 487 event.ie_Qualifier = 0; |
481 long actual; | 488 event.ie_Class = IECLASS_RAWKEY; |
482 char buffer[5]; | 489 event.ie_SubClass = 0L; |
483 | 490 event.ie_Code = code; |
484 event.ie_Qualifier=0; | 491 event.ie_X = event.ie_Y = 0; |
485 event.ie_Class=IECLASS_RAWKEY; | 492 event.ie_EventAddress = NULL; |
486 event.ie_SubClass=0L; | 493 event.ie_NextEvent = NULL; |
487 event.ie_Code=code; | 494 event.ie_Prev1DownCode = event.ie_Prev1DownQual = |
488 event.ie_X=event.ie_Y=0; | 495 event.ie_Prev2DownCode = event.ie_Prev2DownQual = 0; |
489 event.ie_EventAddress=NULL; | 496 |
490 event.ie_NextEvent=NULL; | 497 #ifdef STORMC4_WOS |
491 event.ie_Prev1DownCode=event.ie_Prev1DownQual=event.ie_Prev2DownCode=event.ie_Prev2DownQual=0; | 498 if ((actual = MapRawKey (&event, buffer, 5, NULL)) >= 0) |
492 | 499 #else |
493 #ifdef STORMC4_WOS | 500 if ((actual = RawKeyConvert (&event, buffer, 5, NULL)) >= 0) |
494 if( (actual=MapRawKey(&event,buffer,5,NULL))>=0) | 501 #endif |
495 #else | 502 { |
496 if( (actual=RawKeyConvert(&event,buffer,5,NULL))>=0) | 503 if (actual > 1) { |
497 #endif | 504 D (bug ("Warning (%ld) character conversion!\n", actual)); |
498 { | 505 } else if (actual == 1) { |
499 if(actual>1) | 506 keysym->sym = *buffer; |
500 { | 507 D (bug |
501 D(bug("Warning (%ld) character conversion!\n",actual)); | 508 ("Converted rawcode %ld to <%lc>\n", code, *buffer)); |
502 } | |
503 else if(actual==1) | |
504 { | |
505 keysym->sym=*buffer; | |
506 D(bug("Converted rawcode %ld to <%lc>\n",code,*buffer)); | |
507 // Bufferizzo x le successive chiamate! | 509 // Bufferizzo x le successive chiamate! |
508 MISC_keymap[code]=*buffer; | 510 MISC_keymap[code] = *buffer; |
509 } | 511 } |
510 } | 512 } |
511 } | 513 } |
512 | 514 |
513 } | 515 } |
514 keysym->mod = KMOD_NONE; | 516 keysym->mod = KMOD_NONE; |
515 | 517 |
516 /* If UNICODE is on, get the UNICODE value for the key */ | 518 /* If UNICODE is on, get the UNICODE value for the key */ |
517 keysym->unicode = 0; | 519 keysym->unicode = 0; |
518 if ( SDL_TranslateUNICODE ) { | 520 if (SDL_TranslateUNICODE) { |
519 #if 0 | 521 #if 0 |
520 static XComposeStatus state; | 522 static XComposeStatus state; |
521 /* Until we handle the IM protocol, use XLookupString() */ | 523 /* Until we handle the IM protocol, use XLookupString() */ |
522 unsigned char keybuf[32]; | 524 unsigned char keybuf[32]; |
523 if ( XLookupString(xkey, (char *)keybuf, sizeof(keybuf), | 525 if (XLookupString (xkey, (char *) keybuf, sizeof (keybuf), |
524 NULL, &state) ) { | 526 NULL, &state)) { |
525 keysym->unicode = keybuf[0]; | 527 keysym->unicode = keybuf[0]; |
526 } | 528 } |
527 #endif | 529 #endif |
528 } | 530 } |
529 return(keysym); | 531 return (keysym); |
530 } | 532 } |
531 | 533 |
532 void amiga_InitOSKeymap(_THIS) | 534 void |
533 { | 535 amiga_InitOSKeymap (_THIS) |
534 amiga_InitKeymap(); | 536 { |
535 } | 537 amiga_InitKeymap (); |
538 } | |
539 | |
540 /* vi: set ts=4 sw=4 expandtab: */ |