aboutsummaryrefslogtreecommitdiffstats
path: root/distrib/sdl-1.2.15/src/video/qtopia
diff options
context:
space:
mode:
Diffstat (limited to 'distrib/sdl-1.2.15/src/video/qtopia')
-rw-r--r--distrib/sdl-1.2.15/src/video/qtopia/SDL_QPEApp.cc63
-rw-r--r--distrib/sdl-1.2.15/src/video/qtopia/SDL_QPEApp.h33
-rw-r--r--distrib/sdl-1.2.15/src/video/qtopia/SDL_QWin.cc527
-rw-r--r--distrib/sdl-1.2.15/src/video/qtopia/SDL_QWin.h110
-rw-r--r--distrib/sdl-1.2.15/src/video/qtopia/SDL_lowvideo.h65
-rw-r--r--distrib/sdl-1.2.15/src/video/qtopia/SDL_sysevents.cc269
-rw-r--r--distrib/sdl-1.2.15/src/video/qtopia/SDL_sysevents_c.h31
-rw-r--r--distrib/sdl-1.2.15/src/video/qtopia/SDL_sysmouse.cc56
-rw-r--r--distrib/sdl-1.2.15/src/video/qtopia/SDL_sysmouse_c.h32
-rw-r--r--distrib/sdl-1.2.15/src/video/qtopia/SDL_sysvideo.cc403
-rw-r--r--distrib/sdl-1.2.15/src/video/qtopia/SDL_syswm.cc35
-rw-r--r--distrib/sdl-1.2.15/src/video/qtopia/SDL_syswm_c.h28
12 files changed, 1652 insertions, 0 deletions
diff --git a/distrib/sdl-1.2.15/src/video/qtopia/SDL_QPEApp.cc b/distrib/sdl-1.2.15/src/video/qtopia/SDL_QPEApp.cc
new file mode 100644
index 0000000..8daf1c5
--- /dev/null
+++ b/distrib/sdl-1.2.15/src/video/qtopia/SDL_QPEApp.cc
@@ -0,0 +1,63 @@
+/*
+ SDL - Simple DirectMedia Layer
+ Copyright (C) 1997-2012 Sam Lantinga
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with this library; if not, write to the Free
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+ Sam Lantinga
+ slouken@libsdl.org
+*/
+#include "SDL_config.h"
+
+#include <qpe/qpeapplication.h>
+#include <qapplication.h>
+#include <qevent.h>
+
+#include "SDL_thread.h"
+#include "SDL_timer.h"
+#include "SDL_error.h"
+
+/* Flag to tell whether or not the Be application is active or not */
+int SDL_QPEAppActive = 0;
+static QPEApplication *app;
+
+int SDL_InitQPEApp() {
+ if(SDL_QPEAppActive <= 0) {
+ if(!qApp) {
+ int argc = 1;
+ char *argv[] = { { "SDLApp" } };
+ app = new QPEApplication(argc, argv);
+ QWidget dummy;
+ app->showMainWidget(&dummy);
+ } else {
+ app = (QPEApplication*)qApp;
+ }
+ SDL_QPEAppActive++;
+ }
+ return 0;
+}
+
+/* Quit the QPE Application, if there's nothing left to do */
+void SDL_QuitQPEApp(void)
+{
+ /* Decrement the application reference count */
+ SDL_QPEAppActive--;
+ /* If the reference count reached zero, clean up the app */
+ if ( SDL_QPEAppActive == 0 && app) {
+ delete app;
+ app = 0;
+ qApp = 0;
+ }
+}
diff --git a/distrib/sdl-1.2.15/src/video/qtopia/SDL_QPEApp.h b/distrib/sdl-1.2.15/src/video/qtopia/SDL_QPEApp.h
new file mode 100644
index 0000000..8a9ab77
--- /dev/null
+++ b/distrib/sdl-1.2.15/src/video/qtopia/SDL_QPEApp.h
@@ -0,0 +1,33 @@
+/*
+ SDL - Simple DirectMedia Layer
+ Copyright (C) 1997-2012 Sam Lantinga
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+ Sam Lantinga
+ slouken@libsdl.org
+*/
+#include "SDL_config.h"
+
+/* Handle the QPE application loop */
+
+/* Initialize the QPE Application, if it's not already started */
+extern int SDL_InitQPEApp(void);
+
+/* Quit the QPE Application, if there's nothing left to do */
+extern void SDL_QuitQPEApp(void);
+
+/* Flag to tell whether the app is active or not */
+extern int SDL_QPEAppActive;
diff --git a/distrib/sdl-1.2.15/src/video/qtopia/SDL_QWin.cc b/distrib/sdl-1.2.15/src/video/qtopia/SDL_QWin.cc
new file mode 100644
index 0000000..04474ed
--- /dev/null
+++ b/distrib/sdl-1.2.15/src/video/qtopia/SDL_QWin.cc
@@ -0,0 +1,527 @@
+/*
+ SDL - Simple DirectMedia Layer
+ Copyright (C) 1997-2012 Sam Lantinga
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+ Sam Lantinga
+ slouken@libsdl.org
+*/
+#include "SDL_config.h"
+
+#include "SDL_QWin.h"
+#include <qapplication.h>
+#include <qdirectpainter_qws.h>
+
+screenRotationT screenRotation = SDL_QT_NO_ROTATION;
+
+SDL_QWin::SDL_QWin(const QSize& size)
+ : QWidget(0, "SDL_main"), my_painter(0), my_image(0),
+ my_inhibit_resize(false), my_mouse_pos(-1,-1), my_flags(0),
+ my_has_fullscreen(false), my_locked(0)
+{
+ setBackgroundMode(NoBackground);
+}
+
+SDL_QWin::~SDL_QWin() {
+ // Nothing to do yet.
+ if(my_image) {
+ delete my_image;
+ }
+}
+
+void SDL_QWin::setImage(QImage *image) {
+ if ( my_image ) {
+ delete my_image;
+ }
+ my_image = image;
+ // setFixedSize(image->size());
+}
+
+void SDL_QWin::resizeEvent(QResizeEvent *e) {
+ if(size() != qApp->desktop()->size()) {
+ // Widget is not the correct size, so do the fullscreen magic
+ my_has_fullscreen = false;
+ enableFullscreen();
+ }
+ if(my_inhibit_resize) {
+ my_inhibit_resize = false;
+ } else {
+ SDL_PrivateResize(e->size().width(), e->size().height());
+ }
+}
+
+void SDL_QWin::focusInEvent(QFocusEvent *) {
+ // Always do it here, no matter the size.
+ enableFullscreen();
+ SDL_PrivateAppActive(true, SDL_APPINPUTFOCUS);
+}
+
+void SDL_QWin::focusOutEvent(QFocusEvent *) {
+ my_has_fullscreen = false;
+ SDL_PrivateAppActive(false, SDL_APPINPUTFOCUS);
+}
+
+void SDL_QWin::closeEvent(QCloseEvent *e) {
+ SDL_PrivateQuit();
+ e->ignore();
+}
+
+void SDL_QWin::setMousePos(const QPoint &pos) {
+ if(my_image->width() == height()) {
+ if (screenRotation == SDL_QT_ROTATION_90)
+ my_mouse_pos = QPoint(height()-pos.y(), pos.x());
+ else if (screenRotation == SDL_QT_ROTATION_270)
+ my_mouse_pos = QPoint(pos.y(), width()-pos.x());
+ } else {
+ my_mouse_pos = pos;
+ }
+}
+
+void SDL_QWin::mouseMoveEvent(QMouseEvent *e) {
+ Qt::ButtonState button = e->button();
+ int sdlstate = 0;
+ if( (button & Qt::LeftButton)) {
+ sdlstate |= SDL_BUTTON_LMASK;
+ }
+ if( (button & Qt::RightButton)) {
+ sdlstate |= SDL_BUTTON_RMASK;
+ }
+ if( (button & Qt::MidButton)) {
+ sdlstate |= SDL_BUTTON_MMASK;
+ }
+ setMousePos(e->pos());
+ SDL_PrivateMouseMotion(sdlstate, 0, my_mouse_pos.x(), my_mouse_pos.y());
+}
+
+void SDL_QWin::mousePressEvent(QMouseEvent *e) {
+ mouseMoveEvent(e);
+ Qt::ButtonState button = e->button();
+ SDL_PrivateMouseButton(SDL_PRESSED,
+ (button & Qt::LeftButton) ? 1 :
+ ((button & Qt::RightButton) ? 2 : 3),
+ my_mouse_pos.x(), my_mouse_pos.y());
+}
+
+void SDL_QWin::mouseReleaseEvent(QMouseEvent *e) {
+ setMousePos(e->pos());
+ Qt::ButtonState button = e->button();
+ SDL_PrivateMouseButton(SDL_RELEASED,
+ (button & Qt::LeftButton) ? 1 :
+ ((button & Qt::RightButton) ? 2 : 3),
+ my_mouse_pos.x(), my_mouse_pos.y());
+ my_mouse_pos = QPoint(-1, -1);
+}
+
+static inline void
+gs_fastRotateBlit_3 ( unsigned short *fb,
+ unsigned short *bits,
+ const QRect& rect )
+{
+ // FIXME: this only works correctly for 240x320 displays
+ int startx, starty;
+ int width, height;
+
+ startx = rect.left() >> 1;
+ starty = rect.top() >> 1;
+ width = ((rect.right() - rect.left()) >> 1) + 2;
+ height = ((rect.bottom() - rect.top()) >> 1) + 2;
+
+ if((startx+width) > 120) {
+ width = 120 - startx; // avoid horizontal overflow
+ }
+ if((starty+height) > 160) {
+ height = 160 - starty; // avoid vertical overflow
+ }
+
+ ulong *sp1, *sp2, *dp1, *dp2;
+ ulong stop, sbot, dtop, dbot;
+
+ sp1 = (ulong*)bits + startx + starty*240;
+ sp2 = sp1 + 120;
+ dp1 = (ulong *)fb + (159 - starty) + startx*320;
+ dp2 = dp1 + 160;
+ int rowadd = (-320*width) - 1;
+ int rowadd2 = 240 - width;
+ // transfer in cells of 2x2 pixels in words
+ for (int y=0; y<height; y++) {
+ for (int x=0; x<width; x++) {
+ // read source pixels
+ stop = *sp1;
+ sbot = *sp2;
+ // rotate pixels
+ dtop = (sbot & 0xffff) + ((stop & 0xffff)<<16);
+ dbot = ((sbot & 0xffff0000)>>16) + (stop & 0xffff0000);
+ // write to framebuffer
+ *dp1 = dtop;
+ *dp2 = dbot;
+ // update source ptrs
+ sp1++; sp2++;
+ // update dest ptrs - 2 pix at a time
+ dp1 += 320;
+ dp2 += 320;
+ }
+ // adjust src ptrs - skip a row as we work in pairs
+ sp1 += rowadd2;
+ sp2 += rowadd2;
+ // adjust dest ptrs for rotation
+ dp1 += rowadd;
+ dp2 += rowadd;
+ }
+}
+
+static inline void
+gs_fastRotateBlit_1 ( unsigned short *fb,
+ unsigned short *bits,
+ const QRect& rect ) {
+ // FIXME: this only works correctly for 240x320 displays
+ int startx, starty;
+ int width, height;
+
+ startx = rect.left() >> 1;
+ starty = rect.top() >> 1;
+ width = ((rect.right() - rect.left()) >> 1) + 2;
+ height = ((rect.bottom() - rect.top()) >> 1) + 2;
+
+ if((startx+width) > 120) {
+ width = 120 - startx; // avoid horizontal overflow
+ }
+ if((starty+height) > 160) {
+ height = 160 - starty; // avoid vertical overflow
+ }
+
+ ulong *sp1, *sp2, *dp1, *dp2;
+ ulong stop, sbot, dtop, dbot;
+ fb += 320*239; // Move "fb" to top left corner
+ sp1 = (ulong*)bits + startx + starty*240;
+ sp2 = sp1 + 120;
+ dp1 = (ulong*)fb - startx * 320 - starty;
+ dp2 = dp1 - 160;
+ int rowadd = (320*width) + 1;
+ int rowadd2 = 240 - width;
+ // transfer in cells of 2x2 pixels in words
+ for (int y=0; y<height; y++) {
+ for (int x=0; x<width; x++) {
+ // read
+ stop = *sp1;
+ sbot = *sp2;
+ // rotate
+ dtop = (stop & 0xffff) + ((sbot & 0xffff)<<16);
+ dbot = ((stop & 0xffff0000)>>16) + (sbot & 0xffff0000);
+ // write
+ *dp1 = dtop;
+ *dp2 = dbot;
+ // update source ptrs
+ sp1++; sp2++;
+ // update dest ptrs - 2 pix at a time
+ dp1 -= 320;
+ dp2 -= 320;
+ }
+ // adjust src ptrs - skip a row as we work in pairs
+ sp1 += rowadd2;
+ sp2 += rowadd2;
+ // adjust dest ptrs for rotation
+ dp1 += rowadd;
+ dp2 += rowadd;
+ }
+}
+
+// desktop, SL-A300 etc
+bool SDL_QWin::repaintRotation0(const QRect& rect) {
+ if(my_image->width() == width()) {
+ uchar *fb = (uchar*)my_painter->frameBuffer();
+ uchar *buf = (uchar*)my_image->bits();
+ if(rect == my_image->rect()) {
+ SDL_memcpy(fb, buf, width()*height()*2);
+ } else {
+ int h = rect.height();
+ int wd = rect.width()<<1;
+ int fblineadd = my_painter->lineStep();
+ int buflineadd = my_image->bytesPerLine();
+ fb += (rect.left()<<1) + rect.top() * my_painter->lineStep();
+ buf += (rect.left()<<1) + rect.top() * my_image->bytesPerLine();
+ while(h--) {
+ SDL_memcpy(fb, buf, wd);
+ fb += fblineadd;
+ buf += buflineadd;
+ }
+ }
+ } else {
+ return false; // FIXME: Landscape
+ }
+#ifdef __i386__
+ my_painter->fillRect( rect, QBrush( Qt::NoBrush ) );
+#endif
+ return true;
+}
+
+
+// Sharp Zaurus SL-5500 etc
+bool SDL_QWin::repaintRotation3(const QRect& rect) {
+ if(my_image->width() == width()) {
+ ushort *fb = (ushort*)my_painter->frameBuffer();
+ ushort *buf = (ushort*)my_image->bits();
+ gs_fastRotateBlit_3(fb, buf, rect);
+ } else {
+ // landscape mode
+ if (screenRotation == SDL_QT_ROTATION_90) {
+ uchar *fb = (uchar*)my_painter->frameBuffer();
+ uchar *buf = (uchar*)my_image->bits();
+ if(rect == my_image->rect()) {
+ SDL_memcpy(fb, buf, width()*height()*2);
+ } else {
+ int h = rect.height();
+ int wd = rect.width()<<1;
+ int fblineadd = my_painter->lineStep();
+ int buflineadd = my_image->bytesPerLine();
+ fb += (rect.left()<<1) + rect.top() * my_painter->lineStep();
+ buf += (rect.left()<<1) + rect.top() * my_image->bytesPerLine();
+ while(h--) {
+ SDL_memcpy(fb, buf, wd);
+ fb += fblineadd;
+ buf += buflineadd;
+ }
+ }
+ } else if (screenRotation == SDL_QT_ROTATION_270) {
+ int h = rect.height();
+ int wd = rect.width();
+ int fblineadd = my_painter->lineStep() - (rect.width() << 1);
+ int buflineadd = my_image->bytesPerLine() - (rect.width() << 1);
+ int w;
+
+ uchar *fb = (uchar*)my_painter->frameBuffer();
+ uchar *buf = (uchar*)my_image->bits();
+
+ fb += ((my_painter->width() - (rect.top() + rect.height())) *
+ my_painter->lineStep()) + ((my_painter->height() - ((rect.left() +
+ rect.width()))) << 1);
+
+ buf += my_image->bytesPerLine() * (rect.top() + rect.height()) -
+ (((my_image->width() - (rect.left() + rect.width())) << 1) + 2);
+
+ while(h--) {
+ w = wd;
+ while(w--) *((unsigned short*)fb)++ = *((unsigned short*)buf)--;
+ fb += fblineadd;
+ buf -= buflineadd;
+ }
+ }
+ }
+ return true;
+}
+
+// ipaq 3800...
+bool SDL_QWin::repaintRotation1(const QRect& rect) {
+ if(my_image->width() == width()) {
+ ushort *fb = (ushort*)my_painter->frameBuffer();
+ ushort *buf = (ushort*)my_image->bits();
+ gs_fastRotateBlit_1(fb, buf, rect);
+ } else {
+ return false; // FIXME: landscape mode
+ }
+ return true;
+}
+
+void SDL_QWin::repaintRect(const QRect& rect) {
+ if(!my_painter || !rect.width() || !rect.height()) {
+ return;
+ }
+
+ if(QPixmap::defaultDepth() == 16) {
+ switch(my_painter->transformOrientation()) {
+ case 3:
+ if(repaintRotation3(rect)) { return; }
+ break;
+ case 1:
+ if(repaintRotation1(rect)) { return; }
+ break;
+ case 0:
+ if(repaintRotation0(rect)) { return; }
+ break;
+ }
+ }
+ my_painter->drawImage(rect.topLeft(), *my_image, rect);
+}
+
+// This paints the current buffer to the screen, when desired.
+void SDL_QWin::paintEvent(QPaintEvent *ev) {
+ if(my_image) {
+ lockScreen(true);
+ repaintRect(ev->rect());
+ unlockScreen();
+ }
+}
+
+/* Function to translate a keyboard transition and queue the key event
+ * This should probably be a table although this method isn't exactly
+ * slow.
+ */
+void SDL_QWin::QueueKey(QKeyEvent *e, int pressed)
+{
+ SDL_keysym keysym;
+ int scancode = e->key();
+ /* Set the keysym information */
+ if(scancode >= 'A' && scancode <= 'Z') {
+ // Qt sends uppercase, SDL wants lowercase
+ keysym.sym = static_cast<SDLKey>(scancode + 32);
+ } else if(scancode >= 0x1000) {
+ // Special keys
+ switch(scancode) {
+ case Qt::Key_Escape: scancode = SDLK_ESCAPE; break;
+ case Qt::Key_Tab: scancode = SDLK_TAB; break;
+ case Qt::Key_Backspace: scancode = SDLK_BACKSPACE; break;
+ case Qt::Key_Return: scancode = SDLK_RETURN; break;
+ case Qt::Key_Enter: scancode = SDLK_KP_ENTER; break;
+ case Qt::Key_Insert: scancode = SDLK_INSERT; break;
+ case Qt::Key_Delete: scancode = SDLK_DELETE; break;
+ case Qt::Key_Pause: scancode = SDLK_PAUSE; break;
+ case Qt::Key_Print: scancode = SDLK_PRINT; break;
+ case Qt::Key_SysReq: scancode = SDLK_SYSREQ; break;
+ case Qt::Key_Home: scancode = SDLK_HOME; break;
+ case Qt::Key_End: scancode = SDLK_END; break;
+ // We want the control keys to rotate with the screen
+ case Qt::Key_Left:
+ if (screenRotation == SDL_QT_ROTATION_90) scancode = SDLK_UP;
+ else if (screenRotation == SDL_QT_ROTATION_270) scancode = SDLK_DOWN;
+ else scancode = SDLK_LEFT;
+ break;
+ case Qt::Key_Up:
+ if (screenRotation == SDL_QT_ROTATION_90) scancode = SDLK_RIGHT;
+ else if (screenRotation == SDL_QT_ROTATION_270) scancode = SDLK_LEFT;
+ else scancode = SDLK_UP;
+ break;
+ case Qt::Key_Right:
+ if (screenRotation == SDL_QT_ROTATION_90) scancode = SDLK_DOWN;
+ else if (screenRotation == SDL_QT_ROTATION_270) scancode = SDLK_UP;
+ else scancode = SDLK_RIGHT;
+ break;
+ case Qt::Key_Down:
+ if (screenRotation == SDL_QT_ROTATION_90) scancode = SDLK_LEFT;
+ else if (screenRotation == SDL_QT_ROTATION_270) scancode = SDLK_RIGHT;
+ else scancode = SDLK_DOWN;
+ break;
+ case Qt::Key_Prior: scancode = SDLK_PAGEUP; break;
+ case Qt::Key_Next: scancode = SDLK_PAGEDOWN; break;
+ case Qt::Key_Shift: scancode = SDLK_LSHIFT; break;
+ case Qt::Key_Control: scancode = SDLK_LCTRL; break;
+ case Qt::Key_Meta: scancode = SDLK_LMETA; break;
+ case Qt::Key_Alt: scancode = SDLK_LALT; break;
+ case Qt::Key_CapsLock: scancode = SDLK_CAPSLOCK; break;
+ case Qt::Key_NumLock: scancode = SDLK_NUMLOCK; break;
+ case Qt::Key_ScrollLock: scancode = SDLK_SCROLLOCK; break;
+ case Qt::Key_F1: scancode = SDLK_F1; break;
+ case Qt::Key_F2: scancode = SDLK_F2; break;
+ case Qt::Key_F3: scancode = SDLK_F3; break;
+ case Qt::Key_F4: scancode = SDLK_F4; break;
+ case Qt::Key_F5: scancode = SDLK_F5; break;
+ case Qt::Key_F6: scancode = SDLK_F6; break;
+ case Qt::Key_F7: scancode = SDLK_F7; break;
+ case Qt::Key_F8: scancode = SDLK_F8; break;
+ case Qt::Key_F9: scancode = SDLK_F9; break;
+ case Qt::Key_F10: scancode = SDLK_F10; break;
+ case Qt::Key_F11: scancode = SDLK_F11; break;
+ case Qt::Key_F12: scancode = SDLK_F12; break;
+ case Qt::Key_F13: scancode = SDLK_F13; break;
+ case Qt::Key_F14: scancode = SDLK_F14; break;
+ case Qt::Key_F15: scancode = SDLK_F15; break;
+ case Qt::Key_Super_L: scancode = SDLK_LSUPER; break;
+ case Qt::Key_Super_R: scancode = SDLK_RSUPER; break;
+ case Qt::Key_Menu: scancode = SDLK_MENU; break;
+ case Qt::Key_Help: scancode = SDLK_HELP; break;
+
+ case Qt::Key_F33:
+ // FIXME: This is a hack to enable the OK key on
+ // Zaurii devices. SDLK_RETURN is a suitable key to use
+ // since it often is used as such.
+ // david@hedbor.org
+ scancode = SDLK_RETURN;
+ break;
+ default:
+ scancode = SDLK_UNKNOWN;
+ break;
+ }
+ keysym.sym = static_cast<SDLKey>(scancode);
+ } else {
+ keysym.sym = static_cast<SDLKey>(scancode);
+ }
+ keysym.scancode = scancode;
+ keysym.mod = KMOD_NONE;
+ ButtonState st = e->state();
+ if( (st & ShiftButton) ) { keysym.mod = static_cast<SDLMod>(keysym.mod | KMOD_LSHIFT); }
+ if( (st & ControlButton) ) { keysym.mod = static_cast<SDLMod>(keysym.mod | KMOD_LCTRL); }
+ if( (st & AltButton) ) { keysym.mod = static_cast<SDLMod>(keysym.mod | KMOD_LALT); }
+ if ( SDL_TranslateUNICODE ) {
+ QChar qchar = e->text()[0];
+ keysym.unicode = qchar.unicode();
+ } else {
+ keysym.unicode = 0;
+ }
+
+ /* NUMLOCK and CAPSLOCK are implemented as double-presses in reality */
+ // if ( (keysym.sym == SDLK_NUMLOCK) || (keysym.sym == SDLK_CAPSLOCK) ) {
+ // pressed = 1;
+ // }
+
+ /* Queue the key event */
+ if ( pressed ) {
+ SDL_PrivateKeyboard(SDL_PRESSED, &keysym);
+ } else {
+ SDL_PrivateKeyboard(SDL_RELEASED, &keysym);
+ }
+}
+
+void SDL_QWin::setFullscreen(bool fs_on) {
+ my_has_fullscreen = false;
+ enableFullscreen();
+}
+
+void SDL_QWin::enableFullscreen() {
+ // Make sure size is correct
+ if(!my_has_fullscreen) {
+ setFixedSize(qApp->desktop()->size());
+ // This call is needed because showFullScreen won't work
+ // correctly if the widget already considers itself to be fullscreen.
+ showNormal();
+ // This is needed because showNormal() forcefully changes the window
+ // style to WSTyle_TopLevel.
+ setWFlags(WStyle_Customize | WStyle_NoBorder);
+ // Enable fullscreen.
+ showFullScreen();
+ my_has_fullscreen = true;
+ }
+}
+
+bool SDL_QWin::lockScreen(bool force) {
+ if(!my_painter) {
+ if(force || (isVisible() && isActiveWindow())) {
+ my_painter = new QDirectPainter(this);
+ } else {
+ return false;
+ }
+ }
+ my_locked++; // Increate lock refcount
+ return true;
+}
+
+void SDL_QWin::unlockScreen() {
+ if(my_locked > 0) {
+ my_locked--; // decrease lock refcount;
+ }
+ if(!my_locked && my_painter) {
+ my_painter->end();
+ delete my_painter;
+ my_painter = 0;
+ }
+}
diff --git a/distrib/sdl-1.2.15/src/video/qtopia/SDL_QWin.h b/distrib/sdl-1.2.15/src/video/qtopia/SDL_QWin.h
new file mode 100644
index 0000000..2531834
--- /dev/null
+++ b/distrib/sdl-1.2.15/src/video/qtopia/SDL_QWin.h
@@ -0,0 +1,110 @@
+/*
+ SDL - Simple DirectMedia Layer
+ Copyright (C) 1997-2012 Sam Lantinga
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+ Sam Lantinga
+ slouken@libsdl.org
+*/
+#include "SDL_config.h"
+
+#ifndef _SDL_QWin_h
+#define _SDL_QWin_h
+
+#include <stdio.h>
+
+#include <qimage.h>
+#include <qpixmap.h>
+#include <qwidget.h>
+#include <qpainter.h>
+#include <qdirectpainter_qws.h>
+
+#include "SDL_events.h"
+
+extern "C" {
+#include "../../events/SDL_events_c.h"
+};
+
+typedef enum {
+ SDL_QT_NO_ROTATION = 0,
+ SDL_QT_ROTATION_90,
+ SDL_QT_ROTATION_270
+} screenRotationT;
+
+extern screenRotationT screenRotation;
+
+class SDL_QWin : public QWidget
+{
+ void QueueKey(QKeyEvent *e, int pressed);
+ public:
+ SDL_QWin(const QSize& size);
+ virtual ~SDL_QWin();
+ virtual bool shown(void) {
+ return isVisible();
+ }
+ /* If called, the next resize event will not be forwarded to SDL. */
+ virtual void inhibitResize(void) {
+ my_inhibit_resize = true;
+ }
+ void setImage(QImage *image);
+ void setOffset(int x, int y) {
+ my_offset = QPoint(x, y);
+ }
+ void GetXYOffset(int &x, int &y) {
+ x = my_offset.x();
+ y = my_offset.y();
+ }
+ QImage *image(void) { return my_image; }
+
+ void setWFlags(WFlags flags) {
+ QWidget::setWFlags(flags);
+ my_flags = flags;
+ }
+ const QPoint& mousePos() const { return my_mouse_pos; }
+ void setMousePos(const QPoint& newpos);
+ void setFullscreen(bool);
+
+ bool lockScreen(bool force=false);
+ void unlockScreen();
+ void repaintRect(const QRect& rect);
+ protected:
+ /* Handle resizing of the window */
+ virtual void resizeEvent(QResizeEvent *e);
+ void focusInEvent(QFocusEvent *);
+ void focusOutEvent(QFocusEvent *);
+ void closeEvent(QCloseEvent *e);
+ void mouseMoveEvent(QMouseEvent *e);
+ void mousePressEvent(QMouseEvent *e);
+ void mouseReleaseEvent(QMouseEvent *e);
+ void paintEvent(QPaintEvent *ev);
+ void keyPressEvent(QKeyEvent *e) { QueueKey(e, 1); }
+ void keyReleaseEvent(QKeyEvent *e) { QueueKey(e, 0); }
+ private:
+ bool repaintRotation0(const QRect& rect);
+ bool repaintRotation1(const QRect& rect);
+ bool repaintRotation3(const QRect& rect);
+ void enableFullscreen();
+ QDirectPainter *my_painter;
+ QImage *my_image;
+ bool my_inhibit_resize;
+ QPoint my_offset;
+ QPoint my_mouse_pos;
+ WFlags my_flags;
+ WFlags my_has_fullscreen;
+ unsigned int my_locked;
+};
+
+#endif /* _SDL_QWin_h */
diff --git a/distrib/sdl-1.2.15/src/video/qtopia/SDL_lowvideo.h b/distrib/sdl-1.2.15/src/video/qtopia/SDL_lowvideo.h
new file mode 100644
index 0000000..1d05c72
--- /dev/null
+++ b/distrib/sdl-1.2.15/src/video/qtopia/SDL_lowvideo.h
@@ -0,0 +1,65 @@
+/*
+ SDL - Simple DirectMedia Layer
+ Copyright (C) 1997-2012 Sam Lantinga
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+ Sam Lantinga
+ slouken@libsdl.org
+*/
+#include "SDL_config.h"
+
+#ifndef _SDL_lowvideo_h
+#define _SDL_lowvideo_h
+
+#include "SDL_mouse.h"
+#include "../SDL_sysvideo.h"
+
+/* Hidden "this" pointer for the video functions */
+#define _THIS SDL_VideoDevice *_this
+
+/* Private display data */
+struct SDL_PrivateVideoData {
+ /* The main window */
+ SDL_QWin *SDL_Win;
+
+ /* The fullscreen mode list */
+#define NUM_MODELISTS 4 /* 8, 16, 24, and 32 bits-per-pixel */
+ int SDL_nummodes[NUM_MODELISTS];
+ SDL_Rect **SDL_modelist[NUM_MODELISTS];
+
+ /* A completely clear cursor */
+ WMcursor *BlankCursor;
+
+ /* Mouse state variables */
+ Uint32 last_buttons;
+ QPoint last_point;
+
+ /* Keyboard state variables */
+ int key_flip;
+ //struct key_info keyinfo[2];
+};
+/* Old variable names */
+#define SDL_Win (_this->hidden->SDL_Win)
+#define saved_mode (_this->hidden->saved_mode)
+#define SDL_nummodes (_this->hidden->SDL_nummodes)
+#define SDL_modelist (_this->hidden->SDL_modelist)
+#define SDL_BlankCursor (_this->hidden->BlankCursor)
+#define last_buttons (_this->hidden->last_buttons)
+#define last_point (_this->hidden->last_point)
+#define key_flip (_this->hidden->key_flip)
+#define keyinfo (_this->hidden->keyinfo)
+
+#endif /* _SDL_lowvideo_h */
diff --git a/distrib/sdl-1.2.15/src/video/qtopia/SDL_sysevents.cc b/distrib/sdl-1.2.15/src/video/qtopia/SDL_sysevents.cc
new file mode 100644
index 0000000..4aaf814
--- /dev/null
+++ b/distrib/sdl-1.2.15/src/video/qtopia/SDL_sysevents.cc
@@ -0,0 +1,269 @@
+/*
+ SDL - Simple DirectMedia Layer
+ Copyright (C) 1997-2012 Sam Lantinga
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+ Sam Lantinga
+ slouken@libsdl.org
+*/
+#include "SDL_config.h"
+
+#include <qpe/qpeapplication.h>
+
+#include <stdio.h>
+#include <string.h>
+#include "SDL_error.h"
+#include "SDL_events.h"
+#include "SDL_QWin.h"
+#include "SDL_lowvideo.h"
+#include "SDL_timer.h"
+
+extern "C" {
+#include "../../events/SDL_sysevents.h"
+#include "../../events/SDL_events_c.h"
+#include "SDL_sysevents_c.h"
+
+ // static SDLKey keymap[128];
+/* This is special because we know it will be run in a loop in a separate
+ thread. Normally this function should loop as long as there are input
+ states changing, i.e. new events arriving.
+*/
+void QT_PumpEvents(_THIS)
+{
+ if(!qApp) {
+ return;
+ }
+ // printf("processing events: %p\n", qApp);
+ //qApp->processOneEvent(); // wait for a event
+ qApp->processEvents(); // and process all outstanding ones
+#if 0
+ BView *view;
+ BRect bounds;
+ BPoint point;
+ uint32 buttons;
+ const uint32 button_masks[3] = {
+ B_PRIMARY_MOUSE_BUTTON,
+ B_TERTIARY_MOUSE_BUTTON,
+ B_SECONDARY_MOUSE_BUTTON,
+ };
+ unsigned int i, j;
+
+ /* Check out the mouse buttons and position (slight race condition) */
+ if ( SDL_Win->Lock() ) {
+ /* Don't do anything if we have no view */
+ view = SDL_Win->View();
+ if ( ! view ) {
+ SDL_Win->Unlock();
+ return;
+ }
+ bounds = view->Bounds();
+ /* Get new input state, if still active */
+ if ( SDL_Win->IsActive() ) {
+ key_flip = !key_flip;
+ get_key_info(&keyinfo[key_flip]);
+ view->GetMouse(&point, &buttons, true);
+ } else {
+ key_flip = key_flip;
+ point = last_point;
+ buttons = last_buttons;
+ }
+ SDL_Win->Unlock();
+ } else {
+ return;
+ }
+
+ /* If our view is active, we'll find key changes here */
+ if ( SDL_memcmp(keyinfo[0].key_states, keyinfo[1].key_states, 16) != 0 ) {
+ for ( i=0; i<16; ++i ) {
+ Uint8 new_state, transition;
+
+ new_state = keyinfo[key_flip].key_states[i];
+ transition = keyinfo[!key_flip].key_states[i] ^
+ keyinfo[ key_flip].key_states[i];
+ for ( j=0; j<8; ++j ) {
+ if ( transition&0x80 )
+ QueueKey(i*8+j, new_state&0x80);
+ transition <<= 1;
+ new_state <<= 1;
+ }
+ }
+ }
+
+ /* We check keyboard, but not mouse if mouse isn't in window */
+ if ( ! bounds.Contains(point) ) {
+ /* Mouse moved outside our view? */
+ if ( SDL_GetAppState() & SDL_APPMOUSEFOCUS ) {
+ SDL_PrivateAppActive(0, SDL_APPMOUSEFOCUS);
+ be_app->SetCursor(B_HAND_CURSOR);
+ }
+ return;
+ }
+ /* Has the mouse moved back into our view? */
+ if ( ! (SDL_GetAppState() & SDL_APPMOUSEFOCUS) ) {
+ /* Reset the B_HAND_CURSOR to our own */
+ SDL_PrivateAppActive(1, SDL_APPMOUSEFOCUS);
+ SDL_SetCursor(NULL);
+ }
+
+ /* Check for mouse motion */
+ if ( point != last_point ) {
+ int x, y;
+
+ SDL_Win->GetXYOffset(x, y);
+ x = (int)point.x - x;
+ y = (int)point.y - y;
+ SDL_PrivateMouseMotion(0, 0, x, y);
+ }
+ last_point = point;
+
+ /* Add any mouse button events */
+ for ( i=0; i<SDL_TABLESIZE(button_masks); ++i ) {
+ if ( (buttons ^ last_buttons) & button_masks[i] ) {
+ if ( buttons & button_masks[i] ) {
+ SDL_PrivateMouseButton(SDL_PRESSED, 1+i, 0, 0);
+ } else {
+ SDL_PrivateMouseButton(SDL_RELEASED, 1+i, 0, 0);
+ }
+ }
+ }
+ last_buttons = buttons;
+#endif
+}
+
+void QT_InitOSKeymap(_THIS)
+{
+#if 0
+ unsigned int i;
+
+ /* Initialize all the key states as "up" */
+ key_flip = 0;
+ SDL_memset(keyinfo[key_flip].key_states, 0, 16);
+
+ /* Initialize the key translation table */
+ for ( i=0; i<SDL_TABLESIZE(keymap); ++i )
+ keymap[i] = SDLK_UNKNOWN;
+
+ // keymap[0x01] = SDLK_ESCAPE;
+ // keymap[B_F1_KEY] = SDLK_F1;
+ // keymap[B_F2_KEY] = SDLK_F2;
+ // keymap[B_F3_KEY] = SDLK_F3;
+ // keymap[B_F4_KEY] = SDLK_F4;
+ // keymap[B_F5_KEY] = SDLK_F5;
+ // keymap[B_F6_KEY] = SDLK_F6;
+ // keymap[B_F7_KEY] = SDLK_F7;
+ // keymap[B_F8_KEY] = SDLK_F8;
+ // keymap[B_F9_KEY] = SDLK_F9;
+ // keymap[B_F10_KEY] = SDLK_F10;
+ // keymap[B_F11_KEY] = SDLK_F11;
+ // keymap[B_F12_KEY] = SDLK_F12;
+ // keymap[B_PRINT_KEY] = SDLK_PRINT;
+ //keymap[B_SCROLL_KEY] = SDLK_SCROLLOCK;
+ // keymap[B_PAUSE_KEY] = SDLK_PAUSE;
+ keymap[0x11] = SDLK_BACKQUOTE;
+ keymap[0x12] = SDLK_1;
+ keymap[0x13] = SDLK_2;
+ keymap[0x14] = SDLK_3;
+ keymap[0x15] = SDLK_4;
+ keymap[0x16] = SDLK_5;
+ keymap[0x17] = SDLK_6;
+ keymap[0x18] = SDLK_7;
+ keymap[0x19] = SDLK_8;
+ keymap[0x1a] = SDLK_9;
+ keymap[0x1b] = SDLK_0;
+ keymap[0x1c] = SDLK_MINUS;
+ keymap[0x1d] = SDLK_EQUALS;
+ keymap[0x1e] = SDLK_BACKSPACE;
+ keymap[0x1f] = SDLK_INSERT;
+ keymap[0x20] = SDLK_HOME;
+ keymap[0x21] = SDLK_PAGEUP;
+ //keymap[0x22] = SDLK_NUMLOCK;
+ keymap[0x23] = SDLK_KP_DIVIDE;
+ keymap[0x24] = SDLK_KP_MULTIPLY;
+ keymap[0x25] = SDLK_KP_MINUS;
+ keymap[0x26] = SDLK_TAB;
+ keymap[0x27] = SDLK_q;
+ keymap[0x28] = SDLK_w;
+ keymap[0x29] = SDLK_e;
+ keymap[0x2a] = SDLK_r;
+ keymap[0x2b] = SDLK_t;
+ keymap[0x2c] = SDLK_y;
+ keymap[0x2d] = SDLK_u;
+ keymap[0x2e] = SDLK_i;
+ keymap[0x2f] = SDLK_o;
+ keymap[0x30] = SDLK_p;
+ keymap[0x31] = SDLK_LEFTBRACKET;
+ keymap[0x32] = SDLK_RIGHTBRACKET;
+ keymap[0x33] = SDLK_BACKSLASH;
+ keymap[0x34] = SDLK_DELETE;
+ keymap[0x35] = SDLK_END;
+ keymap[0x36] = SDLK_PAGEDOWN;
+ keymap[0x37] = SDLK_KP7;
+ keymap[0x38] = SDLK_KP8;
+ keymap[0x39] = SDLK_KP9;
+ keymap[0x3a] = SDLK_KP_PLUS;
+ //keymap[0x3b] = SDLK_CAPSLOCK;
+ keymap[0x3c] = SDLK_a;
+ keymap[0x3d] = SDLK_s;
+ keymap[0x3e] = SDLK_d;
+ keymap[0x3f] = SDLK_f;
+ keymap[0x40] = SDLK_g;
+ keymap[0x41] = SDLK_h;
+ keymap[0x42] = SDLK_j;
+ keymap[0x43] = SDLK_k;
+ keymap[0x44] = SDLK_l;
+ keymap[0x45] = SDLK_SEMICOLON;
+ keymap[0x46] = SDLK_QUOTE;
+ keymap[0x47] = SDLK_RETURN;
+ keymap[0x48] = SDLK_KP4;
+ keymap[0x49] = SDLK_KP5;
+ keymap[0x4a] = SDLK_KP6;
+ keymap[0x4b] = SDLK_LSHIFT;
+ keymap[0x4c] = SDLK_z;
+ keymap[0x4d] = SDLK_x;
+ keymap[0x4e] = SDLK_c;
+ keymap[0x4f] = SDLK_v;
+ keymap[0x50] = SDLK_b;
+ keymap[0x51] = SDLK_n;
+ keymap[0x52] = SDLK_m;
+ keymap[0x53] = SDLK_COMMA;
+ keymap[0x54] = SDLK_PERIOD;
+ keymap[0x55] = SDLK_SLASH;
+ keymap[0x56] = SDLK_RSHIFT;
+ keymap[0x57] = SDLK_UP;
+ keymap[0x58] = SDLK_KP1;
+ keymap[0x59] = SDLK_KP2;
+ keymap[0x5a] = SDLK_KP3;
+ keymap[0x5b] = SDLK_KP_ENTER;
+ //keymap[0x5c] = SDLK_LCTRL;
+ //keymap[0x5d] = SDLK_LALT;
+ keymap[0x5e] = SDLK_SPACE;
+ //keymap[0x5f] = SDLK_RALT;
+ //keymap[0x60] = SDLK_RCTRL;
+ keymap[0x61] = SDLK_LEFT;
+ keymap[0x62] = SDLK_DOWN;
+ keymap[0x63] = SDLK_RIGHT;
+ keymap[0x64] = SDLK_KP0;
+ keymap[0x65] = SDLK_KP_PERIOD;
+ //keymap[0x66] = SDLK_LMETA;
+ //keymap[0x67] = SDLK_RMETA;
+ //keymap[0x68] = SDLK_MENU;
+ keymap[0x69] = SDLK_EURO;
+ keymap[0x6a] = SDLK_KP_EQUALS;
+ keymap[0x6b] = SDLK_POWER;
+#endif
+}
+
+}; /* Extern C */
diff --git a/distrib/sdl-1.2.15/src/video/qtopia/SDL_sysevents_c.h b/distrib/sdl-1.2.15/src/video/qtopia/SDL_sysevents_c.h
new file mode 100644
index 0000000..5e26759
--- /dev/null
+++ b/distrib/sdl-1.2.15/src/video/qtopia/SDL_sysevents_c.h
@@ -0,0 +1,31 @@
+/*
+ SDL - Simple DirectMedia Layer
+ Copyright (C) 1997-2012 Sam Lantinga
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+ Sam Lantinga
+ slouken@libsdl.org
+*/
+#include "SDL_config.h"
+
+#include "SDL_lowvideo.h"
+
+/* Variables and functions exported by SDL_sysevents.c to other parts
+ of the native video subsystem (SDL_sysvideo.c)
+*/
+
+extern void QT_InitOSKeymap(_THIS);
+extern void QT_PumpEvents(_THIS);
diff --git a/distrib/sdl-1.2.15/src/video/qtopia/SDL_sysmouse.cc b/distrib/sdl-1.2.15/src/video/qtopia/SDL_sysmouse.cc
new file mode 100644
index 0000000..1a655b6
--- /dev/null
+++ b/distrib/sdl-1.2.15/src/video/qtopia/SDL_sysmouse.cc
@@ -0,0 +1,56 @@
+/*
+ SDL - Simple DirectMedia Layer
+ Copyright (C) 1997-2012 Sam Lantinga
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+ Sam Lantinga
+ slouken@libsdl.org
+*/
+#include "SDL_config.h"
+
+#include "SDL_QWin.h"
+
+extern "C" {
+
+#include "SDL_sysmouse_c.h"
+
+/* The implementation dependent data for the window manager cursor */
+struct WMcursor {
+ char *bits;
+};
+WMcursor *QT_CreateWMCursor(_THIS,
+ Uint8 *data, Uint8 *mask, int w, int h, int hot_x, int hot_y)
+{
+ static WMcursor dummy;
+ dummy.bits = 0;
+ return &dummy;
+}
+
+int QT_ShowWMCursor(_THIS, WMcursor *cursor)
+{
+ return 1;
+}
+
+void QT_FreeWMCursor(_THIS, WMcursor *cursor)
+{
+}
+
+void QT_WarpWMCursor(_THIS, Uint16 x, Uint16 y)
+{
+ SDL_Win->setMousePos(QPoint(x, y));
+}
+
+}; /* Extern C */
diff --git a/distrib/sdl-1.2.15/src/video/qtopia/SDL_sysmouse_c.h b/distrib/sdl-1.2.15/src/video/qtopia/SDL_sysmouse_c.h
new file mode 100644
index 0000000..98e4cf5
--- /dev/null
+++ b/distrib/sdl-1.2.15/src/video/qtopia/SDL_sysmouse_c.h
@@ -0,0 +1,32 @@
+/*
+ SDL - Simple DirectMedia Layer
+ Copyright (C) 1997-2012 Sam Lantinga
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+ Sam Lantinga
+ slouken@libsdl.org
+*/
+#include "SDL_config.h"
+
+#include "SDL_lowvideo.h"
+
+/* Functions to be exported */
+extern void QT_FreeWMCursor(_THIS, WMcursor *cursor);
+extern WMcursor *QT_CreateWMCursor(_THIS,
+ Uint8 *data, Uint8 *mask, int w, int h, int hot_x, int hot_y);
+extern int QT_ShowWMCursor(_THIS, WMcursor *cursor);
+extern void QT_WarpWMCursor(_THIS, Uint16 x, Uint16 y);
+
diff --git a/distrib/sdl-1.2.15/src/video/qtopia/SDL_sysvideo.cc b/distrib/sdl-1.2.15/src/video/qtopia/SDL_sysvideo.cc
new file mode 100644
index 0000000..0e07874
--- /dev/null
+++ b/distrib/sdl-1.2.15/src/video/qtopia/SDL_sysvideo.cc
@@ -0,0 +1,403 @@
+/*
+ SDL - Simple DirectMedia Layer
+ Copyright (C) 1997-2012 Sam Lantinga
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+ Sam Lantinga
+ slouken@libsdl.org
+*/
+#include "SDL_config.h"
+
+/* Qtopia based framebuffer implementation */
+
+#include <unistd.h>
+
+#include <qapplication.h>
+#include <qpe/qpeapplication.h>
+
+#include "SDL_timer.h"
+
+#include "SDL_QWin.h"
+
+extern "C" {
+
+#include "../SDL_sysvideo.h"
+#include "../../events/SDL_events_c.h"
+#include "SDL_sysevents_c.h"
+#include "SDL_sysmouse_c.h"
+#include "SDL_syswm_c.h"
+#include "SDL_lowvideo.h"
+
+ //#define QTOPIA_DEBUG
+#define QT_HIDDEN_SIZE 32 /* starting hidden window size */
+
+ /* Name of the environment variable used to invert the screen rotation or not:
+ Possible values:
+ !=0 : Screen is 270° rotated
+ 0: Screen is 90° rotated*/
+#define SDL_QT_ROTATION_ENV_NAME "SDL_QT_INVERT_ROTATION"
+
+ /* Initialization/Query functions */
+ static int QT_VideoInit(_THIS, SDL_PixelFormat *vformat);
+ static SDL_Rect **QT_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags);
+ static SDL_Surface *QT_SetVideoMode(_THIS, SDL_Surface *current, int width, int height, int bpp, Uint32 flags);
+ static void QT_UpdateMouse(_THIS);
+ static int QT_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors);
+ static void QT_VideoQuit(_THIS);
+
+ /* Hardware surface functions */
+ static int QT_AllocHWSurface(_THIS, SDL_Surface *surface);
+ static int QT_LockHWSurface(_THIS, SDL_Surface *surface);
+ static void QT_UnlockHWSurface(_THIS, SDL_Surface *surface);
+ static void QT_FreeHWSurface(_THIS, SDL_Surface *surface);
+
+ static int QT_ToggleFullScreen(_THIS, int fullscreen);
+
+ static int QT_IconifyWindow(_THIS);
+ static SDL_GrabMode QT_GrabInput(_THIS, SDL_GrabMode mode);
+
+ /* FB driver bootstrap functions */
+
+ static int QT_Available(void)
+ {
+ return(1);
+ }
+
+ static void QT_DeleteDevice(SDL_VideoDevice *device)
+ {
+ SDL_free(device->hidden);
+ SDL_free(device);
+ }
+
+ static SDL_VideoDevice *QT_CreateDevice(int devindex)
+ {
+ SDL_VideoDevice *device;
+
+ /* Initialize all variables that we clean on shutdown */
+ device = (SDL_VideoDevice *)SDL_malloc(sizeof(SDL_VideoDevice));
+ if ( device ) {
+ SDL_memset(device, 0, (sizeof *device));
+ device->hidden = (struct SDL_PrivateVideoData *)
+ SDL_malloc((sizeof *device->hidden));
+ }
+ if ( (device == NULL) || (device->hidden == NULL) ) {
+ SDL_OutOfMemory();
+ if ( device ) {
+ SDL_free(device);
+ }
+ return(0);
+ }
+ SDL_memset(device->hidden, 0, (sizeof *device->hidden));
+
+ /* Set the function pointers */
+ device->VideoInit = QT_VideoInit;
+ device->ListModes = QT_ListModes;
+ device->SetVideoMode = QT_SetVideoMode;
+ device->UpdateMouse = QT_UpdateMouse;
+ device->SetColors = QT_SetColors;
+ device->UpdateRects = NULL;
+ device->VideoQuit = QT_VideoQuit;
+ device->AllocHWSurface = QT_AllocHWSurface;
+ device->CheckHWBlit = NULL;
+ device->FillHWRect = NULL;
+ device->SetHWColorKey = NULL;
+ device->SetHWAlpha = NULL;
+ device->LockHWSurface = QT_LockHWSurface;
+ device->UnlockHWSurface = QT_UnlockHWSurface;
+ device->FlipHWSurface = NULL;
+ device->FreeHWSurface = QT_FreeHWSurface;
+ device->SetIcon = NULL;
+ device->SetCaption = QT_SetWMCaption;
+ device->IconifyWindow = QT_IconifyWindow;
+ device->GrabInput = QT_GrabInput;
+ device->GetWMInfo = NULL;
+ device->FreeWMCursor = QT_FreeWMCursor;
+ device->CreateWMCursor = QT_CreateWMCursor;
+ device->ShowWMCursor = QT_ShowWMCursor;
+ device->WarpWMCursor = QT_WarpWMCursor;
+ device->InitOSKeymap = QT_InitOSKeymap;
+ device->PumpEvents = QT_PumpEvents;
+
+ device->free = QT_DeleteDevice;
+ device->ToggleFullScreen = QT_ToggleFullScreen;
+
+ /* Set the driver flags */
+ device->handles_any_size = 0;
+
+ return device;
+ }
+
+ VideoBootStrap Qtopia_bootstrap = {
+ "qtopia", "Qtopia / QPE graphics",
+ QT_Available, QT_CreateDevice
+ };
+
+ /* Function to sort the display_list */
+ static int CompareModes(const void *A, const void *B)
+ {
+#if 0
+ const display_mode *a = (display_mode *)A;
+ const display_mode *b = (display_mode *)B;
+
+ if ( a->space == b->space ) {
+ return((b->virtual_width*b->virtual_height)-
+ (a->virtual_width*a->virtual_height));
+ } else {
+ return(ColorSpaceToBitsPerPixel(b->space)-
+ ColorSpaceToBitsPerPixel(a->space));
+ }
+#endif
+ return 0;
+ }
+
+ /* Yes, this isn't the fastest it could be, but it works nicely */
+ static int QT_AddMode(_THIS, int index, unsigned int w, unsigned int h)
+ {
+ SDL_Rect *mode;
+ int i;
+ int next_mode;
+
+ /* Check to see if we already have this mode */
+ if ( SDL_nummodes[index] > 0 ) {
+ for ( i=SDL_nummodes[index]-1; i >= 0; --i ) {
+ mode = SDL_modelist[index][i];
+ if ( (mode->w == w) && (mode->h == h) ) {
+ return(0);
+ }
+ }
+ }
+
+ /* Set up the new video mode rectangle */
+ mode = (SDL_Rect *)SDL_malloc(sizeof *mode);
+ if ( mode == NULL ) {
+ SDL_OutOfMemory();
+ return(-1);
+ }
+ mode->x = 0;
+ mode->y = 0;
+ mode->w = w;
+ mode->h = h;
+#ifdef QTOPIA_DEBUG
+ fprintf(stderr, "Adding mode %dx%d at %d bytes per pixel\n", w, h, index+1);
+#endif
+
+ /* Allocate the new list of modes, and fill in the new mode */
+ next_mode = SDL_nummodes[index];
+ SDL_modelist[index] = (SDL_Rect **)
+ SDL_realloc(SDL_modelist[index], (1+next_mode+1)*sizeof(SDL_Rect *));
+ if ( SDL_modelist[index] == NULL ) {
+ SDL_OutOfMemory();
+ SDL_nummodes[index] = 0;
+ SDL_free(mode);
+ return(-1);
+ }
+ SDL_modelist[index][next_mode] = mode;
+ SDL_modelist[index][next_mode+1] = NULL;
+ SDL_nummodes[index]++;
+
+ return(0);
+ }
+
+ int QT_VideoInit(_THIS, SDL_PixelFormat *vformat)
+ {
+ /* Initialize the QPE Application */
+ /* Determine the screen depth */
+ vformat->BitsPerPixel = QPixmap::defaultDepth();
+
+ // For now we hardcode the current depth because anything else
+ // might as well be emulated by SDL rather than by Qtopia.
+
+ QSize desktop_size = qApp->desktop()->size();
+ QT_AddMode(_this, ((vformat->BitsPerPixel+7)/8)-1,
+ desktop_size.width(), desktop_size.height());
+ QT_AddMode(_this, ((vformat->BitsPerPixel+7)/8)-1,
+ desktop_size.height(), desktop_size.width());
+
+ /* Determine the current screen size */
+ _this->info.current_w = desktop_size.width();
+ _this->info.current_h = desktop_size.height();
+
+ /* Create the window / widget */
+ SDL_Win = new SDL_QWin(QSize(QT_HIDDEN_SIZE, QT_HIDDEN_SIZE));
+ ((QPEApplication*)qApp)->showMainWidget(SDL_Win);
+ /* Fill in some window manager capabilities */
+ _this->info.wm_available = 0;
+
+ /* We're done! */
+ return(0);
+ }
+
+ /* We support any dimension at our bit-depth */
+ SDL_Rect **QT_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags)
+ {
+ SDL_Rect **modes;
+
+ modes = ((SDL_Rect **)0);
+ if ( (flags & SDL_FULLSCREEN) == SDL_FULLSCREEN ) {
+ modes = SDL_modelist[((format->BitsPerPixel+7)/8)-1];
+ } else {
+ if ( format->BitsPerPixel ==
+ _this->screen->format->BitsPerPixel ) {
+ modes = ((SDL_Rect **)-1);
+ }
+ }
+ return(modes);
+ }
+
+ /* Various screen update functions available */
+ static void QT_NormalUpdate(_THIS, int numrects, SDL_Rect *rects);
+
+
+ static int QT_SetFullScreen(_THIS, SDL_Surface *screen, int fullscreen)
+ {
+ return -1;
+ }
+
+ static int QT_ToggleFullScreen(_THIS, int fullscreen)
+ {
+ return -1;
+ }
+
+ /* FIXME: check return values and cleanup here */
+ SDL_Surface *QT_SetVideoMode(_THIS, SDL_Surface *current,
+ int width, int height, int bpp, Uint32 flags)
+ {
+
+ QImage *qimage;
+ QSize desktop_size = qApp->desktop()->size();
+
+
+ current->flags = 0; //SDL_FULLSCREEN; // We always run fullscreen.
+
+ if(width <= desktop_size.width()
+ && height <= desktop_size.height()) {
+ current->w = desktop_size.width();
+ current->h = desktop_size.height();
+ } else if(width <= desktop_size.height() && height <= desktop_size.width()) {
+ // Landscape mode
+ char * envString = SDL_getenv(SDL_QT_ROTATION_ENV_NAME);
+ int envValue = envString ? atoi(envString) : 0;
+ screenRotation = envValue ? SDL_QT_ROTATION_270 : SDL_QT_ROTATION_90;
+ current->h = desktop_size.width();
+ current->w = desktop_size.height();
+ } else {
+ SDL_SetError("Unsupported resolution, %dx%d\n", width, height);
+ }
+ if ( flags & SDL_OPENGL ) {
+ SDL_SetError("OpenGL not supported");
+ return(NULL);
+ }
+ /* Create the QImage framebuffer */
+ qimage = new QImage(current->w, current->h, bpp);
+ if (qimage->isNull()) {
+ SDL_SetError("Couldn't create screen bitmap");
+ delete qimage;
+ return(NULL);
+ }
+ current->pitch = qimage->bytesPerLine();
+ current->pixels = (void *)qimage->bits();
+ SDL_Win->setImage(qimage);
+ _this->UpdateRects = QT_NormalUpdate;
+ SDL_Win->setFullscreen(true);
+ /* We're done */
+ return(current);
+ }
+
+ /* Update the current mouse state and position */
+ void QT_UpdateMouse(_THIS)
+ {
+ QPoint point(-1, -1);
+ if ( SDL_Win->isActiveWindow() ) {
+ point = SDL_Win->mousePos();
+ }
+
+ if ( (point.x() >= 0) && (point.x() < SDL_VideoSurface->w) &&
+ (point.y() >= 0) && (point.y() < SDL_VideoSurface->h) ) {
+ SDL_PrivateAppActive(1, SDL_APPMOUSEFOCUS);
+ SDL_PrivateMouseMotion(0, 0,
+ (Sint16)point.x(), (Sint16)point.y());
+ } else {
+ SDL_PrivateAppActive(0, SDL_APPMOUSEFOCUS);
+ }
+ }
+
+ /* We don't actually allow hardware surfaces other than the main one */
+ static int QT_AllocHWSurface(_THIS, SDL_Surface *surface)
+ {
+ return(-1);
+ }
+ static void QT_FreeHWSurface(_THIS, SDL_Surface *surface)
+ {
+ return;
+ }
+ static int QT_LockHWSurface(_THIS, SDL_Surface *surface)
+ {
+ return(0);
+ }
+ static void QT_UnlockHWSurface(_THIS, SDL_Surface *surface)
+ {
+ return;
+ }
+
+ static void QT_NormalUpdate(_THIS, int numrects, SDL_Rect *rects)
+ {
+ if(SDL_Win->lockScreen()) {
+ for(int i=0; i<numrects; ++i ) {
+ QRect rect(rects[i].x, rects[i].y,
+ rects[i].w, rects[i].h);
+ SDL_Win->repaintRect(rect);
+ }
+ SDL_Win->unlockScreen();
+ }
+ }
+ /* Is the system palette settable? */
+ int QT_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors)
+ {
+ return -1;
+ }
+
+ void QT_VideoQuit(_THIS)
+ {
+ // This is dumb, but if I free this, the app doesn't exit correctly.
+ // Of course, this will leak memory if init video is done more than once.
+ // Sucks but such is life.
+
+ // -- David Hedbor
+ // delete SDL_Win;
+ // SDL_Win = 0;
+ _this->screen->pixels = NULL;
+ QT_GrabInput(_this, SDL_GRAB_OFF);
+ }
+
+ static int QT_IconifyWindow(_THIS) {
+ SDL_Win->hide();
+
+ return true;
+ }
+
+ static SDL_GrabMode QT_GrabInput(_THIS, SDL_GrabMode mode) {
+ if(mode == SDL_GRAB_OFF) {
+ QPEApplication::grabKeyboard();
+ qApp->processEvents();
+ QPEApplication::ungrabKeyboard();
+ } else {
+ QPEApplication::grabKeyboard();
+ }
+ qApp->processEvents();
+ return mode;
+ }
+
+}; /* Extern C */
diff --git a/distrib/sdl-1.2.15/src/video/qtopia/SDL_syswm.cc b/distrib/sdl-1.2.15/src/video/qtopia/SDL_syswm.cc
new file mode 100644
index 0000000..47f988f
--- /dev/null
+++ b/distrib/sdl-1.2.15/src/video/qtopia/SDL_syswm.cc
@@ -0,0 +1,35 @@
+/*
+ SDL - Simple DirectMedia Layer
+ Copyright (C) 1997-2012 Sam Lantinga
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+ Sam Lantinga
+ slouken@libsdl.org
+*/
+#include "SDL_config.h"
+
+#include "SDL_QWin.h"
+
+extern "C" {
+
+#include "SDL_syswm_c.h"
+
+void QT_SetWMCaption(_THIS, const char *title, const char *icon)
+{
+ SDL_Win->setCaption(title);
+}
+
+}; /* Extern C */
diff --git a/distrib/sdl-1.2.15/src/video/qtopia/SDL_syswm_c.h b/distrib/sdl-1.2.15/src/video/qtopia/SDL_syswm_c.h
new file mode 100644
index 0000000..4e4326b
--- /dev/null
+++ b/distrib/sdl-1.2.15/src/video/qtopia/SDL_syswm_c.h
@@ -0,0 +1,28 @@
+/*
+ SDL - Simple DirectMedia Layer
+ Copyright (C) 1997-2012 Sam Lantinga
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+ Sam Lantinga
+ slouken@libsdl.org
+*/
+#include "SDL_config.h"
+
+#include "SDL_lowvideo.h"
+
+/* Functions to be exported */
+extern void QT_SetWMCaption(_THIS, const char *title, const char *icon);
+