Mercurial > sdl-ios-xcode
comparison src/video/photon/SDL_ph_events.c @ 1668:4da1ee79c9af SDL-1.3
more tweaking indent options
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Mon, 29 May 2006 04:04:35 +0000 |
parents | 782fd950bd46 |
children |
comparison
equal
deleted
inserted
replaced
1667:1fddae038bc8 | 1668:4da1ee79c9af |
---|---|
42 #include "SDL_phyuv_c.h" | 42 #include "SDL_phyuv_c.h" |
43 | 43 |
44 /* The translation tables from a photon keysym to a SDL keysym */ | 44 /* The translation tables from a photon keysym to a SDL keysym */ |
45 static SDLKey ODD_keymap[256]; | 45 static SDLKey ODD_keymap[256]; |
46 static SDLKey MISC_keymap[0xFF + 1]; | 46 static SDLKey MISC_keymap[0xFF + 1]; |
47 SDL_keysym *ph_TranslateKey (PhKeyEvent_t * key, SDL_keysym * keysym); | 47 SDL_keysym *ph_TranslateKey(PhKeyEvent_t * key, SDL_keysym * keysym); |
48 | 48 |
49 /* Check to see if this is a repeated key. | 49 /* Check to see if this is a repeated key. |
50 (idea shamelessly lifted from GII -- thanks guys! :) */ | 50 (idea shamelessly lifted from GII -- thanks guys! :) */ |
51 static int | 51 static int |
52 ph_WarpedMotion (_THIS, PhEvent_t * winEvent) | 52 ph_WarpedMotion(_THIS, PhEvent_t * winEvent) |
53 { | 53 { |
54 PhRect_t *rect = PhGetRects (winEvent); | 54 PhRect_t *rect = PhGetRects(winEvent); |
55 | 55 |
56 int centre_x, centre_y; | 56 int centre_x, centre_y; |
57 int dx, dy; | 57 int dx, dy; |
58 short abs_x, abs_y; | 58 short abs_x, abs_y; |
59 int posted; | 59 int posted; |
62 centre_y = SDL_VideoSurface->h / 2; | 62 centre_y = SDL_VideoSurface->h / 2; |
63 | 63 |
64 dx = rect->ul.x - centre_x; | 64 dx = rect->ul.x - centre_x; |
65 dy = rect->ul.y - centre_y; | 65 dy = rect->ul.y - centre_y; |
66 | 66 |
67 posted = SDL_PrivateMouseMotion (0, 1, dx, dy); | 67 posted = SDL_PrivateMouseMotion(0, 1, dx, dy); |
68 | 68 |
69 /* Move mouse cursor to middle of the window */ | 69 /* Move mouse cursor to middle of the window */ |
70 PtGetAbsPosition (window, &abs_x, &abs_y); | 70 PtGetAbsPosition(window, &abs_x, &abs_y); |
71 PhMoveCursorAbs (PhInputGroup (NULL), abs_x + centre_x, abs_y + centre_y); | 71 PhMoveCursorAbs(PhInputGroup(NULL), abs_x + centre_x, abs_y + centre_y); |
72 | 72 |
73 return (posted); | 73 return (posted); |
74 } | 74 } |
75 | 75 |
76 /* Control which motion flags the window has set, a flags value of -1 sets | 76 /* Control which motion flags the window has set, a flags value of -1 sets |
77 * MOTION_BUTTON and MOTION_NOBUTTON */ | 77 * MOTION_BUTTON and MOTION_NOBUTTON */ |
78 | 78 |
79 static void | 79 static void |
80 set_motion_sensitivity (_THIS, unsigned int flags) | 80 set_motion_sensitivity(_THIS, unsigned int flags) |
81 { | 81 { |
82 int rid; | 82 int rid; |
83 int fields = Ph_EV_PTR_MOTION_BUTTON | Ph_EV_PTR_MOTION_NOBUTTON; | 83 int fields = Ph_EV_PTR_MOTION_BUTTON | Ph_EV_PTR_MOTION_NOBUTTON; |
84 PhRegion_t region; | 84 PhRegion_t region; |
85 | 85 |
86 if (window) { | 86 if (window) { |
87 rid = PtWidgetRid (window); | 87 rid = PtWidgetRid(window); |
88 if (rid != 0 && PhRegionQuery (rid, ®ion, NULL, NULL, 0) == 0) { | 88 if (rid != 0 && PhRegionQuery(rid, ®ion, NULL, NULL, 0) == 0) { |
89 region.events_sense = | 89 region.events_sense = |
90 (region.events_sense & ~fields) | (flags & fields); | 90 (region.events_sense & ~fields) | (flags & fields); |
91 PhRegionChange (Ph_REGION_EV_SENSE, 0, ®ion, NULL, NULL); | 91 PhRegionChange(Ph_REGION_EV_SENSE, 0, ®ion, NULL, NULL); |
92 } | 92 } |
93 } | 93 } |
94 } | 94 } |
95 | 95 |
96 /* Convert the photon button state value to an SDL value */ | 96 /* Convert the photon button state value to an SDL value */ |
97 static Uint8 | 97 static Uint8 |
98 ph2sdl_mousebutton (unsigned short button_state) | 98 ph2sdl_mousebutton(unsigned short button_state) |
99 { | 99 { |
100 Uint8 mouse_button = 0; | 100 Uint8 mouse_button = 0; |
101 | 101 |
102 if (button_state & Ph_BUTTON_SELECT) | 102 if (button_state & Ph_BUTTON_SELECT) |
103 mouse_button |= SDL_BUTTON_LEFT; | 103 mouse_button |= SDL_BUTTON_LEFT; |
108 | 108 |
109 return (mouse_button); | 109 return (mouse_button); |
110 } | 110 } |
111 | 111 |
112 static int | 112 static int |
113 ph_DispatchEvent (_THIS) | 113 ph_DispatchEvent(_THIS) |
114 { | 114 { |
115 int posted; | 115 int posted; |
116 PhRect_t *rect; | 116 PhRect_t *rect; |
117 PhPointerEvent_t *pointerEvent; | 117 PhPointerEvent_t *pointerEvent; |
118 PhKeyEvent_t *keyEvent; | 118 PhKeyEvent_t *keyEvent; |
124 | 124 |
125 switch (phevent->type) { | 125 switch (phevent->type) { |
126 case Ph_EV_BOUNDARY: | 126 case Ph_EV_BOUNDARY: |
127 { | 127 { |
128 if (phevent->subtype == Ph_EV_PTR_ENTER) { | 128 if (phevent->subtype == Ph_EV_PTR_ENTER) { |
129 posted = SDL_PrivateAppActive (1, SDL_APPMOUSEFOCUS); | 129 posted = SDL_PrivateAppActive(1, SDL_APPMOUSEFOCUS); |
130 } else if (phevent->subtype == Ph_EV_PTR_LEAVE) { | 130 } else if (phevent->subtype == Ph_EV_PTR_LEAVE) { |
131 posted = SDL_PrivateAppActive (0, SDL_APPMOUSEFOCUS); | 131 posted = SDL_PrivateAppActive(0, SDL_APPMOUSEFOCUS); |
132 } | 132 } |
133 } | 133 } |
134 break; | 134 break; |
135 | 135 |
136 case Ph_EV_PTR_MOTION_BUTTON: | 136 case Ph_EV_PTR_MOTION_BUTTON: |
137 case Ph_EV_PTR_MOTION_NOBUTTON: | 137 case Ph_EV_PTR_MOTION_NOBUTTON: |
138 { | 138 { |
139 if (SDL_VideoSurface) { | 139 if (SDL_VideoSurface) { |
140 pointerEvent = PhGetData (phevent); | 140 pointerEvent = PhGetData(phevent); |
141 rect = PhGetRects (phevent); | 141 rect = PhGetRects(phevent); |
142 | 142 |
143 if (mouse_relative) { | 143 if (mouse_relative) { |
144 posted = ph_WarpedMotion (this, phevent); | 144 posted = ph_WarpedMotion(this, phevent); |
145 } else { | 145 } else { |
146 posted = | 146 posted = |
147 SDL_PrivateMouseMotion (0, 0, rect->ul.x, rect->ul.y); | 147 SDL_PrivateMouseMotion(0, 0, rect->ul.x, rect->ul.y); |
148 } | 148 } |
149 } | 149 } |
150 } | 150 } |
151 break; | 151 break; |
152 | 152 |
153 case Ph_EV_BUT_PRESS: | 153 case Ph_EV_BUT_PRESS: |
154 { | 154 { |
155 pointerEvent = PhGetData (phevent); | 155 pointerEvent = PhGetData(phevent); |
156 buttons = ph2sdl_mousebutton (pointerEvent->buttons); | 156 buttons = ph2sdl_mousebutton(pointerEvent->buttons); |
157 if (buttons != 0) { | 157 if (buttons != 0) { |
158 posted = SDL_PrivateMouseButton (SDL_PRESSED, buttons, 0, 0); | 158 posted = SDL_PrivateMouseButton(SDL_PRESSED, buttons, 0, 0); |
159 } | 159 } |
160 } | 160 } |
161 break; | 161 break; |
162 | 162 |
163 case Ph_EV_BUT_RELEASE: | 163 case Ph_EV_BUT_RELEASE: |
164 { | 164 { |
165 pointerEvent = PhGetData (phevent); | 165 pointerEvent = PhGetData(phevent); |
166 buttons = ph2sdl_mousebutton (pointerEvent->buttons); | 166 buttons = ph2sdl_mousebutton(pointerEvent->buttons); |
167 if (phevent->subtype == Ph_EV_RELEASE_REAL && buttons != 0) { | 167 if (phevent->subtype == Ph_EV_RELEASE_REAL && buttons != 0) { |
168 posted = SDL_PrivateMouseButton (SDL_RELEASED, buttons, 0, 0); | 168 posted = SDL_PrivateMouseButton(SDL_RELEASED, buttons, 0, 0); |
169 } else if (phevent->subtype == Ph_EV_RELEASE_PHANTOM) { | 169 } else if (phevent->subtype == Ph_EV_RELEASE_PHANTOM) { |
170 /* If the mouse is outside the window, | 170 /* If the mouse is outside the window, |
171 * only a phantom release event is sent, so | 171 * only a phantom release event is sent, so |
172 * check if the window doesn't have mouse focus. | 172 * check if the window doesn't have mouse focus. |
173 * Not perfect, maybe checking the mouse button | 173 * Not perfect, maybe checking the mouse button |
174 * state for Ph_EV_BOUNDARY events would be | 174 * state for Ph_EV_BOUNDARY events would be |
175 * better. */ | 175 * better. */ |
176 if ((SDL_GetAppState () & SDL_APPMOUSEFOCUS) == 0) { | 176 if ((SDL_GetAppState() & SDL_APPMOUSEFOCUS) == 0) { |
177 posted = | 177 posted = |
178 SDL_PrivateMouseButton (SDL_RELEASED, buttons, 0, 0); | 178 SDL_PrivateMouseButton(SDL_RELEASED, buttons, 0, 0); |
179 } | 179 } |
180 } | 180 } |
181 } | 181 } |
182 break; | 182 break; |
183 | 183 |
184 case Ph_EV_WM: | 184 case Ph_EV_WM: |
185 { | 185 { |
186 winEvent = PhGetData (phevent); | 186 winEvent = PhGetData(phevent); |
187 | 187 |
188 /* losing focus */ | 188 /* losing focus */ |
189 if ((winEvent->event_f == Ph_WM_FOCUS) | 189 if ((winEvent->event_f == Ph_WM_FOCUS) |
190 && (winEvent->event_state == Ph_WM_EVSTATE_FOCUSLOST)) { | 190 && (winEvent->event_state == Ph_WM_EVSTATE_FOCUSLOST)) { |
191 set_motion_sensitivity (this, Ph_EV_PTR_MOTION_BUTTON); | 191 set_motion_sensitivity(this, Ph_EV_PTR_MOTION_BUTTON); |
192 posted = SDL_PrivateAppActive (0, SDL_APPINPUTFOCUS); | 192 posted = SDL_PrivateAppActive(0, SDL_APPINPUTFOCUS); |
193 } | 193 } |
194 /* gaining focus */ | 194 /* gaining focus */ |
195 else if ((winEvent->event_f == Ph_WM_FOCUS) | 195 else if ((winEvent->event_f == Ph_WM_FOCUS) |
196 && (winEvent->event_state == Ph_WM_EVSTATE_FOCUS)) { | 196 && (winEvent->event_state == Ph_WM_EVSTATE_FOCUS)) { |
197 set_motion_sensitivity (this, -1); | 197 set_motion_sensitivity(this, -1); |
198 posted = SDL_PrivateAppActive (1, SDL_APPINPUTFOCUS); | 198 posted = SDL_PrivateAppActive(1, SDL_APPINPUTFOCUS); |
199 } | 199 } |
200 /* request quit */ | 200 /* request quit */ |
201 else if (winEvent->event_f == Ph_WM_CLOSE) { | 201 else if (winEvent->event_f == Ph_WM_CLOSE) { |
202 posted = SDL_PrivateQuit (); | 202 posted = SDL_PrivateQuit(); |
203 } | 203 } |
204 /* request hide/unhide */ | 204 /* request hide/unhide */ |
205 else if (winEvent->event_f == Ph_WM_HIDE) { | 205 else if (winEvent->event_f == Ph_WM_HIDE) { |
206 if (currently_hided) { | 206 if (currently_hided) { |
207 /* got unhide window event */ | 207 /* got unhide window event */ |
215 } | 215 } |
216 /* request to resize */ | 216 /* request to resize */ |
217 else if (winEvent->event_f == Ph_WM_RESIZE) { | 217 else if (winEvent->event_f == Ph_WM_RESIZE) { |
218 currently_maximized = 0; | 218 currently_maximized = 0; |
219 #if (_NTO_VERSION < 630) | 219 #if (_NTO_VERSION < 630) |
220 SDL_PrivateResize (winEvent->size.w + 1, | 220 SDL_PrivateResize(winEvent->size.w + 1, winEvent->size.h + 1); |
221 winEvent->size.h + 1); | |
222 #else | 221 #else |
223 /* QNX 6.3.0 have this bug fixed */ | 222 /* QNX 6.3.0 have this bug fixed */ |
224 SDL_PrivateResize (winEvent->size.w, winEvent->size.h); | 223 SDL_PrivateResize(winEvent->size.w, winEvent->size.h); |
225 #endif /* _NTO_VERSION */ | 224 #endif /* _NTO_VERSION */ |
226 } | 225 } |
227 /* request to move */ | 226 /* request to move */ |
228 else if (winEvent->event_f == Ph_WM_MOVE) { | 227 else if (winEvent->event_f == Ph_WM_MOVE) { |
229 if (current_overlay != NULL) { | 228 if (current_overlay != NULL) { |
241 dst.y = current_overlay->hwdata->CurrentViewPort.pos.y; | 240 dst.y = current_overlay->hwdata->CurrentViewPort.pos.y; |
242 dst.w = current_overlay->hwdata->CurrentViewPort.size.w; | 241 dst.w = current_overlay->hwdata->CurrentViewPort.size.w; |
243 dst.h = current_overlay->hwdata->CurrentViewPort.size.h; | 242 dst.h = current_overlay->hwdata->CurrentViewPort.size.h; |
244 current_overlay->hwdata->ischromakey = 0; | 243 current_overlay->hwdata->ischromakey = 0; |
245 error = | 244 error = |
246 ph_DisplayYUVOverlay (this, current_overlay, | 245 ph_DisplayYUVOverlay(this, current_overlay, |
247 &src, &dst); | 246 &src, &dst); |
248 if (!error) { | 247 if (!error) { |
249 current_overlay->hwdata->ischromakey = chromastate; | 248 current_overlay->hwdata->ischromakey = chromastate; |
250 current_overlay->hwdata->locked = lockedstate; | 249 current_overlay->hwdata->locked = lockedstate; |
251 } | 250 } |
252 } | 251 } |
269 { | 268 { |
270 if (phevent->num_rects != 0) { | 269 if (phevent->num_rects != 0) { |
271 int numrects; | 270 int numrects; |
272 | 271 |
273 if (SDL_VideoSurface) { | 272 if (SDL_VideoSurface) { |
274 rect = PhGetRects (phevent); | 273 rect = PhGetRects(phevent); |
275 if (phevent->num_rects > PH_SDL_MAX_RECTS) { | 274 if (phevent->num_rects > PH_SDL_MAX_RECTS) { |
276 /* sorry, buffers underrun, we'll update only first PH_SDL_MAX_RECTS rects */ | 275 /* sorry, buffers underrun, we'll update only first PH_SDL_MAX_RECTS rects */ |
277 numrects = PH_SDL_MAX_RECTS; | 276 numrects = PH_SDL_MAX_RECTS; |
278 } | 277 } |
279 | 278 |
282 sdlrects[i].y = rect[i].ul.y; | 281 sdlrects[i].y = rect[i].ul.y; |
283 sdlrects[i].w = rect[i].lr.x - rect[i].ul.x + 1; | 282 sdlrects[i].w = rect[i].lr.x - rect[i].ul.x + 1; |
284 sdlrects[i].h = rect[i].lr.y - rect[i].ul.y + 1; | 283 sdlrects[i].h = rect[i].lr.y - rect[i].ul.y + 1; |
285 } | 284 } |
286 | 285 |
287 this->UpdateRects (this, phevent->num_rects, sdlrects); | 286 this->UpdateRects(this, phevent->num_rects, sdlrects); |
288 | 287 |
289 if (current_overlay != NULL) { | 288 if (current_overlay != NULL) { |
290 int lockedstate = current_overlay->hwdata->locked; | 289 int lockedstate = current_overlay->hwdata->locked; |
291 int error; | 290 int error; |
292 SDL_Rect src, dst; | 291 SDL_Rect src, dst; |
304 current_overlay->hwdata->CurrentViewPort.size.w; | 303 current_overlay->hwdata->CurrentViewPort.size.w; |
305 dst.h = | 304 dst.h = |
306 current_overlay->hwdata->CurrentViewPort.size.h; | 305 current_overlay->hwdata->CurrentViewPort.size.h; |
307 current_overlay->hwdata->forcedredraw = 1; | 306 current_overlay->hwdata->forcedredraw = 1; |
308 error = | 307 error = |
309 ph_DisplayYUVOverlay (this, | 308 ph_DisplayYUVOverlay(this, |
310 current_overlay, | 309 current_overlay, &src, &dst); |
311 &src, &dst); | |
312 if (!error) { | 310 if (!error) { |
313 current_overlay->hwdata->forcedredraw = 0; | 311 current_overlay->hwdata->forcedredraw = 0; |
314 current_overlay->hwdata->locked = lockedstate; | 312 current_overlay->hwdata->locked = lockedstate; |
315 } | 313 } |
316 } | 314 } |
323 { | 321 { |
324 SDL_keysym keysym; | 322 SDL_keysym keysym; |
325 | 323 |
326 posted = 0; | 324 posted = 0; |
327 | 325 |
328 keyEvent = PhGetData (phevent); | 326 keyEvent = PhGetData(phevent); |
329 | 327 |
330 if (Pk_KF_Key_Down & keyEvent->key_flags) { | 328 if (Pk_KF_Key_Down & keyEvent->key_flags) { |
331 /* split the wheel events from real key events */ | 329 /* split the wheel events from real key events */ |
332 if ((keyEvent->key_cap == Pk_Up) | 330 if ((keyEvent->key_cap == Pk_Up) |
333 && (keyEvent->key_scan == 0) | 331 && (keyEvent->key_scan == 0) |
334 && ((keyEvent->key_flags & Pk_KF_Scan_Valid) == | 332 && ((keyEvent->key_flags & Pk_KF_Scan_Valid) == |
335 Pk_KF_Scan_Valid)) { | 333 Pk_KF_Scan_Valid)) { |
336 posted = | 334 posted = |
337 SDL_PrivateMouseButton (SDL_PRESSED, | 335 SDL_PrivateMouseButton(SDL_PRESSED, |
338 SDL_BUTTON_WHEELUP, 0, 0); | 336 SDL_BUTTON_WHEELUP, 0, 0); |
339 break; | 337 break; |
340 } | 338 } |
341 if ((keyEvent->key_cap == Pk_Down) | 339 if ((keyEvent->key_cap == Pk_Down) |
342 && (keyEvent->key_scan == 0) | 340 && (keyEvent->key_scan == 0) |
343 && ((keyEvent->key_flags & Pk_KF_Scan_Valid) == | 341 && ((keyEvent->key_flags & Pk_KF_Scan_Valid) == |
344 Pk_KF_Scan_Valid)) { | 342 Pk_KF_Scan_Valid)) { |
345 posted = | 343 posted = |
346 SDL_PrivateMouseButton (SDL_PRESSED, | 344 SDL_PrivateMouseButton(SDL_PRESSED, |
347 SDL_BUTTON_WHEELDOWN, 0, 0); | 345 SDL_BUTTON_WHEELDOWN, 0, 0); |
348 break; | 346 break; |
349 } | 347 } |
350 posted = | 348 posted = |
351 SDL_PrivateKeyboard (SDL_PRESSED, | 349 SDL_PrivateKeyboard(SDL_PRESSED, |
352 ph_TranslateKey (keyEvent, &keysym)); | 350 ph_TranslateKey(keyEvent, &keysym)); |
353 } else { /* must be key release */ | 351 } else { /* must be key release */ |
354 | 352 |
355 /* split the wheel events from real key events */ | 353 /* split the wheel events from real key events */ |
356 if ((keyEvent->key_cap == Pk_Up) | 354 if ((keyEvent->key_cap == Pk_Up) |
357 && (keyEvent->key_scan == 0) | 355 && (keyEvent->key_scan == 0) |
358 && ((keyEvent->key_flags & Pk_KF_Scan_Valid) == | 356 && ((keyEvent->key_flags & Pk_KF_Scan_Valid) == |
359 Pk_KF_Scan_Valid)) { | 357 Pk_KF_Scan_Valid)) { |
360 posted = | 358 posted = |
361 SDL_PrivateMouseButton (SDL_RELEASED, | 359 SDL_PrivateMouseButton(SDL_RELEASED, |
362 SDL_BUTTON_WHEELUP, 0, 0); | 360 SDL_BUTTON_WHEELUP, 0, 0); |
363 break; | 361 break; |
364 } | 362 } |
365 if ((keyEvent->key_cap == Pk_Down) | 363 if ((keyEvent->key_cap == Pk_Down) |
366 && (keyEvent->key_scan == 0) | 364 && (keyEvent->key_scan == 0) |
367 && ((keyEvent->key_flags & Pk_KF_Scan_Valid) == | 365 && ((keyEvent->key_flags & Pk_KF_Scan_Valid) == |
368 Pk_KF_Scan_Valid)) { | 366 Pk_KF_Scan_Valid)) { |
369 posted = | 367 posted = |
370 SDL_PrivateMouseButton (SDL_RELEASED, | 368 SDL_PrivateMouseButton(SDL_RELEASED, |
371 SDL_BUTTON_WHEELDOWN, 0, 0); | 369 SDL_BUTTON_WHEELDOWN, 0, 0); |
372 break; | 370 break; |
373 } | 371 } |
374 posted = | 372 posted = |
375 SDL_PrivateKeyboard (SDL_RELEASED, | 373 SDL_PrivateKeyboard(SDL_RELEASED, |
376 ph_TranslateKey (keyEvent, &keysym)); | 374 ph_TranslateKey(keyEvent, &keysym)); |
377 } | 375 } |
378 } | 376 } |
379 break; | 377 break; |
380 | 378 |
381 case Ph_EV_INFO: | 379 case Ph_EV_INFO: |
382 { | 380 { |
383 if (phevent->subtype == Ph_OFFSCREEN_INVALID) { | 381 if (phevent->subtype == Ph_OFFSCREEN_INVALID) { |
384 unsigned long *EvInfoData; | 382 unsigned long *EvInfoData; |
385 | 383 |
386 EvInfoData = (unsigned long *) PhGetData (phevent); | 384 EvInfoData = (unsigned long *) PhGetData(phevent); |
387 | 385 |
388 switch (*EvInfoData) { | 386 switch (*EvInfoData) { |
389 case Pg_VIDEO_MODE_SWITCHED: | 387 case Pg_VIDEO_MODE_SWITCHED: |
390 { | 388 { |
391 } | 389 } |
411 return (posted); | 409 return (posted); |
412 } | 410 } |
413 | 411 |
414 /* perform a blocking read if no events available */ | 412 /* perform a blocking read if no events available */ |
415 int | 413 int |
416 ph_Pending (_THIS) | 414 ph_Pending(_THIS) |
417 { | 415 { |
418 /* Flush the display connection and look to see if events are queued */ | 416 /* Flush the display connection and look to see if events are queued */ |
419 PgFlush (); | 417 PgFlush(); |
420 | 418 |
421 while (1) { | 419 while (1) { |
422 switch (PhEventPeek (phevent, EVENT_SIZE)) { | 420 switch (PhEventPeek(phevent, EVENT_SIZE)) { |
423 case Ph_EVENT_MSG: | 421 case Ph_EVENT_MSG: |
424 return 1; | 422 return 1; |
425 case -1: | 423 case -1: |
426 SDL_SetError ("ph_Pending(): PhEventNext failed.\n"); | 424 SDL_SetError("ph_Pending(): PhEventNext failed.\n"); |
427 return 0; | 425 return 0; |
428 default: | 426 default: |
429 return 0; | 427 return 0; |
430 } | 428 } |
431 } | 429 } |
433 /* Oh well, nothing is ready .. */ | 431 /* Oh well, nothing is ready .. */ |
434 return (0); | 432 return (0); |
435 } | 433 } |
436 | 434 |
437 void | 435 void |
438 ph_PumpEvents (_THIS) | 436 ph_PumpEvents(_THIS) |
439 { | 437 { |
440 /* Flush the display connection and look to see if events are queued */ | 438 /* Flush the display connection and look to see if events are queued */ |
441 PgFlush (); | 439 PgFlush(); |
442 | 440 |
443 while (ph_Pending (this)) { | 441 while (ph_Pending(this)) { |
444 PtEventHandler (phevent); | 442 PtEventHandler(phevent); |
445 ph_DispatchEvent (this); | 443 ph_DispatchEvent(this); |
446 } | 444 } |
447 } | 445 } |
448 | 446 |
449 void | 447 void |
450 ph_InitKeymap (void) | 448 ph_InitKeymap(void) |
451 { | 449 { |
452 int i; | 450 int i; |
453 | 451 |
454 /* Odd keys used in international keyboards */ | 452 /* Odd keys used in international keyboards */ |
455 for (i = 0; i < SDL_arraysize (ODD_keymap); ++i) { | 453 for (i = 0; i < SDL_arraysize(ODD_keymap); ++i) { |
456 ODD_keymap[i] = SDLK_UNKNOWN; | 454 ODD_keymap[i] = SDLK_UNKNOWN; |
457 } | 455 } |
458 | 456 |
459 /* Map the miscellaneous keys */ | 457 /* Map the miscellaneous keys */ |
460 for (i = 0; i < SDL_arraysize (MISC_keymap); ++i) { | 458 for (i = 0; i < SDL_arraysize(MISC_keymap); ++i) { |
461 MISC_keymap[i] = SDLK_UNKNOWN; | 459 MISC_keymap[i] = SDLK_UNKNOWN; |
462 } | 460 } |
463 | 461 |
464 MISC_keymap[Pk_BackSpace & 0xFF] = SDLK_BACKSPACE; | 462 MISC_keymap[Pk_BackSpace & 0xFF] = SDLK_BACKSPACE; |
465 MISC_keymap[Pk_Tab & 0xFF] = SDLK_TAB; | 463 MISC_keymap[Pk_Tab & 0xFF] = SDLK_TAB; |
541 } | 539 } |
542 | 540 |
543 static unsigned long cap; | 541 static unsigned long cap; |
544 | 542 |
545 SDL_keysym * | 543 SDL_keysym * |
546 ph_TranslateKey (PhKeyEvent_t * key, SDL_keysym * keysym) | 544 ph_TranslateKey(PhKeyEvent_t * key, SDL_keysym * keysym) |
547 { | 545 { |
548 /* 'sym' is set to the value of the key with modifiers applied to it. | 546 /* 'sym' is set to the value of the key with modifiers applied to it. |
549 This member is valid only if Pk_KF_Sym_Valid is set in the key_flags. | 547 This member is valid only if Pk_KF_Sym_Valid is set in the key_flags. |
550 We will assume it is valid. */ | 548 We will assume it is valid. */ |
551 | 549 |
599 /* Enter key */ | 597 /* Enter key */ |
600 case 0x1C: | 598 case 0x1C: |
601 keysym->unicode = 10; | 599 keysym->unicode = 10; |
602 break; | 600 break; |
603 default: | 601 default: |
604 utf8len = PhKeyToMb (utf8, key); | 602 utf8len = PhKeyToMb(utf8, key); |
605 if (utf8len > 0) { | 603 if (utf8len > 0) { |
606 utf8len = mbtowc (&unicode, utf8, utf8len); | 604 utf8len = mbtowc(&unicode, utf8, utf8len); |
607 if (utf8len > 0) { | 605 if (utf8len > 0) { |
608 keysym->unicode = unicode; | 606 keysym->unicode = unicode; |
609 } | 607 } |
610 } | 608 } |
611 break; | 609 break; |
615 | 613 |
616 return (keysym); | 614 return (keysym); |
617 } | 615 } |
618 | 616 |
619 void | 617 void |
620 ph_InitOSKeymap (_THIS) | 618 ph_InitOSKeymap(_THIS) |
621 { | 619 { |
622 ph_InitKeymap (); | 620 ph_InitKeymap(); |
623 } | 621 } |
624 | 622 |
625 /* vi: set ts=4 sw=4 expandtab: */ | 623 /* vi: set ts=4 sw=4 expandtab: */ |