Mercurial > sdl-ios-xcode
annotate src/video/qtopia/SDL_QWin.cc @ 379:11c8a7684f74
Date: Fri, 24 May 2002 10:32:00 -0700
From: David Hedbor <david@hedbor.org>
Subject: more patches
Ok, another thing I discovered when porting prboom to the Zaurus -
mouse events weren't rotated when the screen was (i.e you got
incorrect events there).
This is now fixed. Also noticed that SDL_WarpMouse isn't handled
correctly, but I haven't looked at fixing that yes.
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Tue, 28 May 2002 19:24:11 +0000 |
parents | db0cc6034336 |
children | c96e2137f9eb |
rev | line source |
---|---|
371
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1 /* |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2 SDL - Simple DirectMedia Layer |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3 Copyright (C) 1997, 1998, 1999, 2000, 2001 Sam Lantinga |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4 |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5 This library is free software; you can redistribute it and/or |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
6 modify it under the terms of the GNU Library General Public |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
7 License as published by the Free Software Foundation; either |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
8 version 2 of the License, or (at your option) any later version. |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
9 |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
10 This library is distributed in the hope that it will be useful, |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
11 but WITHOUT ANY WARRANTY; without even the implied warranty of |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
13 Library General Public License for more details. |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
14 |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
15 You should have received a copy of the GNU Library General Public |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
16 License along with this library; if not, write to the Free |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
18 |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
19 Sam Lantinga |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
20 slouken@libsdl.org |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
21 */ |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
22 |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
23 #ifdef SAVE_RCSID |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
24 static char rcsid = |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
25 "@(#) $Id$"; |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
26 #endif |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
27 |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
28 #include "SDL_QWin.h" |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
29 #include <qapplication.h> |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
30 #include <qdirectpainter_qws.h> |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
31 SDL_QWin::SDL_QWin(const QSize& size) |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
32 : QWidget(0, "SDL_main"), my_painter(0), my_image(0), |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
33 my_inhibit_resize(false), my_mouse_pos(-1,-1), my_flags(0), |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
34 my_has_fullscreen(false), my_locked(0) |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
35 { |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
36 setBackgroundMode(NoBackground); |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
37 } |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
38 |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
39 SDL_QWin::~SDL_QWin() { |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
40 // Nothing to do yet. |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
41 if(my_image) { |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
42 delete my_image; |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
43 } |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
44 } |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
45 |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
46 void SDL_QWin::setImage(QImage *image) { |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
47 if ( my_image ) { |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
48 delete my_image; |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
49 } |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
50 my_image = image; |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
51 // setFixedSize(image->size()); |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
52 } |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
53 |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
54 void SDL_QWin::resizeEvent(QResizeEvent *e) { |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
55 if(size() != qApp->desktop()->size()) { |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
56 // Widget is not the correct size, so do the fullscreen magic |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
57 my_has_fullscreen = false; |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
58 enableFullscreen(); |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
59 } |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
60 if(my_inhibit_resize) { |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
61 my_inhibit_resize = false; |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
62 } else { |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
63 SDL_PrivateResize(e->size().width(), e->size().height()); |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
64 } |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
65 } |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
66 |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
67 void SDL_QWin::focusInEvent(QFocusEvent *) { |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
68 // Always do it here, no matter the size. |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
69 enableFullscreen(); |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
70 SDL_PrivateAppActive(true, SDL_APPINPUTFOCUS); |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
71 } |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
72 |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
73 void SDL_QWin::focusOutEvent(QFocusEvent *) { |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
74 my_has_fullscreen = false; |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
75 SDL_PrivateAppActive(false, SDL_APPINPUTFOCUS); |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
76 } |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
77 |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
78 void SDL_QWin::closeEvent(QCloseEvent *e) { |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
79 SDL_PrivateQuit(); |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
80 e->ignore(); |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
81 } |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
82 |
379
11c8a7684f74
Date: Fri, 24 May 2002 10:32:00 -0700
Sam Lantinga <slouken@libsdl.org>
parents:
371
diff
changeset
|
83 void SDL_QWin::setMousePos(const QPoint &pos) { |
11c8a7684f74
Date: Fri, 24 May 2002 10:32:00 -0700
Sam Lantinga <slouken@libsdl.org>
parents:
371
diff
changeset
|
84 if(my_image->width() == height()) { |
11c8a7684f74
Date: Fri, 24 May 2002 10:32:00 -0700
Sam Lantinga <slouken@libsdl.org>
parents:
371
diff
changeset
|
85 my_mouse_pos = QPoint(height()-pos.y(), pos.x()); |
11c8a7684f74
Date: Fri, 24 May 2002 10:32:00 -0700
Sam Lantinga <slouken@libsdl.org>
parents:
371
diff
changeset
|
86 } else { |
11c8a7684f74
Date: Fri, 24 May 2002 10:32:00 -0700
Sam Lantinga <slouken@libsdl.org>
parents:
371
diff
changeset
|
87 my_mouse_pos = pos; |
11c8a7684f74
Date: Fri, 24 May 2002 10:32:00 -0700
Sam Lantinga <slouken@libsdl.org>
parents:
371
diff
changeset
|
88 } |
11c8a7684f74
Date: Fri, 24 May 2002 10:32:00 -0700
Sam Lantinga <slouken@libsdl.org>
parents:
371
diff
changeset
|
89 } |
11c8a7684f74
Date: Fri, 24 May 2002 10:32:00 -0700
Sam Lantinga <slouken@libsdl.org>
parents:
371
diff
changeset
|
90 |
371
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
91 void SDL_QWin::mouseMoveEvent(QMouseEvent *e) { |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
92 Qt::ButtonState button = e->button(); |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
93 int sdlstate = 0; |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
94 if( (button & Qt::LeftButton)) { |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
95 sdlstate |= SDL_BUTTON_LMASK; |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
96 } |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
97 if( (button & Qt::RightButton)) { |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
98 sdlstate |= SDL_BUTTON_RMASK; |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
99 } |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
100 if( (button & Qt::MidButton)) { |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
101 sdlstate |= SDL_BUTTON_MMASK; |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
102 } |
379
11c8a7684f74
Date: Fri, 24 May 2002 10:32:00 -0700
Sam Lantinga <slouken@libsdl.org>
parents:
371
diff
changeset
|
103 setMousePos(e->pos()); |
11c8a7684f74
Date: Fri, 24 May 2002 10:32:00 -0700
Sam Lantinga <slouken@libsdl.org>
parents:
371
diff
changeset
|
104 SDL_PrivateMouseMotion(sdlstate, 0, my_mouse_pos.x(), my_mouse_pos.y()); |
371
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
105 } |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
106 |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
107 void SDL_QWin::mousePressEvent(QMouseEvent *e) { |
379
11c8a7684f74
Date: Fri, 24 May 2002 10:32:00 -0700
Sam Lantinga <slouken@libsdl.org>
parents:
371
diff
changeset
|
108 setMousePos(e->pos()); |
371
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
109 Qt::ButtonState button = e->button(); |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
110 SDL_PrivateMouseButton(SDL_PRESSED, |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
111 (button & Qt::LeftButton) ? 1 : |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
112 ((button & Qt::RightButton) ? 2 : 3), |
379
11c8a7684f74
Date: Fri, 24 May 2002 10:32:00 -0700
Sam Lantinga <slouken@libsdl.org>
parents:
371
diff
changeset
|
113 my_mouse_pos.x(), my_mouse_pos.y()); |
371
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
114 } |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
115 |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
116 void SDL_QWin::mouseReleaseEvent(QMouseEvent *e) { |
379
11c8a7684f74
Date: Fri, 24 May 2002 10:32:00 -0700
Sam Lantinga <slouken@libsdl.org>
parents:
371
diff
changeset
|
117 setMousePos(e->pos()); |
371
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
118 Qt::ButtonState button = e->button(); |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
119 SDL_PrivateMouseButton(SDL_RELEASED, |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
120 (button & Qt::LeftButton) ? 1 : |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
121 ((button & Qt::RightButton) ? 2 : 3), |
379
11c8a7684f74
Date: Fri, 24 May 2002 10:32:00 -0700
Sam Lantinga <slouken@libsdl.org>
parents:
371
diff
changeset
|
122 my_mouse_pos.x(), my_mouse_pos.y()); |
11c8a7684f74
Date: Fri, 24 May 2002 10:32:00 -0700
Sam Lantinga <slouken@libsdl.org>
parents:
371
diff
changeset
|
123 my_mouse_pos = QPoint(-1, -1); |
371
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
124 } |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
125 |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
126 #define USE_DIRECTPAINTER |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
127 |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
128 |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
129 #ifndef __i386__ |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
130 static inline void gs_fastRotateBlit_3 ( unsigned short *fb, |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
131 unsigned short *bits, |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
132 const QRect& rect ) |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
133 { |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
134 int startx, starty; |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
135 int width, height; |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
136 |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
137 startx = rect.left() >> 1; |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
138 starty = rect.top() >> 1; |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
139 width = ((rect.right() - rect.left()) >> 1) + 2; |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
140 height = ((rect.bottom() - rect.top()) >> 1) + 2; |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
141 |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
142 if((startx+width) > 120) { |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
143 width = 120 - startx; // avoid horizontal overflow |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
144 } |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
145 if((starty+height) > 160) { |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
146 height = 160 - starty; // avoid vertical overflow |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
147 } |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
148 |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
149 ulong *sp1, *sp2, *dp1, *dp2; |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
150 ulong stop, sbot, dtop, dbot; |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
151 |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
152 sp1 = (ulong*)bits + startx + starty*240; |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
153 sp2 = sp1 + 120; |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
154 dp1 = (ulong *)fb + (159 - starty) + startx*320; |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
155 dp2 = dp1 + 160; |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
156 int rowadd = (-320*width) - 1; |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
157 int rowadd2 = 240 - width; |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
158 // transfer in cells of 2x2 pixels in words |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
159 for (int y=0; y<height; y++) { |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
160 for (int x=0; x<width; x++) { |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
161 // read source pixels |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
162 stop = *sp1; |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
163 sbot = *sp2; |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
164 // rotate pixels |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
165 dtop = (sbot & 0xffff) + ((stop & 0xffff)<<16); |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
166 dbot = ((sbot & 0xffff0000)>>16) + (stop & 0xffff0000); |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
167 // write to framebuffer |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
168 *dp1 = dtop; |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
169 *dp2 = dbot; |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
170 // update source ptrs |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
171 sp1++; sp2++; |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
172 // update dest ptrs - 2 pix at a time |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
173 dp1 += 320; |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
174 dp2 += 320; |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
175 } |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
176 // adjust src ptrs - skip a row as we work in pairs |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
177 sp1 += rowadd2; |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
178 sp2 += rowadd2; |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
179 // adjust dest ptrs for rotation |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
180 dp1 += rowadd; |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
181 dp2 += rowadd; |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
182 } |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
183 } |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
184 #endif |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
185 |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
186 void SDL_QWin::repaintRect(const QRect& rect) { |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
187 if(!my_painter || !rect.width() || !rect.height()) { |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
188 return; |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
189 } |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
190 #ifndef __i386__ |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
191 |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
192 if(QPixmap::defaultDepth() == 16 && |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
193 my_painter->transformOrientation() == 3 && |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
194 my_painter->numRects() >= 0) { |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
195 if(my_image->width() == width()) { |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
196 ushort *fb = (ushort*)my_painter->frameBuffer(); |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
197 ushort *buf = (ushort*)my_image->bits(); |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
198 gs_fastRotateBlit_3(fb, buf, rect); |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
199 } else { |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
200 // landscape mode |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
201 uchar *fb = (uchar*)my_painter->frameBuffer(); |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
202 uchar *buf = (uchar*)my_image->bits(); |
379
11c8a7684f74
Date: Fri, 24 May 2002 10:32:00 -0700
Sam Lantinga <slouken@libsdl.org>
parents:
371
diff
changeset
|
203 if(rect == my_image->rect()) { |
11c8a7684f74
Date: Fri, 24 May 2002 10:32:00 -0700
Sam Lantinga <slouken@libsdl.org>
parents:
371
diff
changeset
|
204 memcpy(fb, buf, width()*height()*2); |
11c8a7684f74
Date: Fri, 24 May 2002 10:32:00 -0700
Sam Lantinga <slouken@libsdl.org>
parents:
371
diff
changeset
|
205 } else { |
11c8a7684f74
Date: Fri, 24 May 2002 10:32:00 -0700
Sam Lantinga <slouken@libsdl.org>
parents:
371
diff
changeset
|
206 int h = rect.height(); |
11c8a7684f74
Date: Fri, 24 May 2002 10:32:00 -0700
Sam Lantinga <slouken@libsdl.org>
parents:
371
diff
changeset
|
207 int wd = rect.width()<<1; |
11c8a7684f74
Date: Fri, 24 May 2002 10:32:00 -0700
Sam Lantinga <slouken@libsdl.org>
parents:
371
diff
changeset
|
208 int fblineadd = my_painter->lineStep(); |
11c8a7684f74
Date: Fri, 24 May 2002 10:32:00 -0700
Sam Lantinga <slouken@libsdl.org>
parents:
371
diff
changeset
|
209 int buflineadd = my_image->bytesPerLine(); |
11c8a7684f74
Date: Fri, 24 May 2002 10:32:00 -0700
Sam Lantinga <slouken@libsdl.org>
parents:
371
diff
changeset
|
210 fb += (rect.left()<<1) + rect.top() * my_painter->lineStep(); |
11c8a7684f74
Date: Fri, 24 May 2002 10:32:00 -0700
Sam Lantinga <slouken@libsdl.org>
parents:
371
diff
changeset
|
211 buf += (rect.left()<<1) + rect.top() * my_image->bytesPerLine(); |
11c8a7684f74
Date: Fri, 24 May 2002 10:32:00 -0700
Sam Lantinga <slouken@libsdl.org>
parents:
371
diff
changeset
|
212 while(h--) { |
11c8a7684f74
Date: Fri, 24 May 2002 10:32:00 -0700
Sam Lantinga <slouken@libsdl.org>
parents:
371
diff
changeset
|
213 memcpy(fb, buf, wd); |
11c8a7684f74
Date: Fri, 24 May 2002 10:32:00 -0700
Sam Lantinga <slouken@libsdl.org>
parents:
371
diff
changeset
|
214 fb += fblineadd; |
11c8a7684f74
Date: Fri, 24 May 2002 10:32:00 -0700
Sam Lantinga <slouken@libsdl.org>
parents:
371
diff
changeset
|
215 buf += buflineadd; |
11c8a7684f74
Date: Fri, 24 May 2002 10:32:00 -0700
Sam Lantinga <slouken@libsdl.org>
parents:
371
diff
changeset
|
216 } |
371
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
217 } |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
218 } |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
219 } else { |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
220 #endif |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
221 QPainter pp(this); |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
222 pp.drawImage(rect.topLeft(), *my_image, rect); |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
223 pp.end(); |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
224 #ifndef __i386__ |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
225 } |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
226 #endif |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
227 } |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
228 |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
229 // This paints the current buffer to the screen, when desired. |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
230 void SDL_QWin::paintEvent(QPaintEvent *ev) { |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
231 if(my_image && isVisible() && isActiveWindow()) { |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
232 lockScreen(); |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
233 repaintRect(ev->rect()); |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
234 unlockScreen(); |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
235 } |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
236 } |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
237 |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
238 /* Function to translate a keyboard transition and queue the key event */ |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
239 void SDL_QWin::QueueKey(QKeyEvent *e, int pressed) |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
240 { |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
241 SDL_keysym keysym; |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
242 int scancode = e->key(); |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
243 /* Set the keysym information */ |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
244 if(scancode >= 'A' && scancode <= 'Z') { |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
245 // Qt sends uppercase, SDL wants lowercase |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
246 keysym.sym = static_cast<SDLKey>(scancode + 32); |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
247 } else if(scancode >= 0x1000) { |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
248 // Special keys |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
249 switch(scancode) { |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
250 case Qt::Key_Escape: scancode = SDLK_ESCAPE; break; |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
251 case Qt::Key_Tab: scancode = SDLK_TAB; break; |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
252 case Qt::Key_Backspace: scancode = SDLK_BACKSPACE; break; |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
253 case Qt::Key_Return: scancode = SDLK_RETURN; break; |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
254 case Qt::Key_Enter: scancode = SDLK_KP_ENTER; break; |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
255 case Qt::Key_Insert: scancode = SDLK_INSERT; break; |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
256 case Qt::Key_Delete: scancode = SDLK_DELETE; break; |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
257 case Qt::Key_Pause: scancode = SDLK_PAUSE; break; |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
258 case Qt::Key_Print: scancode = SDLK_PRINT; break; |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
259 case Qt::Key_SysReq: scancode = SDLK_SYSREQ; break; |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
260 case Qt::Key_Home: scancode = SDLK_HOME; break; |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
261 case Qt::Key_End: scancode = SDLK_END; break; |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
262 case Qt::Key_Left: scancode = SDLK_LEFT; break; |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
263 case Qt::Key_Up: scancode = SDLK_UP; break; |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
264 case Qt::Key_Right: scancode = SDLK_RIGHT; break; |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
265 case Qt::Key_Down: scancode = SDLK_DOWN; break; |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
266 case Qt::Key_Prior: scancode = SDLK_PAGEUP; break; |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
267 case Qt::Key_Next: scancode = SDLK_PAGEDOWN; break; |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
268 case Qt::Key_Shift: scancode = SDLK_LSHIFT; break; |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
269 case Qt::Key_Control: scancode = SDLK_LCTRL; break; |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
270 case Qt::Key_Meta: scancode = SDLK_LMETA; break; |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
271 case Qt::Key_Alt: scancode = SDLK_LALT; break; |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
272 case Qt::Key_CapsLock: scancode = SDLK_CAPSLOCK; break; |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
273 case Qt::Key_NumLock: scancode = SDLK_NUMLOCK; break; |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
274 case Qt::Key_ScrollLock: scancode = SDLK_SCROLLOCK; break; |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
275 case Qt::Key_F1: scancode = SDLK_F1; break; |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
276 case Qt::Key_F2: scancode = SDLK_F2; break; |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
277 case Qt::Key_F3: scancode = SDLK_F3; break; |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
278 case Qt::Key_F4: scancode = SDLK_F4; break; |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
279 case Qt::Key_F5: scancode = SDLK_F5; break; |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
280 case Qt::Key_F6: scancode = SDLK_F6; break; |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
281 case Qt::Key_F7: scancode = SDLK_F7; break; |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
282 case Qt::Key_F8: scancode = SDLK_F8; break; |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
283 case Qt::Key_F9: scancode = SDLK_F9; break; |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
284 case Qt::Key_F10: scancode = SDLK_F10; break; |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
285 case Qt::Key_F11: scancode = SDLK_F11; break; |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
286 case Qt::Key_F12: scancode = SDLK_F12; break; |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
287 case Qt::Key_F13: scancode = SDLK_F13; break; |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
288 case Qt::Key_F14: scancode = SDLK_F14; break; |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
289 case Qt::Key_F15: scancode = SDLK_F15; break; |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
290 case Qt::Key_Super_L: scancode = SDLK_LSUPER; break; |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
291 case Qt::Key_Super_R: scancode = SDLK_RSUPER; break; |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
292 case Qt::Key_Menu: scancode = SDLK_MENU; break; |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
293 case Qt::Key_Help: scancode = SDLK_HELP; break; |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
294 default: |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
295 scancode = SDLK_UNKNOWN; |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
296 break; |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
297 } |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
298 keysym.sym = static_cast<SDLKey>(scancode); |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
299 } else { |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
300 keysym.sym = static_cast<SDLKey>(scancode); |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
301 } |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
302 keysym.scancode = scancode; |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
303 keysym.mod = KMOD_NONE; |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
304 ButtonState st = e->state(); |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
305 if( (st & ShiftButton) ) { keysym.mod = static_cast<SDLMod>(keysym.mod | KMOD_LSHIFT); } |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
306 if( (st & ControlButton) ) { keysym.mod = static_cast<SDLMod>(keysym.mod | KMOD_LCTRL); } |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
307 if( (st & AltButton) ) { keysym.mod = static_cast<SDLMod>(keysym.mod | KMOD_LALT); } |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
308 if ( SDL_TranslateUNICODE ) { |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
309 QChar qchar = e->text()[0]; |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
310 keysym.unicode = qchar.unicode(); |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
311 } else { |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
312 keysym.unicode = 0; |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
313 } |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
314 |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
315 /* NUMLOCK and CAPSLOCK are implemented as double-presses in reality */ |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
316 // if ( (keysym.sym == SDLK_NUMLOCK) || (keysym.sym == SDLK_CAPSLOCK) ) { |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
317 // pressed = 1; |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
318 // } |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
319 |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
320 /* Queue the key event */ |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
321 if ( pressed ) { |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
322 SDL_PrivateKeyboard(SDL_PRESSED, &keysym); |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
323 } else { |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
324 SDL_PrivateKeyboard(SDL_RELEASED, &keysym); |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
325 } |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
326 } |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
327 |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
328 void SDL_QWin::setFullscreen(bool fs_on) { |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
329 my_has_fullscreen = false; |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
330 enableFullscreen(); |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
331 } |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
332 |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
333 void SDL_QWin::enableFullscreen() { |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
334 // Make sure size is correct |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
335 if(!my_has_fullscreen) { |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
336 setFixedSize(qApp->desktop()->size()); |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
337 // This call is needed because showFullScreen won't work |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
338 // correctly if the widget already considers itself to be fullscreen. |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
339 showNormal(); |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
340 // This is needed because showNormal() forcefully changes the window |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
341 // style to WSTyle_TopLevel. |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
342 setWFlags(WStyle_Customize | WStyle_NoBorder); |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
343 // Enable fullscreen. |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
344 showFullScreen(); |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
345 my_has_fullscreen = true; |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
346 } |
db0cc6034336
Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
347 } |