diff options
Diffstat (limited to 'apps/plugins/sdl/src/video/qtopia')
-rw-r--r-- | apps/plugins/sdl/src/video/qtopia/SDL_QPEApp.cc | 63 | ||||
-rw-r--r-- | apps/plugins/sdl/src/video/qtopia/SDL_QPEApp.h | 33 | ||||
-rw-r--r-- | apps/plugins/sdl/src/video/qtopia/SDL_QWin.cc | 527 | ||||
-rw-r--r-- | apps/plugins/sdl/src/video/qtopia/SDL_QWin.h | 110 | ||||
-rw-r--r-- | apps/plugins/sdl/src/video/qtopia/SDL_lowvideo.h | 65 | ||||
-rw-r--r-- | apps/plugins/sdl/src/video/qtopia/SDL_sysevents.cc | 269 | ||||
-rw-r--r-- | apps/plugins/sdl/src/video/qtopia/SDL_sysevents_c.h | 31 | ||||
-rw-r--r-- | apps/plugins/sdl/src/video/qtopia/SDL_sysmouse.cc | 56 | ||||
-rw-r--r-- | apps/plugins/sdl/src/video/qtopia/SDL_sysmouse_c.h | 32 | ||||
-rw-r--r-- | apps/plugins/sdl/src/video/qtopia/SDL_sysvideo.cc | 403 | ||||
-rw-r--r-- | apps/plugins/sdl/src/video/qtopia/SDL_syswm.cc | 35 | ||||
-rw-r--r-- | apps/plugins/sdl/src/video/qtopia/SDL_syswm_c.h | 28 |
12 files changed, 1652 insertions, 0 deletions
diff --git a/apps/plugins/sdl/src/video/qtopia/SDL_QPEApp.cc b/apps/plugins/sdl/src/video/qtopia/SDL_QPEApp.cc new file mode 100644 index 0000000000..8daf1c524c --- /dev/null +++ b/apps/plugins/sdl/src/video/qtopia/SDL_QPEApp.cc | |||
@@ -0,0 +1,63 @@ | |||
1 | /* | ||
2 | SDL - Simple DirectMedia Layer | ||
3 | Copyright (C) 1997-2012 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 | #include "SDL_config.h" | ||
23 | |||
24 | #include <qpe/qpeapplication.h> | ||
25 | #include <qapplication.h> | ||
26 | #include <qevent.h> | ||
27 | |||
28 | #include "SDL_thread.h" | ||
29 | #include "SDL_timer.h" | ||
30 | #include "SDL_error.h" | ||
31 | |||
32 | /* Flag to tell whether or not the Be application is active or not */ | ||
33 | int SDL_QPEAppActive = 0; | ||
34 | static QPEApplication *app; | ||
35 | |||
36 | int SDL_InitQPEApp() { | ||
37 | if(SDL_QPEAppActive <= 0) { | ||
38 | if(!qApp) { | ||
39 | int argc = 1; | ||
40 | char *argv[] = { { "SDLApp" } }; | ||
41 | app = new QPEApplication(argc, argv); | ||
42 | QWidget dummy; | ||
43 | app->showMainWidget(&dummy); | ||
44 | } else { | ||
45 | app = (QPEApplication*)qApp; | ||
46 | } | ||
47 | SDL_QPEAppActive++; | ||
48 | } | ||
49 | return 0; | ||
50 | } | ||
51 | |||
52 | /* Quit the QPE Application, if there's nothing left to do */ | ||
53 | void SDL_QuitQPEApp(void) | ||
54 | { | ||
55 | /* Decrement the application reference count */ | ||
56 | SDL_QPEAppActive--; | ||
57 | /* If the reference count reached zero, clean up the app */ | ||
58 | if ( SDL_QPEAppActive == 0 && app) { | ||
59 | delete app; | ||
60 | app = 0; | ||
61 | qApp = 0; | ||
62 | } | ||
63 | } | ||
diff --git a/apps/plugins/sdl/src/video/qtopia/SDL_QPEApp.h b/apps/plugins/sdl/src/video/qtopia/SDL_QPEApp.h new file mode 100644 index 0000000000..8a9ab77d88 --- /dev/null +++ b/apps/plugins/sdl/src/video/qtopia/SDL_QPEApp.h | |||
@@ -0,0 +1,33 @@ | |||
1 | /* | ||
2 | SDL - Simple DirectMedia Layer | ||
3 | Copyright (C) 1997-2012 Sam Lantinga | ||
4 | |||
5 | This library is free software; you can redistribute it and/or | ||
6 | modify it under the terms of the GNU Lesser General Public | ||
7 | License as published by the Free Software Foundation; either | ||
8 | version 2.1 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 | Lesser General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU Lesser General Public | ||
16 | License along with this library; if not, write to the Free Software | ||
17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
18 | |||
19 | Sam Lantinga | ||
20 | slouken@libsdl.org | ||
21 | */ | ||
22 | #include "SDL_config.h" | ||
23 | |||
24 | /* Handle the QPE application loop */ | ||
25 | |||
26 | /* Initialize the QPE Application, if it's not already started */ | ||
27 | extern int SDL_InitQPEApp(void); | ||
28 | |||
29 | /* Quit the QPE Application, if there's nothing left to do */ | ||
30 | extern void SDL_QuitQPEApp(void); | ||
31 | |||
32 | /* Flag to tell whether the app is active or not */ | ||
33 | extern int SDL_QPEAppActive; | ||
diff --git a/apps/plugins/sdl/src/video/qtopia/SDL_QWin.cc b/apps/plugins/sdl/src/video/qtopia/SDL_QWin.cc new file mode 100644 index 0000000000..04474ed9be --- /dev/null +++ b/apps/plugins/sdl/src/video/qtopia/SDL_QWin.cc | |||
@@ -0,0 +1,527 @@ | |||
1 | /* | ||
2 | SDL - Simple DirectMedia Layer | ||
3 | Copyright (C) 1997-2012 Sam Lantinga | ||
4 | |||
5 | This library is free software; you can redistribute it and/or | ||
6 | modify it under the terms of the GNU Lesser General Public | ||
7 | License as published by the Free Software Foundation; either | ||
8 | version 2.1 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 | Lesser General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU Lesser General Public | ||
16 | License along with this library; if not, write to the Free Software | ||
17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
18 | |||
19 | Sam Lantinga | ||
20 | slouken@libsdl.org | ||
21 | */ | ||
22 | #include "SDL_config.h" | ||
23 | |||
24 | #include "SDL_QWin.h" | ||
25 | #include <qapplication.h> | ||
26 | #include <qdirectpainter_qws.h> | ||
27 | |||
28 | screenRotationT screenRotation = SDL_QT_NO_ROTATION; | ||
29 | |||
30 | SDL_QWin::SDL_QWin(const QSize& size) | ||
31 | : QWidget(0, "SDL_main"), my_painter(0), my_image(0), | ||
32 | my_inhibit_resize(false), my_mouse_pos(-1,-1), my_flags(0), | ||
33 | my_has_fullscreen(false), my_locked(0) | ||
34 | { | ||
35 | setBackgroundMode(NoBackground); | ||
36 | } | ||
37 | |||
38 | SDL_QWin::~SDL_QWin() { | ||
39 | // Nothing to do yet. | ||
40 | if(my_image) { | ||
41 | delete my_image; | ||
42 | } | ||
43 | } | ||
44 | |||
45 | void SDL_QWin::setImage(QImage *image) { | ||
46 | if ( my_image ) { | ||
47 | delete my_image; | ||
48 | } | ||
49 | my_image = image; | ||
50 | // setFixedSize(image->size()); | ||
51 | } | ||
52 | |||
53 | void SDL_QWin::resizeEvent(QResizeEvent *e) { | ||
54 | if(size() != qApp->desktop()->size()) { | ||
55 | // Widget is not the correct size, so do the fullscreen magic | ||
56 | my_has_fullscreen = false; | ||
57 | enableFullscreen(); | ||
58 | } | ||
59 | if(my_inhibit_resize) { | ||
60 | my_inhibit_resize = false; | ||
61 | } else { | ||
62 | SDL_PrivateResize(e->size().width(), e->size().height()); | ||
63 | } | ||
64 | } | ||
65 | |||
66 | void SDL_QWin::focusInEvent(QFocusEvent *) { | ||
67 | // Always do it here, no matter the size. | ||
68 | enableFullscreen(); | ||
69 | SDL_PrivateAppActive(true, SDL_APPINPUTFOCUS); | ||
70 | } | ||
71 | |||
72 | void SDL_QWin::focusOutEvent(QFocusEvent *) { | ||
73 | my_has_fullscreen = false; | ||
74 | SDL_PrivateAppActive(false, SDL_APPINPUTFOCUS); | ||
75 | } | ||
76 | |||
77 | void SDL_QWin::closeEvent(QCloseEvent *e) { | ||
78 | SDL_PrivateQuit(); | ||
79 | e->ignore(); | ||
80 | } | ||
81 | |||
82 | void SDL_QWin::setMousePos(const QPoint &pos) { | ||
83 | if(my_image->width() == height()) { | ||
84 | if (screenRotation == SDL_QT_ROTATION_90) | ||
85 | my_mouse_pos = QPoint(height()-pos.y(), pos.x()); | ||
86 | else if (screenRotation == SDL_QT_ROTATION_270) | ||
87 | my_mouse_pos = QPoint(pos.y(), width()-pos.x()); | ||
88 | } else { | ||
89 | my_mouse_pos = pos; | ||
90 | } | ||
91 | } | ||
92 | |||
93 | void SDL_QWin::mouseMoveEvent(QMouseEvent *e) { | ||
94 | Qt::ButtonState button = e->button(); | ||
95 | int sdlstate = 0; | ||
96 | if( (button & Qt::LeftButton)) { | ||
97 | sdlstate |= SDL_BUTTON_LMASK; | ||
98 | } | ||
99 | if( (button & Qt::RightButton)) { | ||
100 | sdlstate |= SDL_BUTTON_RMASK; | ||
101 | } | ||
102 | if( (button & Qt::MidButton)) { | ||
103 | sdlstate |= SDL_BUTTON_MMASK; | ||
104 | } | ||
105 | setMousePos(e->pos()); | ||
106 | SDL_PrivateMouseMotion(sdlstate, 0, my_mouse_pos.x(), my_mouse_pos.y()); | ||
107 | } | ||
108 | |||
109 | void SDL_QWin::mousePressEvent(QMouseEvent *e) { | ||
110 | mouseMoveEvent(e); | ||
111 | Qt::ButtonState button = e->button(); | ||
112 | SDL_PrivateMouseButton(SDL_PRESSED, | ||
113 | (button & Qt::LeftButton) ? 1 : | ||
114 | ((button & Qt::RightButton) ? 2 : 3), | ||
115 | my_mouse_pos.x(), my_mouse_pos.y()); | ||
116 | } | ||
117 | |||
118 | void SDL_QWin::mouseReleaseEvent(QMouseEvent *e) { | ||
119 | setMousePos(e->pos()); | ||
120 | Qt::ButtonState button = e->button(); | ||
121 | SDL_PrivateMouseButton(SDL_RELEASED, | ||
122 | (button & Qt::LeftButton) ? 1 : | ||
123 | ((button & Qt::RightButton) ? 2 : 3), | ||
124 | my_mouse_pos.x(), my_mouse_pos.y()); | ||
125 | my_mouse_pos = QPoint(-1, -1); | ||
126 | } | ||
127 | |||
128 | static inline void | ||
129 | gs_fastRotateBlit_3 ( unsigned short *fb, | ||
130 | unsigned short *bits, | ||
131 | const QRect& rect ) | ||
132 | { | ||
133 | // FIXME: this only works correctly for 240x320 displays | ||
134 | int startx, starty; | ||
135 | int width, height; | ||
136 | |||
137 | startx = rect.left() >> 1; | ||
138 | starty = rect.top() >> 1; | ||
139 | width = ((rect.right() - rect.left()) >> 1) + 2; | ||
140 | height = ((rect.bottom() - rect.top()) >> 1) + 2; | ||
141 | |||
142 | if((startx+width) > 120) { | ||
143 | width = 120 - startx; // avoid horizontal overflow | ||
144 | } | ||
145 | if((starty+height) > 160) { | ||
146 | height = 160 - starty; // avoid vertical overflow | ||
147 | } | ||
148 | |||
149 | ulong *sp1, *sp2, *dp1, *dp2; | ||
150 | ulong stop, sbot, dtop, dbot; | ||
151 | |||
152 | sp1 = (ulong*)bits + startx + starty*240; | ||
153 | sp2 = sp1 + 120; | ||
154 | dp1 = (ulong *)fb + (159 - starty) + startx*320; | ||
155 | dp2 = dp1 + 160; | ||
156 | int rowadd = (-320*width) - 1; | ||
157 | int rowadd2 = 240 - width; | ||
158 | // transfer in cells of 2x2 pixels in words | ||
159 | for (int y=0; y<height; y++) { | ||
160 | for (int x=0; x<width; x++) { | ||
161 | // read source pixels | ||
162 | stop = *sp1; | ||
163 | sbot = *sp2; | ||
164 | // rotate pixels | ||
165 | dtop = (sbot & 0xffff) + ((stop & 0xffff)<<16); | ||
166 | dbot = ((sbot & 0xffff0000)>>16) + (stop & 0xffff0000); | ||
167 | // write to framebuffer | ||
168 | *dp1 = dtop; | ||
169 | *dp2 = dbot; | ||
170 | // update source ptrs | ||
171 | sp1++; sp2++; | ||
172 | // update dest ptrs - 2 pix at a time | ||
173 | dp1 += 320; | ||
174 | dp2 += 320; | ||
175 | } | ||
176 | // adjust src ptrs - skip a row as we work in pairs | ||
177 | sp1 += rowadd2; | ||
178 | sp2 += rowadd2; | ||
179 | // adjust dest ptrs for rotation | ||
180 | dp1 += rowadd; | ||
181 | dp2 += rowadd; | ||
182 | } | ||
183 | } | ||
184 | |||
185 | static inline void | ||
186 | gs_fastRotateBlit_1 ( unsigned short *fb, | ||
187 | unsigned short *bits, | ||
188 | const QRect& rect ) { | ||
189 | // FIXME: this only works correctly for 240x320 displays | ||
190 | int startx, starty; | ||
191 | int width, height; | ||
192 | |||
193 | startx = rect.left() >> 1; | ||
194 | starty = rect.top() >> 1; | ||
195 | width = ((rect.right() - rect.left()) >> 1) + 2; | ||
196 | height = ((rect.bottom() - rect.top()) >> 1) + 2; | ||
197 | |||
198 | if((startx+width) > 120) { | ||
199 | width = 120 - startx; // avoid horizontal overflow | ||
200 | } | ||
201 | if((starty+height) > 160) { | ||
202 | height = 160 - starty; // avoid vertical overflow | ||
203 | } | ||
204 | |||
205 | ulong *sp1, *sp2, *dp1, *dp2; | ||
206 | ulong stop, sbot, dtop, dbot; | ||
207 | fb += 320*239; // Move "fb" to top left corner | ||
208 | sp1 = (ulong*)bits + startx + starty*240; | ||
209 | sp2 = sp1 + 120; | ||
210 | dp1 = (ulong*)fb - startx * 320 - starty; | ||
211 | dp2 = dp1 - 160; | ||
212 | int rowadd = (320*width) + 1; | ||
213 | int rowadd2 = 240 - width; | ||
214 | // transfer in cells of 2x2 pixels in words | ||
215 | for (int y=0; y<height; y++) { | ||
216 | for (int x=0; x<width; x++) { | ||
217 | // read | ||
218 | stop = *sp1; | ||
219 | sbot = *sp2; | ||
220 | // rotate | ||
221 | dtop = (stop & 0xffff) + ((sbot & 0xffff)<<16); | ||
222 | dbot = ((stop & 0xffff0000)>>16) + (sbot & 0xffff0000); | ||
223 | // write | ||
224 | *dp1 = dtop; | ||
225 | *dp2 = dbot; | ||
226 | // update source ptrs | ||
227 | sp1++; sp2++; | ||
228 | // update dest ptrs - 2 pix at a time | ||
229 | dp1 -= 320; | ||
230 | dp2 -= 320; | ||
231 | } | ||
232 | // adjust src ptrs - skip a row as we work in pairs | ||
233 | sp1 += rowadd2; | ||
234 | sp2 += rowadd2; | ||
235 | // adjust dest ptrs for rotation | ||
236 | dp1 += rowadd; | ||
237 | dp2 += rowadd; | ||
238 | } | ||
239 | } | ||
240 | |||
241 | // desktop, SL-A300 etc | ||
242 | bool SDL_QWin::repaintRotation0(const QRect& rect) { | ||
243 | if(my_image->width() == width()) { | ||
244 | uchar *fb = (uchar*)my_painter->frameBuffer(); | ||
245 | uchar *buf = (uchar*)my_image->bits(); | ||
246 | if(rect == my_image->rect()) { | ||
247 | SDL_memcpy(fb, buf, width()*height()*2); | ||
248 | } else { | ||
249 | int h = rect.height(); | ||
250 | int wd = rect.width()<<1; | ||
251 | int fblineadd = my_painter->lineStep(); | ||
252 | int buflineadd = my_image->bytesPerLine(); | ||
253 | fb += (rect.left()<<1) + rect.top() * my_painter->lineStep(); | ||
254 | buf += (rect.left()<<1) + rect.top() * my_image->bytesPerLine(); | ||
255 | while(h--) { | ||
256 | SDL_memcpy(fb, buf, wd); | ||
257 | fb += fblineadd; | ||
258 | buf += buflineadd; | ||
259 | } | ||
260 | } | ||
261 | } else { | ||
262 | return false; // FIXME: Landscape | ||
263 | } | ||
264 | #ifdef __i386__ | ||
265 | my_painter->fillRect( rect, QBrush( Qt::NoBrush ) ); | ||
266 | #endif | ||
267 | return true; | ||
268 | } | ||
269 | |||
270 | |||
271 | // Sharp Zaurus SL-5500 etc | ||
272 | bool SDL_QWin::repaintRotation3(const QRect& rect) { | ||
273 | if(my_image->width() == width()) { | ||
274 | ushort *fb = (ushort*)my_painter->frameBuffer(); | ||
275 | ushort *buf = (ushort*)my_image->bits(); | ||
276 | gs_fastRotateBlit_3(fb, buf, rect); | ||
277 | } else { | ||
278 | // landscape mode | ||
279 | if (screenRotation == SDL_QT_ROTATION_90) { | ||
280 | uchar *fb = (uchar*)my_painter->frameBuffer(); | ||
281 | uchar *buf = (uchar*)my_image->bits(); | ||
282 | if(rect == my_image->rect()) { | ||
283 | SDL_memcpy(fb, buf, width()*height()*2); | ||
284 | } else { | ||
285 | int h = rect.height(); | ||
286 | int wd = rect.width()<<1; | ||
287 | int fblineadd = my_painter->lineStep(); | ||
288 | int buflineadd = my_image->bytesPerLine(); | ||
289 | fb += (rect.left()<<1) + rect.top() * my_painter->lineStep(); | ||
290 | buf += (rect.left()<<1) + rect.top() * my_image->bytesPerLine(); | ||
291 | while(h--) { | ||
292 | SDL_memcpy(fb, buf, wd); | ||
293 | fb += fblineadd; | ||
294 | buf += buflineadd; | ||
295 | } | ||
296 | } | ||
297 | } else if (screenRotation == SDL_QT_ROTATION_270) { | ||
298 | int h = rect.height(); | ||
299 | int wd = rect.width(); | ||
300 | int fblineadd = my_painter->lineStep() - (rect.width() << 1); | ||
301 | int buflineadd = my_image->bytesPerLine() - (rect.width() << 1); | ||
302 | int w; | ||
303 | |||
304 | uchar *fb = (uchar*)my_painter->frameBuffer(); | ||
305 | uchar *buf = (uchar*)my_image->bits(); | ||
306 | |||
307 | fb += ((my_painter->width() - (rect.top() + rect.height())) * | ||
308 | my_painter->lineStep()) + ((my_painter->height() - ((rect.left() + | ||
309 | rect.width()))) << 1); | ||
310 | |||
311 | buf += my_image->bytesPerLine() * (rect.top() + rect.height()) - | ||
312 | (((my_image->width() - (rect.left() + rect.width())) << 1) + 2); | ||
313 | |||
314 | while(h--) { | ||
315 | w = wd; | ||
316 | while(w--) *((unsigned short*)fb)++ = *((unsigned short*)buf)--; | ||
317 | fb += fblineadd; | ||
318 | buf -= buflineadd; | ||
319 | } | ||
320 | } | ||
321 | } | ||
322 | return true; | ||
323 | } | ||
324 | |||
325 | // ipaq 3800... | ||
326 | bool SDL_QWin::repaintRotation1(const QRect& rect) { | ||
327 | if(my_image->width() == width()) { | ||
328 | ushort *fb = (ushort*)my_painter->frameBuffer(); | ||
329 | ushort *buf = (ushort*)my_image->bits(); | ||
330 | gs_fastRotateBlit_1(fb, buf, rect); | ||
331 | } else { | ||
332 | return false; // FIXME: landscape mode | ||
333 | } | ||
334 | return true; | ||
335 | } | ||
336 | |||
337 | void SDL_QWin::repaintRect(const QRect& rect) { | ||
338 | if(!my_painter || !rect.width() || !rect.height()) { | ||
339 | return; | ||
340 | } | ||
341 | |||
342 | if(QPixmap::defaultDepth() == 16) { | ||
343 | switch(my_painter->transformOrientation()) { | ||
344 | case 3: | ||
345 | if(repaintRotation3(rect)) { return; } | ||
346 | break; | ||
347 | case 1: | ||
348 | if(repaintRotation1(rect)) { return; } | ||
349 | break; | ||
350 | case 0: | ||
351 | if(repaintRotation0(rect)) { return; } | ||
352 | break; | ||
353 | } | ||
354 | } | ||
355 | my_painter->drawImage(rect.topLeft(), *my_image, rect); | ||
356 | } | ||
357 | |||
358 | // This paints the current buffer to the screen, when desired. | ||
359 | void SDL_QWin::paintEvent(QPaintEvent *ev) { | ||
360 | if(my_image) { | ||
361 | lockScreen(true); | ||
362 | repaintRect(ev->rect()); | ||
363 | unlockScreen(); | ||
364 | } | ||
365 | } | ||
366 | |||
367 | /* Function to translate a keyboard transition and queue the key event | ||
368 | * This should probably be a table although this method isn't exactly | ||
369 | * slow. | ||
370 | */ | ||
371 | void SDL_QWin::QueueKey(QKeyEvent *e, int pressed) | ||
372 | { | ||
373 | SDL_keysym keysym; | ||
374 | int scancode = e->key(); | ||
375 | /* Set the keysym information */ | ||
376 | if(scancode >= 'A' && scancode <= 'Z') { | ||
377 | // Qt sends uppercase, SDL wants lowercase | ||
378 | keysym.sym = static_cast<SDLKey>(scancode + 32); | ||
379 | } else if(scancode >= 0x1000) { | ||
380 | // Special keys | ||
381 | switch(scancode) { | ||
382 | case Qt::Key_Escape: scancode = SDLK_ESCAPE; break; | ||
383 | case Qt::Key_Tab: scancode = SDLK_TAB; break; | ||
384 | case Qt::Key_Backspace: scancode = SDLK_BACKSPACE; break; | ||
385 | case Qt::Key_Return: scancode = SDLK_RETURN; break; | ||
386 | case Qt::Key_Enter: scancode = SDLK_KP_ENTER; break; | ||
387 | case Qt::Key_Insert: scancode = SDLK_INSERT; break; | ||
388 | case Qt::Key_Delete: scancode = SDLK_DELETE; break; | ||
389 | case Qt::Key_Pause: scancode = SDLK_PAUSE; break; | ||
390 | case Qt::Key_Print: scancode = SDLK_PRINT; break; | ||
391 | case Qt::Key_SysReq: scancode = SDLK_SYSREQ; break; | ||
392 | case Qt::Key_Home: scancode = SDLK_HOME; break; | ||
393 | case Qt::Key_End: scancode = SDLK_END; break; | ||
394 | // We want the control keys to rotate with the screen | ||
395 | case Qt::Key_Left: | ||
396 | if (screenRotation == SDL_QT_ROTATION_90) scancode = SDLK_UP; | ||
397 | else if (screenRotation == SDL_QT_ROTATION_270) scancode = SDLK_DOWN; | ||
398 | else scancode = SDLK_LEFT; | ||
399 | break; | ||
400 | case Qt::Key_Up: | ||
401 | if (screenRotation == SDL_QT_ROTATION_90) scancode = SDLK_RIGHT; | ||
402 | else if (screenRotation == SDL_QT_ROTATION_270) scancode = SDLK_LEFT; | ||
403 | else scancode = SDLK_UP; | ||
404 | break; | ||
405 | case Qt::Key_Right: | ||
406 | if (screenRotation == SDL_QT_ROTATION_90) scancode = SDLK_DOWN; | ||
407 | else if (screenRotation == SDL_QT_ROTATION_270) scancode = SDLK_UP; | ||
408 | else scancode = SDLK_RIGHT; | ||
409 | break; | ||
410 | case Qt::Key_Down: | ||
411 | if (screenRotation == SDL_QT_ROTATION_90) scancode = SDLK_LEFT; | ||
412 | else if (screenRotation == SDL_QT_ROTATION_270) scancode = SDLK_RIGHT; | ||
413 | else scancode = SDLK_DOWN; | ||
414 | break; | ||
415 | case Qt::Key_Prior: scancode = SDLK_PAGEUP; break; | ||
416 | case Qt::Key_Next: scancode = SDLK_PAGEDOWN; break; | ||
417 | case Qt::Key_Shift: scancode = SDLK_LSHIFT; break; | ||
418 | case Qt::Key_Control: scancode = SDLK_LCTRL; break; | ||
419 | case Qt::Key_Meta: scancode = SDLK_LMETA; break; | ||
420 | case Qt::Key_Alt: scancode = SDLK_LALT; break; | ||
421 | case Qt::Key_CapsLock: scancode = SDLK_CAPSLOCK; break; | ||
422 | case Qt::Key_NumLock: scancode = SDLK_NUMLOCK; break; | ||
423 | case Qt::Key_ScrollLock: scancode = SDLK_SCROLLOCK; break; | ||
424 | case Qt::Key_F1: scancode = SDLK_F1; break; | ||
425 | case Qt::Key_F2: scancode = SDLK_F2; break; | ||
426 | case Qt::Key_F3: scancode = SDLK_F3; break; | ||
427 | case Qt::Key_F4: scancode = SDLK_F4; break; | ||
428 | case Qt::Key_F5: scancode = SDLK_F5; break; | ||
429 | case Qt::Key_F6: scancode = SDLK_F6; break; | ||
430 | case Qt::Key_F7: scancode = SDLK_F7; break; | ||
431 | case Qt::Key_F8: scancode = SDLK_F8; break; | ||
432 | case Qt::Key_F9: scancode = SDLK_F9; break; | ||
433 | case Qt::Key_F10: scancode = SDLK_F10; break; | ||
434 | case Qt::Key_F11: scancode = SDLK_F11; break; | ||
435 | case Qt::Key_F12: scancode = SDLK_F12; break; | ||
436 | case Qt::Key_F13: scancode = SDLK_F13; break; | ||
437 | case Qt::Key_F14: scancode = SDLK_F14; break; | ||
438 | case Qt::Key_F15: scancode = SDLK_F15; break; | ||
439 | case Qt::Key_Super_L: scancode = SDLK_LSUPER; break; | ||
440 | case Qt::Key_Super_R: scancode = SDLK_RSUPER; break; | ||
441 | case Qt::Key_Menu: scancode = SDLK_MENU; break; | ||
442 | case Qt::Key_Help: scancode = SDLK_HELP; break; | ||
443 | |||
444 | case Qt::Key_F33: | ||
445 | // FIXME: This is a hack to enable the OK key on | ||
446 | // Zaurii devices. SDLK_RETURN is a suitable key to use | ||
447 | // since it often is used as such. | ||
448 | // david@hedbor.org | ||
449 | scancode = SDLK_RETURN; | ||
450 | break; | ||
451 | default: | ||
452 | scancode = SDLK_UNKNOWN; | ||
453 | break; | ||
454 | } | ||
455 | keysym.sym = static_cast<SDLKey>(scancode); | ||
456 | } else { | ||
457 | keysym.sym = static_cast<SDLKey>(scancode); | ||
458 | } | ||
459 | keysym.scancode = scancode; | ||
460 | keysym.mod = KMOD_NONE; | ||
461 | ButtonState st = e->state(); | ||
462 | if( (st & ShiftButton) ) { keysym.mod = static_cast<SDLMod>(keysym.mod | KMOD_LSHIFT); } | ||
463 | if( (st & ControlButton) ) { keysym.mod = static_cast<SDLMod>(keysym.mod | KMOD_LCTRL); } | ||
464 | if( (st & AltButton) ) { keysym.mod = static_cast<SDLMod>(keysym.mod | KMOD_LALT); } | ||
465 | if ( SDL_TranslateUNICODE ) { | ||
466 | QChar qchar = e->text()[0]; | ||
467 | keysym.unicode = qchar.unicode(); | ||
468 | } else { | ||
469 | keysym.unicode = 0; | ||
470 | } | ||
471 | |||
472 | /* NUMLOCK and CAPSLOCK are implemented as double-presses in reality */ | ||
473 | // if ( (keysym.sym == SDLK_NUMLOCK) || (keysym.sym == SDLK_CAPSLOCK) ) { | ||
474 | // pressed = 1; | ||
475 | // } | ||
476 | |||
477 | /* Queue the key event */ | ||
478 | if ( pressed ) { | ||
479 | SDL_PrivateKeyboard(SDL_PRESSED, &keysym); | ||
480 | } else { | ||
481 | SDL_PrivateKeyboard(SDL_RELEASED, &keysym); | ||
482 | } | ||
483 | } | ||
484 | |||
485 | void SDL_QWin::setFullscreen(bool fs_on) { | ||
486 | my_has_fullscreen = false; | ||
487 | enableFullscreen(); | ||
488 | } | ||
489 | |||
490 | void SDL_QWin::enableFullscreen() { | ||
491 | // Make sure size is correct | ||
492 | if(!my_has_fullscreen) { | ||
493 | setFixedSize(qApp->desktop()->size()); | ||
494 | // This call is needed because showFullScreen won't work | ||
495 | // correctly if the widget already considers itself to be fullscreen. | ||
496 | showNormal(); | ||
497 | // This is needed because showNormal() forcefully changes the window | ||
498 | // style to WSTyle_TopLevel. | ||
499 | setWFlags(WStyle_Customize | WStyle_NoBorder); | ||
500 | // Enable fullscreen. | ||
501 | showFullScreen(); | ||
502 | my_has_fullscreen = true; | ||
503 | } | ||
504 | } | ||
505 | |||
506 | bool SDL_QWin::lockScreen(bool force) { | ||
507 | if(!my_painter) { | ||
508 | if(force || (isVisible() && isActiveWindow())) { | ||
509 | my_painter = new QDirectPainter(this); | ||
510 | } else { | ||
511 | return false; | ||
512 | } | ||
513 | } | ||
514 | my_locked++; // Increate lock refcount | ||
515 | return true; | ||
516 | } | ||
517 | |||
518 | void SDL_QWin::unlockScreen() { | ||
519 | if(my_locked > 0) { | ||
520 | my_locked--; // decrease lock refcount; | ||
521 | } | ||
522 | if(!my_locked && my_painter) { | ||
523 | my_painter->end(); | ||
524 | delete my_painter; | ||
525 | my_painter = 0; | ||
526 | } | ||
527 | } | ||
diff --git a/apps/plugins/sdl/src/video/qtopia/SDL_QWin.h b/apps/plugins/sdl/src/video/qtopia/SDL_QWin.h new file mode 100644 index 0000000000..2531834a91 --- /dev/null +++ b/apps/plugins/sdl/src/video/qtopia/SDL_QWin.h | |||
@@ -0,0 +1,110 @@ | |||
1 | /* | ||
2 | SDL - Simple DirectMedia Layer | ||
3 | Copyright (C) 1997-2012 Sam Lantinga | ||
4 | |||
5 | This library is free software; you can redistribute it and/or | ||
6 | modify it under the terms of the GNU Lesser General Public | ||
7 | License as published by the Free Software Foundation; either | ||
8 | version 2.1 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 | Lesser General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU Lesser General Public | ||
16 | License along with this library; if not, write to the Free Software | ||
17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
18 | |||
19 | Sam Lantinga | ||
20 | slouken@libsdl.org | ||
21 | */ | ||
22 | #include "SDL_config.h" | ||
23 | |||
24 | #ifndef _SDL_QWin_h | ||
25 | #define _SDL_QWin_h | ||
26 | |||
27 | #include <stdio.h> | ||
28 | |||
29 | #include <qimage.h> | ||
30 | #include <qpixmap.h> | ||
31 | #include <qwidget.h> | ||
32 | #include <qpainter.h> | ||
33 | #include <qdirectpainter_qws.h> | ||
34 | |||
35 | #include "SDL_events.h" | ||
36 | |||
37 | extern "C" { | ||
38 | #include "../../events/SDL_events_c.h" | ||
39 | }; | ||
40 | |||
41 | typedef enum { | ||
42 | SDL_QT_NO_ROTATION = 0, | ||
43 | SDL_QT_ROTATION_90, | ||
44 | SDL_QT_ROTATION_270 | ||
45 | } screenRotationT; | ||
46 | |||
47 | extern screenRotationT screenRotation; | ||
48 | |||
49 | class SDL_QWin : public QWidget | ||
50 | { | ||
51 | void QueueKey(QKeyEvent *e, int pressed); | ||
52 | public: | ||
53 | SDL_QWin(const QSize& size); | ||
54 | virtual ~SDL_QWin(); | ||
55 | virtual bool shown(void) { | ||
56 | return isVisible(); | ||
57 | } | ||
58 | /* If called, the next resize event will not be forwarded to SDL. */ | ||
59 | virtual void inhibitResize(void) { | ||
60 | my_inhibit_resize = true; | ||
61 | } | ||
62 | void setImage(QImage *image); | ||
63 | void setOffset(int x, int y) { | ||
64 | my_offset = QPoint(x, y); | ||
65 | } | ||
66 | void GetXYOffset(int &x, int &y) { | ||
67 | x = my_offset.x(); | ||
68 | y = my_offset.y(); | ||
69 | } | ||
70 | QImage *image(void) { return my_image; } | ||
71 | |||
72 | void setWFlags(WFlags flags) { | ||
73 | QWidget::setWFlags(flags); | ||
74 | my_flags = flags; | ||
75 | } | ||
76 | const QPoint& mousePos() const { return my_mouse_pos; } | ||
77 | void setMousePos(const QPoint& newpos); | ||
78 | void setFullscreen(bool); | ||
79 | |||
80 | bool lockScreen(bool force=false); | ||
81 | void unlockScreen(); | ||
82 | void repaintRect(const QRect& rect); | ||
83 | protected: | ||
84 | /* Handle resizing of the window */ | ||
85 | virtual void resizeEvent(QResizeEvent *e); | ||
86 | void focusInEvent(QFocusEvent *); | ||
87 | void focusOutEvent(QFocusEvent *); | ||
88 | void closeEvent(QCloseEvent *e); | ||
89 | void mouseMoveEvent(QMouseEvent *e); | ||
90 | void mousePressEvent(QMouseEvent *e); | ||
91 | void mouseReleaseEvent(QMouseEvent *e); | ||
92 | void paintEvent(QPaintEvent *ev); | ||
93 | void keyPressEvent(QKeyEvent *e) { QueueKey(e, 1); } | ||
94 | void keyReleaseEvent(QKeyEvent *e) { QueueKey(e, 0); } | ||
95 | private: | ||
96 | bool repaintRotation0(const QRect& rect); | ||
97 | bool repaintRotation1(const QRect& rect); | ||
98 | bool repaintRotation3(const QRect& rect); | ||
99 | void enableFullscreen(); | ||
100 | QDirectPainter *my_painter; | ||
101 | QImage *my_image; | ||
102 | bool my_inhibit_resize; | ||
103 | QPoint my_offset; | ||
104 | QPoint my_mouse_pos; | ||
105 | WFlags my_flags; | ||
106 | WFlags my_has_fullscreen; | ||
107 | unsigned int my_locked; | ||
108 | }; | ||
109 | |||
110 | #endif /* _SDL_QWin_h */ | ||
diff --git a/apps/plugins/sdl/src/video/qtopia/SDL_lowvideo.h b/apps/plugins/sdl/src/video/qtopia/SDL_lowvideo.h new file mode 100644 index 0000000000..1d05c72b14 --- /dev/null +++ b/apps/plugins/sdl/src/video/qtopia/SDL_lowvideo.h | |||
@@ -0,0 +1,65 @@ | |||
1 | /* | ||
2 | SDL - Simple DirectMedia Layer | ||
3 | Copyright (C) 1997-2012 Sam Lantinga | ||
4 | |||
5 | This library is free software; you can redistribute it and/or | ||
6 | modify it under the terms of the GNU Lesser General Public | ||
7 | License as published by the Free Software Foundation; either | ||
8 | version 2.1 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 | Lesser General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU Lesser General Public | ||
16 | License along with this library; if not, write to the Free Software | ||
17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
18 | |||
19 | Sam Lantinga | ||
20 | slouken@libsdl.org | ||
21 | */ | ||
22 | #include "SDL_config.h" | ||
23 | |||
24 | #ifndef _SDL_lowvideo_h | ||
25 | #define _SDL_lowvideo_h | ||
26 | |||
27 | #include "SDL_mouse.h" | ||
28 | #include "../SDL_sysvideo.h" | ||
29 | |||
30 | /* Hidden "this" pointer for the video functions */ | ||
31 | #define _THIS SDL_VideoDevice *_this | ||
32 | |||
33 | /* Private display data */ | ||
34 | struct SDL_PrivateVideoData { | ||
35 | /* The main window */ | ||
36 | SDL_QWin *SDL_Win; | ||
37 | |||
38 | /* The fullscreen mode list */ | ||
39 | #define NUM_MODELISTS 4 /* 8, 16, 24, and 32 bits-per-pixel */ | ||
40 | int SDL_nummodes[NUM_MODELISTS]; | ||
41 | SDL_Rect **SDL_modelist[NUM_MODELISTS]; | ||
42 | |||
43 | /* A completely clear cursor */ | ||
44 | WMcursor *BlankCursor; | ||
45 | |||
46 | /* Mouse state variables */ | ||
47 | Uint32 last_buttons; | ||
48 | QPoint last_point; | ||
49 | |||
50 | /* Keyboard state variables */ | ||
51 | int key_flip; | ||
52 | //struct key_info keyinfo[2]; | ||
53 | }; | ||
54 | /* Old variable names */ | ||
55 | #define SDL_Win (_this->hidden->SDL_Win) | ||
56 | #define saved_mode (_this->hidden->saved_mode) | ||
57 | #define SDL_nummodes (_this->hidden->SDL_nummodes) | ||
58 | #define SDL_modelist (_this->hidden->SDL_modelist) | ||
59 | #define SDL_BlankCursor (_this->hidden->BlankCursor) | ||
60 | #define last_buttons (_this->hidden->last_buttons) | ||
61 | #define last_point (_this->hidden->last_point) | ||
62 | #define key_flip (_this->hidden->key_flip) | ||
63 | #define keyinfo (_this->hidden->keyinfo) | ||
64 | |||
65 | #endif /* _SDL_lowvideo_h */ | ||
diff --git a/apps/plugins/sdl/src/video/qtopia/SDL_sysevents.cc b/apps/plugins/sdl/src/video/qtopia/SDL_sysevents.cc new file mode 100644 index 0000000000..4aaf81437c --- /dev/null +++ b/apps/plugins/sdl/src/video/qtopia/SDL_sysevents.cc | |||
@@ -0,0 +1,269 @@ | |||
1 | /* | ||
2 | SDL - Simple DirectMedia Layer | ||
3 | Copyright (C) 1997-2012 Sam Lantinga | ||
4 | |||
5 | This library is free software; you can redistribute it and/or | ||
6 | modify it under the terms of the GNU Lesser General Public | ||
7 | License as published by the Free Software Foundation; either | ||
8 | version 2.1 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 | Lesser General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU Lesser General Public | ||
16 | License along with this library; if not, write to the Free Software | ||
17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
18 | |||
19 | Sam Lantinga | ||
20 | slouken@libsdl.org | ||
21 | */ | ||
22 | #include "SDL_config.h" | ||
23 | |||
24 | #include <qpe/qpeapplication.h> | ||
25 | |||
26 | #include <stdio.h> | ||
27 | #include <string.h> | ||
28 | #include "SDL_error.h" | ||
29 | #include "SDL_events.h" | ||
30 | #include "SDL_QWin.h" | ||
31 | #include "SDL_lowvideo.h" | ||
32 | #include "SDL_timer.h" | ||
33 | |||
34 | extern "C" { | ||
35 | #include "../../events/SDL_sysevents.h" | ||
36 | #include "../../events/SDL_events_c.h" | ||
37 | #include "SDL_sysevents_c.h" | ||
38 | |||
39 | // static SDLKey keymap[128]; | ||
40 | /* This is special because we know it will be run in a loop in a separate | ||
41 | thread. Normally this function should loop as long as there are input | ||
42 | states changing, i.e. new events arriving. | ||
43 | */ | ||
44 | void QT_PumpEvents(_THIS) | ||
45 | { | ||
46 | if(!qApp) { | ||
47 | return; | ||
48 | } | ||
49 | // printf("processing events: %p\n", qApp); | ||
50 | //qApp->processOneEvent(); // wait for a event | ||
51 | qApp->processEvents(); // and process all outstanding ones | ||
52 | #if 0 | ||
53 | BView *view; | ||
54 | BRect bounds; | ||
55 | BPoint point; | ||
56 | uint32 buttons; | ||
57 | const uint32 button_masks[3] = { | ||
58 | B_PRIMARY_MOUSE_BUTTON, | ||
59 | B_TERTIARY_MOUSE_BUTTON, | ||
60 | B_SECONDARY_MOUSE_BUTTON, | ||
61 | }; | ||
62 | unsigned int i, j; | ||
63 | |||
64 | /* Check out the mouse buttons and position (slight race condition) */ | ||
65 | if ( SDL_Win->Lock() ) { | ||
66 | /* Don't do anything if we have no view */ | ||
67 | view = SDL_Win->View(); | ||
68 | if ( ! view ) { | ||
69 | SDL_Win->Unlock(); | ||
70 | return; | ||
71 | } | ||
72 | bounds = view->Bounds(); | ||
73 | /* Get new input state, if still active */ | ||
74 | if ( SDL_Win->IsActive() ) { | ||
75 | key_flip = !key_flip; | ||
76 | get_key_info(&keyinfo[key_flip]); | ||
77 | view->GetMouse(&point, &buttons, true); | ||
78 | } else { | ||
79 | key_flip = key_flip; | ||
80 | point = last_point; | ||
81 | buttons = last_buttons; | ||
82 | } | ||
83 | SDL_Win->Unlock(); | ||
84 | } else { | ||
85 | return; | ||
86 | } | ||
87 | |||
88 | /* If our view is active, we'll find key changes here */ | ||
89 | if ( SDL_memcmp(keyinfo[0].key_states, keyinfo[1].key_states, 16) != 0 ) { | ||
90 | for ( i=0; i<16; ++i ) { | ||
91 | Uint8 new_state, transition; | ||
92 | |||
93 | new_state = keyinfo[key_flip].key_states[i]; | ||
94 | transition = keyinfo[!key_flip].key_states[i] ^ | ||
95 | keyinfo[ key_flip].key_states[i]; | ||
96 | for ( j=0; j<8; ++j ) { | ||
97 | if ( transition&0x80 ) | ||
98 | QueueKey(i*8+j, new_state&0x80); | ||
99 | transition <<= 1; | ||
100 | new_state <<= 1; | ||
101 | } | ||
102 | } | ||
103 | } | ||
104 | |||
105 | /* We check keyboard, but not mouse if mouse isn't in window */ | ||
106 | if ( ! bounds.Contains(point) ) { | ||
107 | /* Mouse moved outside our view? */ | ||
108 | if ( SDL_GetAppState() & SDL_APPMOUSEFOCUS ) { | ||
109 | SDL_PrivateAppActive(0, SDL_APPMOUSEFOCUS); | ||
110 | be_app->SetCursor(B_HAND_CURSOR); | ||
111 | } | ||
112 | return; | ||
113 | } | ||
114 | /* Has the mouse moved back into our view? */ | ||
115 | if ( ! (SDL_GetAppState() & SDL_APPMOUSEFOCUS) ) { | ||
116 | /* Reset the B_HAND_CURSOR to our own */ | ||
117 | SDL_PrivateAppActive(1, SDL_APPMOUSEFOCUS); | ||
118 | SDL_SetCursor(NULL); | ||
119 | } | ||
120 | |||
121 | /* Check for mouse motion */ | ||
122 | if ( point != last_point ) { | ||
123 | int x, y; | ||
124 | |||
125 | SDL_Win->GetXYOffset(x, y); | ||
126 | x = (int)point.x - x; | ||
127 | y = (int)point.y - y; | ||
128 | SDL_PrivateMouseMotion(0, 0, x, y); | ||
129 | } | ||
130 | last_point = point; | ||
131 | |||
132 | /* Add any mouse button events */ | ||
133 | for ( i=0; i<SDL_TABLESIZE(button_masks); ++i ) { | ||
134 | if ( (buttons ^ last_buttons) & button_masks[i] ) { | ||
135 | if ( buttons & button_masks[i] ) { | ||
136 | SDL_PrivateMouseButton(SDL_PRESSED, 1+i, 0, 0); | ||
137 | } else { | ||
138 | SDL_PrivateMouseButton(SDL_RELEASED, 1+i, 0, 0); | ||
139 | } | ||
140 | } | ||
141 | } | ||
142 | last_buttons = buttons; | ||
143 | #endif | ||
144 | } | ||
145 | |||
146 | void QT_InitOSKeymap(_THIS) | ||
147 | { | ||
148 | #if 0 | ||
149 | unsigned int i; | ||
150 | |||
151 | /* Initialize all the key states as "up" */ | ||
152 | key_flip = 0; | ||
153 | SDL_memset(keyinfo[key_flip].key_states, 0, 16); | ||
154 | |||
155 | /* Initialize the key translation table */ | ||
156 | for ( i=0; i<SDL_TABLESIZE(keymap); ++i ) | ||
157 | keymap[i] = SDLK_UNKNOWN; | ||
158 | |||
159 | // keymap[0x01] = SDLK_ESCAPE; | ||
160 | // keymap[B_F1_KEY] = SDLK_F1; | ||
161 | // keymap[B_F2_KEY] = SDLK_F2; | ||
162 | // keymap[B_F3_KEY] = SDLK_F3; | ||
163 | // keymap[B_F4_KEY] = SDLK_F4; | ||
164 | // keymap[B_F5_KEY] = SDLK_F5; | ||
165 | // keymap[B_F6_KEY] = SDLK_F6; | ||
166 | // keymap[B_F7_KEY] = SDLK_F7; | ||
167 | // keymap[B_F8_KEY] = SDLK_F8; | ||
168 | // keymap[B_F9_KEY] = SDLK_F9; | ||
169 | // keymap[B_F10_KEY] = SDLK_F10; | ||
170 | // keymap[B_F11_KEY] = SDLK_F11; | ||
171 | // keymap[B_F12_KEY] = SDLK_F12; | ||
172 | // keymap[B_PRINT_KEY] = SDLK_PRINT; | ||
173 | //keymap[B_SCROLL_KEY] = SDLK_SCROLLOCK; | ||
174 | // keymap[B_PAUSE_KEY] = SDLK_PAUSE; | ||
175 | keymap[0x11] = SDLK_BACKQUOTE; | ||
176 | keymap[0x12] = SDLK_1; | ||
177 | keymap[0x13] = SDLK_2; | ||
178 | keymap[0x14] = SDLK_3; | ||
179 | keymap[0x15] = SDLK_4; | ||
180 | keymap[0x16] = SDLK_5; | ||
181 | keymap[0x17] = SDLK_6; | ||
182 | keymap[0x18] = SDLK_7; | ||
183 | keymap[0x19] = SDLK_8; | ||
184 | keymap[0x1a] = SDLK_9; | ||
185 | keymap[0x1b] = SDLK_0; | ||
186 | keymap[0x1c] = SDLK_MINUS; | ||
187 | keymap[0x1d] = SDLK_EQUALS; | ||
188 | keymap[0x1e] = SDLK_BACKSPACE; | ||
189 | keymap[0x1f] = SDLK_INSERT; | ||
190 | keymap[0x20] = SDLK_HOME; | ||
191 | keymap[0x21] = SDLK_PAGEUP; | ||
192 | //keymap[0x22] = SDLK_NUMLOCK; | ||
193 | keymap[0x23] = SDLK_KP_DIVIDE; | ||
194 | keymap[0x24] = SDLK_KP_MULTIPLY; | ||
195 | keymap[0x25] = SDLK_KP_MINUS; | ||
196 | keymap[0x26] = SDLK_TAB; | ||
197 | keymap[0x27] = SDLK_q; | ||
198 | keymap[0x28] = SDLK_w; | ||
199 | keymap[0x29] = SDLK_e; | ||
200 | keymap[0x2a] = SDLK_r; | ||
201 | keymap[0x2b] = SDLK_t; | ||
202 | keymap[0x2c] = SDLK_y; | ||
203 | keymap[0x2d] = SDLK_u; | ||
204 | keymap[0x2e] = SDLK_i; | ||
205 | keymap[0x2f] = SDLK_o; | ||
206 | keymap[0x30] = SDLK_p; | ||
207 | keymap[0x31] = SDLK_LEFTBRACKET; | ||
208 | keymap[0x32] = SDLK_RIGHTBRACKET; | ||
209 | keymap[0x33] = SDLK_BACKSLASH; | ||
210 | keymap[0x34] = SDLK_DELETE; | ||
211 | keymap[0x35] = SDLK_END; | ||
212 | keymap[0x36] = SDLK_PAGEDOWN; | ||
213 | keymap[0x37] = SDLK_KP7; | ||
214 | keymap[0x38] = SDLK_KP8; | ||
215 | keymap[0x39] = SDLK_KP9; | ||
216 | keymap[0x3a] = SDLK_KP_PLUS; | ||
217 | //keymap[0x3b] = SDLK_CAPSLOCK; | ||
218 | keymap[0x3c] = SDLK_a; | ||
219 | keymap[0x3d] = SDLK_s; | ||
220 | keymap[0x3e] = SDLK_d; | ||
221 | keymap[0x3f] = SDLK_f; | ||
222 | keymap[0x40] = SDLK_g; | ||
223 | keymap[0x41] = SDLK_h; | ||
224 | keymap[0x42] = SDLK_j; | ||
225 | keymap[0x43] = SDLK_k; | ||
226 | keymap[0x44] = SDLK_l; | ||
227 | keymap[0x45] = SDLK_SEMICOLON; | ||
228 | keymap[0x46] = SDLK_QUOTE; | ||
229 | keymap[0x47] = SDLK_RETURN; | ||
230 | keymap[0x48] = SDLK_KP4; | ||
231 | keymap[0x49] = SDLK_KP5; | ||
232 | keymap[0x4a] = SDLK_KP6; | ||
233 | keymap[0x4b] = SDLK_LSHIFT; | ||
234 | keymap[0x4c] = SDLK_z; | ||
235 | keymap[0x4d] = SDLK_x; | ||
236 | keymap[0x4e] = SDLK_c; | ||
237 | keymap[0x4f] = SDLK_v; | ||
238 | keymap[0x50] = SDLK_b; | ||
239 | keymap[0x51] = SDLK_n; | ||
240 | keymap[0x52] = SDLK_m; | ||
241 | keymap[0x53] = SDLK_COMMA; | ||
242 | keymap[0x54] = SDLK_PERIOD; | ||
243 | keymap[0x55] = SDLK_SLASH; | ||
244 | keymap[0x56] = SDLK_RSHIFT; | ||
245 | keymap[0x57] = SDLK_UP; | ||
246 | keymap[0x58] = SDLK_KP1; | ||
247 | keymap[0x59] = SDLK_KP2; | ||
248 | keymap[0x5a] = SDLK_KP3; | ||
249 | keymap[0x5b] = SDLK_KP_ENTER; | ||
250 | //keymap[0x5c] = SDLK_LCTRL; | ||
251 | //keymap[0x5d] = SDLK_LALT; | ||
252 | keymap[0x5e] = SDLK_SPACE; | ||
253 | //keymap[0x5f] = SDLK_RALT; | ||
254 | //keymap[0x60] = SDLK_RCTRL; | ||
255 | keymap[0x61] = SDLK_LEFT; | ||
256 | keymap[0x62] = SDLK_DOWN; | ||
257 | keymap[0x63] = SDLK_RIGHT; | ||
258 | keymap[0x64] = SDLK_KP0; | ||
259 | keymap[0x65] = SDLK_KP_PERIOD; | ||
260 | //keymap[0x66] = SDLK_LMETA; | ||
261 | //keymap[0x67] = SDLK_RMETA; | ||
262 | //keymap[0x68] = SDLK_MENU; | ||
263 | keymap[0x69] = SDLK_EURO; | ||
264 | keymap[0x6a] = SDLK_KP_EQUALS; | ||
265 | keymap[0x6b] = SDLK_POWER; | ||
266 | #endif | ||
267 | } | ||
268 | |||
269 | }; /* Extern C */ | ||
diff --git a/apps/plugins/sdl/src/video/qtopia/SDL_sysevents_c.h b/apps/plugins/sdl/src/video/qtopia/SDL_sysevents_c.h new file mode 100644 index 0000000000..5e267592de --- /dev/null +++ b/apps/plugins/sdl/src/video/qtopia/SDL_sysevents_c.h | |||
@@ -0,0 +1,31 @@ | |||
1 | /* | ||
2 | SDL - Simple DirectMedia Layer | ||
3 | Copyright (C) 1997-2012 Sam Lantinga | ||
4 | |||
5 | This library is free software; you can redistribute it and/or | ||
6 | modify it under the terms of the GNU Lesser General Public | ||
7 | License as published by the Free Software Foundation; either | ||
8 | version 2.1 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 | Lesser General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU Lesser General Public | ||
16 | License along with this library; if not, write to the Free Software | ||
17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
18 | |||
19 | Sam Lantinga | ||
20 | slouken@libsdl.org | ||
21 | */ | ||
22 | #include "SDL_config.h" | ||
23 | |||
24 | #include "SDL_lowvideo.h" | ||
25 | |||
26 | /* Variables and functions exported by SDL_sysevents.c to other parts | ||
27 | of the native video subsystem (SDL_sysvideo.c) | ||
28 | */ | ||
29 | |||
30 | extern void QT_InitOSKeymap(_THIS); | ||
31 | extern void QT_PumpEvents(_THIS); | ||
diff --git a/apps/plugins/sdl/src/video/qtopia/SDL_sysmouse.cc b/apps/plugins/sdl/src/video/qtopia/SDL_sysmouse.cc new file mode 100644 index 0000000000..1a655b6f3d --- /dev/null +++ b/apps/plugins/sdl/src/video/qtopia/SDL_sysmouse.cc | |||
@@ -0,0 +1,56 @@ | |||
1 | /* | ||
2 | SDL - Simple DirectMedia Layer | ||
3 | Copyright (C) 1997-2012 Sam Lantinga | ||
4 | |||
5 | This library is free software; you can redistribute it and/or | ||
6 | modify it under the terms of the GNU Lesser General Public | ||
7 | License as published by the Free Software Foundation; either | ||
8 | version 2.1 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 | Lesser General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU Lesser General Public | ||
16 | License along with this library; if not, write to the Free Software | ||
17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
18 | |||
19 | Sam Lantinga | ||
20 | slouken@libsdl.org | ||
21 | */ | ||
22 | #include "SDL_config.h" | ||
23 | |||
24 | #include "SDL_QWin.h" | ||
25 | |||
26 | extern "C" { | ||
27 | |||
28 | #include "SDL_sysmouse_c.h" | ||
29 | |||
30 | /* The implementation dependent data for the window manager cursor */ | ||
31 | struct WMcursor { | ||
32 | char *bits; | ||
33 | }; | ||
34 | WMcursor *QT_CreateWMCursor(_THIS, | ||
35 | Uint8 *data, Uint8 *mask, int w, int h, int hot_x, int hot_y) | ||
36 | { | ||
37 | static WMcursor dummy; | ||
38 | dummy.bits = 0; | ||
39 | return &dummy; | ||
40 | } | ||
41 | |||
42 | int QT_ShowWMCursor(_THIS, WMcursor *cursor) | ||
43 | { | ||
44 | return 1; | ||
45 | } | ||
46 | |||
47 | void QT_FreeWMCursor(_THIS, WMcursor *cursor) | ||
48 | { | ||
49 | } | ||
50 | |||
51 | void QT_WarpWMCursor(_THIS, Uint16 x, Uint16 y) | ||
52 | { | ||
53 | SDL_Win->setMousePos(QPoint(x, y)); | ||
54 | } | ||
55 | |||
56 | }; /* Extern C */ | ||
diff --git a/apps/plugins/sdl/src/video/qtopia/SDL_sysmouse_c.h b/apps/plugins/sdl/src/video/qtopia/SDL_sysmouse_c.h new file mode 100644 index 0000000000..98e4cf5f36 --- /dev/null +++ b/apps/plugins/sdl/src/video/qtopia/SDL_sysmouse_c.h | |||
@@ -0,0 +1,32 @@ | |||
1 | /* | ||
2 | SDL - Simple DirectMedia Layer | ||
3 | Copyright (C) 1997-2012 Sam Lantinga | ||
4 | |||
5 | This library is free software; you can redistribute it and/or | ||
6 | modify it under the terms of the GNU Lesser General Public | ||
7 | License as published by the Free Software Foundation; either | ||
8 | version 2.1 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 | Lesser General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU Lesser General Public | ||
16 | License along with this library; if not, write to the Free Software | ||
17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
18 | |||
19 | Sam Lantinga | ||
20 | slouken@libsdl.org | ||
21 | */ | ||
22 | #include "SDL_config.h" | ||
23 | |||
24 | #include "SDL_lowvideo.h" | ||
25 | |||
26 | /* Functions to be exported */ | ||
27 | extern void QT_FreeWMCursor(_THIS, WMcursor *cursor); | ||
28 | extern WMcursor *QT_CreateWMCursor(_THIS, | ||
29 | Uint8 *data, Uint8 *mask, int w, int h, int hot_x, int hot_y); | ||
30 | extern int QT_ShowWMCursor(_THIS, WMcursor *cursor); | ||
31 | extern void QT_WarpWMCursor(_THIS, Uint16 x, Uint16 y); | ||
32 | |||
diff --git a/apps/plugins/sdl/src/video/qtopia/SDL_sysvideo.cc b/apps/plugins/sdl/src/video/qtopia/SDL_sysvideo.cc new file mode 100644 index 0000000000..0e07874c7a --- /dev/null +++ b/apps/plugins/sdl/src/video/qtopia/SDL_sysvideo.cc | |||
@@ -0,0 +1,403 @@ | |||
1 | /* | ||
2 | SDL - Simple DirectMedia Layer | ||
3 | Copyright (C) 1997-2012 Sam Lantinga | ||
4 | |||
5 | This library is free software; you can redistribute it and/or | ||
6 | modify it under the terms of the GNU Lesser General Public | ||
7 | License as published by the Free Software Foundation; either | ||
8 | version 2.1 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 | Lesser General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU Lesser General Public | ||
16 | License along with this library; if not, write to the Free Software | ||
17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
18 | |||
19 | Sam Lantinga | ||
20 | slouken@libsdl.org | ||
21 | */ | ||
22 | #include "SDL_config.h" | ||
23 | |||
24 | /* Qtopia based framebuffer implementation */ | ||
25 | |||
26 | #include <unistd.h> | ||
27 | |||
28 | #include <qapplication.h> | ||
29 | #include <qpe/qpeapplication.h> | ||
30 | |||
31 | #include "SDL_timer.h" | ||
32 | |||
33 | #include "SDL_QWin.h" | ||
34 | |||
35 | extern "C" { | ||
36 | |||
37 | #include "../SDL_sysvideo.h" | ||
38 | #include "../../events/SDL_events_c.h" | ||
39 | #include "SDL_sysevents_c.h" | ||
40 | #include "SDL_sysmouse_c.h" | ||
41 | #include "SDL_syswm_c.h" | ||
42 | #include "SDL_lowvideo.h" | ||
43 | |||
44 | //#define QTOPIA_DEBUG | ||
45 | #define QT_HIDDEN_SIZE 32 /* starting hidden window size */ | ||
46 | |||
47 | /* Name of the environment variable used to invert the screen rotation or not: | ||
48 | Possible values: | ||
49 | !=0 : Screen is 270° rotated | ||
50 | 0: Screen is 90° rotated*/ | ||
51 | #define SDL_QT_ROTATION_ENV_NAME "SDL_QT_INVERT_ROTATION" | ||
52 | |||
53 | /* Initialization/Query functions */ | ||
54 | static int QT_VideoInit(_THIS, SDL_PixelFormat *vformat); | ||
55 | static SDL_Rect **QT_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags); | ||
56 | static SDL_Surface *QT_SetVideoMode(_THIS, SDL_Surface *current, int width, int height, int bpp, Uint32 flags); | ||
57 | static void QT_UpdateMouse(_THIS); | ||
58 | static int QT_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors); | ||
59 | static void QT_VideoQuit(_THIS); | ||
60 | |||
61 | /* Hardware surface functions */ | ||
62 | static int QT_AllocHWSurface(_THIS, SDL_Surface *surface); | ||
63 | static int QT_LockHWSurface(_THIS, SDL_Surface *surface); | ||
64 | static void QT_UnlockHWSurface(_THIS, SDL_Surface *surface); | ||
65 | static void QT_FreeHWSurface(_THIS, SDL_Surface *surface); | ||
66 | |||
67 | static int QT_ToggleFullScreen(_THIS, int fullscreen); | ||
68 | |||
69 | static int QT_IconifyWindow(_THIS); | ||
70 | static SDL_GrabMode QT_GrabInput(_THIS, SDL_GrabMode mode); | ||
71 | |||
72 | /* FB driver bootstrap functions */ | ||
73 | |||
74 | static int QT_Available(void) | ||
75 | { | ||
76 | return(1); | ||
77 | } | ||
78 | |||
79 | static void QT_DeleteDevice(SDL_VideoDevice *device) | ||
80 | { | ||
81 | SDL_free(device->hidden); | ||
82 | SDL_free(device); | ||
83 | } | ||
84 | |||
85 | static SDL_VideoDevice *QT_CreateDevice(int devindex) | ||
86 | { | ||
87 | SDL_VideoDevice *device; | ||
88 | |||
89 | /* Initialize all variables that we clean on shutdown */ | ||
90 | device = (SDL_VideoDevice *)SDL_malloc(sizeof(SDL_VideoDevice)); | ||
91 | if ( device ) { | ||
92 | SDL_memset(device, 0, (sizeof *device)); | ||
93 | device->hidden = (struct SDL_PrivateVideoData *) | ||
94 | SDL_malloc((sizeof *device->hidden)); | ||
95 | } | ||
96 | if ( (device == NULL) || (device->hidden == NULL) ) { | ||
97 | SDL_OutOfMemory(); | ||
98 | if ( device ) { | ||
99 | SDL_free(device); | ||
100 | } | ||
101 | return(0); | ||
102 | } | ||
103 | SDL_memset(device->hidden, 0, (sizeof *device->hidden)); | ||
104 | |||
105 | /* Set the function pointers */ | ||
106 | device->VideoInit = QT_VideoInit; | ||
107 | device->ListModes = QT_ListModes; | ||
108 | device->SetVideoMode = QT_SetVideoMode; | ||
109 | device->UpdateMouse = QT_UpdateMouse; | ||
110 | device->SetColors = QT_SetColors; | ||
111 | device->UpdateRects = NULL; | ||
112 | device->VideoQuit = QT_VideoQuit; | ||
113 | device->AllocHWSurface = QT_AllocHWSurface; | ||
114 | device->CheckHWBlit = NULL; | ||
115 | device->FillHWRect = NULL; | ||
116 | device->SetHWColorKey = NULL; | ||
117 | device->SetHWAlpha = NULL; | ||
118 | device->LockHWSurface = QT_LockHWSurface; | ||
119 | device->UnlockHWSurface = QT_UnlockHWSurface; | ||
120 | device->FlipHWSurface = NULL; | ||
121 | device->FreeHWSurface = QT_FreeHWSurface; | ||
122 | device->SetIcon = NULL; | ||
123 | device->SetCaption = QT_SetWMCaption; | ||
124 | device->IconifyWindow = QT_IconifyWindow; | ||
125 | device->GrabInput = QT_GrabInput; | ||
126 | device->GetWMInfo = NULL; | ||
127 | device->FreeWMCursor = QT_FreeWMCursor; | ||
128 | device->CreateWMCursor = QT_CreateWMCursor; | ||
129 | device->ShowWMCursor = QT_ShowWMCursor; | ||
130 | device->WarpWMCursor = QT_WarpWMCursor; | ||
131 | device->InitOSKeymap = QT_InitOSKeymap; | ||
132 | device->PumpEvents = QT_PumpEvents; | ||
133 | |||
134 | device->free = QT_DeleteDevice; | ||
135 | device->ToggleFullScreen = QT_ToggleFullScreen; | ||
136 | |||
137 | /* Set the driver flags */ | ||
138 | device->handles_any_size = 0; | ||
139 | |||
140 | return device; | ||
141 | } | ||
142 | |||
143 | VideoBootStrap Qtopia_bootstrap = { | ||
144 | "qtopia", "Qtopia / QPE graphics", | ||
145 | QT_Available, QT_CreateDevice | ||
146 | }; | ||
147 | |||
148 | /* Function to sort the display_list */ | ||
149 | static int CompareModes(const void *A, const void *B) | ||
150 | { | ||
151 | #if 0 | ||
152 | const display_mode *a = (display_mode *)A; | ||
153 | const display_mode *b = (display_mode *)B; | ||
154 | |||
155 | if ( a->space == b->space ) { | ||
156 | return((b->virtual_width*b->virtual_height)- | ||
157 | (a->virtual_width*a->virtual_height)); | ||
158 | } else { | ||
159 | return(ColorSpaceToBitsPerPixel(b->space)- | ||
160 | ColorSpaceToBitsPerPixel(a->space)); | ||
161 | } | ||
162 | #endif | ||
163 | return 0; | ||
164 | } | ||
165 | |||
166 | /* Yes, this isn't the fastest it could be, but it works nicely */ | ||
167 | static int QT_AddMode(_THIS, int index, unsigned int w, unsigned int h) | ||
168 | { | ||
169 | SDL_Rect *mode; | ||
170 | int i; | ||
171 | int next_mode; | ||
172 | |||
173 | /* Check to see if we already have this mode */ | ||
174 | if ( SDL_nummodes[index] > 0 ) { | ||
175 | for ( i=SDL_nummodes[index]-1; i >= 0; --i ) { | ||
176 | mode = SDL_modelist[index][i]; | ||
177 | if ( (mode->w == w) && (mode->h == h) ) { | ||
178 | return(0); | ||
179 | } | ||
180 | } | ||
181 | } | ||
182 | |||
183 | /* Set up the new video mode rectangle */ | ||
184 | mode = (SDL_Rect *)SDL_malloc(sizeof *mode); | ||
185 | if ( mode == NULL ) { | ||
186 | SDL_OutOfMemory(); | ||
187 | return(-1); | ||
188 | } | ||
189 | mode->x = 0; | ||
190 | mode->y = 0; | ||
191 | mode->w = w; | ||
192 | mode->h = h; | ||
193 | #ifdef QTOPIA_DEBUG | ||
194 | fprintf(stderr, "Adding mode %dx%d at %d bytes per pixel\n", w, h, index+1); | ||
195 | #endif | ||
196 | |||
197 | /* Allocate the new list of modes, and fill in the new mode */ | ||
198 | next_mode = SDL_nummodes[index]; | ||
199 | SDL_modelist[index] = (SDL_Rect **) | ||
200 | SDL_realloc(SDL_modelist[index], (1+next_mode+1)*sizeof(SDL_Rect *)); | ||
201 | if ( SDL_modelist[index] == NULL ) { | ||
202 | SDL_OutOfMemory(); | ||
203 | SDL_nummodes[index] = 0; | ||
204 | SDL_free(mode); | ||
205 | return(-1); | ||
206 | } | ||
207 | SDL_modelist[index][next_mode] = mode; | ||
208 | SDL_modelist[index][next_mode+1] = NULL; | ||
209 | SDL_nummodes[index]++; | ||
210 | |||
211 | return(0); | ||
212 | } | ||
213 | |||
214 | int QT_VideoInit(_THIS, SDL_PixelFormat *vformat) | ||
215 | { | ||
216 | /* Initialize the QPE Application */ | ||
217 | /* Determine the screen depth */ | ||
218 | vformat->BitsPerPixel = QPixmap::defaultDepth(); | ||
219 | |||
220 | // For now we hardcode the current depth because anything else | ||
221 | // might as well be emulated by SDL rather than by Qtopia. | ||
222 | |||
223 | QSize desktop_size = qApp->desktop()->size(); | ||
224 | QT_AddMode(_this, ((vformat->BitsPerPixel+7)/8)-1, | ||
225 | desktop_size.width(), desktop_size.height()); | ||
226 | QT_AddMode(_this, ((vformat->BitsPerPixel+7)/8)-1, | ||
227 | desktop_size.height(), desktop_size.width()); | ||
228 | |||
229 | /* Determine the current screen size */ | ||
230 | _this->info.current_w = desktop_size.width(); | ||
231 | _this->info.current_h = desktop_size.height(); | ||
232 | |||
233 | /* Create the window / widget */ | ||
234 | SDL_Win = new SDL_QWin(QSize(QT_HIDDEN_SIZE, QT_HIDDEN_SIZE)); | ||
235 | ((QPEApplication*)qApp)->showMainWidget(SDL_Win); | ||
236 | /* Fill in some window manager capabilities */ | ||
237 | _this->info.wm_available = 0; | ||
238 | |||
239 | /* We're done! */ | ||
240 | return(0); | ||
241 | } | ||
242 | |||
243 | /* We support any dimension at our bit-depth */ | ||
244 | SDL_Rect **QT_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags) | ||
245 | { | ||
246 | SDL_Rect **modes; | ||
247 | |||
248 | modes = ((SDL_Rect **)0); | ||
249 | if ( (flags & SDL_FULLSCREEN) == SDL_FULLSCREEN ) { | ||
250 | modes = SDL_modelist[((format->BitsPerPixel+7)/8)-1]; | ||
251 | } else { | ||
252 | if ( format->BitsPerPixel == | ||
253 | _this->screen->format->BitsPerPixel ) { | ||
254 | modes = ((SDL_Rect **)-1); | ||
255 | } | ||
256 | } | ||
257 | return(modes); | ||
258 | } | ||
259 | |||
260 | /* Various screen update functions available */ | ||
261 | static void QT_NormalUpdate(_THIS, int numrects, SDL_Rect *rects); | ||
262 | |||
263 | |||
264 | static int QT_SetFullScreen(_THIS, SDL_Surface *screen, int fullscreen) | ||
265 | { | ||
266 | return -1; | ||
267 | } | ||
268 | |||
269 | static int QT_ToggleFullScreen(_THIS, int fullscreen) | ||
270 | { | ||
271 | return -1; | ||
272 | } | ||
273 | |||
274 | /* FIXME: check return values and cleanup here */ | ||
275 | SDL_Surface *QT_SetVideoMode(_THIS, SDL_Surface *current, | ||
276 | int width, int height, int bpp, Uint32 flags) | ||
277 | { | ||
278 | |||
279 | QImage *qimage; | ||
280 | QSize desktop_size = qApp->desktop()->size(); | ||
281 | |||
282 | |||
283 | current->flags = 0; //SDL_FULLSCREEN; // We always run fullscreen. | ||
284 | |||
285 | if(width <= desktop_size.width() | ||
286 | && height <= desktop_size.height()) { | ||
287 | current->w = desktop_size.width(); | ||
288 | current->h = desktop_size.height(); | ||
289 | } else if(width <= desktop_size.height() && height <= desktop_size.width()) { | ||
290 | // Landscape mode | ||
291 | char * envString = SDL_getenv(SDL_QT_ROTATION_ENV_NAME); | ||
292 | int envValue = envString ? atoi(envString) : 0; | ||
293 | screenRotation = envValue ? SDL_QT_ROTATION_270 : SDL_QT_ROTATION_90; | ||
294 | current->h = desktop_size.width(); | ||
295 | current->w = desktop_size.height(); | ||
296 | } else { | ||
297 | SDL_SetError("Unsupported resolution, %dx%d\n", width, height); | ||
298 | } | ||
299 | if ( flags & SDL_OPENGL ) { | ||
300 | SDL_SetError("OpenGL not supported"); | ||
301 | return(NULL); | ||
302 | } | ||
303 | /* Create the QImage framebuffer */ | ||
304 | qimage = new QImage(current->w, current->h, bpp); | ||
305 | if (qimage->isNull()) { | ||
306 | SDL_SetError("Couldn't create screen bitmap"); | ||
307 | delete qimage; | ||
308 | return(NULL); | ||
309 | } | ||
310 | current->pitch = qimage->bytesPerLine(); | ||
311 | current->pixels = (void *)qimage->bits(); | ||
312 | SDL_Win->setImage(qimage); | ||
313 | _this->UpdateRects = QT_NormalUpdate; | ||
314 | SDL_Win->setFullscreen(true); | ||
315 | /* We're done */ | ||
316 | return(current); | ||
317 | } | ||
318 | |||
319 | /* Update the current mouse state and position */ | ||
320 | void QT_UpdateMouse(_THIS) | ||
321 | { | ||
322 | QPoint point(-1, -1); | ||
323 | if ( SDL_Win->isActiveWindow() ) { | ||
324 | point = SDL_Win->mousePos(); | ||
325 | } | ||
326 | |||
327 | if ( (point.x() >= 0) && (point.x() < SDL_VideoSurface->w) && | ||
328 | (point.y() >= 0) && (point.y() < SDL_VideoSurface->h) ) { | ||
329 | SDL_PrivateAppActive(1, SDL_APPMOUSEFOCUS); | ||
330 | SDL_PrivateMouseMotion(0, 0, | ||
331 | (Sint16)point.x(), (Sint16)point.y()); | ||
332 | } else { | ||
333 | SDL_PrivateAppActive(0, SDL_APPMOUSEFOCUS); | ||
334 | } | ||
335 | } | ||
336 | |||
337 | /* We don't actually allow hardware surfaces other than the main one */ | ||
338 | static int QT_AllocHWSurface(_THIS, SDL_Surface *surface) | ||
339 | { | ||
340 | return(-1); | ||
341 | } | ||
342 | static void QT_FreeHWSurface(_THIS, SDL_Surface *surface) | ||
343 | { | ||
344 | return; | ||
345 | } | ||
346 | static int QT_LockHWSurface(_THIS, SDL_Surface *surface) | ||
347 | { | ||
348 | return(0); | ||
349 | } | ||
350 | static void QT_UnlockHWSurface(_THIS, SDL_Surface *surface) | ||
351 | { | ||
352 | return; | ||
353 | } | ||
354 | |||
355 | static void QT_NormalUpdate(_THIS, int numrects, SDL_Rect *rects) | ||
356 | { | ||
357 | if(SDL_Win->lockScreen()) { | ||
358 | for(int i=0; i<numrects; ++i ) { | ||
359 | QRect rect(rects[i].x, rects[i].y, | ||
360 | rects[i].w, rects[i].h); | ||
361 | SDL_Win->repaintRect(rect); | ||
362 | } | ||
363 | SDL_Win->unlockScreen(); | ||
364 | } | ||
365 | } | ||
366 | /* Is the system palette settable? */ | ||
367 | int QT_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors) | ||
368 | { | ||
369 | return -1; | ||
370 | } | ||
371 | |||
372 | void QT_VideoQuit(_THIS) | ||
373 | { | ||
374 | // This is dumb, but if I free this, the app doesn't exit correctly. | ||
375 | // Of course, this will leak memory if init video is done more than once. | ||
376 | // Sucks but such is life. | ||
377 | |||
378 | // -- David Hedbor | ||
379 | // delete SDL_Win; | ||
380 | // SDL_Win = 0; | ||
381 | _this->screen->pixels = NULL; | ||
382 | QT_GrabInput(_this, SDL_GRAB_OFF); | ||
383 | } | ||
384 | |||
385 | static int QT_IconifyWindow(_THIS) { | ||
386 | SDL_Win->hide(); | ||
387 | |||
388 | return true; | ||
389 | } | ||
390 | |||
391 | static SDL_GrabMode QT_GrabInput(_THIS, SDL_GrabMode mode) { | ||
392 | if(mode == SDL_GRAB_OFF) { | ||
393 | QPEApplication::grabKeyboard(); | ||
394 | qApp->processEvents(); | ||
395 | QPEApplication::ungrabKeyboard(); | ||
396 | } else { | ||
397 | QPEApplication::grabKeyboard(); | ||
398 | } | ||
399 | qApp->processEvents(); | ||
400 | return mode; | ||
401 | } | ||
402 | |||
403 | }; /* Extern C */ | ||
diff --git a/apps/plugins/sdl/src/video/qtopia/SDL_syswm.cc b/apps/plugins/sdl/src/video/qtopia/SDL_syswm.cc new file mode 100644 index 0000000000..47f988f4bd --- /dev/null +++ b/apps/plugins/sdl/src/video/qtopia/SDL_syswm.cc | |||
@@ -0,0 +1,35 @@ | |||
1 | /* | ||
2 | SDL - Simple DirectMedia Layer | ||
3 | Copyright (C) 1997-2012 Sam Lantinga | ||
4 | |||
5 | This library is free software; you can redistribute it and/or | ||
6 | modify it under the terms of the GNU Lesser General Public | ||
7 | License as published by the Free Software Foundation; either | ||
8 | version 2.1 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 | Lesser General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU Lesser General Public | ||
16 | License along with this library; if not, write to the Free Software | ||
17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
18 | |||
19 | Sam Lantinga | ||
20 | slouken@libsdl.org | ||
21 | */ | ||
22 | #include "SDL_config.h" | ||
23 | |||
24 | #include "SDL_QWin.h" | ||
25 | |||
26 | extern "C" { | ||
27 | |||
28 | #include "SDL_syswm_c.h" | ||
29 | |||
30 | void QT_SetWMCaption(_THIS, const char *title, const char *icon) | ||
31 | { | ||
32 | SDL_Win->setCaption(title); | ||
33 | } | ||
34 | |||
35 | }; /* Extern C */ | ||
diff --git a/apps/plugins/sdl/src/video/qtopia/SDL_syswm_c.h b/apps/plugins/sdl/src/video/qtopia/SDL_syswm_c.h new file mode 100644 index 0000000000..4e4326b5a1 --- /dev/null +++ b/apps/plugins/sdl/src/video/qtopia/SDL_syswm_c.h | |||
@@ -0,0 +1,28 @@ | |||
1 | /* | ||
2 | SDL - Simple DirectMedia Layer | ||
3 | Copyright (C) 1997-2012 Sam Lantinga | ||
4 | |||
5 | This library is free software; you can redistribute it and/or | ||
6 | modify it under the terms of the GNU Lesser General Public | ||
7 | License as published by the Free Software Foundation; either | ||
8 | version 2.1 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 | Lesser General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU Lesser General Public | ||
16 | License along with this library; if not, write to the Free Software | ||
17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
18 | |||
19 | Sam Lantinga | ||
20 | slouken@libsdl.org | ||
21 | */ | ||
22 | #include "SDL_config.h" | ||
23 | |||
24 | #include "SDL_lowvideo.h" | ||
25 | |||
26 | /* Functions to be exported */ | ||
27 | extern void QT_SetWMCaption(_THIS, const char *title, const char *icon); | ||
28 | |||