annotate src/video/photon/SDL_photon_input.c @ 4839:05d172e92b52

Merging branches. Will begin correcting mistakes introduced by merging.
author Eli Gottlieb <eligottlieb@gmail.com>
date Mon, 09 Aug 2010 15:41:33 -0400
parents f7b03b6838cb
children 25d4feb7c127
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
3697
f7b03b6838cb Fixed bug #926
Sam Lantinga <slouken@libsdl.org>
parents: 3685
diff changeset
3 Copyright (C) 1997-2010 Sam Lantinga
3108
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);
3685
64ce267332c6 Switched from SDL_WindowID and SDL_TextureID to SDL_Window* and SDL_Texture* for code simplicity and improved performance.
Sam Lantinga <slouken@libsdl.org>
parents: 3500
diff changeset
41 void photon_warpmouse(SDL_Mouse * mouse, SDL_Window * window, int x, int y);
3139
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 PhCursorDef_t *internal_cursor;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
232 int32_t status;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
233
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
234 /* Get current window id */
3685
64ce267332c6 Switched from SDL_WindowID and SDL_TextureID to SDL_Window* and SDL_Texture* for code simplicity and improved performance.
Sam Lantinga <slouken@libsdl.org>
parents: 3500
diff changeset
235 window = SDL_GetFocusWindow();
64ce267332c6 Switched from SDL_WindowID and SDL_TextureID to SDL_Window* and SDL_Texture* for code simplicity and improved performance.
Sam Lantinga <slouken@libsdl.org>
parents: 3500
diff changeset
236 if (!window) {
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
237 SDL_MouseData *mdata = NULL;
3108
aa1897bee1e9 Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
238
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
239 /* If there is no current window, then someone calls this function */
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
240 /* to set global mouse settings during SDL initialization */
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
241 if (cursor != NULL) {
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
242 /* Store cursor for future usage */
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
243 mdata = (SDL_MouseData *) cursor->mouse->driverdata;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
244 didata = (SDL_DisplayData *) mdata->didata;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
245 internal_cursor = (PhCursorDef_t *) cursor->driverdata;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
246
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
247 if (didata->cursor_size >=
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
248 (internal_cursor->hdr.len + sizeof(PhRegionDataHdr_t))) {
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
249 SDL_memcpy(didata->cursor, internal_cursor,
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
250 internal_cursor->hdr.len +
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
251 sizeof(PhRegionDataHdr_t));
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
252 } else {
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
253 /* Partitial cursor image */
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
254 SDL_memcpy(didata->cursor, internal_cursor,
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
255 didata->cursor_size);
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
256 }
3108
aa1897bee1e9 Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
257
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
258 didata->cursor_visible = SDL_TRUE;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
259 return 0;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
260 } else {
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
261 /* We can't get SDL_DisplayData at this point, return fake success */
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
262 return 0;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
263 }
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
264 } else {
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
265 /* Sanity checks */
3685
64ce267332c6 Switched from SDL_WindowID and SDL_TextureID to SDL_Window* and SDL_Texture* for code simplicity and improved performance.
Sam Lantinga <slouken@libsdl.org>
parents: 3500
diff changeset
266 display = window->display;
64ce267332c6 Switched from SDL_WindowID and SDL_TextureID to SDL_Window* and SDL_Texture* for code simplicity and improved performance.
Sam Lantinga <slouken@libsdl.org>
parents: 3500
diff changeset
267 if (display != NULL) {
64ce267332c6 Switched from SDL_WindowID and SDL_TextureID to SDL_Window* and SDL_Texture* for code simplicity and improved performance.
Sam Lantinga <slouken@libsdl.org>
parents: 3500
diff changeset
268 didata = (SDL_DisplayData *) display->driverdata;
64ce267332c6 Switched from SDL_WindowID and SDL_TextureID to SDL_Window* and SDL_Texture* for code simplicity and improved performance.
Sam Lantinga <slouken@libsdl.org>
parents: 3500
diff changeset
269 if (didata != NULL) {
64ce267332c6 Switched from SDL_WindowID and SDL_TextureID to SDL_Window* and SDL_Texture* for code simplicity and improved performance.
Sam Lantinga <slouken@libsdl.org>
parents: 3500
diff changeset
270 wdata = (SDL_WindowData *) window->driverdata;
64ce267332c6 Switched from SDL_WindowID and SDL_TextureID to SDL_Window* and SDL_Texture* for code simplicity and improved performance.
Sam Lantinga <slouken@libsdl.org>
parents: 3500
diff changeset
271 if (wdata == NULL) {
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
272 return -1;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
273 }
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
274 } else {
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 }
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
281
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
282 /* return if window widget has been destroyed already */
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
283 if (wdata->window == NULL) {
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
284 return;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
285 }
3108
aa1897bee1e9 Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
286
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
287 /* Check if we need to set new shape or disable cursor shape */
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
288 if (cursor != NULL) {
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
289 /* Retrieve photon cursor shape */
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
290 internal_cursor = (PhCursorDef_t *) cursor->driverdata;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
291 if (internal_cursor == NULL) {
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
292 SDL_SetError("Photon: Internal cursor data is absent");
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
293 return -1;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
294 }
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
295
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
296 /* Setup cursor type */
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
297 status =
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
298 PtSetResource(wdata->window, Pt_ARG_CURSOR_TYPE, Ph_CURSOR_BITMAP,
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
299 0);
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
300 if (status != 0) {
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
301 SDL_SetError("Photon: Failed to set cursor type to bitmap");
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
302 return -1;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
303 }
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
304
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
305 /* Setup cursor color to default */
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
306 status =
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
307 PtSetResource(wdata->window, Pt_ARG_CURSOR_COLOR,
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
308 Ph_CURSOR_DEFAULT_COLOR, 0);
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
309 if (status != 0) {
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
310 SDL_SetError("Photon: Failed to set cursor color");
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
311 return -1;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
312 }
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
313
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
314 /* Setup cursor shape */
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
315 status =
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
316 PtSetResource(wdata->window, Pt_ARG_BITMAP_CURSOR,
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
317 internal_cursor,
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
318 internal_cursor->hdr.len +
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
319 sizeof(PhRegionDataHdr_t));
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
320 if (status != 0) {
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
321 SDL_SetError("Photon: Failed to set cursor color");
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
322 return -1;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
323 }
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
324
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
325 /* Store current cursor for future usage */
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
326 if (didata->cursor_size >=
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
327 (internal_cursor->hdr.len + sizeof(PhRegionDataHdr_t))) {
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
328 SDL_memcpy(didata->cursor, internal_cursor,
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
329 internal_cursor->hdr.len + sizeof(PhRegionDataHdr_t));
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
330 } else {
3108
aa1897bee1e9 Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
331 /* Partitial cursor image */
aa1897bee1e9 Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
332 SDL_memcpy(didata->cursor, internal_cursor, didata->cursor_size);
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
333 }
3108
aa1897bee1e9 Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
334
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
335 /* Set cursor visible */
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
336 didata->cursor_visible = SDL_TRUE;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
337 } else {
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
338 /* SDL requests to disable cursor */
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
339 status =
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
340 PtSetResource(wdata->window, Pt_ARG_CURSOR_TYPE, Ph_CURSOR_NONE,
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
341 0);
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
342 if (status != 0) {
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
343 SDL_SetError("Photon: Can't disable cursor");
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
344 return -1;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
345 }
3108
aa1897bee1e9 Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
346
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
347 /* Set cursor invisible */
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
348 didata->cursor_visible = SDL_FALSE;
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 /* Flush all pending widget data */
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
352 PtFlush();
3108
aa1897bee1e9 Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
353
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
354 /* New cursor shape is set */
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
355 return 0;
3108
aa1897bee1e9 Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
356 }
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 void
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
359 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
360 {
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
361 SDL_VideoDisplay *display;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
362 SDL_DisplayData *didata;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
363 SDL_Window *window;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
364 SDL_WindowData *wdata;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
365 SDL_WindowID window_id;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
366 int32_t status;
3108
aa1897bee1e9 Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
367
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
368 /* Get current window id */
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
369 window_id = SDL_GetFocusWindow();
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
370 if (window_id <= 0) {
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
371 didata = (SDL_DisplayData *) cursor->mouse->driverdata;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
372 } else {
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
373 /* Sanity checks */
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
374 window = SDL_GetWindowFromID(window_id);
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
375 if (window != NULL) {
3685
64ce267332c6 Switched from SDL_WindowID and SDL_TextureID to SDL_Window* and SDL_Texture* for code simplicity and improved performance.
Sam Lantinga <slouken@libsdl.org>
parents: 3500
diff changeset
376 display = window->display;
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
377 if (display != NULL) {
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
378 didata = (SDL_DisplayData *) display->driverdata;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
379 if (didata != NULL) {
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
380 wdata = (SDL_WindowData *) window->driverdata;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
381 if (wdata == NULL) {
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
382 return;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
383 }
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
384 } else {
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
385 return;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
386 }
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
387 } else {
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
388 return;
3115
1102a3305928 Added handler for all window events.
Mike Gorchak <lestat@i.com.ua>
parents: 3108
diff changeset
389 }
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
390 } else {
3108
aa1897bee1e9 Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
391 return;
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
392 }
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
393 }
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
394
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
395 /* No need to move mouse cursor manually in the photon */
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
396
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
397 return;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
398 }
3108
aa1897bee1e9 Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
399
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
400 void
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
401 photon_freecursor(SDL_Cursor * cursor)
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
402 {
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
403 PhCursorDef_t *internal_cursor = NULL;
3115
1102a3305928 Added handler for all window events.
Mike Gorchak <lestat@i.com.ua>
parents: 3108
diff changeset
404
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
405 if (cursor != NULL) {
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
406 internal_cursor = (PhCursorDef_t *) cursor->driverdata;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
407 if (internal_cursor != NULL) {
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
408 SDL_free(internal_cursor);
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
409 cursor->driverdata = NULL;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
410 }
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
411 }
3108
aa1897bee1e9 Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
412 }
aa1897bee1e9 Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
413
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
414 void
3685
64ce267332c6 Switched from SDL_WindowID and SDL_TextureID to SDL_Window* and SDL_Texture* for code simplicity and improved performance.
Sam Lantinga <slouken@libsdl.org>
parents: 3500
diff changeset
415 photon_warpmouse(SDL_Mouse * mouse, SDL_Window * window, int x, int y)
3108
aa1897bee1e9 Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
416 {
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
417 SDL_VideoDisplay *display;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
418 SDL_DisplayData *didata;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
419 SDL_WindowData *wdata;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
420 int16_t wx;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
421 int16_t wy;
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 /* Sanity checks */
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
424 if (window != NULL) {
3685
64ce267332c6 Switched from SDL_WindowID and SDL_TextureID to SDL_Window* and SDL_Texture* for code simplicity and improved performance.
Sam Lantinga <slouken@libsdl.org>
parents: 3500
diff changeset
425 display = window->display;
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
426 if (display != NULL) {
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
427 didata = (SDL_DisplayData *) display->driverdata;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
428 if (didata != NULL) {
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
429 wdata = (SDL_WindowData *) window->driverdata;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
430 if (wdata == NULL) {
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
431 return;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
432 }
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
433 } else {
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
434 return;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
435 }
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
436 } else {
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
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
443 PtGetAbsPosition(wdata->window, &wx, &wy);
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
444 PhMoveCursorAbs(PhInputGroup(NULL), wx + x, wy + y);
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
445
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
446 return;
3108
aa1897bee1e9 Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
447 }
aa1897bee1e9 Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
448
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
449 void
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
450 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
451 {
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
452 if (mouse->driverdata == NULL) {
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
453 return;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
454 }
3108
aa1897bee1e9 Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
455
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
456 /* Mouse framework doesn't deletes automatically our driverdata */
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
457 SDL_free(mouse->driverdata);
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
458 mouse->driverdata = NULL;
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 return;
3108
aa1897bee1e9 Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
461 }
aa1897bee1e9 Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
462
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
463 SDL_scancode
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
464 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
465 {
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
466 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
467
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
468 switch (key & 0x0000007F) {
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
469 case PHOTON_SCANCODE_ESCAPE:
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
470 scancode = SDL_SCANCODE_ESCAPE;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
471 break;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
472 case PHOTON_SCANCODE_F1:
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
473 scancode = SDL_SCANCODE_F1;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
474 break;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
475 case PHOTON_SCANCODE_F2:
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
476 scancode = SDL_SCANCODE_F2;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
477 break;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
478 case PHOTON_SCANCODE_F3:
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
479 scancode = SDL_SCANCODE_F3;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
480 break;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
481 case PHOTON_SCANCODE_F4:
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
482 scancode = SDL_SCANCODE_F4;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
483 break;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
484 case PHOTON_SCANCODE_F5:
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
485 scancode = SDL_SCANCODE_F5;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
486 break;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
487 case PHOTON_SCANCODE_F6:
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
488 scancode = SDL_SCANCODE_F6;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
489 break;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
490 case PHOTON_SCANCODE_F7:
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
491 scancode = SDL_SCANCODE_F7;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
492 break;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
493 case PHOTON_SCANCODE_F8:
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
494 scancode = SDL_SCANCODE_F8;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
495 break;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
496 case PHOTON_SCANCODE_F9:
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
497 scancode = SDL_SCANCODE_F9;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
498 break;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
499 case PHOTON_SCANCODE_F10:
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
500 scancode = SDL_SCANCODE_F10;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
501 break;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
502 case PHOTON_SCANCODE_F11:
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
503 scancode = SDL_SCANCODE_F11;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
504 break;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
505 case PHOTON_SCANCODE_F12:
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
506 scancode = SDL_SCANCODE_F12;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
507 break;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
508 case PHOTON_SCANCODE_BACKQOUTE:
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
509 scancode = SDL_SCANCODE_GRAVE;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
510 break;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
511 case PHOTON_SCANCODE_1:
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
512 scancode = SDL_SCANCODE_1;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
513 break;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
514 case PHOTON_SCANCODE_2:
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
515 scancode = SDL_SCANCODE_2;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
516 break;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
517 case PHOTON_SCANCODE_3:
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
518 scancode = SDL_SCANCODE_3;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
519 break;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
520 case PHOTON_SCANCODE_4:
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
521 scancode = SDL_SCANCODE_4;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
522 break;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
523 case PHOTON_SCANCODE_5:
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
524 scancode = SDL_SCANCODE_5;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
525 break;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
526 case PHOTON_SCANCODE_6:
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
527 scancode = SDL_SCANCODE_6;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
528 break;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
529 case PHOTON_SCANCODE_7:
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
530 scancode = SDL_SCANCODE_7;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
531 break;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
532 case PHOTON_SCANCODE_8:
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
533 scancode = SDL_SCANCODE_8;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
534 break;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
535 case PHOTON_SCANCODE_9:
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
536 scancode = SDL_SCANCODE_9;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
537 break;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
538 case PHOTON_SCANCODE_0:
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
539 scancode = SDL_SCANCODE_0;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
540 break;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
541 case PHOTON_SCANCODE_MINUS:
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
542 scancode = SDL_SCANCODE_MINUS;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
543 break;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
544 case PHOTON_SCANCODE_EQUAL:
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
545 scancode = SDL_SCANCODE_EQUALS;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
546 break;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
547 case PHOTON_SCANCODE_BACKSPACE:
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
548 scancode = SDL_SCANCODE_BACKSPACE;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
549 break;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
550 case PHOTON_SCANCODE_TAB:
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
551 scancode = SDL_SCANCODE_TAB;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
552 break;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
553 case PHOTON_SCANCODE_Q:
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
554 scancode = SDL_SCANCODE_Q;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
555 break;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
556 case PHOTON_SCANCODE_W:
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
557 scancode = SDL_SCANCODE_W;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
558 break;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
559 case PHOTON_SCANCODE_E:
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
560 scancode = SDL_SCANCODE_E;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
561 break;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
562 case PHOTON_SCANCODE_R:
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
563 scancode = SDL_SCANCODE_R;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
564 break;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
565 case PHOTON_SCANCODE_T:
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
566 scancode = SDL_SCANCODE_T;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
567 break;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
568 case PHOTON_SCANCODE_Y:
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
569 scancode = SDL_SCANCODE_Y;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
570 break;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
571 case PHOTON_SCANCODE_U:
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
572 scancode = SDL_SCANCODE_U;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
573 break;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
574 case PHOTON_SCANCODE_I:
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
575 scancode = SDL_SCANCODE_I;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
576 break;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
577 case PHOTON_SCANCODE_O:
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
578 scancode = SDL_SCANCODE_O;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
579 break;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
580 case PHOTON_SCANCODE_P:
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
581 scancode = SDL_SCANCODE_P;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
582 break;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
583 case PHOTON_SCANCODE_LEFT_SQ_BR:
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
584 scancode = SDL_SCANCODE_LEFTBRACKET;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
585 break;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
586 case PHOTON_SCANCODE_RIGHT_SQ_BR:
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
587 scancode = SDL_SCANCODE_RIGHTBRACKET;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
588 break;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
589 case PHOTON_SCANCODE_ENTER:
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
590 scancode = SDL_SCANCODE_RETURN;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
591 break;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
592 case PHOTON_SCANCODE_CAPSLOCK:
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
593 scancode = SDL_SCANCODE_CAPSLOCK;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
594 break;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
595 case PHOTON_SCANCODE_A:
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
596 scancode = SDL_SCANCODE_A;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
597 break;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
598 case PHOTON_SCANCODE_S:
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
599 scancode = SDL_SCANCODE_S;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
600 break;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
601 case PHOTON_SCANCODE_D:
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
602 scancode = SDL_SCANCODE_D;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
603 break;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
604 case PHOTON_SCANCODE_F:
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
605 scancode = SDL_SCANCODE_F;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
606 break;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
607 case PHOTON_SCANCODE_G:
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
608 scancode = SDL_SCANCODE_G;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
609 break;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
610 case PHOTON_SCANCODE_H:
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
611 scancode = SDL_SCANCODE_H;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
612 break;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
613 case PHOTON_SCANCODE_J:
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
614 scancode = SDL_SCANCODE_J;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
615 break;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
616 case PHOTON_SCANCODE_K:
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
617 scancode = SDL_SCANCODE_K;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
618 break;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
619 case PHOTON_SCANCODE_L:
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
620 scancode = SDL_SCANCODE_L;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
621 break;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
622 case PHOTON_SCANCODE_SEMICOLON:
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
623 scancode = SDL_SCANCODE_SEMICOLON;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
624 break;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
625 case PHOTON_SCANCODE_QUOTE:
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
626 scancode = SDL_SCANCODE_APOSTROPHE;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
627 break;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
628 case PHOTON_SCANCODE_BACKSLASH:
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
629 scancode = SDL_SCANCODE_BACKSLASH;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
630 break;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
631 case PHOTON_SCANCODE_LEFT_SHIFT:
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
632 scancode = SDL_SCANCODE_LSHIFT;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
633 break;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
634 case PHOTON_SCANCODE_Z:
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
635 scancode = SDL_SCANCODE_Z;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
636 break;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
637 case PHOTON_SCANCODE_X:
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
638 scancode = SDL_SCANCODE_X;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
639 break;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
640 case PHOTON_SCANCODE_C:
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
641 scancode = SDL_SCANCODE_C;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
642 break;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
643 case PHOTON_SCANCODE_V:
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
644 scancode = SDL_SCANCODE_V;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
645 break;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
646 case PHOTON_SCANCODE_B:
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
647 scancode = SDL_SCANCODE_B;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
648 break;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
649 case PHOTON_SCANCODE_N:
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
650 scancode = SDL_SCANCODE_N;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
651 break;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
652 case PHOTON_SCANCODE_M:
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
653 scancode = SDL_SCANCODE_M;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
654 break;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
655 case PHOTON_SCANCODE_COMMA:
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
656 scancode = SDL_SCANCODE_COMMA;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
657 break;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
658 case PHOTON_SCANCODE_POINT:
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
659 scancode = SDL_SCANCODE_PERIOD;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
660 break;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
661 case PHOTON_SCANCODE_SLASH:
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
662 scancode = SDL_SCANCODE_SLASH;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
663 break;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
664 case PHOTON_SCANCODE_RIGHT_SHIFT:
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
665 scancode = SDL_SCANCODE_RSHIFT;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
666 break;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
667 case PHOTON_SCANCODE_CTRL:
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
668 scancode = SDL_SCANCODE_LCTRL;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
669 break;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
670 case PHOTON_SCANCODE_WFLAG:
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
671 scancode = SDL_SCANCODE_LGUI;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
672 break;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
673 case PHOTON_SCANCODE_ALT:
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
674 scancode = SDL_SCANCODE_LALT;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
675 break;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
676 case PHOTON_SCANCODE_SPACE:
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
677 scancode = SDL_SCANCODE_SPACE;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
678 break;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
679 case PHOTON_SCANCODE_MENU:
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
680 scancode = SDL_SCANCODE_MENU;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
681 break;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
682 case PHOTON_SCANCODE_PRNSCR:
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
683 scancode = SDL_SCANCODE_PRINTSCREEN;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
684 break;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
685 case PHOTON_SCANCODE_SCROLLLOCK:
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
686 scancode = SDL_SCANCODE_SCROLLLOCK;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
687 break;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
688 case PHOTON_SCANCODE_INSERT:
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
689 scancode = SDL_SCANCODE_INSERT;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
690 break;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
691 case PHOTON_SCANCODE_HOME:
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
692 scancode = SDL_SCANCODE_HOME;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
693 break;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
694 case PHOTON_SCANCODE_PAGEUP:
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
695 scancode = SDL_SCANCODE_PAGEUP;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
696 break;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
697 case PHOTON_SCANCODE_DELETE:
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
698 scancode = SDL_SCANCODE_DELETE;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
699 break;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
700 case PHOTON_SCANCODE_END:
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
701 scancode = SDL_SCANCODE_END;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
702 break;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
703 case PHOTON_SCANCODE_PAGEDOWN:
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
704 scancode = SDL_SCANCODE_PAGEDOWN;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
705 break;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
706 case PHOTON_SCANCODE_UP:
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
707 scancode = SDL_SCANCODE_UP;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
708 break;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
709 case PHOTON_SCANCODE_DOWN:
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
710 scancode = SDL_SCANCODE_DOWN;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
711 break;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
712 case PHOTON_SCANCODE_LEFT:
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
713 scancode = SDL_SCANCODE_LEFT;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
714 break;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
715 case PHOTON_SCANCODE_RIGHT:
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
716 scancode = SDL_SCANCODE_RIGHT;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
717 break;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
718 case PHOTON_SCANCODE_NUMLOCK:
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
719 scancode = SDL_SCANCODE_NUMLOCKCLEAR;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
720 break;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
721 default:
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
722 break;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
723 }
3108
aa1897bee1e9 Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
724
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
725 return scancode;
3108
aa1897bee1e9 Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents:
diff changeset
726 }