annotate src/video/photon/SDL_photon_input.c @ 3374:725b16784e96

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