comparison src/video/qtopia/SDL_sysevents.cc @ 371:db0cc6034336

Added David Hedbor's Qtopia patches
author Sam Lantinga <slouken@libsdl.org>
date Sun, 19 May 2002 20:06:01 +0000
parents
children b8d311d90021
comparison
equal deleted inserted replaced
370:ba72f259bc88 371:db0cc6034336
1 /*
2 SDL - Simple DirectMedia Layer
3 Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002 Sam Lantinga
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version.
9
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details.
14
15 You should have received a copy of the GNU Library General Public
16 License along with this library; if not, write to the Free
17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18
19 Sam Lantinga
20 slouken@libsdl.org
21 */
22
23 #ifdef SAVE_RCSID
24 static char rcsid =
25 "@(#) $Id$";
26 #endif
27
28 #include <qpe/qpeapplication.h>
29
30 #include <stdio.h>
31 #include <string.h>
32 #include "SDL_error.h"
33 #include "SDL_events.h"
34 #include "SDL_QWin.h"
35 #include "SDL_lowvideo.h"
36 #include "SDL_timer.h"
37
38 extern "C" {
39 #include "SDL_events_c.h"
40 #include "SDL_sysevents.h"
41 #include "SDL_sysevents_c.h"
42
43 // static SDLKey keymap[128];
44 /* This is special because we know it will be run in a loop in a separate
45 thread. Normally this function should loop as long as there are input
46 states changing, i.e. new events arriving.
47 */
48 void QT_PumpEvents(_THIS)
49 {
50 if(!qApp) {
51 return;
52 }
53 // printf("processing events: %p\n", qApp);
54 //qApp->processOneEvent(); // wait for a event
55 qApp->processEvents(); // and process all outstanding ones
56 #if 0
57 BView *view;
58 BRect bounds;
59 BPoint point;
60 uint32 buttons;
61 const uint32 button_masks[3] = {
62 B_PRIMARY_MOUSE_BUTTON,
63 B_TERTIARY_MOUSE_BUTTON,
64 B_SECONDARY_MOUSE_BUTTON,
65 };
66 unsigned int i, j;
67
68 /* Check out the mouse buttons and position (slight race condition) */
69 if ( SDL_Win->Lock() ) {
70 /* Don't do anything if we have no view */
71 view = SDL_Win->View();
72 if ( ! view ) {
73 SDL_Win->Unlock();
74 return;
75 }
76 bounds = view->Bounds();
77 /* Get new input state, if still active */
78 if ( SDL_Win->IsActive() ) {
79 key_flip = !key_flip;
80 get_key_info(&keyinfo[key_flip]);
81 view->GetMouse(&point, &buttons, true);
82 } else {
83 key_flip = key_flip;
84 point = last_point;
85 buttons = last_buttons;
86 }
87 SDL_Win->Unlock();
88 } else {
89 return;
90 }
91
92 /* If our view is active, we'll find key changes here */
93 if ( memcmp(keyinfo[0].key_states, keyinfo[1].key_states, 16) != 0 ) {
94 for ( i=0; i<16; ++i ) {
95 Uint8 new_state, transition;
96
97 new_state = keyinfo[key_flip].key_states[i];
98 transition = keyinfo[!key_flip].key_states[i] ^
99 keyinfo[ key_flip].key_states[i];
100 for ( j=0; j<8; ++j ) {
101 if ( transition&0x80 )
102 QueueKey(i*8+j, new_state&0x80);
103 transition <<= 1;
104 new_state <<= 1;
105 }
106 }
107 }
108
109 /* We check keyboard, but not mouse if mouse isn't in window */
110 if ( ! bounds.Contains(point) ) {
111 /* Mouse moved outside our view? */
112 if ( SDL_GetAppState() & SDL_APPMOUSEFOCUS ) {
113 SDL_PrivateAppActive(0, SDL_APPMOUSEFOCUS);
114 be_app->SetCursor(B_HAND_CURSOR);
115 }
116 return;
117 }
118 /* Has the mouse moved back into our view? */
119 if ( ! (SDL_GetAppState() & SDL_APPMOUSEFOCUS) ) {
120 /* Reset the B_HAND_CURSOR to our own */
121 SDL_PrivateAppActive(1, SDL_APPMOUSEFOCUS);
122 SDL_SetCursor(NULL);
123 }
124
125 /* Check for mouse motion */
126 if ( point != last_point ) {
127 int x, y;
128
129 SDL_Win->GetXYOffset(x, y);
130 x = (int)point.x - x;
131 y = (int)point.y - y;
132 SDL_PrivateMouseMotion(0, 0, x, y);
133 }
134 last_point = point;
135
136 /* Add any mouse button events */
137 for ( i=0; i<SDL_TABLESIZE(button_masks); ++i ) {
138 if ( (buttons ^ last_buttons) & button_masks[i] ) {
139 if ( buttons & button_masks[i] ) {
140 SDL_PrivateMouseButton(SDL_PRESSED, 1+i, 0, 0);
141 } else {
142 SDL_PrivateMouseButton(SDL_RELEASED, 1+i, 0, 0);
143 }
144 }
145 }
146 last_buttons = buttons;
147 #endif
148 }
149
150 void QT_InitOSKeymap(_THIS)
151 {
152 #if 0
153 unsigned int i;
154
155 /* Initialize all the key states as "up" */
156 key_flip = 0;
157 memset(keyinfo[key_flip].key_states, 0, 16);
158
159 /* Initialize the key translation table */
160 for ( i=0; i<SDL_TABLESIZE(keymap); ++i )
161 keymap[i] = SDLK_UNKNOWN;
162
163 // keymap[0x01] = SDLK_ESCAPE;
164 // keymap[B_F1_KEY] = SDLK_F1;
165 // keymap[B_F2_KEY] = SDLK_F2;
166 // keymap[B_F3_KEY] = SDLK_F3;
167 // keymap[B_F4_KEY] = SDLK_F4;
168 // keymap[B_F5_KEY] = SDLK_F5;
169 // keymap[B_F6_KEY] = SDLK_F6;
170 // keymap[B_F7_KEY] = SDLK_F7;
171 // keymap[B_F8_KEY] = SDLK_F8;
172 // keymap[B_F9_KEY] = SDLK_F9;
173 // keymap[B_F10_KEY] = SDLK_F10;
174 // keymap[B_F11_KEY] = SDLK_F11;
175 // keymap[B_F12_KEY] = SDLK_F12;
176 // keymap[B_PRINT_KEY] = SDLK_PRINT;
177 //keymap[B_SCROLL_KEY] = SDLK_SCROLLOCK;
178 // keymap[B_PAUSE_KEY] = SDLK_PAUSE;
179 keymap[0x11] = SDLK_BACKQUOTE;
180 keymap[0x12] = SDLK_1;
181 keymap[0x13] = SDLK_2;
182 keymap[0x14] = SDLK_3;
183 keymap[0x15] = SDLK_4;
184 keymap[0x16] = SDLK_5;
185 keymap[0x17] = SDLK_6;
186 keymap[0x18] = SDLK_7;
187 keymap[0x19] = SDLK_8;
188 keymap[0x1a] = SDLK_9;
189 keymap[0x1b] = SDLK_0;
190 keymap[0x1c] = SDLK_MINUS;
191 keymap[0x1d] = SDLK_EQUALS;
192 keymap[0x1e] = SDLK_BACKSPACE;
193 keymap[0x1f] = SDLK_INSERT;
194 keymap[0x20] = SDLK_HOME;
195 keymap[0x21] = SDLK_PAGEUP;
196 //keymap[0x22] = SDLK_NUMLOCK;
197 keymap[0x23] = SDLK_KP_DIVIDE;
198 keymap[0x24] = SDLK_KP_MULTIPLY;
199 keymap[0x25] = SDLK_KP_MINUS;
200 keymap[0x26] = SDLK_TAB;
201 keymap[0x27] = SDLK_q;
202 keymap[0x28] = SDLK_w;
203 keymap[0x29] = SDLK_e;
204 keymap[0x2a] = SDLK_r;
205 keymap[0x2b] = SDLK_t;
206 keymap[0x2c] = SDLK_y;
207 keymap[0x2d] = SDLK_u;
208 keymap[0x2e] = SDLK_i;
209 keymap[0x2f] = SDLK_o;
210 keymap[0x30] = SDLK_p;
211 keymap[0x31] = SDLK_LEFTBRACKET;
212 keymap[0x32] = SDLK_RIGHTBRACKET;
213 keymap[0x33] = SDLK_BACKSLASH;
214 keymap[0x34] = SDLK_DELETE;
215 keymap[0x35] = SDLK_END;
216 keymap[0x36] = SDLK_PAGEDOWN;
217 keymap[0x37] = SDLK_KP7;
218 keymap[0x38] = SDLK_KP8;
219 keymap[0x39] = SDLK_KP9;
220 keymap[0x3a] = SDLK_KP_PLUS;
221 //keymap[0x3b] = SDLK_CAPSLOCK;
222 keymap[0x3c] = SDLK_a;
223 keymap[0x3d] = SDLK_s;
224 keymap[0x3e] = SDLK_d;
225 keymap[0x3f] = SDLK_f;
226 keymap[0x40] = SDLK_g;
227 keymap[0x41] = SDLK_h;
228 keymap[0x42] = SDLK_j;
229 keymap[0x43] = SDLK_k;
230 keymap[0x44] = SDLK_l;
231 keymap[0x45] = SDLK_SEMICOLON;
232 keymap[0x46] = SDLK_QUOTE;
233 keymap[0x47] = SDLK_RETURN;
234 keymap[0x48] = SDLK_KP4;
235 keymap[0x49] = SDLK_KP5;
236 keymap[0x4a] = SDLK_KP6;
237 keymap[0x4b] = SDLK_LSHIFT;
238 keymap[0x4c] = SDLK_z;
239 keymap[0x4d] = SDLK_x;
240 keymap[0x4e] = SDLK_c;
241 keymap[0x4f] = SDLK_v;
242 keymap[0x50] = SDLK_b;
243 keymap[0x51] = SDLK_n;
244 keymap[0x52] = SDLK_m;
245 keymap[0x53] = SDLK_COMMA;
246 keymap[0x54] = SDLK_PERIOD;
247 keymap[0x55] = SDLK_SLASH;
248 keymap[0x56] = SDLK_RSHIFT;
249 keymap[0x57] = SDLK_UP;
250 keymap[0x58] = SDLK_KP1;
251 keymap[0x59] = SDLK_KP2;
252 keymap[0x5a] = SDLK_KP3;
253 keymap[0x5b] = SDLK_KP_ENTER;
254 //keymap[0x5c] = SDLK_LCTRL;
255 //keymap[0x5d] = SDLK_LALT;
256 keymap[0x5e] = SDLK_SPACE;
257 //keymap[0x5f] = SDLK_RALT;
258 //keymap[0x60] = SDLK_RCTRL;
259 keymap[0x61] = SDLK_LEFT;
260 keymap[0x62] = SDLK_DOWN;
261 keymap[0x63] = SDLK_RIGHT;
262 keymap[0x64] = SDLK_KP0;
263 keymap[0x65] = SDLK_KP_PERIOD;
264 //keymap[0x66] = SDLK_LMETA;
265 //keymap[0x67] = SDLK_RMETA;
266 //keymap[0x68] = SDLK_MENU;
267 keymap[0x69] = SDLK_EURO;
268 keymap[0x6a] = SDLK_KP_EQUALS;
269 keymap[0x6b] = SDLK_POWER;
270 #endif
271 }
272
273 }; /* Extern C */