comparison src/video/photon/SDL_photon_input.c @ 3139:7f684f249ec9

indent
author Sam Lantinga <slouken@libsdl.org>
date Sat, 23 May 2009 22:41:08 +0000
parents 1102a3305928
children e00d6ecb5d4b
comparison
equal deleted inserted replaced
3125:d71d8ceda8b3 3139:7f684f249ec9
32 #include "../../events/SDL_keyboard_c.h" 32 #include "../../events/SDL_keyboard_c.h"
33 33
34 #include "SDL_photon_keycodes.h" 34 #include "SDL_photon_keycodes.h"
35 35
36 /* Mouse related functions */ 36 /* Mouse related functions */
37 SDL_Cursor* photon_createcursor(SDL_Surface* surface, int hot_x, int hot_y); 37 SDL_Cursor *photon_createcursor(SDL_Surface * surface, int hot_x, int hot_y);
38 int photon_showcursor(SDL_Cursor* cursor); 38 int photon_showcursor(SDL_Cursor * cursor);
39 void photon_movecursor(SDL_Cursor* cursor); 39 void photon_movecursor(SDL_Cursor * cursor);
40 void photon_freecursor(SDL_Cursor* cursor); 40 void photon_freecursor(SDL_Cursor * cursor);
41 void photon_warpmouse(SDL_Mouse* mouse, SDL_WindowID windowID, int x, int y); 41 void photon_warpmouse(SDL_Mouse * mouse, SDL_WindowID windowID, int x, int y);
42 void photon_freemouse(SDL_Mouse* mouse); 42 void photon_freemouse(SDL_Mouse * mouse);
43 43
44 int32_t photon_addinputdevices(_THIS) 44 int32_t
45 { 45 photon_addinputdevices(_THIS)
46 SDL_VideoData* phdata=(SDL_VideoData*)_this->driverdata; 46 {
47 SDL_DisplayData* didata=NULL; 47 SDL_VideoData *phdata = (SDL_VideoData *) _this->driverdata;
48 struct SDL_Mouse photon_mouse; 48 SDL_DisplayData *didata = NULL;
49 SDL_MouseData* mdata=NULL; 49 struct SDL_Mouse photon_mouse;
50 SDL_Keyboard photon_keyboard; 50 SDL_MouseData *mdata = NULL;
51 SDLKey keymap[SDL_NUM_SCANCODES]; 51 SDL_Keyboard photon_keyboard;
52 uint32_t it; 52 SDLKey keymap[SDL_NUM_SCANCODES];
53 53 uint32_t it;
54 for (it=0; it<_this->num_displays; it++) 54
55 { 55 for (it = 0; it < _this->num_displays; it++) {
56 /* Clear SDL mouse structure */ 56 /* Clear SDL mouse structure */
57 SDL_memset(&photon_mouse, 0x00, sizeof(struct SDL_Mouse)); 57 SDL_memset(&photon_mouse, 0x00, sizeof(struct SDL_Mouse));
58 58
59 /* Allocate SDL_MouseData structure */ 59 /* Allocate SDL_MouseData structure */
60 mdata=(SDL_MouseData*)SDL_calloc(1, sizeof(SDL_MouseData)); 60 mdata = (SDL_MouseData *) SDL_calloc(1, sizeof(SDL_MouseData));
61 if (mdata==NULL) 61 if (mdata == NULL) {
62 { 62 SDL_OutOfMemory();
63 SDL_OutOfMemory(); 63 return -1;
64 return -1; 64 }
65 } 65
66 66 /* Mark this mouse with ID 0 */
67 /* Mark this mouse with ID 0 */ 67 photon_mouse.id = it;
68 photon_mouse.id=it; 68 photon_mouse.driverdata = (void *) mdata;
69 photon_mouse.driverdata=(void*)mdata; 69 photon_mouse.CreateCursor = photon_createcursor;
70 photon_mouse.CreateCursor=photon_createcursor; 70 photon_mouse.ShowCursor = photon_showcursor;
71 photon_mouse.ShowCursor=photon_showcursor; 71 photon_mouse.MoveCursor = photon_movecursor;
72 photon_mouse.MoveCursor=photon_movecursor; 72 photon_mouse.FreeCursor = photon_freecursor;
73 photon_mouse.FreeCursor=photon_freecursor; 73 photon_mouse.WarpMouse = photon_warpmouse;
74 photon_mouse.WarpMouse=photon_warpmouse; 74 photon_mouse.FreeMouse = photon_freemouse;
75 photon_mouse.FreeMouse=photon_freemouse; 75
76 76 /* Get display data */
77 /* Get display data */ 77 didata = (SDL_DisplayData *) _this->displays[it].driverdata;
78 didata=(SDL_DisplayData*)_this->displays[it].driverdata; 78
79 79 /* Store SDL_DisplayData pointer in the mouse driver internals */
80 /* Store SDL_DisplayData pointer in the mouse driver internals */ 80 mdata->didata = didata;
81 mdata->didata=didata; 81
82 82 /* Register mouse cursor in SDL */
83 /* Register mouse cursor in SDL */ 83 SDL_AddMouse(&photon_mouse, "Photon mouse cursor", 0, 0, 1);
84 SDL_AddMouse(&photon_mouse, "Photon mouse cursor", 0, 0, 1); 84 }
85 } 85
86 86 /* Photon maps all keyboards to one */
87 /* Photon maps all keyboards to one */ 87 SDL_zero(photon_keyboard);
88 SDL_zero(photon_keyboard); 88 SDL_AddKeyboard(&photon_keyboard, -1);
89 SDL_AddKeyboard(&photon_keyboard, -1); 89
90 90 /* Add default scancode to key mapping */
91 /* Add default scancode to key mapping */ 91 SDL_GetDefaultKeymap(keymap);
92 SDL_GetDefaultKeymap(keymap); 92 SDL_SetKeymap(0, 0, keymap, SDL_NUM_SCANCODES);
93 SDL_SetKeymap(0, 0, keymap, SDL_NUM_SCANCODES); 93
94 94 return 0;
95 return 0; 95 }
96 } 96
97 97 int32_t
98 int32_t photon_delinputdevices(_THIS) 98 photon_delinputdevices(_THIS)
99 { 99 {
100 /* Destroy all of the mice */ 100 /* Destroy all of the mice */
101 SDL_MouseQuit(); 101 SDL_MouseQuit();
102 } 102 }
103 103
104 /*****************************************************************************/ 104 /*****************************************************************************/
105 /* Photon mouse related functions */ 105 /* Photon mouse related functions */
106 /*****************************************************************************/ 106 /*****************************************************************************/
107 SDL_Cursor* photon_createcursor(SDL_Surface* surface, int hot_x, int hot_y) 107 SDL_Cursor *
108 { 108 photon_createcursor(SDL_Surface * surface, int hot_x, int hot_y)
109 PhCursorDef_t* internal_cursor; 109 {
110 SDL_Cursor* sdl_cursor; 110 PhCursorDef_t *internal_cursor;
111 uint8_t* image0=NULL; 111 SDL_Cursor *sdl_cursor;
112 uint8_t* image1=NULL; 112 uint8_t *image0 = NULL;
113 uint32_t it; 113 uint8_t *image1 = NULL;
114 uint32_t jt; 114 uint32_t it;
115 uint32_t shape_color; 115 uint32_t jt;
116 116 uint32_t shape_color;
117 /* SDL converts monochrome cursor shape to 32bpp cursor shape */ 117
118 /* and we must convert it back to monochrome, this routine handles */ 118 /* SDL converts monochrome cursor shape to 32bpp cursor shape */
119 /* 24/32bpp surfaces only */ 119 /* and we must convert it back to monochrome, this routine handles */
120 if ((surface->format->BitsPerPixel!=32) && (surface->format->BitsPerPixel!=24)) 120 /* 24/32bpp surfaces only */
121 { 121 if ((surface->format->BitsPerPixel != 32)
122 SDL_SetError("Photon: Cursor shape is not 24/32bpp."); 122 && (surface->format->BitsPerPixel != 24)) {
123 return NULL; 123 SDL_SetError("Photon: Cursor shape is not 24/32bpp.");
124 } 124 return NULL;
125 125 }
126 /* Checking data parameters */ 126
127 if ((surface->w==0) || (surface->h==0)) 127 /* Checking data parameters */
128 { 128 if ((surface->w == 0) || (surface->h == 0)) {
129 SDL_SetError("Photon: Cursor shape dimensions are zero"); 129 SDL_SetError("Photon: Cursor shape dimensions are zero");
130 return NULL; 130 return NULL;
131 } 131 }
132 132
133 /* Allocate memory for the internal cursor format */ 133 /* Allocate memory for the internal cursor format */
134 internal_cursor=(PhCursorDef_t*)SDL_calloc(1, sizeof(PhCursorDef_t)+ 134 internal_cursor = (PhCursorDef_t *) SDL_calloc(1, sizeof(PhCursorDef_t) +
135 ((((surface->w+7)>>3)*surface->h)*2)-1); 135 ((((surface->w +
136 if (internal_cursor==NULL) 136 7) >> 3) *
137 { 137 surface->h) * 2) - 1);
138 SDL_OutOfMemory(); 138 if (internal_cursor == NULL) {
139 return NULL; 139 SDL_OutOfMemory();
140 } 140 return NULL;
141 141 }
142 /* Allocate memory for the SDL cursor */ 142
143 sdl_cursor=(SDL_Cursor*)SDL_calloc(1, sizeof(SDL_Cursor)); 143 /* Allocate memory for the SDL cursor */
144 if (sdl_cursor==NULL) 144 sdl_cursor = (SDL_Cursor *) SDL_calloc(1, sizeof(SDL_Cursor));
145 { 145 if (sdl_cursor == NULL) {
146 SDL_free(internal_cursor); 146 SDL_free(internal_cursor);
147 SDL_OutOfMemory(); 147 SDL_OutOfMemory();
148 return NULL; 148 return NULL;
149 } 149 }
150 150
151 /* Set driverdata as photon cursor format */ 151 /* Set driverdata as photon cursor format */
152 image0=(uint8_t*)internal_cursor; 152 image0 = (uint8_t *) internal_cursor;
153 image0+=sizeof(PhCursorDef_t)-1; 153 image0 += sizeof(PhCursorDef_t) - 1;
154 image1=image0; 154 image1 = image0;
155 image1+=((surface->w+7)>>3)*surface->h; 155 image1 += ((surface->w + 7) >> 3) * surface->h;
156 sdl_cursor->driverdata=(void*)internal_cursor; 156 sdl_cursor->driverdata = (void *) internal_cursor;
157 internal_cursor->hdr.len=(sizeof(PhCursorDef_t)-sizeof(PhRegionDataHdr_t))+ 157 internal_cursor->hdr.len =
158 ((((surface->w+7)>>3)*surface->h)*2)-1; 158 (sizeof(PhCursorDef_t) - sizeof(PhRegionDataHdr_t)) +
159 internal_cursor->hdr.type=Ph_RDATA_CURSOR; 159 ((((surface->w + 7) >> 3) * surface->h) * 2) - 1;
160 internal_cursor->size1.x=surface->w; 160 internal_cursor->hdr.type = Ph_RDATA_CURSOR;
161 internal_cursor->size1.y=surface->h; 161 internal_cursor->size1.x = surface->w;
162 internal_cursor->size2.x=surface->w; 162 internal_cursor->size1.y = surface->h;
163 internal_cursor->size2.y=surface->h; 163 internal_cursor->size2.x = surface->w;
164 internal_cursor->offset1.x=hot_x; 164 internal_cursor->size2.y = surface->h;
165 internal_cursor->offset1.y=hot_y; 165 internal_cursor->offset1.x = hot_x;
166 internal_cursor->offset2.x=hot_x; 166 internal_cursor->offset1.y = hot_y;
167 internal_cursor->offset2.y=hot_y; 167 internal_cursor->offset2.x = hot_x;
168 internal_cursor->bytesperline1=((surface->w+7)>>3); 168 internal_cursor->offset2.y = hot_y;
169 internal_cursor->bytesperline2=((surface->w+7)>>3); 169 internal_cursor->bytesperline1 = ((surface->w + 7) >> 3);
170 internal_cursor->color1=(SDL_PHOTON_MOUSE_COLOR_BLACK) & 0x00FFFFFF; 170 internal_cursor->bytesperline2 = ((surface->w + 7) >> 3);
171 internal_cursor->color2=(SDL_PHOTON_MOUSE_COLOR_WHITE) & 0x00FFFFFF; 171 internal_cursor->color1 = (SDL_PHOTON_MOUSE_COLOR_BLACK) & 0x00FFFFFF;
172 172 internal_cursor->color2 = (SDL_PHOTON_MOUSE_COLOR_WHITE) & 0x00FFFFFF;
173 /* Convert cursor from 32 bpp */ 173
174 for (jt=0; jt<surface->h; jt++) 174 /* Convert cursor from 32 bpp */
175 { 175 for (jt = 0; jt < surface->h; jt++) {
176 for (it=0; it<surface->w; it++) 176 for (it = 0; it < surface->w; it++) {
177 { 177 shape_color =
178 shape_color=*((uint32_t*)((uint8_t*)surface->pixels+jt*surface->pitch+it*surface->format->BytesPerPixel)); 178 *((uint32_t *) ((uint8_t *) surface->pixels +
179 switch(shape_color) 179 jt * surface->pitch +
180 { 180 it * surface->format->BytesPerPixel));
181 switch (shape_color) {
181 case SDL_PHOTON_MOUSE_COLOR_BLACK: 182 case SDL_PHOTON_MOUSE_COLOR_BLACK:
182 { 183 {
183 *(image0+jt*(internal_cursor->bytesperline1)+(it>>3))|=0x80>>(it%8); 184 *(image0 + jt * (internal_cursor->bytesperline1) +
184 *(image1+jt*(internal_cursor->bytesperline2)+(it>>3))&=~(0x80>>(it%8)); 185 (it >> 3)) |= 0x80 >> (it % 8);
185 } 186 *(image1 + jt * (internal_cursor->bytesperline2) +
186 break; 187 (it >> 3)) &= ~(0x80 >> (it % 8));
188 }
189 break;
187 case SDL_PHOTON_MOUSE_COLOR_WHITE: 190 case SDL_PHOTON_MOUSE_COLOR_WHITE:
188 { 191 {
189 *(image0+jt*(internal_cursor->bytesperline1)+(it>>3))&=~(0x80>>(it%8)); 192 *(image0 + jt * (internal_cursor->bytesperline1) +
190 *(image1+jt*(internal_cursor->bytesperline2)+(it>>3))|=0x80>>(it%8); 193 (it >> 3)) &= ~(0x80 >> (it % 8));
191 } 194 *(image1 + jt * (internal_cursor->bytesperline2) +
192 break; 195 (it >> 3)) |= 0x80 >> (it % 8);
196 }
197 break;
193 case SDL_PHOTON_MOUSE_COLOR_TRANS: 198 case SDL_PHOTON_MOUSE_COLOR_TRANS:
194 { 199 {
195 *(image0+jt*(internal_cursor->bytesperline1)+(it>>3))&=~(0x80>>(it%8)); 200 *(image0 + jt * (internal_cursor->bytesperline1) +
196 *(image1+jt*(internal_cursor->bytesperline2)+(it>>3))&=~(0x80>>(it%8)); 201 (it >> 3)) &= ~(0x80 >> (it % 8));
197 } 202 *(image1 + jt * (internal_cursor->bytesperline2) +
198 break; 203 (it >> 3)) &= ~(0x80 >> (it % 8));
204 }
205 break;
199 default: 206 default:
200 { 207 {
201 /* The same as transparent color, must not happen */ 208 /* The same as transparent color, must not happen */
202 *(image0+jt*(internal_cursor->bytesperline1)+(it>>3))&=~(0x80>>(it%8)); 209 *(image0 + jt * (internal_cursor->bytesperline1) +
203 *(image1+jt*(internal_cursor->bytesperline2)+(it>>3))&=~(0x80>>(it%8)); 210 (it >> 3)) &= ~(0x80 >> (it % 8));
204 } 211 *(image1 + jt * (internal_cursor->bytesperline2) +
205 break; 212 (it >> 3)) &= ~(0x80 >> (it % 8));
206 } 213 }
207 } 214 break;
208 } 215 }
209 216 }
210 return sdl_cursor; 217 }
211 } 218
212 219 return sdl_cursor;
213 int photon_showcursor(SDL_Cursor* cursor) 220 }
214 { 221
215 SDL_VideoDisplay* display; 222 int
216 SDL_DisplayData* didata; 223 photon_showcursor(SDL_Cursor * cursor)
217 SDL_Window* window; 224 {
218 SDL_WindowData* wdata; 225 SDL_VideoDisplay *display;
219 SDL_WindowID window_id; 226 SDL_DisplayData *didata;
220 PhCursorDef_t* internal_cursor; 227 SDL_Window *window;
221 int32_t status; 228 SDL_WindowData *wdata;
222 229 SDL_WindowID window_id;
223 /* Get current window id */ 230 PhCursorDef_t *internal_cursor;
224 window_id=SDL_GetFocusWindow(); 231 int32_t status;
225 if (window_id<=0) 232
226 { 233 /* Get current window id */
227 SDL_MouseData* mdata=NULL; 234 window_id = SDL_GetFocusWindow();
228 235 if (window_id <= 0) {
229 /* If there is no current window, then someone calls this function */ 236 SDL_MouseData *mdata = NULL;
230 /* to set global mouse settings during SDL initialization */ 237
231 if (cursor!=NULL) 238 /* If there is no current window, then someone calls this function */
232 { 239 /* to set global mouse settings during SDL initialization */
233 /* Store cursor for future usage */ 240 if (cursor != NULL) {
234 mdata=(SDL_MouseData*)cursor->mouse->driverdata; 241 /* Store cursor for future usage */
235 didata=(SDL_DisplayData*)mdata->didata; 242 mdata = (SDL_MouseData *) cursor->mouse->driverdata;
236 internal_cursor=(PhCursorDef_t*)cursor->driverdata; 243 didata = (SDL_DisplayData *) mdata->didata;
237 244 internal_cursor = (PhCursorDef_t *) cursor->driverdata;
238 if (didata->cursor_size>=(internal_cursor->hdr.len+sizeof(PhRegionDataHdr_t))) 245
239 { 246 if (didata->cursor_size >=
240 SDL_memcpy(didata->cursor, internal_cursor, internal_cursor->hdr.len+sizeof(PhRegionDataHdr_t)); 247 (internal_cursor->hdr.len + sizeof(PhRegionDataHdr_t))) {
241 } 248 SDL_memcpy(didata->cursor, internal_cursor,
242 else 249 internal_cursor->hdr.len +
243 { 250 sizeof(PhRegionDataHdr_t));
251 } else {
252 /* Partitial cursor image */
253 SDL_memcpy(didata->cursor, internal_cursor,
254 didata->cursor_size);
255 }
256
257 didata->cursor_visible = SDL_TRUE;
258 return 0;
259 } else {
260 /* We can't get SDL_DisplayData at this point, return fake success */
261 return 0;
262 }
263 } else {
264 /* Sanity checks */
265 window = SDL_GetWindowFromID(window_id);
266 if (window != NULL) {
267 display = SDL_GetDisplayFromWindow(window);
268 if (display != NULL) {
269 didata = (SDL_DisplayData *) display->driverdata;
270 if (didata != NULL) {
271 wdata = (SDL_WindowData *) window->driverdata;
272 if (wdata == NULL) {
273 return -1;
274 }
275 } else {
276 return -1;
277 }
278 } else {
279 return -1;
280 }
281 } else {
282 return -1;
283 }
284 }
285
286 /* return if window widget has been destroyed already */
287 if (wdata->window == NULL) {
288 return;
289 }
290
291 /* Check if we need to set new shape or disable cursor shape */
292 if (cursor != NULL) {
293 /* Retrieve photon cursor shape */
294 internal_cursor = (PhCursorDef_t *) cursor->driverdata;
295 if (internal_cursor == NULL) {
296 SDL_SetError("Photon: Internal cursor data is absent");
297 return -1;
298 }
299
300 /* Setup cursor type */
301 status =
302 PtSetResource(wdata->window, Pt_ARG_CURSOR_TYPE, Ph_CURSOR_BITMAP,
303 0);
304 if (status != 0) {
305 SDL_SetError("Photon: Failed to set cursor type to bitmap");
306 return -1;
307 }
308
309 /* Setup cursor color to default */
310 status =
311 PtSetResource(wdata->window, Pt_ARG_CURSOR_COLOR,
312 Ph_CURSOR_DEFAULT_COLOR, 0);
313 if (status != 0) {
314 SDL_SetError("Photon: Failed to set cursor color");
315 return -1;
316 }
317
318 /* Setup cursor shape */
319 status =
320 PtSetResource(wdata->window, Pt_ARG_BITMAP_CURSOR,
321 internal_cursor,
322 internal_cursor->hdr.len +
323 sizeof(PhRegionDataHdr_t));
324 if (status != 0) {
325 SDL_SetError("Photon: Failed to set cursor color");
326 return -1;
327 }
328
329 /* Store current cursor for future usage */
330 if (didata->cursor_size >=
331 (internal_cursor->hdr.len + sizeof(PhRegionDataHdr_t))) {
332 SDL_memcpy(didata->cursor, internal_cursor,
333 internal_cursor->hdr.len + sizeof(PhRegionDataHdr_t));
334 } else {
244 /* Partitial cursor image */ 335 /* Partitial cursor image */
245 SDL_memcpy(didata->cursor, internal_cursor, didata->cursor_size); 336 SDL_memcpy(didata->cursor, internal_cursor, didata->cursor_size);
246 } 337 }
247 338
248 didata->cursor_visible=SDL_TRUE; 339 /* Set cursor visible */
249 return 0; 340 didata->cursor_visible = SDL_TRUE;
250 } 341 } else {
251 else 342 /* SDL requests to disable cursor */
252 { 343 status =
253 /* We can't get SDL_DisplayData at this point, return fake success */ 344 PtSetResource(wdata->window, Pt_ARG_CURSOR_TYPE, Ph_CURSOR_NONE,
254 return 0; 345 0);
255 } 346 if (status != 0) {
256 } 347 SDL_SetError("Photon: Can't disable cursor");
257 else 348 return -1;
258 { 349 }
259 /* Sanity checks */ 350
260 window=SDL_GetWindowFromID(window_id); 351 /* Set cursor invisible */
261 if (window!=NULL) 352 didata->cursor_visible = SDL_FALSE;
262 { 353 }
263 display=SDL_GetDisplayFromWindow(window); 354
264 if (display!=NULL) 355 /* Flush all pending widget data */
265 { 356 PtFlush();
266 didata=(SDL_DisplayData*)display->driverdata; 357
267 if (didata!=NULL) 358 /* New cursor shape is set */
268 { 359 return 0;
269 wdata=(SDL_WindowData*)window->driverdata; 360 }
270 if (wdata==NULL) 361
271 { 362 void
272 return -1; 363 photon_movecursor(SDL_Cursor * cursor)
273 } 364 {
365 SDL_VideoDisplay *display;
366 SDL_DisplayData *didata;
367 SDL_Window *window;
368 SDL_WindowData *wdata;
369 SDL_WindowID window_id;
370 int32_t status;
371
372 /* Get current window id */
373 window_id = SDL_GetFocusWindow();
374 if (window_id <= 0) {
375 didata = (SDL_DisplayData *) cursor->mouse->driverdata;
376 } else {
377 /* Sanity checks */
378 window = SDL_GetWindowFromID(window_id);
379 if (window != NULL) {
380 display = SDL_GetDisplayFromWindow(window);
381 if (display != NULL) {
382 didata = (SDL_DisplayData *) display->driverdata;
383 if (didata != NULL) {
384 wdata = (SDL_WindowData *) window->driverdata;
385 if (wdata == NULL) {
386 return;
387 }
388 } else {
389 return;
390 }
391 } else {
392 return;
274 } 393 }
275 else 394 } else {
276 { 395 return;
277 return -1; 396 }
397 }
398
399 /* No need to move mouse cursor manually in the photon */
400
401 return;
402 }
403
404 void
405 photon_freecursor(SDL_Cursor * cursor)
406 {
407 PhCursorDef_t *internal_cursor = NULL;
408
409 if (cursor != NULL) {
410 internal_cursor = (PhCursorDef_t *) cursor->driverdata;
411 if (internal_cursor != NULL) {
412 SDL_free(internal_cursor);
413 cursor->driverdata = NULL;
414 }
415 }
416 }
417
418 void
419 photon_warpmouse(SDL_Mouse * mouse, SDL_WindowID windowID, int x, int y)
420 {
421 SDL_VideoDisplay *display;
422 SDL_DisplayData *didata;
423 SDL_Window *window;
424 SDL_WindowData *wdata;
425 int16_t wx;
426 int16_t wy;
427
428 /* Sanity checks */
429 window = SDL_GetWindowFromID(windowID);
430 if (window != NULL) {
431 display = SDL_GetDisplayFromWindow(window);
432 if (display != NULL) {
433 didata = (SDL_DisplayData *) display->driverdata;
434 if (didata != NULL) {
435 wdata = (SDL_WindowData *) window->driverdata;
436 if (wdata == NULL) {
437 return;
438 }
439 } else {
440 return;
278 } 441 }
279 } 442 } else {
280 else
281 {
282 return -1;
283 }
284 }
285 else
286 {
287 return -1;
288 }
289 }
290
291 /* return if window widget has been destroyed already */
292 if (wdata->window==NULL)
293 {
294 return;
295 }
296
297 /* Check if we need to set new shape or disable cursor shape */
298 if (cursor!=NULL)
299 {
300 /* Retrieve photon cursor shape */
301 internal_cursor=(PhCursorDef_t*)cursor->driverdata;
302 if (internal_cursor==NULL)
303 {
304 SDL_SetError("Photon: Internal cursor data is absent");
305 return -1;
306 }
307
308 /* Setup cursor type */
309 status=PtSetResource(wdata->window, Pt_ARG_CURSOR_TYPE, Ph_CURSOR_BITMAP, 0);
310 if (status!=0)
311 {
312 SDL_SetError("Photon: Failed to set cursor type to bitmap");
313 return -1;
314 }
315
316 /* Setup cursor color to default */
317 status=PtSetResource(wdata->window, Pt_ARG_CURSOR_COLOR, Ph_CURSOR_DEFAULT_COLOR, 0);
318 if (status!=0)
319 {
320 SDL_SetError("Photon: Failed to set cursor color");
321 return -1;
322 }
323
324 /* Setup cursor shape */
325 status=PtSetResource(wdata->window, Pt_ARG_BITMAP_CURSOR, internal_cursor,
326 internal_cursor->hdr.len+sizeof(PhRegionDataHdr_t));
327 if (status!=0)
328 {
329 SDL_SetError("Photon: Failed to set cursor color");
330 return -1;
331 }
332
333 /* Store current cursor for future usage */
334 if (didata->cursor_size>=(internal_cursor->hdr.len+sizeof(PhRegionDataHdr_t)))
335 {
336 SDL_memcpy(didata->cursor, internal_cursor, internal_cursor->hdr.len+sizeof(PhRegionDataHdr_t));
337 }
338 else
339 {
340 /* Partitial cursor image */
341 SDL_memcpy(didata->cursor, internal_cursor, didata->cursor_size);
342 }
343
344 /* Set cursor visible */
345 didata->cursor_visible=SDL_TRUE;
346 }
347 else
348 {
349 /* SDL requests to disable cursor */
350 status=PtSetResource(wdata->window, Pt_ARG_CURSOR_TYPE, Ph_CURSOR_NONE, 0);
351 if (status!=0)
352 {
353 SDL_SetError("Photon: Can't disable cursor");
354 return -1;
355 }
356
357 /* Set cursor invisible */
358 didata->cursor_visible=SDL_FALSE;
359 }
360
361 /* Flush all pending widget data */
362 PtFlush();
363
364 /* New cursor shape is set */
365 return 0;
366 }
367
368 void photon_movecursor(SDL_Cursor* cursor)
369 {
370 SDL_VideoDisplay* display;
371 SDL_DisplayData* didata;
372 SDL_Window* window;
373 SDL_WindowData* wdata;
374 SDL_WindowID window_id;
375 int32_t status;
376
377 /* Get current window id */
378 window_id=SDL_GetFocusWindow();
379 if (window_id<=0)
380 {
381 didata=(SDL_DisplayData*)cursor->mouse->driverdata;
382 }
383 else
384 {
385 /* Sanity checks */
386 window=SDL_GetWindowFromID(window_id);
387 if (window!=NULL)
388 {
389 display=SDL_GetDisplayFromWindow(window);
390 if (display!=NULL)
391 {
392 didata=(SDL_DisplayData*)display->driverdata;
393 if (didata!=NULL)
394 {
395 wdata=(SDL_WindowData*)window->driverdata;
396 if (wdata==NULL)
397 {
398 return;
399 }
400 }
401 else
402 {
403 return;
404 }
405 }
406 else
407 {
408 return; 443 return;
409 } 444 }
410 } 445 } else {
411 else 446 return;
412 { 447 }
413 return; 448
414 } 449 PtGetAbsPosition(wdata->window, &wx, &wy);
415 } 450 PhMoveCursorAbs(PhInputGroup(NULL), wx + x, wy + y);
416 451
417 /* No need to move mouse cursor manually in the photon */ 452 return;
418 453 }
419 return; 454
420 } 455 void
421 456 photon_freemouse(SDL_Mouse * mouse)
422 void photon_freecursor(SDL_Cursor* cursor) 457 {
423 { 458 if (mouse->driverdata == NULL) {
424 PhCursorDef_t* internal_cursor=NULL; 459 return;
425 460 }
426 if (cursor!=NULL) 461
427 { 462 /* Mouse framework doesn't deletes automatically our driverdata */
428 internal_cursor=(PhCursorDef_t*)cursor->driverdata; 463 SDL_free(mouse->driverdata);
429 if (internal_cursor!=NULL) 464 mouse->driverdata = NULL;
430 { 465
431 SDL_free(internal_cursor); 466 return;
432 cursor->driverdata=NULL; 467 }
433 } 468
434 } 469 SDL_scancode
435 } 470 photon_to_sdl_keymap(uint32_t key)
436 471 {
437 void photon_warpmouse(SDL_Mouse* mouse, SDL_WindowID windowID, int x, int y) 472 SDL_scancode scancode = SDL_SCANCODE_UNKNOWN;
438 { 473
439 SDL_VideoDisplay* display; 474 switch (key & 0x0000007F) {
440 SDL_DisplayData* didata; 475 case PHOTON_SCANCODE_ESCAPE:
441 SDL_Window* window; 476 scancode = SDL_SCANCODE_ESCAPE;
442 SDL_WindowData* wdata; 477 break;
443 int16_t wx; 478 case PHOTON_SCANCODE_F1:
444 int16_t wy; 479 scancode = SDL_SCANCODE_F1;
445 480 break;
446 /* Sanity checks */ 481 case PHOTON_SCANCODE_F2:
447 window=SDL_GetWindowFromID(windowID); 482 scancode = SDL_SCANCODE_F2;
448 if (window!=NULL) 483 break;
449 { 484 case PHOTON_SCANCODE_F3:
450 display=SDL_GetDisplayFromWindow(window); 485 scancode = SDL_SCANCODE_F3;
451 if (display!=NULL) 486 break;
452 { 487 case PHOTON_SCANCODE_F4:
453 didata=(SDL_DisplayData*)display->driverdata; 488 scancode = SDL_SCANCODE_F4;
454 if (didata!=NULL) 489 break;
455 { 490 case PHOTON_SCANCODE_F5:
456 wdata=(SDL_WindowData*)window->driverdata; 491 scancode = SDL_SCANCODE_F5;
457 if (wdata==NULL) 492 break;
458 { 493 case PHOTON_SCANCODE_F6:
459 return; 494 scancode = SDL_SCANCODE_F6;
460 } 495 break;
461 } 496 case PHOTON_SCANCODE_F7:
462 else 497 scancode = SDL_SCANCODE_F7;
463 { 498 break;
464 return; 499 case PHOTON_SCANCODE_F8:
465 } 500 scancode = SDL_SCANCODE_F8;
466 } 501 break;
467 else 502 case PHOTON_SCANCODE_F9:
468 { 503 scancode = SDL_SCANCODE_F9;
469 return; 504 break;
470 } 505 case PHOTON_SCANCODE_F10:
471 } 506 scancode = SDL_SCANCODE_F10;
472 else 507 break;
473 { 508 case PHOTON_SCANCODE_F11:
474 return; 509 scancode = SDL_SCANCODE_F11;
475 } 510 break;
476 511 case PHOTON_SCANCODE_F12:
477 PtGetAbsPosition(wdata->window, &wx, &wy); 512 scancode = SDL_SCANCODE_F12;
478 PhMoveCursorAbs(PhInputGroup(NULL), wx+x, wy+y); 513 break;
479 514 case PHOTON_SCANCODE_BACKQOUTE:
480 return; 515 scancode = SDL_SCANCODE_GRAVE;
481 } 516 break;
482 517 case PHOTON_SCANCODE_1:
483 void photon_freemouse(SDL_Mouse* mouse) 518 scancode = SDL_SCANCODE_1;
484 { 519 break;
485 if (mouse->driverdata==NULL) 520 case PHOTON_SCANCODE_2:
486 { 521 scancode = SDL_SCANCODE_2;
487 return; 522 break;
488 } 523 case PHOTON_SCANCODE_3:
489 524 scancode = SDL_SCANCODE_3;
490 /* Mouse framework doesn't deletes automatically our driverdata */ 525 break;
491 SDL_free(mouse->driverdata); 526 case PHOTON_SCANCODE_4:
492 mouse->driverdata=NULL; 527 scancode = SDL_SCANCODE_4;
493 528 break;
494 return; 529 case PHOTON_SCANCODE_5:
495 } 530 scancode = SDL_SCANCODE_5;
496 531 break;
497 SDL_scancode photon_to_sdl_keymap(uint32_t key) 532 case PHOTON_SCANCODE_6:
498 { 533 scancode = SDL_SCANCODE_6;
499 SDL_scancode scancode=SDL_SCANCODE_UNKNOWN; 534 break;
500 535 case PHOTON_SCANCODE_7:
501 switch(key & 0x0000007F) 536 scancode = SDL_SCANCODE_7;
502 { 537 break;
503 case PHOTON_SCANCODE_ESCAPE: 538 case PHOTON_SCANCODE_8:
504 scancode=SDL_SCANCODE_ESCAPE; 539 scancode = SDL_SCANCODE_8;
505 break; 540 break;
506 case PHOTON_SCANCODE_F1: 541 case PHOTON_SCANCODE_9:
507 scancode=SDL_SCANCODE_F1; 542 scancode = SDL_SCANCODE_9;
508 break; 543 break;
509 case PHOTON_SCANCODE_F2: 544 case PHOTON_SCANCODE_0:
510 scancode=SDL_SCANCODE_F2; 545 scancode = SDL_SCANCODE_0;
511 break; 546 break;
512 case PHOTON_SCANCODE_F3: 547 case PHOTON_SCANCODE_MINUS:
513 scancode=SDL_SCANCODE_F3; 548 scancode = SDL_SCANCODE_MINUS;
514 break; 549 break;
515 case PHOTON_SCANCODE_F4: 550 case PHOTON_SCANCODE_EQUAL:
516 scancode=SDL_SCANCODE_F4; 551 scancode = SDL_SCANCODE_EQUALS;
517 break; 552 break;
518 case PHOTON_SCANCODE_F5: 553 case PHOTON_SCANCODE_BACKSPACE:
519 scancode=SDL_SCANCODE_F5; 554 scancode = SDL_SCANCODE_BACKSPACE;
520 break; 555 break;
521 case PHOTON_SCANCODE_F6: 556 case PHOTON_SCANCODE_TAB:
522 scancode=SDL_SCANCODE_F6; 557 scancode = SDL_SCANCODE_TAB;
523 break; 558 break;
524 case PHOTON_SCANCODE_F7: 559 case PHOTON_SCANCODE_Q:
525 scancode=SDL_SCANCODE_F7; 560 scancode = SDL_SCANCODE_Q;
526 break; 561 break;
527 case PHOTON_SCANCODE_F8: 562 case PHOTON_SCANCODE_W:
528 scancode=SDL_SCANCODE_F8; 563 scancode = SDL_SCANCODE_W;
529 break; 564 break;
530 case PHOTON_SCANCODE_F9: 565 case PHOTON_SCANCODE_E:
531 scancode=SDL_SCANCODE_F9; 566 scancode = SDL_SCANCODE_E;
532 break; 567 break;
533 case PHOTON_SCANCODE_F10: 568 case PHOTON_SCANCODE_R:
534 scancode=SDL_SCANCODE_F10; 569 scancode = SDL_SCANCODE_R;
535 break; 570 break;
536 case PHOTON_SCANCODE_F11: 571 case PHOTON_SCANCODE_T:
537 scancode=SDL_SCANCODE_F11; 572 scancode = SDL_SCANCODE_T;
538 break; 573 break;
539 case PHOTON_SCANCODE_F12: 574 case PHOTON_SCANCODE_Y:
540 scancode=SDL_SCANCODE_F12; 575 scancode = SDL_SCANCODE_Y;
541 break; 576 break;
542 case PHOTON_SCANCODE_BACKQOUTE: 577 case PHOTON_SCANCODE_U:
543 scancode=SDL_SCANCODE_GRAVE; 578 scancode = SDL_SCANCODE_U;
544 break; 579 break;
545 case PHOTON_SCANCODE_1: 580 case PHOTON_SCANCODE_I:
546 scancode=SDL_SCANCODE_1; 581 scancode = SDL_SCANCODE_I;
547 break; 582 break;
548 case PHOTON_SCANCODE_2: 583 case PHOTON_SCANCODE_O:
549 scancode=SDL_SCANCODE_2; 584 scancode = SDL_SCANCODE_O;
550 break; 585 break;
551 case PHOTON_SCANCODE_3: 586 case PHOTON_SCANCODE_P:
552 scancode=SDL_SCANCODE_3; 587 scancode = SDL_SCANCODE_P;
553 break; 588 break;
554 case PHOTON_SCANCODE_4: 589 case PHOTON_SCANCODE_LEFT_SQ_BR:
555 scancode=SDL_SCANCODE_4; 590 scancode = SDL_SCANCODE_LEFTBRACKET;
556 break; 591 break;
557 case PHOTON_SCANCODE_5: 592 case PHOTON_SCANCODE_RIGHT_SQ_BR:
558 scancode=SDL_SCANCODE_5; 593 scancode = SDL_SCANCODE_RIGHTBRACKET;
559 break; 594 break;
560 case PHOTON_SCANCODE_6: 595 case PHOTON_SCANCODE_ENTER:
561 scancode=SDL_SCANCODE_6; 596 scancode = SDL_SCANCODE_RETURN;
562 break; 597 break;
563 case PHOTON_SCANCODE_7: 598 case PHOTON_SCANCODE_CAPSLOCK:
564 scancode=SDL_SCANCODE_7; 599 scancode = SDL_SCANCODE_CAPSLOCK;
565 break; 600 break;
566 case PHOTON_SCANCODE_8: 601 case PHOTON_SCANCODE_A:
567 scancode=SDL_SCANCODE_8; 602 scancode = SDL_SCANCODE_A;
568 break; 603 break;
569 case PHOTON_SCANCODE_9: 604 case PHOTON_SCANCODE_S:
570 scancode=SDL_SCANCODE_9; 605 scancode = SDL_SCANCODE_S;
571 break; 606 break;
572 case PHOTON_SCANCODE_0: 607 case PHOTON_SCANCODE_D:
573 scancode=SDL_SCANCODE_0; 608 scancode = SDL_SCANCODE_D;
574 break; 609 break;
575 case PHOTON_SCANCODE_MINUS: 610 case PHOTON_SCANCODE_F:
576 scancode=SDL_SCANCODE_MINUS; 611 scancode = SDL_SCANCODE_F;
577 break; 612 break;
578 case PHOTON_SCANCODE_EQUAL: 613 case PHOTON_SCANCODE_G:
579 scancode=SDL_SCANCODE_EQUALS; 614 scancode = SDL_SCANCODE_G;
580 break; 615 break;
581 case PHOTON_SCANCODE_BACKSPACE: 616 case PHOTON_SCANCODE_H:
582 scancode=SDL_SCANCODE_BACKSPACE; 617 scancode = SDL_SCANCODE_H;
583 break; 618 break;
584 case PHOTON_SCANCODE_TAB: 619 case PHOTON_SCANCODE_J:
585 scancode=SDL_SCANCODE_TAB; 620 scancode = SDL_SCANCODE_J;
586 break; 621 break;
587 case PHOTON_SCANCODE_Q: 622 case PHOTON_SCANCODE_K:
588 scancode=SDL_SCANCODE_Q; 623 scancode = SDL_SCANCODE_K;
589 break; 624 break;
590 case PHOTON_SCANCODE_W: 625 case PHOTON_SCANCODE_L:
591 scancode=SDL_SCANCODE_W; 626 scancode = SDL_SCANCODE_L;
592 break; 627 break;
593 case PHOTON_SCANCODE_E: 628 case PHOTON_SCANCODE_SEMICOLON:
594 scancode=SDL_SCANCODE_E; 629 scancode = SDL_SCANCODE_SEMICOLON;
595 break; 630 break;
596 case PHOTON_SCANCODE_R: 631 case PHOTON_SCANCODE_QUOTE:
597 scancode=SDL_SCANCODE_R; 632 scancode = SDL_SCANCODE_APOSTROPHE;
598 break; 633 break;
599 case PHOTON_SCANCODE_T: 634 case PHOTON_SCANCODE_BACKSLASH:
600 scancode=SDL_SCANCODE_T; 635 scancode = SDL_SCANCODE_BACKSLASH;
601 break; 636 break;
602 case PHOTON_SCANCODE_Y: 637 case PHOTON_SCANCODE_LEFT_SHIFT:
603 scancode=SDL_SCANCODE_Y; 638 scancode = SDL_SCANCODE_LSHIFT;
604 break; 639 break;
605 case PHOTON_SCANCODE_U: 640 case PHOTON_SCANCODE_Z:
606 scancode=SDL_SCANCODE_U; 641 scancode = SDL_SCANCODE_Z;
607 break; 642 break;
608 case PHOTON_SCANCODE_I: 643 case PHOTON_SCANCODE_X:
609 scancode=SDL_SCANCODE_I; 644 scancode = SDL_SCANCODE_X;
610 break; 645 break;
611 case PHOTON_SCANCODE_O: 646 case PHOTON_SCANCODE_C:
612 scancode=SDL_SCANCODE_O; 647 scancode = SDL_SCANCODE_C;
613 break; 648 break;
614 case PHOTON_SCANCODE_P: 649 case PHOTON_SCANCODE_V:
615 scancode=SDL_SCANCODE_P; 650 scancode = SDL_SCANCODE_V;
616 break; 651 break;
617 case PHOTON_SCANCODE_LEFT_SQ_BR: 652 case PHOTON_SCANCODE_B:
618 scancode=SDL_SCANCODE_LEFTBRACKET; 653 scancode = SDL_SCANCODE_B;
619 break; 654 break;
620 case PHOTON_SCANCODE_RIGHT_SQ_BR: 655 case PHOTON_SCANCODE_N:
621 scancode=SDL_SCANCODE_RIGHTBRACKET; 656 scancode = SDL_SCANCODE_N;
622 break; 657 break;
623 case PHOTON_SCANCODE_ENTER: 658 case PHOTON_SCANCODE_M:
624 scancode=SDL_SCANCODE_RETURN; 659 scancode = SDL_SCANCODE_M;
625 break; 660 break;
626 case PHOTON_SCANCODE_CAPSLOCK: 661 case PHOTON_SCANCODE_COMMA:
627 scancode=SDL_SCANCODE_CAPSLOCK; 662 scancode = SDL_SCANCODE_COMMA;
628 break; 663 break;
629 case PHOTON_SCANCODE_A: 664 case PHOTON_SCANCODE_POINT:
630 scancode=SDL_SCANCODE_A; 665 scancode = SDL_SCANCODE_PERIOD;
631 break; 666 break;
632 case PHOTON_SCANCODE_S: 667 case PHOTON_SCANCODE_SLASH:
633 scancode=SDL_SCANCODE_S; 668 scancode = SDL_SCANCODE_SLASH;
634 break; 669 break;
635 case PHOTON_SCANCODE_D: 670 case PHOTON_SCANCODE_RIGHT_SHIFT:
636 scancode=SDL_SCANCODE_D; 671 scancode = SDL_SCANCODE_RSHIFT;
637 break; 672 break;
638 case PHOTON_SCANCODE_F: 673 case PHOTON_SCANCODE_CTRL:
639 scancode=SDL_SCANCODE_F; 674 scancode = SDL_SCANCODE_LCTRL;
640 break; 675 break;
641 case PHOTON_SCANCODE_G: 676 case PHOTON_SCANCODE_WFLAG:
642 scancode=SDL_SCANCODE_G; 677 scancode = SDL_SCANCODE_LGUI;
643 break; 678 break;
644 case PHOTON_SCANCODE_H: 679 case PHOTON_SCANCODE_ALT:
645 scancode=SDL_SCANCODE_H; 680 scancode = SDL_SCANCODE_LALT;
646 break; 681 break;
647 case PHOTON_SCANCODE_J: 682 case PHOTON_SCANCODE_SPACE:
648 scancode=SDL_SCANCODE_J; 683 scancode = SDL_SCANCODE_SPACE;
649 break; 684 break;
650 case PHOTON_SCANCODE_K: 685 case PHOTON_SCANCODE_MENU:
651 scancode=SDL_SCANCODE_K; 686 scancode = SDL_SCANCODE_MENU;
652 break; 687 break;
653 case PHOTON_SCANCODE_L: 688 case PHOTON_SCANCODE_PRNSCR:
654 scancode=SDL_SCANCODE_L; 689 scancode = SDL_SCANCODE_PRINTSCREEN;
655 break; 690 break;
656 case PHOTON_SCANCODE_SEMICOLON: 691 case PHOTON_SCANCODE_SCROLLLOCK:
657 scancode=SDL_SCANCODE_SEMICOLON; 692 scancode = SDL_SCANCODE_SCROLLLOCK;
658 break; 693 break;
659 case PHOTON_SCANCODE_QUOTE: 694 case PHOTON_SCANCODE_INSERT:
660 scancode=SDL_SCANCODE_APOSTROPHE; 695 scancode = SDL_SCANCODE_INSERT;
661 break; 696 break;
662 case PHOTON_SCANCODE_BACKSLASH: 697 case PHOTON_SCANCODE_HOME:
663 scancode=SDL_SCANCODE_BACKSLASH; 698 scancode = SDL_SCANCODE_HOME;
664 break; 699 break;
665 case PHOTON_SCANCODE_LEFT_SHIFT: 700 case PHOTON_SCANCODE_PAGEUP:
666 scancode=SDL_SCANCODE_LSHIFT; 701 scancode = SDL_SCANCODE_PAGEUP;
667 break; 702 break;
668 case PHOTON_SCANCODE_Z: 703 case PHOTON_SCANCODE_DELETE:
669 scancode=SDL_SCANCODE_Z; 704 scancode = SDL_SCANCODE_DELETE;
670 break; 705 break;
671 case PHOTON_SCANCODE_X: 706 case PHOTON_SCANCODE_END:
672 scancode=SDL_SCANCODE_X; 707 scancode = SDL_SCANCODE_END;
673 break; 708 break;
674 case PHOTON_SCANCODE_C: 709 case PHOTON_SCANCODE_PAGEDOWN:
675 scancode=SDL_SCANCODE_C; 710 scancode = SDL_SCANCODE_PAGEDOWN;
676 break; 711 break;
677 case PHOTON_SCANCODE_V: 712 case PHOTON_SCANCODE_UP:
678 scancode=SDL_SCANCODE_V; 713 scancode = SDL_SCANCODE_UP;
679 break; 714 break;
680 case PHOTON_SCANCODE_B: 715 case PHOTON_SCANCODE_DOWN:
681 scancode=SDL_SCANCODE_B; 716 scancode = SDL_SCANCODE_DOWN;
682 break; 717 break;
683 case PHOTON_SCANCODE_N: 718 case PHOTON_SCANCODE_LEFT:
684 scancode=SDL_SCANCODE_N; 719 scancode = SDL_SCANCODE_LEFT;
685 break; 720 break;
686 case PHOTON_SCANCODE_M: 721 case PHOTON_SCANCODE_RIGHT:
687 scancode=SDL_SCANCODE_M; 722 scancode = SDL_SCANCODE_RIGHT;
688 break; 723 break;
689 case PHOTON_SCANCODE_COMMA: 724 case PHOTON_SCANCODE_NUMLOCK:
690 scancode=SDL_SCANCODE_COMMA; 725 scancode = SDL_SCANCODE_NUMLOCKCLEAR;
691 break; 726 break;
692 case PHOTON_SCANCODE_POINT: 727 default:
693 scancode=SDL_SCANCODE_PERIOD; 728 break;
694 break; 729 }
695 case PHOTON_SCANCODE_SLASH: 730
696 scancode=SDL_SCANCODE_SLASH; 731 return scancode;
697 break; 732 }
698 case PHOTON_SCANCODE_RIGHT_SHIFT:
699 scancode=SDL_SCANCODE_RSHIFT;
700 break;
701 case PHOTON_SCANCODE_CTRL:
702 scancode=SDL_SCANCODE_LCTRL;
703 break;
704 case PHOTON_SCANCODE_WFLAG:
705 scancode=SDL_SCANCODE_LGUI;
706 break;
707 case PHOTON_SCANCODE_ALT:
708 scancode=SDL_SCANCODE_LALT;
709 break;
710 case PHOTON_SCANCODE_SPACE:
711 scancode=SDL_SCANCODE_SPACE;
712 break;
713 case PHOTON_SCANCODE_MENU:
714 scancode=SDL_SCANCODE_MENU;
715 break;
716 case PHOTON_SCANCODE_PRNSCR:
717 scancode=SDL_SCANCODE_PRINTSCREEN;
718 break;
719 case PHOTON_SCANCODE_SCROLLLOCK:
720 scancode=SDL_SCANCODE_SCROLLLOCK;
721 break;
722 case PHOTON_SCANCODE_INSERT:
723 scancode=SDL_SCANCODE_INSERT;
724 break;
725 case PHOTON_SCANCODE_HOME:
726 scancode=SDL_SCANCODE_HOME;
727 break;
728 case PHOTON_SCANCODE_PAGEUP:
729 scancode=SDL_SCANCODE_PAGEUP;
730 break;
731 case PHOTON_SCANCODE_DELETE:
732 scancode=SDL_SCANCODE_DELETE;
733 break;
734 case PHOTON_SCANCODE_END:
735 scancode=SDL_SCANCODE_END;
736 break;
737 case PHOTON_SCANCODE_PAGEDOWN:
738 scancode=SDL_SCANCODE_PAGEDOWN;
739 break;
740 case PHOTON_SCANCODE_UP:
741 scancode=SDL_SCANCODE_UP;
742 break;
743 case PHOTON_SCANCODE_DOWN:
744 scancode=SDL_SCANCODE_DOWN;
745 break;
746 case PHOTON_SCANCODE_LEFT:
747 scancode=SDL_SCANCODE_LEFT;
748 break;
749 case PHOTON_SCANCODE_RIGHT:
750 scancode=SDL_SCANCODE_RIGHT;
751 break;
752 case PHOTON_SCANCODE_NUMLOCK:
753 scancode=SDL_SCANCODE_NUMLOCKCLEAR;
754 break;
755 default:
756 break;
757 }
758
759 return scancode;
760 }