annotate src/video/qtopia/SDL_QWin.cc @ 1336:3692456e7b0f

Use SDL_ prefixed versions of C library functions. FIXME: Change #include <stdlib.h> to #include "SDL_stdlib.h" Change #include <string.h> to #include "SDL_string.h" Make sure nothing else broke because of this...
author Sam Lantinga <slouken@libsdl.org>
date Tue, 07 Feb 2006 06:59:48 +0000
parents c9b51268668f
children 376665398b25
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
1312
c9b51268668f Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
3 Copyright (C) 1997-2006 Sam Lantinga
371
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
1312
c9b51268668f Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
6 modify it under the terms of the GNU Lesser General Public
371
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
1312
c9b51268668f Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
8 version 2.1 of the License, or (at your option) any later version.
371
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
1312
c9b51268668f Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
13 Lesser General Public License for more details.
371
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
14
1312
c9b51268668f Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
15 You should have received a copy of the GNU Lesser General Public
c9b51268668f Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
16 License along with this library; if not, write to the Free Software
c9b51268668f Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
371
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 #include "SDL_QWin.h"
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
24 #include <qapplication.h>
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
25 #include <qdirectpainter_qws.h>
481
c96e2137f9eb Date: Sat, 31 Aug 2002 15:42:45 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 379
diff changeset
26
c96e2137f9eb Date: Sat, 31 Aug 2002 15:42:45 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 379
diff changeset
27 screenRotationT screenRotation = SDL_QT_NO_ROTATION;
c96e2137f9eb Date: Sat, 31 Aug 2002 15:42:45 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 379
diff changeset
28
371
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
29 SDL_QWin::SDL_QWin(const QSize& size)
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
30 : 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
31 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
32 my_has_fullscreen(false), my_locked(0)
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
33 {
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
34 setBackgroundMode(NoBackground);
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
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
37 SDL_QWin::~SDL_QWin() {
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
38 // Nothing to do yet.
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
39 if(my_image) {
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
40 delete my_image;
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
41 }
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
42 }
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 void SDL_QWin::setImage(QImage *image) {
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
45 if ( my_image ) {
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
46 delete my_image;
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
47 }
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
48 my_image = image;
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
49 // setFixedSize(image->size());
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
50 }
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
51
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
52 void SDL_QWin::resizeEvent(QResizeEvent *e) {
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
53 if(size() != qApp->desktop()->size()) {
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
54 // 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
55 my_has_fullscreen = false;
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
56 enableFullscreen();
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
57 }
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
58 if(my_inhibit_resize) {
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
59 my_inhibit_resize = false;
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
60 } else {
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
61 SDL_PrivateResize(e->size().width(), e->size().height());
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
62 }
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
63 }
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 void SDL_QWin::focusInEvent(QFocusEvent *) {
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
66 // Always do it here, no matter the size.
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
67 enableFullscreen();
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
68 SDL_PrivateAppActive(true, SDL_APPINPUTFOCUS);
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
69 }
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
70
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
71 void SDL_QWin::focusOutEvent(QFocusEvent *) {
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
72 my_has_fullscreen = false;
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
73 SDL_PrivateAppActive(false, SDL_APPINPUTFOCUS);
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
74 }
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
75
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
76 void SDL_QWin::closeEvent(QCloseEvent *e) {
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
77 SDL_PrivateQuit();
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
78 e->ignore();
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
79 }
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
80
379
11c8a7684f74 Date: Fri, 24 May 2002 10:32:00 -0700
Sam Lantinga <slouken@libsdl.org>
parents: 371
diff changeset
81 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
82 if(my_image->width() == height()) {
481
c96e2137f9eb Date: Sat, 31 Aug 2002 15:42:45 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 379
diff changeset
83 if (screenRotation == SDL_QT_ROTATION_90)
c96e2137f9eb Date: Sat, 31 Aug 2002 15:42:45 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 379
diff changeset
84 my_mouse_pos = QPoint(height()-pos.y(), pos.x());
c96e2137f9eb Date: Sat, 31 Aug 2002 15:42:45 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 379
diff changeset
85 else if (screenRotation == SDL_QT_ROTATION_270)
c96e2137f9eb Date: Sat, 31 Aug 2002 15:42:45 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 379
diff changeset
86 my_mouse_pos = QPoint(pos.y(), width()-pos.x());
379
11c8a7684f74 Date: Fri, 24 May 2002 10:32:00 -0700
Sam Lantinga <slouken@libsdl.org>
parents: 371
diff changeset
87 } else {
11c8a7684f74 Date: Fri, 24 May 2002 10:32:00 -0700
Sam Lantinga <slouken@libsdl.org>
parents: 371
diff changeset
88 my_mouse_pos = pos;
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 }
11c8a7684f74 Date: Fri, 24 May 2002 10:32:00 -0700
Sam Lantinga <slouken@libsdl.org>
parents: 371
diff changeset
91
371
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
92 void SDL_QWin::mouseMoveEvent(QMouseEvent *e) {
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
93 Qt::ButtonState button = e->button();
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
94 int sdlstate = 0;
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
95 if( (button & Qt::LeftButton)) {
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
96 sdlstate |= SDL_BUTTON_LMASK;
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
97 }
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
98 if( (button & Qt::RightButton)) {
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
99 sdlstate |= SDL_BUTTON_RMASK;
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
100 }
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
101 if( (button & Qt::MidButton)) {
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
102 sdlstate |= SDL_BUTTON_MMASK;
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
103 }
379
11c8a7684f74 Date: Fri, 24 May 2002 10:32:00 -0700
Sam Lantinga <slouken@libsdl.org>
parents: 371
diff changeset
104 setMousePos(e->pos());
11c8a7684f74 Date: Fri, 24 May 2002 10:32:00 -0700
Sam Lantinga <slouken@libsdl.org>
parents: 371
diff changeset
105 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
106 }
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
107
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
108 void SDL_QWin::mousePressEvent(QMouseEvent *e) {
481
c96e2137f9eb Date: Sat, 31 Aug 2002 15:42:45 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 379
diff changeset
109 mouseMoveEvent(e);
371
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
110 Qt::ButtonState button = e->button();
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
111 SDL_PrivateMouseButton(SDL_PRESSED,
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
112 (button & Qt::LeftButton) ? 1 :
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
113 ((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
114 my_mouse_pos.x(), my_mouse_pos.y());
371
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
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
117 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
118 setMousePos(e->pos());
371
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
119 Qt::ButtonState button = e->button();
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
120 SDL_PrivateMouseButton(SDL_RELEASED,
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
121 (button & Qt::LeftButton) ? 1 :
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
122 ((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
123 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
124 my_mouse_pos = QPoint(-1, -1);
371
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
567
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
127 static inline void
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
128 gs_fastRotateBlit_3 ( unsigned short *fb,
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
129 unsigned short *bits,
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
130 const QRect& rect )
371
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
131 {
567
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
132 // FIXME: this only works correctly for 240x320 displays
371
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
133 int startx, starty;
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
134 int width, height;
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
135
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
136 startx = rect.left() >> 1;
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
137 starty = rect.top() >> 1;
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
138 width = ((rect.right() - rect.left()) >> 1) + 2;
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
139 height = ((rect.bottom() - rect.top()) >> 1) + 2;
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
140
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
141 if((startx+width) > 120) {
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
142 width = 120 - startx; // avoid horizontal overflow
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
143 }
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
144 if((starty+height) > 160) {
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
145 height = 160 - starty; // avoid vertical overflow
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
146 }
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 ulong *sp1, *sp2, *dp1, *dp2;
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
149 ulong stop, sbot, dtop, dbot;
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
150
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
151 sp1 = (ulong*)bits + startx + starty*240;
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
152 sp2 = sp1 + 120;
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
153 dp1 = (ulong *)fb + (159 - starty) + startx*320;
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
154 dp2 = dp1 + 160;
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
155 int rowadd = (-320*width) - 1;
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
156 int rowadd2 = 240 - width;
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
157 // transfer in cells of 2x2 pixels in words
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
158 for (int y=0; y<height; y++) {
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
159 for (int x=0; x<width; x++) {
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
160 // read source pixels
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
161 stop = *sp1;
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
162 sbot = *sp2;
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
163 // rotate pixels
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
164 dtop = (sbot & 0xffff) + ((stop & 0xffff)<<16);
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
165 dbot = ((sbot & 0xffff0000)>>16) + (stop & 0xffff0000);
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
166 // write to framebuffer
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
167 *dp1 = dtop;
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
168 *dp2 = dbot;
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
169 // update source ptrs
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
170 sp1++; sp2++;
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
171 // update dest ptrs - 2 pix at a time
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
172 dp1 += 320;
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
173 dp2 += 320;
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
174 }
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
175 // 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
176 sp1 += rowadd2;
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
177 sp2 += rowadd2;
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
178 // adjust dest ptrs for rotation
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
179 dp1 += rowadd;
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
180 dp2 += rowadd;
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
181 }
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
182 }
567
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
183
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
184 static inline void
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
185 gs_fastRotateBlit_1 ( unsigned short *fb,
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
186 unsigned short *bits,
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
187 const QRect& rect ) {
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
188 // FIXME: this only works correctly for 240x320 displays
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
189 int startx, starty;
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
190 int width, height;
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
191
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
192 startx = rect.left() >> 1;
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
193 starty = rect.top() >> 1;
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
194 width = ((rect.right() - rect.left()) >> 1) + 2;
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
195 height = ((rect.bottom() - rect.top()) >> 1) + 2;
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
196
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
197 if((startx+width) > 120) {
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
198 width = 120 - startx; // avoid horizontal overflow
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
199 }
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
200 if((starty+height) > 160) {
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
201 height = 160 - starty; // avoid vertical overflow
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
202 }
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
203
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
204 ulong *sp1, *sp2, *dp1, *dp2;
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
205 ulong stop, sbot, dtop, dbot;
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
206 fb += 320*239; // Move "fb" to top left corner
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
207 sp1 = (ulong*)bits + startx + starty*240;
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
208 sp2 = sp1 + 120;
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
209 dp1 = (ulong*)fb - startx * 320 - starty;
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
210 dp2 = dp1 - 160;
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
211 int rowadd = (320*width) + 1;
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
212 int rowadd2 = 240 - width;
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
213 // transfer in cells of 2x2 pixels in words
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
214 for (int y=0; y<height; y++) {
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
215 for (int x=0; x<width; x++) {
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
216 // read
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
217 stop = *sp1;
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
218 sbot = *sp2;
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
219 // rotate
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
220 dtop = (stop & 0xffff) + ((sbot & 0xffff)<<16);
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
221 dbot = ((stop & 0xffff0000)>>16) + (sbot & 0xffff0000);
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
222 // write
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
223 *dp1 = dtop;
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
224 *dp2 = dbot;
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
225 // update source ptrs
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
226 sp1++; sp2++;
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
227 // update dest ptrs - 2 pix at a time
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
228 dp1 -= 320;
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
229 dp2 -= 320;
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
230 }
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
231 // adjust src ptrs - skip a row as we work in pairs
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
232 sp1 += rowadd2;
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
233 sp2 += rowadd2;
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
234 // adjust dest ptrs for rotation
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
235 dp1 += rowadd;
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
236 dp2 += rowadd;
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
237 }
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
238 }
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
239
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
240 // desktop, SL-A300 etc
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
241 bool SDL_QWin::repaintRotation0(const QRect& rect) {
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
242 if(my_image->width() == width()) {
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
243 uchar *fb = (uchar*)my_painter->frameBuffer();
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
244 uchar *buf = (uchar*)my_image->bits();
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
245 if(rect == my_image->rect()) {
1336
3692456e7b0f Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents: 1312
diff changeset
246 SDL_memcpy(fb, buf, width()*height()*2);
567
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
247 } else {
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
248 int h = rect.height();
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
249 int wd = rect.width()<<1;
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
250 int fblineadd = my_painter->lineStep();
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
251 int buflineadd = my_image->bytesPerLine();
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
252 fb += (rect.left()<<1) + rect.top() * my_painter->lineStep();
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
253 buf += (rect.left()<<1) + rect.top() * my_image->bytesPerLine();
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
254 while(h--) {
1336
3692456e7b0f Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents: 1312
diff changeset
255 SDL_memcpy(fb, buf, wd);
567
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
256 fb += fblineadd;
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
257 buf += buflineadd;
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
258 }
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
259 }
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
260 } else {
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
261 return false; // FIXME: Landscape
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
262 }
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
263 #ifdef __i386__
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
264 my_painter->fillRect( rect, QBrush( Qt::NoBrush ) );
371
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
265 #endif
567
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
266 return true;
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
267 }
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
268
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
269
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
270 // Sharp Zaurus SL-5500 etc
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
271 bool SDL_QWin::repaintRotation3(const QRect& rect) {
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
272 if(my_image->width() == width()) {
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
273 ushort *fb = (ushort*)my_painter->frameBuffer();
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
274 ushort *buf = (ushort*)my_image->bits();
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
275 gs_fastRotateBlit_3(fb, buf, rect);
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
276 } else {
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
277 // landscape mode
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
278 if (screenRotation == SDL_QT_ROTATION_90) {
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
279 uchar *fb = (uchar*)my_painter->frameBuffer();
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
280 uchar *buf = (uchar*)my_image->bits();
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
281 if(rect == my_image->rect()) {
1336
3692456e7b0f Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents: 1312
diff changeset
282 SDL_memcpy(fb, buf, width()*height()*2);
567
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
283 } else {
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
284 int h = rect.height();
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
285 int wd = rect.width()<<1;
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
286 int fblineadd = my_painter->lineStep();
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
287 int buflineadd = my_image->bytesPerLine();
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
288 fb += (rect.left()<<1) + rect.top() * my_painter->lineStep();
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
289 buf += (rect.left()<<1) + rect.top() * my_image->bytesPerLine();
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
290 while(h--) {
1336
3692456e7b0f Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents: 1312
diff changeset
291 SDL_memcpy(fb, buf, wd);
567
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
292 fb += fblineadd;
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
293 buf += buflineadd;
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
294 }
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
295 }
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
296 } else if (screenRotation == SDL_QT_ROTATION_270) {
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
297 int h = rect.height();
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
298 int wd = rect.width();
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
299 int fblineadd = my_painter->lineStep() - (rect.width() << 1);
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
300 int buflineadd = my_image->bytesPerLine() - (rect.width() << 1);
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
301 int w;
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
302
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
303 uchar *fb = (uchar*)my_painter->frameBuffer();
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
304 uchar *buf = (uchar*)my_image->bits();
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
305
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
306 fb += ((my_painter->width() - (rect.top() + rect.height())) *
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
307 my_painter->lineStep()) + ((my_painter->height() - ((rect.left() +
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
308 rect.width()))) << 1);
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
309
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
310 buf += my_image->bytesPerLine() * (rect.top() + rect.height()) -
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
311 (((my_image->width() - (rect.left() + rect.width())) << 1) + 2);
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
312
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
313 while(h--) {
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
314 w = wd;
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
315 while(w--) *((unsigned short*)fb)++ = *((unsigned short*)buf)--;
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
316 fb += fblineadd;
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
317 buf -= buflineadd;
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
318 }
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
319 }
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
320 }
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
321 return true;
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
322 }
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
323
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
324 // ipaq 3800...
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
325 bool SDL_QWin::repaintRotation1(const QRect& rect) {
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
326 if(my_image->width() == width()) {
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
327 ushort *fb = (ushort*)my_painter->frameBuffer();
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
328 ushort *buf = (ushort*)my_image->bits();
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
329 gs_fastRotateBlit_1(fb, buf, rect);
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
330 } else {
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
331 return false; // FIXME: landscape mode
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
332 }
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
333 return true;
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
334 }
371
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
335
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
336 void SDL_QWin::repaintRect(const QRect& rect) {
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
337 if(!my_painter || !rect.width() || !rect.height()) {
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
338 return;
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
339 }
567
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
340
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
341 if(QPixmap::defaultDepth() == 16) {
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
342 switch(my_painter->transformOrientation()) {
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
343 case 3:
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
344 if(repaintRotation3(rect)) { return; }
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
345 break;
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
346 case 1:
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
347 if(repaintRotation1(rect)) { return; }
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
348 break;
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
349 case 0:
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
350 if(repaintRotation0(rect)) { return; }
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
351 break;
371
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
352 }
567
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
353 }
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
354 my_painter->drawImage(rect.topLeft(), *my_image, rect);
371
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
355 }
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
356
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
357 // 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
358 void SDL_QWin::paintEvent(QPaintEvent *ev) {
567
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
359 if(my_image) {
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
360 lockScreen(true);
371
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
361 repaintRect(ev->rect());
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
362 unlockScreen();
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
363 }
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
364 }
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
365
567
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
366 /* Function to translate a keyboard transition and queue the key event
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
367 * This should probably be a table although this method isn't exactly
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
368 * slow.
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
369 */
371
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
370 void SDL_QWin::QueueKey(QKeyEvent *e, int pressed)
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
371 {
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
372 SDL_keysym keysym;
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
373 int scancode = e->key();
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
374 /* Set the keysym information */
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
375 if(scancode >= 'A' && scancode <= 'Z') {
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
376 // Qt sends uppercase, SDL wants lowercase
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
377 keysym.sym = static_cast<SDLKey>(scancode + 32);
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
378 } else if(scancode >= 0x1000) {
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
379 // Special keys
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
380 switch(scancode) {
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
381 case Qt::Key_Escape: scancode = SDLK_ESCAPE; break;
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
382 case Qt::Key_Tab: scancode = SDLK_TAB; break;
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
383 case Qt::Key_Backspace: scancode = SDLK_BACKSPACE; break;
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
384 case Qt::Key_Return: scancode = SDLK_RETURN; break;
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
385 case Qt::Key_Enter: scancode = SDLK_KP_ENTER; break;
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
386 case Qt::Key_Insert: scancode = SDLK_INSERT; break;
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
387 case Qt::Key_Delete: scancode = SDLK_DELETE; break;
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
388 case Qt::Key_Pause: scancode = SDLK_PAUSE; break;
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
389 case Qt::Key_Print: scancode = SDLK_PRINT; break;
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
390 case Qt::Key_SysReq: scancode = SDLK_SYSREQ; break;
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
391 case Qt::Key_Home: scancode = SDLK_HOME; break;
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
392 case Qt::Key_End: scancode = SDLK_END; break;
481
c96e2137f9eb Date: Sat, 31 Aug 2002 15:42:45 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 379
diff changeset
393 // We want the control keys to rotate with the screen
c96e2137f9eb Date: Sat, 31 Aug 2002 15:42:45 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 379
diff changeset
394 case Qt::Key_Left:
c96e2137f9eb Date: Sat, 31 Aug 2002 15:42:45 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 379
diff changeset
395 if (screenRotation == SDL_QT_ROTATION_90) scancode = SDLK_UP;
c96e2137f9eb Date: Sat, 31 Aug 2002 15:42:45 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 379
diff changeset
396 else if (screenRotation == SDL_QT_ROTATION_270) scancode = SDLK_DOWN;
c96e2137f9eb Date: Sat, 31 Aug 2002 15:42:45 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 379
diff changeset
397 else scancode = SDLK_LEFT;
c96e2137f9eb Date: Sat, 31 Aug 2002 15:42:45 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 379
diff changeset
398 break;
c96e2137f9eb Date: Sat, 31 Aug 2002 15:42:45 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 379
diff changeset
399 case Qt::Key_Up:
c96e2137f9eb Date: Sat, 31 Aug 2002 15:42:45 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 379
diff changeset
400 if (screenRotation == SDL_QT_ROTATION_90) scancode = SDLK_RIGHT;
c96e2137f9eb Date: Sat, 31 Aug 2002 15:42:45 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 379
diff changeset
401 else if (screenRotation == SDL_QT_ROTATION_270) scancode = SDLK_LEFT;
c96e2137f9eb Date: Sat, 31 Aug 2002 15:42:45 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 379
diff changeset
402 else scancode = SDLK_UP;
c96e2137f9eb Date: Sat, 31 Aug 2002 15:42:45 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 379
diff changeset
403 break;
c96e2137f9eb Date: Sat, 31 Aug 2002 15:42:45 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 379
diff changeset
404 case Qt::Key_Right:
c96e2137f9eb Date: Sat, 31 Aug 2002 15:42:45 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 379
diff changeset
405 if (screenRotation == SDL_QT_ROTATION_90) scancode = SDLK_DOWN;
c96e2137f9eb Date: Sat, 31 Aug 2002 15:42:45 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 379
diff changeset
406 else if (screenRotation == SDL_QT_ROTATION_270) scancode = SDLK_UP;
c96e2137f9eb Date: Sat, 31 Aug 2002 15:42:45 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 379
diff changeset
407 else scancode = SDLK_RIGHT;
c96e2137f9eb Date: Sat, 31 Aug 2002 15:42:45 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 379
diff changeset
408 break;
c96e2137f9eb Date: Sat, 31 Aug 2002 15:42:45 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 379
diff changeset
409 case Qt::Key_Down:
c96e2137f9eb Date: Sat, 31 Aug 2002 15:42:45 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 379
diff changeset
410 if (screenRotation == SDL_QT_ROTATION_90) scancode = SDLK_LEFT;
c96e2137f9eb Date: Sat, 31 Aug 2002 15:42:45 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 379
diff changeset
411 else if (screenRotation == SDL_QT_ROTATION_270) scancode = SDLK_RIGHT;
c96e2137f9eb Date: Sat, 31 Aug 2002 15:42:45 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 379
diff changeset
412 else scancode = SDLK_DOWN;
c96e2137f9eb Date: Sat, 31 Aug 2002 15:42:45 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 379
diff changeset
413 break;
371
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
414 case Qt::Key_Prior: scancode = SDLK_PAGEUP; break;
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
415 case Qt::Key_Next: scancode = SDLK_PAGEDOWN; break;
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
416 case Qt::Key_Shift: scancode = SDLK_LSHIFT; break;
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
417 case Qt::Key_Control: scancode = SDLK_LCTRL; break;
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
418 case Qt::Key_Meta: scancode = SDLK_LMETA; break;
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
419 case Qt::Key_Alt: scancode = SDLK_LALT; break;
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
420 case Qt::Key_CapsLock: scancode = SDLK_CAPSLOCK; break;
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
421 case Qt::Key_NumLock: scancode = SDLK_NUMLOCK; break;
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
422 case Qt::Key_ScrollLock: scancode = SDLK_SCROLLOCK; break;
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
423 case Qt::Key_F1: scancode = SDLK_F1; break;
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
424 case Qt::Key_F2: scancode = SDLK_F2; break;
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
425 case Qt::Key_F3: scancode = SDLK_F3; break;
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
426 case Qt::Key_F4: scancode = SDLK_F4; break;
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
427 case Qt::Key_F5: scancode = SDLK_F5; break;
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
428 case Qt::Key_F6: scancode = SDLK_F6; break;
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
429 case Qt::Key_F7: scancode = SDLK_F7; break;
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
430 case Qt::Key_F8: scancode = SDLK_F8; break;
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
431 case Qt::Key_F9: scancode = SDLK_F9; break;
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
432 case Qt::Key_F10: scancode = SDLK_F10; break;
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
433 case Qt::Key_F11: scancode = SDLK_F11; break;
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
434 case Qt::Key_F12: scancode = SDLK_F12; break;
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
435 case Qt::Key_F13: scancode = SDLK_F13; break;
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
436 case Qt::Key_F14: scancode = SDLK_F14; break;
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
437 case Qt::Key_F15: scancode = SDLK_F15; break;
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
438 case Qt::Key_Super_L: scancode = SDLK_LSUPER; break;
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
439 case Qt::Key_Super_R: scancode = SDLK_RSUPER; break;
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
440 case Qt::Key_Menu: scancode = SDLK_MENU; break;
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
441 case Qt::Key_Help: scancode = SDLK_HELP; break;
567
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
442
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
443 case Qt::Key_F33:
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
444 // FIXME: This is a hack to enable the OK key on
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
445 // Zaurii devices. SDLK_RETURN is a suitable key to use
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
446 // since it often is used as such.
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
447 // david@hedbor.org
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
448 scancode = SDLK_RETURN;
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
449 break;
371
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
450 default:
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
451 scancode = SDLK_UNKNOWN;
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
452 break;
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
453 }
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
454 keysym.sym = static_cast<SDLKey>(scancode);
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
455 } else {
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
456 keysym.sym = static_cast<SDLKey>(scancode);
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
457 }
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
458 keysym.scancode = scancode;
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
459 keysym.mod = KMOD_NONE;
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
460 ButtonState st = e->state();
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
461 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
462 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
463 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
464 if ( SDL_TranslateUNICODE ) {
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
465 QChar qchar = e->text()[0];
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
466 keysym.unicode = qchar.unicode();
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
467 } else {
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
468 keysym.unicode = 0;
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
469 }
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
470
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
471 /* 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
472 // if ( (keysym.sym == SDLK_NUMLOCK) || (keysym.sym == SDLK_CAPSLOCK) ) {
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
473 // pressed = 1;
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
474 // }
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
475
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
476 /* Queue the key event */
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
477 if ( pressed ) {
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
478 SDL_PrivateKeyboard(SDL_PRESSED, &keysym);
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
479 } else {
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
480 SDL_PrivateKeyboard(SDL_RELEASED, &keysym);
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
481 }
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
482 }
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
483
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
484 void SDL_QWin::setFullscreen(bool fs_on) {
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
485 my_has_fullscreen = false;
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
486 enableFullscreen();
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
487 }
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
488
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
489 void SDL_QWin::enableFullscreen() {
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
490 // Make sure size is correct
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
491 if(!my_has_fullscreen) {
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
492 setFixedSize(qApp->desktop()->size());
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
493 // This call is needed because showFullScreen won't work
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
494 // 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
495 showNormal();
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
496 // This is needed because showNormal() forcefully changes the window
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
497 // style to WSTyle_TopLevel.
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
498 setWFlags(WStyle_Customize | WStyle_NoBorder);
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
499 // Enable fullscreen.
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
500 showFullScreen();
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
501 my_has_fullscreen = true;
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
502 }
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
503 }
567
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
504
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
505 bool SDL_QWin::lockScreen(bool force) {
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
506 if(!my_painter) {
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
507 if(force || (isVisible() && isActiveWindow())) {
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
508 my_painter = new QDirectPainter(this);
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
509 } else {
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
510 return false;
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
511 }
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
512 }
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
513 my_locked++; // Increate lock refcount
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
514 return true;
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
515 }
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
516
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
517 void SDL_QWin::unlockScreen() {
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
518 if(my_locked > 0) {
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
519 my_locked--; // decrease lock refcount;
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
520 }
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
521 if(!my_locked && my_painter) {
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
522 my_painter->end();
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
523 delete my_painter;
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
524 my_painter = 0;
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
525 }
969fbd4dcd4e From: David Hedbor
Sam Lantinga <slouken@libsdl.org>
parents: 481
diff changeset
526 }