annotate src/video/qtopia/SDL_sysvideo.cc @ 481:c96e2137f9eb

Date: Sat, 31 Aug 2002 15:42:45 +0200 From: Alexandre Courbot Subject: [SDL] Qtopia port fixes/improvments -Whenever the screen is rotated, the pad is rotated as well, -Fixed a mouse bug: when tapping on the screen, the click event was often sent at the previous position of the stylus (resulting in strange behavior in Scummvm for instance) -Added the SDL_QT_INVERT_ROTATION environment variable which, when set, rotates the screen (and the mouse, and the pad) the other way. This can be useful for left-handed people.
author Sam Lantinga <slouken@libsdl.org>
date Sun, 01 Sep 2002 00:37:24 +0000
parents 11c8a7684f74
children 969fbd4dcd4e
rev   line source
371
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1 /*
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2 SDL - Simple DirectMedia Layer
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3 Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002 Sam Lantinga
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5 This library is free software; you can redistribute it and/or
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
6 modify it under the terms of the GNU Library General Public
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
7 License as published by the Free Software Foundation; either
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
8 version 2 of the License, or (at your option) any later version.
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
9
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
10 This library is distributed in the hope that it will be useful,
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
13 Library General Public License for more details.
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
14
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
15 You should have received a copy of the GNU Library General Public
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
16 License along with this library; if not, write to the Free
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
18
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
19 Sam Lantinga
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
20 slouken@libsdl.org
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
21 */
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
22
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
23 #ifdef SAVE_RCSID
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
24 static char rcsid =
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
25 "@(#) $Id$";
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
26 #endif
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
27
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
28 /* Qtopia based framebuffer implementation */
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
29
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
30 #include <stdlib.h>
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
31 #include <string.h>
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
32
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
33 #include <stdio.h>
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
34 #include <unistd.h>
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 #include <qapplication.h>
379
11c8a7684f74 Date: Fri, 24 May 2002 10:32:00 -0700
Sam Lantinga <slouken@libsdl.org>
parents: 371
diff changeset
37 #include <qpe/qpeapplication.h>
371
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
38
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
39 #include "SDL.h"
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
40 #include "SDL_timer.h"
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 #include "SDL_QWin.h"
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 extern "C" {
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
45
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
46 #include "SDL_sysvideo.h"
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
47 #include "SDL_sysmouse_c.h"
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
48 #include "SDL_sysevents_c.h"
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
49 #include "SDL_events_c.h"
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
50 #include "SDL_syswm_c.h"
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
51 #include "SDL_lowvideo.h"
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
52
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
53 //#define QTOPIA_DEBUG
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
54 #define QT_HIDDEN_SIZE 32 /* starting hidden window size */
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
55
481
c96e2137f9eb Date: Sat, 31 Aug 2002 15:42:45 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 379
diff changeset
56 /* Name of the environment variable used to invert the screen rotation or not:
c96e2137f9eb Date: Sat, 31 Aug 2002 15:42:45 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 379
diff changeset
57 Possible values:
c96e2137f9eb Date: Sat, 31 Aug 2002 15:42:45 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 379
diff changeset
58 !=0 : Screen is 270° rotated
c96e2137f9eb Date: Sat, 31 Aug 2002 15:42:45 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 379
diff changeset
59 0: Screen is 90° rotated*/
c96e2137f9eb Date: Sat, 31 Aug 2002 15:42:45 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 379
diff changeset
60 #define SDL_QT_ROTATION_ENV_NAME "SDL_QT_INVERT_ROTATION"
c96e2137f9eb Date: Sat, 31 Aug 2002 15:42:45 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 379
diff changeset
61
371
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
62 /* Initialization/Query functions */
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
63 static int QT_VideoInit(_THIS, SDL_PixelFormat *vformat);
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
64 static SDL_Rect **QT_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags);
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
65 static SDL_Surface *QT_SetVideoMode(_THIS, SDL_Surface *current, int width, int height, int bpp, Uint32 flags);
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
66 static void QT_UpdateMouse(_THIS);
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
67 static int QT_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors);
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
68 static void QT_VideoQuit(_THIS);
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 /* Hardware surface functions */
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
71 static int QT_AllocHWSurface(_THIS, SDL_Surface *surface);
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
72 static int QT_LockHWSurface(_THIS, SDL_Surface *surface);
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
73 static void QT_UnlockHWSurface(_THIS, SDL_Surface *surface);
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
74 static void QT_FreeHWSurface(_THIS, SDL_Surface *surface);
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 static int QT_ToggleFullScreen(_THIS, int fullscreen);
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
77
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
78
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
79 /* FB driver bootstrap functions */
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
80
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
81 static int QT_Available(void)
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
82 {
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
83 return(1);
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
84 }
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
85
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
86 static void QT_DeleteDevice(SDL_VideoDevice *device)
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
87 {
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
88 free(device->hidden);
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
89 free(device);
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
90 }
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
91
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
92 static SDL_VideoDevice *QT_CreateDevice(int devindex)
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
93 {
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
94 SDL_VideoDevice *device;
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
95
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
96 /* Initialize all variables that we clean on shutdown */
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
97 device = (SDL_VideoDevice *)malloc(sizeof(SDL_VideoDevice));
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
98 if ( device ) {
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
99 memset(device, 0, (sizeof *device));
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
100 device->hidden = (struct SDL_PrivateVideoData *)
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
101 malloc((sizeof *device->hidden));
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
102 }
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
103 if ( (device == NULL) || (device->hidden == NULL) ) {
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
104 SDL_OutOfMemory();
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
105 if ( device ) {
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
106 free(device);
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 return(0);
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
109 }
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
110 memset(device->hidden, 0, (sizeof *device->hidden));
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
111
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
112 /* Set the function pointers */
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
113 device->VideoInit = QT_VideoInit;
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
114 device->ListModes = QT_ListModes;
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
115 device->SetVideoMode = QT_SetVideoMode;
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
116 device->UpdateMouse = QT_UpdateMouse;
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
117 device->SetColors = QT_SetColors;
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
118 device->UpdateRects = NULL;
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
119 device->VideoQuit = QT_VideoQuit;
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
120 device->AllocHWSurface = QT_AllocHWSurface;
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
121 device->CheckHWBlit = NULL;
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
122 device->FillHWRect = NULL;
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
123 device->SetHWColorKey = NULL;
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
124 device->SetHWAlpha = NULL;
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
125 device->LockHWSurface = QT_LockHWSurface;
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
126 device->UnlockHWSurface = QT_UnlockHWSurface;
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
127 device->FlipHWSurface = NULL;
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
128 device->FreeHWSurface = QT_FreeHWSurface;
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
129 device->SetIcon = NULL;
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
130 device->SetCaption = QT_SetWMCaption;
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
131 device->GetWMInfo = NULL;
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
132 device->FreeWMCursor = QT_FreeWMCursor;
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
133 device->CreateWMCursor = QT_CreateWMCursor;
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
134 device->ShowWMCursor = QT_ShowWMCursor;
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
135 device->WarpWMCursor = QT_WarpWMCursor;
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
136 device->InitOSKeymap = QT_InitOSKeymap;
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
137 device->PumpEvents = QT_PumpEvents;
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
138
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
139 device->free = QT_DeleteDevice;
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
140 device->ToggleFullScreen = QT_ToggleFullScreen;
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
141
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
142 /* Set the driver flags */
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
143 device->handles_any_size = 0;
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
144
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
145 return device;
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 VideoBootStrap Qtopia_bootstrap = {
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
149 "qtopia", "Qtopia / QPE graphics",
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
150 QT_Available, QT_CreateDevice
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
151 };
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
152
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
153 /* Function to sort the display_list */
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
154 static int CompareModes(const void *A, const void *B)
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
155 {
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
156 #if 0
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
157 const display_mode *a = (display_mode *)A;
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
158 const display_mode *b = (display_mode *)B;
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
159
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
160 if ( a->space == b->space ) {
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
161 return((b->virtual_width*b->virtual_height)-
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
162 (a->virtual_width*a->virtual_height));
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
163 } else {
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
164 return(ColorSpaceToBitsPerPixel(b->space)-
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
165 ColorSpaceToBitsPerPixel(a->space));
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
166 }
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
167 #endif
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
168 return 0;
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
169 }
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
170
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
171 /* Yes, this isn't the fastest it could be, but it works nicely */
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
172 static int QT_AddMode(_THIS, int index, unsigned int w, unsigned int h)
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
173 {
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
174 SDL_Rect *mode;
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
175 int i;
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
176 int next_mode;
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
177
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
178 /* Check to see if we already have this mode */
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
179 if ( SDL_nummodes[index] > 0 ) {
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
180 for ( i=SDL_nummodes[index]-1; i >= 0; --i ) {
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
181 mode = SDL_modelist[index][i];
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
182 if ( (mode->w == w) && (mode->h == h) ) {
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
183 return(0);
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
184 }
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
185 }
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
186 }
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
187
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
188 /* Set up the new video mode rectangle */
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
189 mode = (SDL_Rect *)malloc(sizeof *mode);
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
190 if ( mode == NULL ) {
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
191 SDL_OutOfMemory();
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
192 return(-1);
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
193 }
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
194 mode->x = 0;
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
195 mode->y = 0;
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
196 mode->w = w;
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
197 mode->h = h;
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
198 #ifdef QTOPIA_DEBUG
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
199 fprintf(stderr, "Adding mode %dx%d at %d bytes per pixel\n", w, h, index+1);
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
200 #endif
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
201
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
202 /* Allocate the new list of modes, and fill in the new mode */
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
203 next_mode = SDL_nummodes[index];
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
204 SDL_modelist[index] = (SDL_Rect **)
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
205 realloc(SDL_modelist[index], (1+next_mode+1)*sizeof(SDL_Rect *));
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
206 if ( SDL_modelist[index] == NULL ) {
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
207 SDL_OutOfMemory();
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
208 SDL_nummodes[index] = 0;
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
209 free(mode);
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
210 return(-1);
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
211 }
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
212 SDL_modelist[index][next_mode] = mode;
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
213 SDL_modelist[index][next_mode+1] = NULL;
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
214 SDL_nummodes[index]++;
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
215
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
216 return(0);
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
217 }
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
218
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
219 int QT_VideoInit(_THIS, SDL_PixelFormat *vformat)
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
220 {
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
221 /* Initialize the QPE Application */
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
222 /* Determine the screen depth */
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
223 vformat->BitsPerPixel = QPixmap::defaultDepth();
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
224
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
225 // For now we hardcode the current depth because anything else
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
226 // might as well be emulated by SDL rather than by Qtopia.
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
227
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
228 QSize desktop_size = qApp->desktop()->size();
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
229 QT_AddMode(_this, ((vformat->BitsPerPixel+7)/8)-1,
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
230 desktop_size.width(), desktop_size.height());
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
231 QT_AddMode(_this, ((vformat->BitsPerPixel+7)/8)-1,
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
232 desktop_size.height(), desktop_size.width());
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
233
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
234 /* Create the window / widget */
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
235 SDL_Win = new SDL_QWin(QSize(QT_HIDDEN_SIZE, QT_HIDDEN_SIZE));
379
11c8a7684f74 Date: Fri, 24 May 2002 10:32:00 -0700
Sam Lantinga <slouken@libsdl.org>
parents: 371
diff changeset
236 ((QPEApplication*)qApp)->showMainWidget(SDL_Win);
371
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
237 /* Fill in some window manager capabilities */
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
238 _this->info.wm_available = 0;
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
239
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
240 /* We're done! */
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
241 return(0);
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
242 }
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
243
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
244 /* We support any dimension at our bit-depth */
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
245 SDL_Rect **QT_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags)
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
246 {
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
247 SDL_Rect **modes;
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
248
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
249 modes = ((SDL_Rect **)0);
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
250 if ( (flags & SDL_FULLSCREEN) == SDL_FULLSCREEN ) {
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
251 modes = SDL_modelist[((format->BitsPerPixel+7)/8)-1];
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
252 } else {
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
253 if ( format->BitsPerPixel ==
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
254 _this->screen->format->BitsPerPixel ) {
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
255 modes = ((SDL_Rect **)-1);
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
256 }
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
257 }
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
258 return(modes);
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
259 }
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
260
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
261 /* Various screen update functions available */
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
262 static void QT_NormalUpdate(_THIS, int numrects, SDL_Rect *rects);
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
263
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
264
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
265 static int QT_SetFullScreen(_THIS, SDL_Surface *screen, int fullscreen)
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
266 {
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
267 return -1;
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
268 }
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
269
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
270 static int QT_ToggleFullScreen(_THIS, int fullscreen)
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
271 {
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
272 return -1;
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
273 }
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
274
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
275 /* FIXME: check return values and cleanup here */
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
276 SDL_Surface *QT_SetVideoMode(_THIS, SDL_Surface *current,
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
277 int width, int height, int bpp, Uint32 flags)
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
278 {
379
11c8a7684f74 Date: Fri, 24 May 2002 10:32:00 -0700
Sam Lantinga <slouken@libsdl.org>
parents: 371
diff changeset
279
371
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
280 QImage *qimage;
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
281 QSize desktop_size = qApp->desktop()->size();
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
282
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
283
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
284 current->flags = SDL_FULLSCREEN; // We always run fullscreen.
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
285
481
c96e2137f9eb Date: Sat, 31 Aug 2002 15:42:45 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 379
diff changeset
286 if(width <= desktop_size.width()
c96e2137f9eb Date: Sat, 31 Aug 2002 15:42:45 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 379
diff changeset
287 && height <= desktop_size.height()) {
371
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
288 current->w = desktop_size.width();
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
289 current->h = desktop_size.height();
481
c96e2137f9eb Date: Sat, 31 Aug 2002 15:42:45 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 379
diff changeset
290 } else if(width <= desktop_size.height() && height <= desktop_size.width()) {
371
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
291 // Landscape mode
481
c96e2137f9eb Date: Sat, 31 Aug 2002 15:42:45 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 379
diff changeset
292 char * envString = getenv(SDL_QT_ROTATION_ENV_NAME);
c96e2137f9eb Date: Sat, 31 Aug 2002 15:42:45 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 379
diff changeset
293 int envValue = envString ? atoi(envString) : 0;
c96e2137f9eb Date: Sat, 31 Aug 2002 15:42:45 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 379
diff changeset
294 screenRotation = envValue ? SDL_QT_ROTATION_270 : SDL_QT_ROTATION_90;
371
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
295 current->h = desktop_size.width();
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
296 current->w = desktop_size.height();
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
297 } else {
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
298 SDL_SetError("Unsupported resolution, %dx%d\n", width, height);
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
299 }
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
300 if ( flags & SDL_OPENGL ) {
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
301 SDL_SetError("OpenGL not supported");
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
302 return(NULL);
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
303 }
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
304 /* Create the QImage framebuffer */
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
305 qimage = new QImage(current->w, current->h, bpp);
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
306 if (qimage->isNull()) {
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
307 SDL_SetError("Couldn't create screen bitmap");
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
308 delete qimage;
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
309 return(NULL);
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
310 }
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
311 current->pitch = qimage->bytesPerLine();
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
312 current->pixels = (void *)qimage->bits();
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
313 SDL_Win->setImage(qimage);
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
314 _this->UpdateRects = QT_NormalUpdate;
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
315 SDL_Win->setFullscreen(true);
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
316 /* We're done */
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
317 return(current);
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
318 }
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
319
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
320 /* Update the current mouse state and position */
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
321 void QT_UpdateMouse(_THIS)
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
322 {
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
323 QPoint point(-1, -1);
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
324 if ( SDL_Win->isActiveWindow() ) {
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
325 point = SDL_Win->mousePos();
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
326 }
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
327
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
328 if ( (point.x() >= 0) && (point.x() < SDL_VideoSurface->w) &&
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
329 (point.y() >= 0) && (point.y() < SDL_VideoSurface->h) ) {
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
330 SDL_PrivateAppActive(1, SDL_APPMOUSEFOCUS);
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
331 SDL_PrivateMouseMotion(0, 0,
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
332 (Sint16)point.x(), (Sint16)point.y());
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
333 } else {
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
334 SDL_PrivateAppActive(0, SDL_APPMOUSEFOCUS);
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 }
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
337
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
338 /* We don't actually allow hardware surfaces other than the main one */
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
339 static int QT_AllocHWSurface(_THIS, SDL_Surface *surface)
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
340 {
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
341 return(-1);
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
342 }
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
343 static void QT_FreeHWSurface(_THIS, SDL_Surface *surface)
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
344 {
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
345 return;
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
346 }
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
347 static int QT_LockHWSurface(_THIS, SDL_Surface *surface)
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
348 {
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
349 return(0);
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
350 }
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
351 static void QT_UnlockHWSurface(_THIS, SDL_Surface *surface)
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
352 {
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
353 return;
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
354 }
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 static void QT_NormalUpdate(_THIS, int numrects, SDL_Rect *rects)
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
357 {
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
358 int i;
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
359 SDL_Win->lockScreen();
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
360 for ( i=0; i<numrects; ++i ) {
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
361 QRect rect(rects[i].x, rects[i].y,
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
362 rects[i].w, rects[i].h);
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
363 SDL_Win->repaintRect(rect);
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 SDL_Win->unlockScreen();
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
366 }
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
367 /* Is the system palette settable? */
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
368 int QT_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors)
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
369 {
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
370 return -1;
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
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
373 void QT_VideoQuit(_THIS)
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
374 {
379
11c8a7684f74 Date: Fri, 24 May 2002 10:32:00 -0700
Sam Lantinga <slouken@libsdl.org>
parents: 371
diff changeset
375 // This is dumb, but if I free this, the app doesn't exit correctly.
11c8a7684f74 Date: Fri, 24 May 2002 10:32:00 -0700
Sam Lantinga <slouken@libsdl.org>
parents: 371
diff changeset
376 // Of course, this will leak memory if init video is done more than once.
11c8a7684f74 Date: Fri, 24 May 2002 10:32:00 -0700
Sam Lantinga <slouken@libsdl.org>
parents: 371
diff changeset
377 // Sucks but such is life.
11c8a7684f74 Date: Fri, 24 May 2002 10:32:00 -0700
Sam Lantinga <slouken@libsdl.org>
parents: 371
diff changeset
378
11c8a7684f74 Date: Fri, 24 May 2002 10:32:00 -0700
Sam Lantinga <slouken@libsdl.org>
parents: 371
diff changeset
379 // -- David Hedbor
11c8a7684f74 Date: Fri, 24 May 2002 10:32:00 -0700
Sam Lantinga <slouken@libsdl.org>
parents: 371
diff changeset
380 // delete SDL_Win;
11c8a7684f74 Date: Fri, 24 May 2002 10:32:00 -0700
Sam Lantinga <slouken@libsdl.org>
parents: 371
diff changeset
381 // SDL_Win = 0;
371
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
382 _this->screen->pixels = NULL;
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
383 }
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
384
db0cc6034336 Added David Hedbor's Qtopia patches
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
385 }; /* Extern C */