annotate src/video/photon/SDL_photon_input.c @ 3669:46d27a9571fa

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