1.1 --- a/configure.in Sun May 19 19:54:01 2002 +0000
1.2 +++ b/configure.in Sun May 19 20:06:01 2002 +0000
1.3 @@ -322,15 +322,15 @@
1.4 [ --enable-esd support the Enlightened Sound Daemon [default=yes]],
1.5 , enable_esd=yes)
1.6 if test x$enable_audio = xyes -a x$enable_esd = xyes; then
1.7 - use_esd=no
1.8 + use_esd=no
1.9 AM_PATH_ESD(0.2.8, use_esd=yes)
1.10 - if test x$use_esd = xyes; then
1.11 + if test x$use_esd = xyes; then
1.12 AC_ARG_ENABLE(esd-shared,
1.13 [ --enable-esd-shared dynamically load ESD audio support [default=no]],
1.14 , enable_esd_shared=no)
1.15 esd_lib_spec=`echo $ESD_LIBS | sed 's/.*-L\([[^ ]]*\).*/\1\/libesd.so.*/'`
1.16 - esd_lib=`ls $esd_lib_spec | head -1 | sed 's/.*\/\(.*\)/\1/'`
1.17 - echo "-- $esd_lib_spec -> $esd_lib"
1.18 + esd_lib=`ls $esd_lib_spec | head -1 | sed 's/.*\/\(.*\)/\1/'`
1.19 + echo "-- $esd_lib_spec -> $esd_lib"
1.20 if test x$enable_dlopen != xyes && \
1.21 test x$enable_esd_shared = xyes; then
1.22 AC_MSG_ERROR([You must have dlopen() support and use the --enable-dlopen option])
1.23 @@ -338,7 +338,7 @@
1.24 if test x$enable_dlopen = xyes && \
1.25 test x$enable_esd_shared = xyes && test x$esd_lib != x; then
1.26 CFLAGS="$CFLAGS -DESD_SUPPORT -DESD_DYNAMIC=\$(esd_lib) $ESD_CFLAGS"
1.27 - AC_SUBST(esd_lib)
1.28 + AC_SUBST(esd_lib)
1.29 else
1.30 CFLAGS="$CFLAGS -DESD_SUPPORT $ESD_CFLAGS"
1.31 SYSTEM_LIBS="$SYSTEM_LIBS $ESD_LIBS"
1.32 @@ -379,8 +379,8 @@
1.33 [ --enable-arts-shared dynamically load aRts audio support [default=no]],
1.34 , enable_arts_shared=no)
1.35 arts_lib_spec=`echo $ARTSC_LIBS | sed 's/.*-L\([[^ ]]*\).*/\1\/libartsc.so.*/'`
1.36 - arts_lib=`ls $arts_lib_spec | head -1 | sed 's/.*\/\(.*\)/\1/'`
1.37 - echo "-- $arts_lib_spec -> $arts_lib"
1.38 + arts_lib=`ls $arts_lib_spec | head -1 | sed 's/.*\/\(.*\)/\1/'`
1.39 + echo "-- $arts_lib_spec -> $arts_lib"
1.40 if test x$enable_dlopen != xyes && \
1.41 test x$enable_arts_shared = xyes; then
1.42 AC_MSG_ERROR([You must have dlopen() support and use the --enable-dlopen option])
1.43 @@ -388,7 +388,7 @@
1.44 if test x$enable_dlopen = xyes && \
1.45 test x$enable_arts_shared = xyes && test x$arts_lib != x; then
1.46 CFLAGS="$CFLAGS -DARTSC_SUPPORT -DARTSC_DYNAMIC=\$(arts_lib) $ARTSC_CFLAGS"
1.47 - AC_SUBST(arts_lib)
1.48 + AC_SUBST(arts_lib)
1.49 else
1.50 CFLAGS="$CFLAGS -DARTSC_SUPPORT $ARTSC_CFLAGS"
1.51 SYSTEM_LIBS="$SYSTEM_LIBS $ARTSC_LIBS"
1.52 @@ -1165,7 +1165,7 @@
1.53 #include <pthread.h>
1.54 ],[
1.55 pthread_mutexattr_t attr;
1.56 - #ifdef linux
1.57 + #if defined(linux) && !(defined(__arm__) && defined(QWS))
1.58 pthread_mutexattr_setkind_np(&attr, PTHREAD_MUTEX_RECURSIVE_NP);
1.59 #else
1.60 pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
1.61 @@ -1349,6 +1349,36 @@
1.62 VIDEO_DRIVERS="$VIDEO_DRIVERS bwindow/libvideo_bwindow.la"
1.63 }
1.64
1.65 +dnl Set up the QTopia video driver if enabled
1.66 +CheckQtopia()
1.67 +{
1.68 + AC_ARG_ENABLE(video-qtopia,
1.69 +[ --enable-video-qtopia use Qtopia video driver [default=no]],
1.70 + , enable_video_qtopia=no)
1.71 + if test x$enable_video = xyes -a x$enable_video_qtopia = xyes; then
1.72 + AC_MSG_CHECKING(for Qtopia support)
1.73 + video_qtopia=no
1.74 + AC_LANG_CPLUSPLUS
1.75 + OLD_CXX="$CXXFLAGS"
1.76 + CXXFLAGS="-DQT_QWS_EBX -fno-rtti -fno-exceptions -DQT_QWS_CUSTOM -DQWS -I${QPEDIR}/include -I${QTDIR}/include/ -DNO_DEBUG"
1.77 + AC_TRY_COMPILE([
1.78 + #include <qpe/qpeapplication.h>
1.79 + ],[
1.80 + ],[
1.81 + video_qtopia=yes
1.82 + ])
1.83 + CXXFLAGS="$OLD_CXX"
1.84 + AC_MSG_RESULT($video_qtopia)
1.85 + if test x$video_qtopia = xyes; then
1.86 + CFLAGS="$CFLAGS -DENABLE_QTOPIA -DQT_QWS_EBX -DQT_QWS_CUSTOM -DQWS -I${QPEDIR}/include -I${QTDIR}/include/ -DNO_DEBUG -fno-rtti -fno-exceptions"
1.87 + SYSTEM_LIBS="$SYSTEM_LIBS -:${QPEDIR}/lib -L${QTDIR}/lib/ -lqpe -lqte"
1.88 + VIDEO_SUBDIRS="$VIDEO_SUBDIRS qtopia"
1.89 + VIDEO_DRIVERS="$VIDEO_DRIVERS qtopia/libvideo_qtopia.la"
1.90 + fi
1.91 + AC_LANG_C
1.92 + fi
1.93 +}
1.94 +
1.95 dnl Set up the Mac toolbox video driver for Mac OS 7-9
1.96 CheckTOOLBOX()
1.97 {
1.98 @@ -1420,7 +1450,7 @@
1.99 ARCH=linux
1.100 CheckDummyVideo
1.101 CheckDiskAudio
1.102 - CheckDLOPEN
1.103 + CheckDLOPEN
1.104 CheckNASM
1.105 CheckOSS
1.106 CheckALSA
1.107 @@ -1436,11 +1466,18 @@
1.108 CheckGGI
1.109 CheckSVGA
1.110 CheckAAlib
1.111 + CheckQtopia
1.112 CheckOpenGL
1.113 CheckInputEvents
1.114 CheckPTHREAD
1.115 # Set up files for the main() stub
1.116 - COPY_ARCH_SRC(src/main, linux, SDL_main.c)
1.117 + if test "x$video_qtopia" = "xyes"; then
1.118 + COPY_ARCH_SRC(src/main, linux, SDL_Qtopia_main.cc)
1.119 + SDL_CFLAGS="$SDL_CFLAGS -Dmain=SDL_main"
1.120 + SDL_LIBS="-lSDLmain $SDL_LIBS"
1.121 + else
1.122 + COPY_ARCH_SRC(src/main, linux, SDL_main.c)
1.123 + fi
1.124 # Set up files for the audio library
1.125 # We use the OSS and ALSA API's, not the Sun audio API
1.126 #if test x$enable_audio = xyes; then
1.127 @@ -1479,7 +1516,11 @@
1.128 else
1.129 COPY_ARCH_SRC(src/thread, linux, SDL_sysmutex.c)
1.130 COPY_ARCH_SRC(src/thread, linux, SDL_sysmutex_c.h)
1.131 - COPY_ARCH_SRC(src/thread, linux, SDL_syscond.c)
1.132 + if test x$has_recursive_mutexes != xyes; then
1.133 + COPY_ARCH_SRC(src/thread, generic, SDL_syscond.c)
1.134 + else
1.135 + COPY_ARCH_SRC(src/thread, linux, SDL_syscond.c)
1.136 + fi
1.137 COPY_ARCH_SRC(src/thread, generic, SDL_syscond_c.h)
1.138 fi
1.139 fi
1.140 @@ -1492,7 +1533,7 @@
1.141 ARCH=bsdi
1.142 CheckDummyVideo
1.143 CheckDiskAudio
1.144 - CheckDLOPEN
1.145 + CheckDLOPEN
1.146 CheckNASM
1.147 CheckOSS
1.148 CheckARTSC
1.149 @@ -1544,7 +1585,7 @@
1.150 ARCH=freebsd
1.151 CheckDummyVideo
1.152 CheckDiskAudio
1.153 - CheckDLOPEN
1.154 + CheckDLOPEN
1.155 CheckVGL
1.156 CheckNASM
1.157 CheckOSS
1.158 @@ -1601,7 +1642,7 @@
1.159 ARCH=netbsd
1.160 CheckDummyVideo
1.161 CheckDiskAudio
1.162 - CheckDLOPEN
1.163 + CheckDLOPEN
1.164 CheckNASM
1.165 CheckOSS
1.166 CheckARTSC
1.167 @@ -1656,7 +1697,7 @@
1.168 ARCH=openbsd
1.169 CheckDummyVideo
1.170 CheckDiskAudio
1.171 - CheckDLOPEN
1.172 + CheckDLOPEN
1.173 CheckNASM
1.174 CheckOSS
1.175 CheckARTSC
1.176 @@ -1715,7 +1756,7 @@
1.177 ARCH=sysv5
1.178 CheckDummyVideo
1.179 CheckDiskAudio
1.180 - CheckDLOPEN
1.181 + CheckDLOPEN
1.182 CheckNASM
1.183 CheckOSS
1.184 CheckARTSC
1.185 @@ -1765,7 +1806,7 @@
1.186 CFLAGS="$CFLAGS -D__ELF__" # Fix for nasm on Solaris x86
1.187 CheckDummyVideo
1.188 CheckDiskAudio
1.189 - CheckDLOPEN
1.190 + CheckDLOPEN
1.191 CheckNASM
1.192 CheckOSS
1.193 CheckARTSC
1.194 @@ -1814,7 +1855,7 @@
1.195 ARCH=irix
1.196 CheckDummyVideo
1.197 CheckDiskAudio
1.198 - CheckDLOPEN
1.199 + CheckDLOPEN
1.200 CheckDMEDIA
1.201 CheckESD
1.202 CheckNAS
1.203 @@ -1877,7 +1918,7 @@
1.204 ARCH=hpux
1.205 CheckDummyVideo
1.206 CheckDiskAudio
1.207 - CheckDLOPEN
1.208 + CheckDLOPEN
1.209 CheckOSS
1.210 CheckNAS
1.211 CheckX11
1.212 @@ -1925,7 +1966,7 @@
1.213 ARCH=aix
1.214 CheckDummyVideo
1.215 CheckDiskAudio
1.216 - CheckDLOPEN
1.217 + CheckDLOPEN
1.218 CheckOSS
1.219 CheckNAS
1.220 CheckX11
1.221 @@ -1971,7 +2012,7 @@
1.222 ARCH=osf
1.223 CheckDummyVideo
1.224 CheckDiskAudio
1.225 - CheckDLOPEN
1.226 + CheckDLOPEN
1.227 CheckNAS
1.228 CheckX11
1.229 CheckGGI
1.230 @@ -2018,7 +2059,7 @@
1.231 ARCH=qnx
1.232 CheckDummyVideo
1.233 CheckDiskAudio
1.234 - CheckDLOPEN
1.235 + CheckDLOPEN
1.236 CheckNAS
1.237 CheckPHOTON
1.238 CheckX11
1.239 @@ -2330,6 +2371,7 @@
1.240
1.241 # Set the conditional variables for this target
1.242 AM_CONDITIONAL(TARGET_LINUX, test $ARCH = linux)
1.243 +AM_CONDITIONAL(TARGET_QTOPIA, test "x$video_qtopia" = "xyes")
1.244 AM_CONDITIONAL(TARGET_SOLARIS, test $ARCH = solaris)
1.245 AM_CONDITIONAL(TARGET_IRIX, test $ARCH = irix)
1.246 AM_CONDITIONAL(TARGET_BSDI, test $ARCH = bsdi)
1.247 @@ -2486,6 +2528,7 @@
1.248 src/video/ataricommon/Makefile
1.249 src/video/xbios/Makefile
1.250 src/video/gem/Makefile
1.251 +src/video/qtopia/Makefile
1.252 src/events/Makefile
1.253 src/joystick/Makefile
1.254 src/joystick/amigaos/Makefile
2.1 --- a/include/SDL_main.h Sun May 19 19:54:01 2002 +0000
2.2 +++ b/include/SDL_main.h Sun May 19 20:06:01 2002 +0000
2.3 @@ -31,7 +31,8 @@
2.4 /* Redefine main() on Win32 and MacOS so that it is called by winmain.c */
2.5
2.6 #if defined(WIN32) || (defined(__MWERKS__) && !defined(__BEOS__)) || \
2.7 - defined(macintosh) || defined(__APPLE__) || defined(__SYMBIAN32__)
2.8 + defined(macintosh) || defined(__APPLE__) || defined(__SYMBIAN32__) || \
2.9 + defined(QWS)
2.10
2.11 #ifdef __cplusplus
2.12 #define C_LINKAGE "C"
3.1 --- a/src/main/Makefile.am Sun May 19 19:54:01 2002 +0000
3.2 +++ b/src/main/Makefile.am Sun May 19 20:06:01 2002 +0000
3.3 @@ -17,9 +17,12 @@
3.4 if TARGET_MACOSX
3.5 MAINLIB_ARCH_SRCS = SDLMain.m SDLMain.h
3.6 else
3.7 +if TARGET_QTOPIA
3.8 +MAINLIB_ARCH_SRCS = SDL_Qtopia_main.cc
3.9 +else
3.10 MAINLIB_ARCH_SRCS = SDL_main.c
3.11 endif
3.12 -
3.13 +endif
3.14 libSDLmain_a_SOURCES = $(MAINLIB_ARCH_SRCS)
3.15
3.16 # Build an internal library of any special app setup functions
4.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
4.2 +++ b/src/main/linux/SDL_Qtopia_main.cc Sun May 19 20:06:01 2002 +0000
4.3 @@ -0,0 +1,24 @@
4.4 +
4.5 +/* Include the SDL main definition header */
4.6 +#include "SDL_main.h"
4.7 +#ifdef main
4.8 +#undef main
4.9 +#endif
4.10 +#ifdef QWS
4.11 +#include <qpe/qpeapplication.h>
4.12 +#include <qapplication.h>
4.13 +#endif
4.14 +
4.15 +extern int SDL_main(int argc, char *argv[]);
4.16 +
4.17 +int main(int argc, char *argv[])
4.18 +{
4.19 +#ifdef QWS
4.20 + // This initializes the Qtopia application. It needs to be done here
4.21 + // because it parses command line options.
4.22 + QPEApplication *app = new QPEApplication(argc, argv);
4.23 + QWidget dummy;
4.24 + app->showMainWidget(&dummy);
4.25 +#endif
4.26 + return(SDL_main(argc, argv));
4.27 +}
5.1 --- a/src/video/SDL_sysvideo.h Sun May 19 19:54:01 2002 +0000
5.2 +++ b/src/video/SDL_sysvideo.h Sun May 19 20:06:01 2002 +0000
5.3 @@ -398,6 +398,9 @@
5.4 #ifdef ENABLE_GEM
5.5 extern VideoBootStrap GEM_bootstrap;
5.6 #endif
5.7 +#ifdef ENABLE_QTOPIA
5.8 +extern VideoBootStrap Qtopia_bootstrap;
5.9 +#endif
5.10 /* This is the current video device */
5.11 extern SDL_VideoDevice *current_video;
5.12
6.1 --- a/src/video/SDL_video.c Sun May 19 19:54:01 2002 +0000
6.2 +++ b/src/video/SDL_video.c Sun May 19 20:06:01 2002 +0000
6.3 @@ -111,6 +111,9 @@
6.4 #ifdef ENABLE_GEM
6.5 &GEM_bootstrap,
6.6 #endif
6.7 +#ifdef ENABLE_QTOPIA
6.8 + &Qtopia_bootstrap,
6.9 +#endif
6.10 NULL
6.11 };
6.12
7.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
7.2 +++ b/src/video/qtopia/.cvsignore Sun May 19 20:06:01 2002 +0000
7.3 @@ -0,0 +1,6 @@
7.4 +Makefile.in
7.5 +Makefile
7.6 +.libs
7.7 +*.o
7.8 +*.lo
7.9 +*.la
8.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
8.2 +++ b/src/video/qtopia/Makefile.am Sun May 19 20:06:01 2002 +0000
8.3 @@ -0,0 +1,20 @@
8.4 +
8.5 +## Makefile.am for SDL using the Qtopia backend
8.6 +
8.7 +noinst_LTLIBRARIES = libvideo_qtopia.la
8.8 +libvideo_qtopia_la_SOURCES = $(QTOPIA_SRCS)
8.9 +
8.10 +# The SDL BWindow video driver sources
8.11 +QTOPIA_SRCS = \
8.12 + SDL_QWin.h \
8.13 + SDL_QWin.cc \
8.14 + SDL_QPEApp.h \
8.15 + SDL_QPEApp.cc \
8.16 + SDL_lowvideo.h \
8.17 + SDL_sysmouse.cc \
8.18 + SDL_sysmouse_c.h \
8.19 + SDL_sysvideo.cc \
8.20 + SDL_syswm.cc \
8.21 + SDL_syswm_c.h \
8.22 + SDL_sysevents.cc \
8.23 + SDL_sysevents_c.h
9.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
9.2 +++ b/src/video/qtopia/SDL_QPEApp.cc Sun May 19 20:06:01 2002 +0000
9.3 @@ -0,0 +1,62 @@
9.4 +/*
9.5 + SDL - Simple DirectMedia Layer
9.6 + Copyright (C) 1997, 1998, 1999, 2000, 2001 Sam Lantinga
9.7 +
9.8 + This library is free software; you can redistribute it and/or
9.9 + modify it under the terms of the GNU Library General Public
9.10 + License as published by the Free Software Foundation; either
9.11 + version 2 of the License, or (at your option) any later version.
9.12 +
9.13 + This library is distributed in the hope that it will be useful,
9.14 + but WITHOUT ANY WARRANTY; without even the implied warranty of
9.15 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
9.16 + Library General Public License for more details.
9.17 +
9.18 + You should have received a copy of the GNU Library General Public
9.19 + License along with this library; if not, write to the Free
9.20 + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
9.21 +
9.22 + Sam Lantinga
9.23 + slouken@libsdl.org
9.24 +*/
9.25 +
9.26 +#include <qpe/qpeapplication.h>
9.27 +#include <qapplication.h>
9.28 +#include <qevent.h>
9.29 +
9.30 +#include "SDL_thread.h"
9.31 +#include "SDL_timer.h"
9.32 +#include "SDL_error.h"
9.33 +
9.34 +/* Flag to tell whether or not the Be application is active or not */
9.35 +int SDL_QPEAppActive = 0;
9.36 +static QPEApplication *app;
9.37 +
9.38 +int SDL_InitQPEApp() {
9.39 + if(SDL_QPEAppActive <= 0) {
9.40 + if(!qApp) {
9.41 + int argc = 1;
9.42 + char *argv[] = { { "SDLApp" } };
9.43 + app = new QPEApplication(argc, argv);
9.44 + QWidget dummy;
9.45 + app->showMainWidget(&dummy);
9.46 + } else {
9.47 + app = (QPEApplication*)qApp;
9.48 + }
9.49 + SDL_QPEAppActive++;
9.50 + }
9.51 + return 0;
9.52 +}
9.53 +
9.54 +/* Quit the QPE Application, if there's nothing left to do */
9.55 +void SDL_QuitQPEApp(void)
9.56 +{
9.57 + /* Decrement the application reference count */
9.58 + SDL_QPEAppActive--;
9.59 + /* If the reference count reached zero, clean up the app */
9.60 + if ( SDL_QPEAppActive == 0 && app) {
9.61 + delete app;
9.62 + app = 0;
9.63 + qApp = 0;
9.64 + }
9.65 +}
10.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
10.2 +++ b/src/video/qtopia/SDL_QPEApp.h Sun May 19 20:06:01 2002 +0000
10.3 @@ -0,0 +1,37 @@
10.4 +/*
10.5 + SDL - Simple DirectMedia Layer
10.6 + Copyright (C) 1997 Sam Lantinga
10.7 +
10.8 + This library is free software; you can redistribute it and/or
10.9 + modify it under the terms of the GNU Library General Public
10.10 + License as published by the Free Software Foundation; either
10.11 + version 2 of the License, or (at your option) any later version.
10.12 +
10.13 + This library is distributed in the hope that it will be useful,
10.14 + but WITHOUT ANY WARRANTY; without even the implied warranty of
10.15 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
10.16 + Library General Public License for more details.
10.17 +
10.18 + You should have received a copy of the GNU Library General Public
10.19 + License along with this library; if not, write to the Free
10.20 + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
10.21 +
10.22 + Sam Lantinga
10.23 + slouken@libsdl.org
10.24 +*/
10.25 +
10.26 +#ifdef SAVE_RCSID
10.27 +static char rcsid =
10.28 + "@(#) $Id$";
10.29 +#endif
10.30 +
10.31 +/* Handle the QPE application loop */
10.32 +
10.33 +/* Initialize the QPE Application, if it's not already started */
10.34 +extern int SDL_InitQPEApp(void);
10.35 +
10.36 +/* Quit the QPE Application, if there's nothing left to do */
10.37 +extern void SDL_QuitQPEApp(void);
10.38 +
10.39 +/* Flag to tell whether the app is active or not */
10.40 +extern int SDL_QPEAppActive;
11.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
11.2 +++ b/src/video/qtopia/SDL_QWin.cc Sun May 19 20:06:01 2002 +0000
11.3 @@ -0,0 +1,333 @@
11.4 +/*
11.5 + SDL - Simple DirectMedia Layer
11.6 + Copyright (C) 1997, 1998, 1999, 2000, 2001 Sam Lantinga
11.7 +
11.8 + This library is free software; you can redistribute it and/or
11.9 + modify it under the terms of the GNU Library General Public
11.10 + License as published by the Free Software Foundation; either
11.11 + version 2 of the License, or (at your option) any later version.
11.12 +
11.13 + This library is distributed in the hope that it will be useful,
11.14 + but WITHOUT ANY WARRANTY; without even the implied warranty of
11.15 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11.16 + Library General Public License for more details.
11.17 +
11.18 + You should have received a copy of the GNU Library General Public
11.19 + License along with this library; if not, write to the Free
11.20 + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
11.21 +
11.22 + Sam Lantinga
11.23 + slouken@libsdl.org
11.24 +*/
11.25 +
11.26 +#ifdef SAVE_RCSID
11.27 +static char rcsid =
11.28 + "@(#) $Id$";
11.29 +#endif
11.30 +
11.31 +#include "SDL_QWin.h"
11.32 +#include <qapplication.h>
11.33 +#include <qdirectpainter_qws.h>
11.34 +SDL_QWin::SDL_QWin(const QSize& size)
11.35 + : QWidget(0, "SDL_main"), my_painter(0), my_image(0),
11.36 + my_inhibit_resize(false), my_mouse_pos(-1,-1), my_flags(0),
11.37 + my_has_fullscreen(false), my_locked(0)
11.38 +{
11.39 + setBackgroundMode(NoBackground);
11.40 +}
11.41 +
11.42 +SDL_QWin::~SDL_QWin() {
11.43 + // Nothing to do yet.
11.44 + if(my_image) {
11.45 + delete my_image;
11.46 + }
11.47 +}
11.48 +
11.49 +void SDL_QWin::setImage(QImage *image) {
11.50 + if ( my_image ) {
11.51 + delete my_image;
11.52 + }
11.53 + my_image = image;
11.54 + // setFixedSize(image->size());
11.55 +}
11.56 +
11.57 +void SDL_QWin::resizeEvent(QResizeEvent *e) {
11.58 + if(size() != qApp->desktop()->size()) {
11.59 + // Widget is not the correct size, so do the fullscreen magic
11.60 + my_has_fullscreen = false;
11.61 + enableFullscreen();
11.62 + }
11.63 + if(my_inhibit_resize) {
11.64 + my_inhibit_resize = false;
11.65 + } else {
11.66 + SDL_PrivateResize(e->size().width(), e->size().height());
11.67 + }
11.68 +}
11.69 +
11.70 +void SDL_QWin::focusInEvent(QFocusEvent *) {
11.71 + // Always do it here, no matter the size.
11.72 + enableFullscreen();
11.73 + SDL_PrivateAppActive(true, SDL_APPINPUTFOCUS);
11.74 +}
11.75 +
11.76 +void SDL_QWin::focusOutEvent(QFocusEvent *) {
11.77 + my_has_fullscreen = false;
11.78 + SDL_PrivateAppActive(false, SDL_APPINPUTFOCUS);
11.79 +}
11.80 +
11.81 +void SDL_QWin::closeEvent(QCloseEvent *e) {
11.82 + SDL_PrivateQuit();
11.83 + e->ignore();
11.84 +}
11.85 +
11.86 +void SDL_QWin::mouseMoveEvent(QMouseEvent *e) {
11.87 + Qt::ButtonState button = e->button();
11.88 + int sdlstate = 0;
11.89 + if( (button & Qt::LeftButton)) {
11.90 + sdlstate |= SDL_BUTTON_LMASK;
11.91 + }
11.92 + if( (button & Qt::RightButton)) {
11.93 + sdlstate |= SDL_BUTTON_RMASK;
11.94 + }
11.95 + if( (button & Qt::MidButton)) {
11.96 + sdlstate |= SDL_BUTTON_MMASK;
11.97 + }
11.98 + SDL_PrivateMouseMotion(sdlstate, 0, e->pos().x(), e->pos().y());
11.99 +}
11.100 +
11.101 +void SDL_QWin::mousePressEvent(QMouseEvent *e) {
11.102 + my_mouse_pos = e->pos();
11.103 + Qt::ButtonState button = e->button();
11.104 + SDL_PrivateMouseButton(SDL_PRESSED,
11.105 + (button & Qt::LeftButton) ? 1 :
11.106 + ((button & Qt::RightButton) ? 2 : 3),
11.107 + e->x(), e->y());
11.108 +}
11.109 +
11.110 +void SDL_QWin::mouseReleaseEvent(QMouseEvent *e) {
11.111 + my_mouse_pos = QPoint(-1, -1);
11.112 + Qt::ButtonState button = e->button();
11.113 + SDL_PrivateMouseButton(SDL_RELEASED,
11.114 + (button & Qt::LeftButton) ? 1 :
11.115 + ((button & Qt::RightButton) ? 2 : 3),
11.116 + e->x(), e->y());
11.117 +}
11.118 +
11.119 +#define USE_DIRECTPAINTER
11.120 +
11.121 +
11.122 +#ifndef __i386__
11.123 +static inline void gs_fastRotateBlit_3 ( unsigned short *fb,
11.124 + unsigned short *bits,
11.125 + const QRect& rect )
11.126 +{
11.127 + int startx, starty;
11.128 + int width, height;
11.129 +
11.130 + startx = rect.left() >> 1;
11.131 + starty = rect.top() >> 1;
11.132 + width = ((rect.right() - rect.left()) >> 1) + 2;
11.133 + height = ((rect.bottom() - rect.top()) >> 1) + 2;
11.134 +
11.135 + if((startx+width) > 120) {
11.136 + width = 120 - startx; // avoid horizontal overflow
11.137 + }
11.138 + if((starty+height) > 160) {
11.139 + height = 160 - starty; // avoid vertical overflow
11.140 + }
11.141 +
11.142 + ulong *sp1, *sp2, *dp1, *dp2;
11.143 + ulong stop, sbot, dtop, dbot;
11.144 +
11.145 + sp1 = (ulong*)bits + startx + starty*240;
11.146 + sp2 = sp1 + 120;
11.147 + dp1 = (ulong *)fb + (159 - starty) + startx*320;
11.148 + dp2 = dp1 + 160;
11.149 + int rowadd = (-320*width) - 1;
11.150 + int rowadd2 = 240 - width;
11.151 + // transfer in cells of 2x2 pixels in words
11.152 + for (int y=0; y<height; y++) {
11.153 + for (int x=0; x<width; x++) {
11.154 + // read source pixels
11.155 + stop = *sp1;
11.156 + sbot = *sp2;
11.157 + // rotate pixels
11.158 + dtop = (sbot & 0xffff) + ((stop & 0xffff)<<16);
11.159 + dbot = ((sbot & 0xffff0000)>>16) + (stop & 0xffff0000);
11.160 + // write to framebuffer
11.161 + *dp1 = dtop;
11.162 + *dp2 = dbot;
11.163 + // update source ptrs
11.164 + sp1++; sp2++;
11.165 + // update dest ptrs - 2 pix at a time
11.166 + dp1 += 320;
11.167 + dp2 += 320;
11.168 + }
11.169 + // adjust src ptrs - skip a row as we work in pairs
11.170 + sp1 += rowadd2;
11.171 + sp2 += rowadd2;
11.172 + // adjust dest ptrs for rotation
11.173 + dp1 += rowadd;
11.174 + dp2 += rowadd;
11.175 + }
11.176 +}
11.177 +#endif
11.178 +
11.179 +void SDL_QWin::repaintRect(const QRect& rect) {
11.180 + if(!my_painter || !rect.width() || !rect.height()) {
11.181 + return;
11.182 + }
11.183 +#ifndef __i386__
11.184 +
11.185 + if(QPixmap::defaultDepth() == 16 &&
11.186 + my_painter->transformOrientation() == 3 &&
11.187 + my_painter->numRects() >= 0) {
11.188 + if(my_image->width() == width()) {
11.189 + ushort *fb = (ushort*)my_painter->frameBuffer();
11.190 + ushort *buf = (ushort*)my_image->bits();
11.191 + gs_fastRotateBlit_3(fb, buf, rect);
11.192 + } else {
11.193 + // landscape mode
11.194 + uchar *fb = (uchar*)my_painter->frameBuffer();
11.195 + uchar *buf = (uchar*)my_image->bits();
11.196 + int h = rect.height();
11.197 + int wd = rect.width()<<1;
11.198 + int fblineadd = my_painter->lineStep();
11.199 + int buflineadd = my_image->bytesPerLine();
11.200 + fb += (rect.left()<<1) + rect.top() * my_painter->lineStep();
11.201 + buf += (rect.left()<<1) + rect.top() * my_image->bytesPerLine();
11.202 + while(h--) {
11.203 + memcpy(fb, buf, wd);
11.204 + fb += fblineadd;
11.205 + buf += buflineadd;
11.206 + }
11.207 + }
11.208 + } else {
11.209 +#endif
11.210 + QPainter pp(this);
11.211 + pp.drawImage(rect.topLeft(), *my_image, rect);
11.212 + pp.end();
11.213 +#ifndef __i386__
11.214 + }
11.215 +#endif
11.216 +}
11.217 +
11.218 +// This paints the current buffer to the screen, when desired.
11.219 +void SDL_QWin::paintEvent(QPaintEvent *ev) {
11.220 + if(my_image && isVisible() && isActiveWindow()) {
11.221 + lockScreen();
11.222 + repaintRect(ev->rect());
11.223 + unlockScreen();
11.224 + }
11.225 +}
11.226 +
11.227 +/* Function to translate a keyboard transition and queue the key event */
11.228 +void SDL_QWin::QueueKey(QKeyEvent *e, int pressed)
11.229 +{
11.230 + SDL_keysym keysym;
11.231 + int scancode = e->key();
11.232 + /* Set the keysym information */
11.233 + if(scancode >= 'A' && scancode <= 'Z') {
11.234 + // Qt sends uppercase, SDL wants lowercase
11.235 + keysym.sym = static_cast<SDLKey>(scancode + 32);
11.236 + } else if(scancode >= 0x1000) {
11.237 + // Special keys
11.238 + switch(scancode) {
11.239 + case Qt::Key_Escape: scancode = SDLK_ESCAPE; break;
11.240 + case Qt::Key_Tab: scancode = SDLK_TAB; break;
11.241 + case Qt::Key_Backspace: scancode = SDLK_BACKSPACE; break;
11.242 + case Qt::Key_Return: scancode = SDLK_RETURN; break;
11.243 + case Qt::Key_Enter: scancode = SDLK_KP_ENTER; break;
11.244 + case Qt::Key_Insert: scancode = SDLK_INSERT; break;
11.245 + case Qt::Key_Delete: scancode = SDLK_DELETE; break;
11.246 + case Qt::Key_Pause: scancode = SDLK_PAUSE; break;
11.247 + case Qt::Key_Print: scancode = SDLK_PRINT; break;
11.248 + case Qt::Key_SysReq: scancode = SDLK_SYSREQ; break;
11.249 + case Qt::Key_Home: scancode = SDLK_HOME; break;
11.250 + case Qt::Key_End: scancode = SDLK_END; break;
11.251 + case Qt::Key_Left: scancode = SDLK_LEFT; break;
11.252 + case Qt::Key_Up: scancode = SDLK_UP; break;
11.253 + case Qt::Key_Right: scancode = SDLK_RIGHT; break;
11.254 + case Qt::Key_Down: scancode = SDLK_DOWN; break;
11.255 + case Qt::Key_Prior: scancode = SDLK_PAGEUP; break;
11.256 + case Qt::Key_Next: scancode = SDLK_PAGEDOWN; break;
11.257 + case Qt::Key_Shift: scancode = SDLK_LSHIFT; break;
11.258 + case Qt::Key_Control: scancode = SDLK_LCTRL; break;
11.259 + case Qt::Key_Meta: scancode = SDLK_LMETA; break;
11.260 + case Qt::Key_Alt: scancode = SDLK_LALT; break;
11.261 + case Qt::Key_CapsLock: scancode = SDLK_CAPSLOCK; break;
11.262 + case Qt::Key_NumLock: scancode = SDLK_NUMLOCK; break;
11.263 + case Qt::Key_ScrollLock: scancode = SDLK_SCROLLOCK; break;
11.264 + case Qt::Key_F1: scancode = SDLK_F1; break;
11.265 + case Qt::Key_F2: scancode = SDLK_F2; break;
11.266 + case Qt::Key_F3: scancode = SDLK_F3; break;
11.267 + case Qt::Key_F4: scancode = SDLK_F4; break;
11.268 + case Qt::Key_F5: scancode = SDLK_F5; break;
11.269 + case Qt::Key_F6: scancode = SDLK_F6; break;
11.270 + case Qt::Key_F7: scancode = SDLK_F7; break;
11.271 + case Qt::Key_F8: scancode = SDLK_F8; break;
11.272 + case Qt::Key_F9: scancode = SDLK_F9; break;
11.273 + case Qt::Key_F10: scancode = SDLK_F10; break;
11.274 + case Qt::Key_F11: scancode = SDLK_F11; break;
11.275 + case Qt::Key_F12: scancode = SDLK_F12; break;
11.276 + case Qt::Key_F13: scancode = SDLK_F13; break;
11.277 + case Qt::Key_F14: scancode = SDLK_F14; break;
11.278 + case Qt::Key_F15: scancode = SDLK_F15; break;
11.279 + case Qt::Key_Super_L: scancode = SDLK_LSUPER; break;
11.280 + case Qt::Key_Super_R: scancode = SDLK_RSUPER; break;
11.281 + case Qt::Key_Menu: scancode = SDLK_MENU; break;
11.282 + case Qt::Key_Help: scancode = SDLK_HELP; break;
11.283 + default:
11.284 + scancode = SDLK_UNKNOWN;
11.285 + break;
11.286 + }
11.287 + keysym.sym = static_cast<SDLKey>(scancode);
11.288 + } else {
11.289 + keysym.sym = static_cast<SDLKey>(scancode);
11.290 + }
11.291 + keysym.scancode = scancode;
11.292 + keysym.mod = KMOD_NONE;
11.293 + ButtonState st = e->state();
11.294 + if( (st & ShiftButton) ) { keysym.mod = static_cast<SDLMod>(keysym.mod | KMOD_LSHIFT); }
11.295 + if( (st & ControlButton) ) { keysym.mod = static_cast<SDLMod>(keysym.mod | KMOD_LCTRL); }
11.296 + if( (st & AltButton) ) { keysym.mod = static_cast<SDLMod>(keysym.mod | KMOD_LALT); }
11.297 + if ( SDL_TranslateUNICODE ) {
11.298 + QChar qchar = e->text()[0];
11.299 + keysym.unicode = qchar.unicode();
11.300 + } else {
11.301 + keysym.unicode = 0;
11.302 + }
11.303 +
11.304 + /* NUMLOCK and CAPSLOCK are implemented as double-presses in reality */
11.305 + // if ( (keysym.sym == SDLK_NUMLOCK) || (keysym.sym == SDLK_CAPSLOCK) ) {
11.306 + // pressed = 1;
11.307 + // }
11.308 +
11.309 + /* Queue the key event */
11.310 + if ( pressed ) {
11.311 + SDL_PrivateKeyboard(SDL_PRESSED, &keysym);
11.312 + } else {
11.313 + SDL_PrivateKeyboard(SDL_RELEASED, &keysym);
11.314 + }
11.315 +}
11.316 +
11.317 +void SDL_QWin::setFullscreen(bool fs_on) {
11.318 + my_has_fullscreen = false;
11.319 + enableFullscreen();
11.320 +}
11.321 +
11.322 +void SDL_QWin::enableFullscreen() {
11.323 + // Make sure size is correct
11.324 + if(!my_has_fullscreen) {
11.325 + setFixedSize(qApp->desktop()->size());
11.326 + // This call is needed because showFullScreen won't work
11.327 + // correctly if the widget already considers itself to be fullscreen.
11.328 + showNormal();
11.329 + // This is needed because showNormal() forcefully changes the window
11.330 + // style to WSTyle_TopLevel.
11.331 + setWFlags(WStyle_Customize | WStyle_NoBorder);
11.332 + // Enable fullscreen.
11.333 + showFullScreen();
11.334 + my_has_fullscreen = true;
11.335 + }
11.336 +}
12.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
12.2 +++ b/src/video/qtopia/SDL_QWin.h Sun May 19 20:06:01 2002 +0000
12.3 @@ -0,0 +1,128 @@
12.4 +/*
12.5 + SDL - Simple DirectMedia Layer
12.6 + Copyright (C) 1997, 1998, 1999, 2000, 2001 Sam Lantinga
12.7 +
12.8 + This library is free software; you can redistribute it and/or
12.9 + modify it under the terms of the GNU Library General Public
12.10 + License as published by the Free Software Foundation; either
12.11 + version 2 of the License, or (at your option) any later version.
12.12 +
12.13 + This library is distributed in the hope that it will be useful,
12.14 + but WITHOUT ANY WARRANTY; without even the implied warranty of
12.15 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12.16 + Library General Public License for more details.
12.17 +
12.18 + You should have received a copy of the GNU Library General Public
12.19 + License along with this library; if not, write to the Free
12.20 + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
12.21 +
12.22 + Sam Lantinga
12.23 + slouken@libsdl.org
12.24 +*/
12.25 +
12.26 +#ifdef SAVE_RCSID
12.27 +static char rcsid =
12.28 + "@(#) $Id$";
12.29 +#endif
12.30 +
12.31 +#ifndef _SDL_QWin_h
12.32 +#define _SDL_QWin_h
12.33 +#include <stdio.h>
12.34 +
12.35 +#include <qimage.h>
12.36 +#include <qpixmap.h>
12.37 +#include <qwidget.h>
12.38 +#include <qpainter.h>
12.39 +#include <qdirectpainter_qws.h>
12.40 +
12.41 +#include "SDL_events.h"
12.42 +//#include "SDL_BView.h"
12.43 +
12.44 +extern "C" {
12.45 +#include "SDL_events_c.h"
12.46 +};
12.47 +
12.48 +class SDL_QWin : public QWidget
12.49 +{
12.50 + void QueueKey(QKeyEvent *e, int pressed);
12.51 + public:
12.52 + SDL_QWin(const QSize& size);
12.53 + virtual ~SDL_QWin();
12.54 + virtual bool shown(void) {
12.55 + return isVisible();
12.56 + }
12.57 + /* If called, the next resize event will not be forwarded to SDL. */
12.58 + virtual void inhibitResize(void) {
12.59 + my_inhibit_resize = true;
12.60 + }
12.61 + void setImage(QImage *image);
12.62 + void setOffset(int x, int y) {
12.63 + my_offset = QPoint(x, y);
12.64 + }
12.65 + void GetXYOffset(int &x, int &y) {
12.66 + x = my_offset.x();
12.67 + y = my_offset.y();
12.68 + }
12.69 + bool beginDraw(void) {
12.70 + return true;
12.71 + }
12.72 + void endDraw(void) {
12.73 + }
12.74 + QImage *image(void) {
12.75 + return my_image;
12.76 + }
12.77 +
12.78 + void setWFlags(WFlags flags) {
12.79 + QWidget::setWFlags(flags);
12.80 + my_flags = flags;
12.81 + }
12.82 + const QPoint& mousePos() const { return my_mouse_pos; }
12.83 + void setMousePos(const QPoint& newpos) { my_mouse_pos = newpos; }
12.84 + void setFullscreen(bool);
12.85 +
12.86 + void lockScreen() {
12.87 + if(!my_painter) {
12.88 + my_painter = new QDirectPainter(this);
12.89 + }
12.90 + my_locked++; // Increate lock refcount
12.91 + }
12.92 + void unlockScreen() {
12.93 + if(my_locked > 0) {
12.94 + my_locked--; // decrease lock refcount;
12.95 + }
12.96 + if(!my_locked && my_painter) {
12.97 + my_painter->end();
12.98 + delete my_painter;
12.99 + my_painter = 0;
12.100 + }
12.101 + }
12.102 + void repaintRect(const QRect& rect);
12.103 + protected:
12.104 + /* Handle resizing of the window */
12.105 + virtual void resizeEvent(QResizeEvent *e);
12.106 + void focusInEvent(QFocusEvent *);
12.107 + void focusOutEvent(QFocusEvent *);
12.108 + void closeEvent(QCloseEvent *e);
12.109 + void mouseMoveEvent(QMouseEvent *e);
12.110 + void mousePressEvent(QMouseEvent *e);
12.111 + void mouseReleaseEvent(QMouseEvent *e);
12.112 + void paintEvent(QPaintEvent *ev);
12.113 + void keyPressEvent(QKeyEvent *e) {
12.114 + QueueKey(e, 1);
12.115 + }
12.116 + void keyReleaseEvent(QKeyEvent *e) {
12.117 + QueueKey(e, 0);
12.118 + }
12.119 + private:
12.120 + void enableFullscreen();
12.121 + QDirectPainter *my_painter;
12.122 + QImage *my_image;
12.123 + bool my_inhibit_resize;
12.124 + QPoint my_offset;
12.125 + QPoint my_mouse_pos;
12.126 + WFlags my_flags;
12.127 + WFlags my_has_fullscreen;
12.128 + unsigned int my_locked;
12.129 +};
12.130 +
12.131 +#endif /* _SDL_QWin_h */
13.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
13.2 +++ b/src/video/qtopia/SDL_lowvideo.h Sun May 19 20:06:01 2002 +0000
13.3 @@ -0,0 +1,69 @@
13.4 +/*
13.5 + SDL - Simple DirectMedia Layer
13.6 + Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002 Sam Lantinga
13.7 +
13.8 + This library is free software; you can redistribute it and/or
13.9 + modify it under the terms of the GNU Library General Public
13.10 + License as published by the Free Software Foundation; either
13.11 + version 2 of the License, or (at your option) any later version.
13.12 +
13.13 + This library is distributed in the hope that it will be useful,
13.14 + but WITHOUT ANY WARRANTY; without even the implied warranty of
13.15 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13.16 + Library General Public License for more details.
13.17 +
13.18 + You should have received a copy of the GNU Library General Public
13.19 + License along with this library; if not, write to the Free
13.20 + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
13.21 +
13.22 + Sam Lantinga
13.23 + slouken@libsdl.org
13.24 +*/
13.25 +
13.26 +#ifdef SAVE_RCSID
13.27 +static char rcsid =
13.28 + "@(#) $Id$";
13.29 +#endif
13.30 +
13.31 +#ifndef _SDL_lowvideo_h
13.32 +#define _SDL_lowvideo_h
13.33 +
13.34 +#include "SDL_mouse.h"
13.35 +#include "SDL_sysvideo.h"
13.36 +
13.37 +/* Hidden "this" pointer for the video functions */
13.38 +#define _THIS SDL_VideoDevice *_this
13.39 +
13.40 +/* Private display data */
13.41 +struct SDL_PrivateVideoData {
13.42 + /* The main window */
13.43 + SDL_QWin *SDL_Win;
13.44 +
13.45 + /* The fullscreen mode list */
13.46 +#define NUM_MODELISTS 4 /* 8, 16, 24, and 32 bits-per-pixel */
13.47 + int SDL_nummodes[NUM_MODELISTS];
13.48 + SDL_Rect **SDL_modelist[NUM_MODELISTS];
13.49 +
13.50 + /* A completely clear cursor */
13.51 + WMcursor *BlankCursor;
13.52 +
13.53 + /* Mouse state variables */
13.54 + Uint32 last_buttons;
13.55 + QPoint last_point;
13.56 +
13.57 + /* Keyboard state variables */
13.58 + int key_flip;
13.59 + //struct key_info keyinfo[2];
13.60 +};
13.61 +/* Old variable names */
13.62 +#define SDL_Win (_this->hidden->SDL_Win)
13.63 +#define saved_mode (_this->hidden->saved_mode)
13.64 +#define SDL_nummodes (_this->hidden->SDL_nummodes)
13.65 +#define SDL_modelist (_this->hidden->SDL_modelist)
13.66 +#define SDL_BlankCursor (_this->hidden->BlankCursor)
13.67 +#define last_buttons (_this->hidden->last_buttons)
13.68 +#define last_point (_this->hidden->last_point)
13.69 +#define key_flip (_this->hidden->key_flip)
13.70 +#define keyinfo (_this->hidden->keyinfo)
13.71 +
13.72 +#endif /* _SDL_lowvideo_h */
14.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
14.2 +++ b/src/video/qtopia/SDL_sysevents.cc Sun May 19 20:06:01 2002 +0000
14.3 @@ -0,0 +1,273 @@
14.4 +/*
14.5 + SDL - Simple DirectMedia Layer
14.6 + Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002 Sam Lantinga
14.7 +
14.8 + This library is free software; you can redistribute it and/or
14.9 + modify it under the terms of the GNU Library General Public
14.10 + License as published by the Free Software Foundation; either
14.11 + version 2 of the License, or (at your option) any later version.
14.12 +
14.13 + This library is distributed in the hope that it will be useful,
14.14 + but WITHOUT ANY WARRANTY; without even the implied warranty of
14.15 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14.16 + Library General Public License for more details.
14.17 +
14.18 + You should have received a copy of the GNU Library General Public
14.19 + License along with this library; if not, write to the Free
14.20 + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
14.21 +
14.22 + Sam Lantinga
14.23 + slouken@libsdl.org
14.24 +*/
14.25 +
14.26 +#ifdef SAVE_RCSID
14.27 +static char rcsid =
14.28 + "@(#) $Id$";
14.29 +#endif
14.30 +
14.31 +#include <qpe/qpeapplication.h>
14.32 +
14.33 +#include <stdio.h>
14.34 +#include <string.h>
14.35 +#include "SDL_error.h"
14.36 +#include "SDL_events.h"
14.37 +#include "SDL_QWin.h"
14.38 +#include "SDL_lowvideo.h"
14.39 +#include "SDL_timer.h"
14.40 +
14.41 +extern "C" {
14.42 +#include "SDL_events_c.h"
14.43 +#include "SDL_sysevents.h"
14.44 +#include "SDL_sysevents_c.h"
14.45 +
14.46 + // static SDLKey keymap[128];
14.47 +/* This is special because we know it will be run in a loop in a separate
14.48 + thread. Normally this function should loop as long as there are input
14.49 + states changing, i.e. new events arriving.
14.50 +*/
14.51 +void QT_PumpEvents(_THIS)
14.52 +{
14.53 + if(!qApp) {
14.54 + return;
14.55 + }
14.56 + // printf("processing events: %p\n", qApp);
14.57 + //qApp->processOneEvent(); // wait for a event
14.58 + qApp->processEvents(); // and process all outstanding ones
14.59 +#if 0
14.60 + BView *view;
14.61 + BRect bounds;
14.62 + BPoint point;
14.63 + uint32 buttons;
14.64 + const uint32 button_masks[3] = {
14.65 + B_PRIMARY_MOUSE_BUTTON,
14.66 + B_TERTIARY_MOUSE_BUTTON,
14.67 + B_SECONDARY_MOUSE_BUTTON,
14.68 + };
14.69 + unsigned int i, j;
14.70 +
14.71 + /* Check out the mouse buttons and position (slight race condition) */
14.72 + if ( SDL_Win->Lock() ) {
14.73 + /* Don't do anything if we have no view */
14.74 + view = SDL_Win->View();
14.75 + if ( ! view ) {
14.76 + SDL_Win->Unlock();
14.77 + return;
14.78 + }
14.79 + bounds = view->Bounds();
14.80 + /* Get new input state, if still active */
14.81 + if ( SDL_Win->IsActive() ) {
14.82 + key_flip = !key_flip;
14.83 + get_key_info(&keyinfo[key_flip]);
14.84 + view->GetMouse(&point, &buttons, true);
14.85 + } else {
14.86 + key_flip = key_flip;
14.87 + point = last_point;
14.88 + buttons = last_buttons;
14.89 + }
14.90 + SDL_Win->Unlock();
14.91 + } else {
14.92 + return;
14.93 + }
14.94 +
14.95 + /* If our view is active, we'll find key changes here */
14.96 + if ( memcmp(keyinfo[0].key_states, keyinfo[1].key_states, 16) != 0 ) {
14.97 + for ( i=0; i<16; ++i ) {
14.98 + Uint8 new_state, transition;
14.99 +
14.100 + new_state = keyinfo[key_flip].key_states[i];
14.101 + transition = keyinfo[!key_flip].key_states[i] ^
14.102 + keyinfo[ key_flip].key_states[i];
14.103 + for ( j=0; j<8; ++j ) {
14.104 + if ( transition&0x80 )
14.105 + QueueKey(i*8+j, new_state&0x80);
14.106 + transition <<= 1;
14.107 + new_state <<= 1;
14.108 + }
14.109 + }
14.110 + }
14.111 +
14.112 + /* We check keyboard, but not mouse if mouse isn't in window */
14.113 + if ( ! bounds.Contains(point) ) {
14.114 + /* Mouse moved outside our view? */
14.115 + if ( SDL_GetAppState() & SDL_APPMOUSEFOCUS ) {
14.116 + SDL_PrivateAppActive(0, SDL_APPMOUSEFOCUS);
14.117 + be_app->SetCursor(B_HAND_CURSOR);
14.118 + }
14.119 + return;
14.120 + }
14.121 + /* Has the mouse moved back into our view? */
14.122 + if ( ! (SDL_GetAppState() & SDL_APPMOUSEFOCUS) ) {
14.123 + /* Reset the B_HAND_CURSOR to our own */
14.124 + SDL_PrivateAppActive(1, SDL_APPMOUSEFOCUS);
14.125 + SDL_SetCursor(NULL);
14.126 + }
14.127 +
14.128 + /* Check for mouse motion */
14.129 + if ( point != last_point ) {
14.130 + int x, y;
14.131 +
14.132 + SDL_Win->GetXYOffset(x, y);
14.133 + x = (int)point.x - x;
14.134 + y = (int)point.y - y;
14.135 + SDL_PrivateMouseMotion(0, 0, x, y);
14.136 + }
14.137 + last_point = point;
14.138 +
14.139 + /* Add any mouse button events */
14.140 + for ( i=0; i<SDL_TABLESIZE(button_masks); ++i ) {
14.141 + if ( (buttons ^ last_buttons) & button_masks[i] ) {
14.142 + if ( buttons & button_masks[i] ) {
14.143 + SDL_PrivateMouseButton(SDL_PRESSED, 1+i, 0, 0);
14.144 + } else {
14.145 + SDL_PrivateMouseButton(SDL_RELEASED, 1+i, 0, 0);
14.146 + }
14.147 + }
14.148 + }
14.149 + last_buttons = buttons;
14.150 +#endif
14.151 +}
14.152 +
14.153 +void QT_InitOSKeymap(_THIS)
14.154 +{
14.155 +#if 0
14.156 + unsigned int i;
14.157 +
14.158 + /* Initialize all the key states as "up" */
14.159 + key_flip = 0;
14.160 + memset(keyinfo[key_flip].key_states, 0, 16);
14.161 +
14.162 + /* Initialize the key translation table */
14.163 + for ( i=0; i<SDL_TABLESIZE(keymap); ++i )
14.164 + keymap[i] = SDLK_UNKNOWN;
14.165 +
14.166 + // keymap[0x01] = SDLK_ESCAPE;
14.167 + // keymap[B_F1_KEY] = SDLK_F1;
14.168 + // keymap[B_F2_KEY] = SDLK_F2;
14.169 + // keymap[B_F3_KEY] = SDLK_F3;
14.170 + // keymap[B_F4_KEY] = SDLK_F4;
14.171 + // keymap[B_F5_KEY] = SDLK_F5;
14.172 + // keymap[B_F6_KEY] = SDLK_F6;
14.173 + // keymap[B_F7_KEY] = SDLK_F7;
14.174 + // keymap[B_F8_KEY] = SDLK_F8;
14.175 + // keymap[B_F9_KEY] = SDLK_F9;
14.176 + // keymap[B_F10_KEY] = SDLK_F10;
14.177 + // keymap[B_F11_KEY] = SDLK_F11;
14.178 + // keymap[B_F12_KEY] = SDLK_F12;
14.179 + // keymap[B_PRINT_KEY] = SDLK_PRINT;
14.180 + //keymap[B_SCROLL_KEY] = SDLK_SCROLLOCK;
14.181 + // keymap[B_PAUSE_KEY] = SDLK_PAUSE;
14.182 + keymap[0x11] = SDLK_BACKQUOTE;
14.183 + keymap[0x12] = SDLK_1;
14.184 + keymap[0x13] = SDLK_2;
14.185 + keymap[0x14] = SDLK_3;
14.186 + keymap[0x15] = SDLK_4;
14.187 + keymap[0x16] = SDLK_5;
14.188 + keymap[0x17] = SDLK_6;
14.189 + keymap[0x18] = SDLK_7;
14.190 + keymap[0x19] = SDLK_8;
14.191 + keymap[0x1a] = SDLK_9;
14.192 + keymap[0x1b] = SDLK_0;
14.193 + keymap[0x1c] = SDLK_MINUS;
14.194 + keymap[0x1d] = SDLK_EQUALS;
14.195 + keymap[0x1e] = SDLK_BACKSPACE;
14.196 + keymap[0x1f] = SDLK_INSERT;
14.197 + keymap[0x20] = SDLK_HOME;
14.198 + keymap[0x21] = SDLK_PAGEUP;
14.199 + //keymap[0x22] = SDLK_NUMLOCK;
14.200 + keymap[0x23] = SDLK_KP_DIVIDE;
14.201 + keymap[0x24] = SDLK_KP_MULTIPLY;
14.202 + keymap[0x25] = SDLK_KP_MINUS;
14.203 + keymap[0x26] = SDLK_TAB;
14.204 + keymap[0x27] = SDLK_q;
14.205 + keymap[0x28] = SDLK_w;
14.206 + keymap[0x29] = SDLK_e;
14.207 + keymap[0x2a] = SDLK_r;
14.208 + keymap[0x2b] = SDLK_t;
14.209 + keymap[0x2c] = SDLK_y;
14.210 + keymap[0x2d] = SDLK_u;
14.211 + keymap[0x2e] = SDLK_i;
14.212 + keymap[0x2f] = SDLK_o;
14.213 + keymap[0x30] = SDLK_p;
14.214 + keymap[0x31] = SDLK_LEFTBRACKET;
14.215 + keymap[0x32] = SDLK_RIGHTBRACKET;
14.216 + keymap[0x33] = SDLK_BACKSLASH;
14.217 + keymap[0x34] = SDLK_DELETE;
14.218 + keymap[0x35] = SDLK_END;
14.219 + keymap[0x36] = SDLK_PAGEDOWN;
14.220 + keymap[0x37] = SDLK_KP7;
14.221 + keymap[0x38] = SDLK_KP8;
14.222 + keymap[0x39] = SDLK_KP9;
14.223 + keymap[0x3a] = SDLK_KP_PLUS;
14.224 + //keymap[0x3b] = SDLK_CAPSLOCK;
14.225 + keymap[0x3c] = SDLK_a;
14.226 + keymap[0x3d] = SDLK_s;
14.227 + keymap[0x3e] = SDLK_d;
14.228 + keymap[0x3f] = SDLK_f;
14.229 + keymap[0x40] = SDLK_g;
14.230 + keymap[0x41] = SDLK_h;
14.231 + keymap[0x42] = SDLK_j;
14.232 + keymap[0x43] = SDLK_k;
14.233 + keymap[0x44] = SDLK_l;
14.234 + keymap[0x45] = SDLK_SEMICOLON;
14.235 + keymap[0x46] = SDLK_QUOTE;
14.236 + keymap[0x47] = SDLK_RETURN;
14.237 + keymap[0x48] = SDLK_KP4;
14.238 + keymap[0x49] = SDLK_KP5;
14.239 + keymap[0x4a] = SDLK_KP6;
14.240 + keymap[0x4b] = SDLK_LSHIFT;
14.241 + keymap[0x4c] = SDLK_z;
14.242 + keymap[0x4d] = SDLK_x;
14.243 + keymap[0x4e] = SDLK_c;
14.244 + keymap[0x4f] = SDLK_v;
14.245 + keymap[0x50] = SDLK_b;
14.246 + keymap[0x51] = SDLK_n;
14.247 + keymap[0x52] = SDLK_m;
14.248 + keymap[0x53] = SDLK_COMMA;
14.249 + keymap[0x54] = SDLK_PERIOD;
14.250 + keymap[0x55] = SDLK_SLASH;
14.251 + keymap[0x56] = SDLK_RSHIFT;
14.252 + keymap[0x57] = SDLK_UP;
14.253 + keymap[0x58] = SDLK_KP1;
14.254 + keymap[0x59] = SDLK_KP2;
14.255 + keymap[0x5a] = SDLK_KP3;
14.256 + keymap[0x5b] = SDLK_KP_ENTER;
14.257 + //keymap[0x5c] = SDLK_LCTRL;
14.258 + //keymap[0x5d] = SDLK_LALT;
14.259 + keymap[0x5e] = SDLK_SPACE;
14.260 + //keymap[0x5f] = SDLK_RALT;
14.261 + //keymap[0x60] = SDLK_RCTRL;
14.262 + keymap[0x61] = SDLK_LEFT;
14.263 + keymap[0x62] = SDLK_DOWN;
14.264 + keymap[0x63] = SDLK_RIGHT;
14.265 + keymap[0x64] = SDLK_KP0;
14.266 + keymap[0x65] = SDLK_KP_PERIOD;
14.267 + //keymap[0x66] = SDLK_LMETA;
14.268 + //keymap[0x67] = SDLK_RMETA;
14.269 + //keymap[0x68] = SDLK_MENU;
14.270 + keymap[0x69] = SDLK_EURO;
14.271 + keymap[0x6a] = SDLK_KP_EQUALS;
14.272 + keymap[0x6b] = SDLK_POWER;
14.273 +#endif
14.274 +}
14.275 +
14.276 +}; /* Extern C */
15.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
15.2 +++ b/src/video/qtopia/SDL_sysevents_c.h Sun May 19 20:06:01 2002 +0000
15.3 @@ -0,0 +1,35 @@
15.4 +/*
15.5 + SDL - Simple DirectMedia Layer
15.6 + Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002 Sam Lantinga
15.7 +
15.8 + This library is free software; you can redistribute it and/or
15.9 + modify it under the terms of the GNU Library General Public
15.10 + License as published by the Free Software Foundation; either
15.11 + version 2 of the License, or (at your option) any later version.
15.12 +
15.13 + This library is distributed in the hope that it will be useful,
15.14 + but WITHOUT ANY WARRANTY; without even the implied warranty of
15.15 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15.16 + Library General Public License for more details.
15.17 +
15.18 + You should have received a copy of the GNU Library General Public
15.19 + License along with this library; if not, write to the Free
15.20 + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
15.21 +
15.22 + Sam Lantinga
15.23 + slouken@libsdl.org
15.24 +*/
15.25 +
15.26 +#ifdef SAVE_RCSID
15.27 +static char rcsid =
15.28 + "@(#) $Id$";
15.29 +#endif
15.30 +
15.31 +#include "SDL_lowvideo.h"
15.32 +
15.33 +/* Variables and functions exported by SDL_sysevents.c to other parts
15.34 + of the native video subsystem (SDL_sysvideo.c)
15.35 +*/
15.36 +
15.37 +extern void QT_InitOSKeymap(_THIS);
15.38 +extern void QT_PumpEvents(_THIS);
16.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
16.2 +++ b/src/video/qtopia/SDL_sysmouse.cc Sun May 19 20:06:01 2002 +0000
16.3 @@ -0,0 +1,65 @@
16.4 +/*
16.5 + SDL - Simple DirectMedia Layer
16.6 + Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002 Sam Lantinga
16.7 +
16.8 + This library is free software; you can redistribute it and/or
16.9 + modify it under the terms of the GNU Library General Public
16.10 + License as published by the Free Software Foundation; either
16.11 + version 2 of the License, or (at your option) any later version.
16.12 +
16.13 + This library is distributed in the hope that it will be useful,
16.14 + but WITHOUT ANY WARRANTY; without even the implied warranty of
16.15 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16.16 + Library General Public License for more details.
16.17 +
16.18 + You should have received a copy of the GNU Library General Public
16.19 + License along with this library; if not, write to the Free
16.20 + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16.21 +
16.22 + Sam Lantinga
16.23 + slouken@libsdl.org
16.24 +*/
16.25 +
16.26 +#ifdef SAVE_RCSID
16.27 +static char rcsid =
16.28 + "@(#) $Id$";
16.29 +#endif
16.30 +
16.31 +#include <stdlib.h>
16.32 +#include <string.h>
16.33 +
16.34 +
16.35 +#include "SDL_error.h"
16.36 +#include "SDL_QWin.h"
16.37 +
16.38 +extern "C" {
16.39 +
16.40 +#include "SDL_sysmouse_c.h"
16.41 +
16.42 +/* The implementation dependent data for the window manager cursor */
16.43 +struct WMcursor {
16.44 + char *bits;
16.45 +};
16.46 +WMcursor *QT_CreateWMCursor(_THIS,
16.47 + Uint8 *data, Uint8 *mask, int w, int h, int hot_x, int hot_y)
16.48 +{
16.49 + static WMcursor dummy;
16.50 + dummy.bits = 0;
16.51 + return &dummy;
16.52 +}
16.53 +
16.54 +int QT_ShowWMCursor(_THIS, WMcursor *cursor)
16.55 +{
16.56 + return 1;
16.57 +}
16.58 +
16.59 +void QT_FreeWMCursor(_THIS, WMcursor *cursor)
16.60 +{
16.61 +}
16.62 +
16.63 +void QT_WarpWMCursor(_THIS, Uint16 x, Uint16 y)
16.64 +{
16.65 + SDL_Win->setMousePos(QPoint(x, y));
16.66 +}
16.67 +
16.68 +}; /* Extern C */
17.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
17.2 +++ b/src/video/qtopia/SDL_sysmouse_c.h Sun May 19 20:06:01 2002 +0000
17.3 @@ -0,0 +1,36 @@
17.4 +/*
17.5 + SDL - Simple DirectMedia Layer
17.6 + Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002 Sam Lantinga
17.7 +
17.8 + This library is free software; you can redistribute it and/or
17.9 + modify it under the terms of the GNU Library General Public
17.10 + License as published by the Free Software Foundation; either
17.11 + version 2 of the License, or (at your option) any later version.
17.12 +
17.13 + This library is distributed in the hope that it will be useful,
17.14 + but WITHOUT ANY WARRANTY; without even the implied warranty of
17.15 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17.16 + Library General Public License for more details.
17.17 +
17.18 + You should have received a copy of the GNU Library General Public
17.19 + License along with this library; if not, write to the Free
17.20 + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17.21 +
17.22 + Sam Lantinga
17.23 + slouken@libsdl.org
17.24 +*/
17.25 +
17.26 +#ifdef SAVE_RCSID
17.27 +static char rcsid =
17.28 + "@(#) $Id$";
17.29 +#endif
17.30 +
17.31 +#include "SDL_lowvideo.h"
17.32 +
17.33 +/* Functions to be exported */
17.34 +extern void QT_FreeWMCursor(_THIS, WMcursor *cursor);
17.35 +extern WMcursor *QT_CreateWMCursor(_THIS,
17.36 + Uint8 *data, Uint8 *mask, int w, int h, int hot_x, int hot_y);
17.37 +extern int QT_ShowWMCursor(_THIS, WMcursor *cursor);
17.38 +extern void QT_WarpWMCursor(_THIS, Uint16 x, Uint16 y);
17.39 +
18.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
18.2 +++ b/src/video/qtopia/SDL_sysvideo.cc Sun May 19 20:06:01 2002 +0000
18.3 @@ -0,0 +1,376 @@
18.4 +/*
18.5 + SDL - Simple DirectMedia Layer
18.6 + Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002 Sam Lantinga
18.7 +
18.8 + This library is free software; you can redistribute it and/or
18.9 + modify it under the terms of the GNU Library General Public
18.10 + License as published by the Free Software Foundation; either
18.11 + version 2 of the License, or (at your option) any later version.
18.12 +
18.13 + This library is distributed in the hope that it will be useful,
18.14 + but WITHOUT ANY WARRANTY; without even the implied warranty of
18.15 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18.16 + Library General Public License for more details.
18.17 +
18.18 + You should have received a copy of the GNU Library General Public
18.19 + License along with this library; if not, write to the Free
18.20 + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18.21 +
18.22 + Sam Lantinga
18.23 + slouken@libsdl.org
18.24 +*/
18.25 +
18.26 +#ifdef SAVE_RCSID
18.27 +static char rcsid =
18.28 + "@(#) $Id$";
18.29 +#endif
18.30 +
18.31 +/* Qtopia based framebuffer implementation */
18.32 +
18.33 +#include <stdlib.h>
18.34 +#include <string.h>
18.35 +
18.36 +#include <stdio.h>
18.37 +#include <unistd.h>
18.38 +
18.39 +#include <qapplication.h>
18.40 +
18.41 +#include "SDL.h"
18.42 +#include "SDL_timer.h"
18.43 +
18.44 +#include "SDL_QWin.h"
18.45 +#include "SDL_QPEApp.h"
18.46 +
18.47 +extern "C" {
18.48 +
18.49 +#include "SDL_sysvideo.h"
18.50 +#include "SDL_sysmouse_c.h"
18.51 +#include "SDL_sysevents_c.h"
18.52 +#include "SDL_events_c.h"
18.53 +#include "SDL_syswm_c.h"
18.54 +#include "SDL_lowvideo.h"
18.55 +
18.56 + //#define QTOPIA_DEBUG
18.57 +#define QT_HIDDEN_SIZE 32 /* starting hidden window size */
18.58 +
18.59 + /* Initialization/Query functions */
18.60 + static int QT_VideoInit(_THIS, SDL_PixelFormat *vformat);
18.61 + static SDL_Rect **QT_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags);
18.62 + static SDL_Surface *QT_SetVideoMode(_THIS, SDL_Surface *current, int width, int height, int bpp, Uint32 flags);
18.63 + static void QT_UpdateMouse(_THIS);
18.64 + static int QT_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors);
18.65 + static void QT_VideoQuit(_THIS);
18.66 +
18.67 + /* Hardware surface functions */
18.68 + static int QT_AllocHWSurface(_THIS, SDL_Surface *surface);
18.69 + static int QT_LockHWSurface(_THIS, SDL_Surface *surface);
18.70 + static void QT_UnlockHWSurface(_THIS, SDL_Surface *surface);
18.71 + static void QT_FreeHWSurface(_THIS, SDL_Surface *surface);
18.72 +
18.73 + static int QT_ToggleFullScreen(_THIS, int fullscreen);
18.74 +
18.75 +
18.76 + /* FB driver bootstrap functions */
18.77 +
18.78 + static int QT_Available(void)
18.79 + {
18.80 + return(1);
18.81 + }
18.82 +
18.83 + static void QT_DeleteDevice(SDL_VideoDevice *device)
18.84 + {
18.85 + free(device->hidden);
18.86 + free(device);
18.87 + }
18.88 +
18.89 + static SDL_VideoDevice *QT_CreateDevice(int devindex)
18.90 + {
18.91 + SDL_VideoDevice *device;
18.92 +
18.93 + /* Initialize all variables that we clean on shutdown */
18.94 + device = (SDL_VideoDevice *)malloc(sizeof(SDL_VideoDevice));
18.95 + if ( device ) {
18.96 + memset(device, 0, (sizeof *device));
18.97 + device->hidden = (struct SDL_PrivateVideoData *)
18.98 + malloc((sizeof *device->hidden));
18.99 + }
18.100 + if ( (device == NULL) || (device->hidden == NULL) ) {
18.101 + SDL_OutOfMemory();
18.102 + if ( device ) {
18.103 + free(device);
18.104 + }
18.105 + return(0);
18.106 + }
18.107 + memset(device->hidden, 0, (sizeof *device->hidden));
18.108 +
18.109 + /* Set the function pointers */
18.110 + device->VideoInit = QT_VideoInit;
18.111 + device->ListModes = QT_ListModes;
18.112 + device->SetVideoMode = QT_SetVideoMode;
18.113 + device->UpdateMouse = QT_UpdateMouse;
18.114 + device->SetColors = QT_SetColors;
18.115 + device->UpdateRects = NULL;
18.116 + device->VideoQuit = QT_VideoQuit;
18.117 + device->AllocHWSurface = QT_AllocHWSurface;
18.118 + device->CheckHWBlit = NULL;
18.119 + device->FillHWRect = NULL;
18.120 + device->SetHWColorKey = NULL;
18.121 + device->SetHWAlpha = NULL;
18.122 + device->LockHWSurface = QT_LockHWSurface;
18.123 + device->UnlockHWSurface = QT_UnlockHWSurface;
18.124 + device->FlipHWSurface = NULL;
18.125 + device->FreeHWSurface = QT_FreeHWSurface;
18.126 + device->SetIcon = NULL;
18.127 + device->SetCaption = QT_SetWMCaption;
18.128 + device->GetWMInfo = NULL;
18.129 + device->FreeWMCursor = QT_FreeWMCursor;
18.130 + device->CreateWMCursor = QT_CreateWMCursor;
18.131 + device->ShowWMCursor = QT_ShowWMCursor;
18.132 + device->WarpWMCursor = QT_WarpWMCursor;
18.133 + device->InitOSKeymap = QT_InitOSKeymap;
18.134 + device->PumpEvents = QT_PumpEvents;
18.135 +
18.136 + device->free = QT_DeleteDevice;
18.137 + device->ToggleFullScreen = QT_ToggleFullScreen;
18.138 +
18.139 + /* Set the driver flags */
18.140 + device->handles_any_size = 0;
18.141 +
18.142 + return device;
18.143 + }
18.144 +
18.145 + VideoBootStrap Qtopia_bootstrap = {
18.146 + "qtopia", "Qtopia / QPE graphics",
18.147 + QT_Available, QT_CreateDevice
18.148 + };
18.149 +
18.150 + /* Function to sort the display_list */
18.151 + static int CompareModes(const void *A, const void *B)
18.152 + {
18.153 +#if 0
18.154 + const display_mode *a = (display_mode *)A;
18.155 + const display_mode *b = (display_mode *)B;
18.156 +
18.157 + if ( a->space == b->space ) {
18.158 + return((b->virtual_width*b->virtual_height)-
18.159 + (a->virtual_width*a->virtual_height));
18.160 + } else {
18.161 + return(ColorSpaceToBitsPerPixel(b->space)-
18.162 + ColorSpaceToBitsPerPixel(a->space));
18.163 + }
18.164 +#endif
18.165 + return 0;
18.166 + }
18.167 +
18.168 + /* Yes, this isn't the fastest it could be, but it works nicely */
18.169 + static int QT_AddMode(_THIS, int index, unsigned int w, unsigned int h)
18.170 + {
18.171 + SDL_Rect *mode;
18.172 + int i;
18.173 + int next_mode;
18.174 +
18.175 + /* Check to see if we already have this mode */
18.176 + if ( SDL_nummodes[index] > 0 ) {
18.177 + for ( i=SDL_nummodes[index]-1; i >= 0; --i ) {
18.178 + mode = SDL_modelist[index][i];
18.179 + if ( (mode->w == w) && (mode->h == h) ) {
18.180 + return(0);
18.181 + }
18.182 + }
18.183 + }
18.184 +
18.185 + /* Set up the new video mode rectangle */
18.186 + mode = (SDL_Rect *)malloc(sizeof *mode);
18.187 + if ( mode == NULL ) {
18.188 + SDL_OutOfMemory();
18.189 + return(-1);
18.190 + }
18.191 + mode->x = 0;
18.192 + mode->y = 0;
18.193 + mode->w = w;
18.194 + mode->h = h;
18.195 +#ifdef QTOPIA_DEBUG
18.196 + fprintf(stderr, "Adding mode %dx%d at %d bytes per pixel\n", w, h, index+1);
18.197 +#endif
18.198 +
18.199 + /* Allocate the new list of modes, and fill in the new mode */
18.200 + next_mode = SDL_nummodes[index];
18.201 + SDL_modelist[index] = (SDL_Rect **)
18.202 + realloc(SDL_modelist[index], (1+next_mode+1)*sizeof(SDL_Rect *));
18.203 + if ( SDL_modelist[index] == NULL ) {
18.204 + SDL_OutOfMemory();
18.205 + SDL_nummodes[index] = 0;
18.206 + free(mode);
18.207 + return(-1);
18.208 + }
18.209 + SDL_modelist[index][next_mode] = mode;
18.210 + SDL_modelist[index][next_mode+1] = NULL;
18.211 + SDL_nummodes[index]++;
18.212 +
18.213 + return(0);
18.214 + }
18.215 +
18.216 + int QT_VideoInit(_THIS, SDL_PixelFormat *vformat)
18.217 + {
18.218 + /* Initialize the QPE Application */
18.219 + if(SDL_InitQPEApp() == -1) {
18.220 + return -1;
18.221 + }
18.222 +
18.223 + /* Determine the screen depth */
18.224 + vformat->BitsPerPixel = QPixmap::defaultDepth();
18.225 +
18.226 + // For now we hardcode the current depth because anything else
18.227 + // might as well be emulated by SDL rather than by Qtopia.
18.228 +
18.229 + QSize desktop_size = qApp->desktop()->size();
18.230 + QT_AddMode(_this, ((vformat->BitsPerPixel+7)/8)-1,
18.231 + desktop_size.width(), desktop_size.height());
18.232 + QT_AddMode(_this, ((vformat->BitsPerPixel+7)/8)-1,
18.233 + desktop_size.height(), desktop_size.width());
18.234 +
18.235 + /* Create the window / widget */
18.236 + SDL_Win = new SDL_QWin(QSize(QT_HIDDEN_SIZE, QT_HIDDEN_SIZE));
18.237 + qApp->setMainWidget(SDL_Win);
18.238 + /* Fill in some window manager capabilities */
18.239 + _this->info.wm_available = 0;
18.240 +
18.241 + /* We're done! */
18.242 + return(0);
18.243 + }
18.244 +
18.245 + /* We support any dimension at our bit-depth */
18.246 + SDL_Rect **QT_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags)
18.247 + {
18.248 + SDL_Rect **modes;
18.249 +
18.250 + modes = ((SDL_Rect **)0);
18.251 + if ( (flags & SDL_FULLSCREEN) == SDL_FULLSCREEN ) {
18.252 + modes = SDL_modelist[((format->BitsPerPixel+7)/8)-1];
18.253 + } else {
18.254 + if ( format->BitsPerPixel ==
18.255 + _this->screen->format->BitsPerPixel ) {
18.256 + modes = ((SDL_Rect **)-1);
18.257 + }
18.258 + }
18.259 + return(modes);
18.260 + }
18.261 +
18.262 + /* Various screen update functions available */
18.263 + static void QT_NormalUpdate(_THIS, int numrects, SDL_Rect *rects);
18.264 +
18.265 +
18.266 + static int QT_SetFullScreen(_THIS, SDL_Surface *screen, int fullscreen)
18.267 + {
18.268 + return -1;
18.269 + }
18.270 +
18.271 + static int QT_ToggleFullScreen(_THIS, int fullscreen)
18.272 + {
18.273 + return -1;
18.274 + }
18.275 +
18.276 + /* FIXME: check return values and cleanup here */
18.277 + SDL_Surface *QT_SetVideoMode(_THIS, SDL_Surface *current,
18.278 + int width, int height, int bpp, Uint32 flags)
18.279 + {
18.280 + Qt::WFlags wflags = Qt::WType_TopLevel|Qt::WStyle_Customize;
18.281 + QImage *qimage;
18.282 + QSize desktop_size = qApp->desktop()->size();
18.283 +
18.284 +
18.285 + current->flags = SDL_FULLSCREEN; // We always run fullscreen.
18.286 +
18.287 + if(width <= desktop_size.width() && height <= desktop_size.height()) {
18.288 + current->w = desktop_size.width();
18.289 + current->h = desktop_size.height();
18.290 + } else if(width <= desktop_size.height()
18.291 + && height <= desktop_size.width()) {
18.292 + // Landscape mode
18.293 + current->h = desktop_size.width();
18.294 + current->w = desktop_size.height();
18.295 + } else {
18.296 + SDL_SetError("Unsupported resolution, %dx%d\n", width, height);
18.297 + }
18.298 + if ( flags & SDL_OPENGL ) {
18.299 + SDL_SetError("OpenGL not supported");
18.300 + return(NULL);
18.301 + }
18.302 + /* Create the QImage framebuffer */
18.303 + qimage = new QImage(current->w, current->h, bpp);
18.304 + if (qimage->isNull()) {
18.305 + SDL_SetError("Couldn't create screen bitmap");
18.306 + delete qimage;
18.307 + return(NULL);
18.308 + }
18.309 + current->pitch = qimage->bytesPerLine();
18.310 + current->pixels = (void *)qimage->bits();
18.311 + SDL_Win->setImage(qimage);
18.312 + _this->UpdateRects = QT_NormalUpdate;
18.313 + SDL_Win->setFullscreen(true);
18.314 + /* We're done */
18.315 + return(current);
18.316 + }
18.317 +
18.318 + /* Update the current mouse state and position */
18.319 + void QT_UpdateMouse(_THIS)
18.320 + {
18.321 + QPoint point(-1, -1);
18.322 + if ( SDL_Win->isActiveWindow() ) {
18.323 + point = SDL_Win->mousePos();
18.324 + }
18.325 +
18.326 + if ( (point.x() >= 0) && (point.x() < SDL_VideoSurface->w) &&
18.327 + (point.y() >= 0) && (point.y() < SDL_VideoSurface->h) ) {
18.328 + SDL_PrivateAppActive(1, SDL_APPMOUSEFOCUS);
18.329 + SDL_PrivateMouseMotion(0, 0,
18.330 + (Sint16)point.x(), (Sint16)point.y());
18.331 + } else {
18.332 + SDL_PrivateAppActive(0, SDL_APPMOUSEFOCUS);
18.333 + }
18.334 + }
18.335 +
18.336 + /* We don't actually allow hardware surfaces other than the main one */
18.337 + static int QT_AllocHWSurface(_THIS, SDL_Surface *surface)
18.338 + {
18.339 + return(-1);
18.340 + }
18.341 + static void QT_FreeHWSurface(_THIS, SDL_Surface *surface)
18.342 + {
18.343 + return;
18.344 + }
18.345 + static int QT_LockHWSurface(_THIS, SDL_Surface *surface)
18.346 + {
18.347 + return(0);
18.348 + }
18.349 + static void QT_UnlockHWSurface(_THIS, SDL_Surface *surface)
18.350 + {
18.351 + return;
18.352 + }
18.353 +
18.354 + static void QT_NormalUpdate(_THIS, int numrects, SDL_Rect *rects)
18.355 + {
18.356 + int i;
18.357 + SDL_Win->lockScreen();
18.358 + for ( i=0; i<numrects; ++i ) {
18.359 + QRect rect(rects[i].x, rects[i].y,
18.360 + rects[i].w, rects[i].h);
18.361 + SDL_Win->repaintRect(rect);
18.362 + }
18.363 + SDL_Win->unlockScreen();
18.364 + }
18.365 + /* Is the system palette settable? */
18.366 + int QT_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors)
18.367 + {
18.368 + return -1;
18.369 + }
18.370 +
18.371 + void QT_VideoQuit(_THIS)
18.372 + {
18.373 + qApp->setMainWidget(0);
18.374 + delete SDL_Win;
18.375 + SDL_QuitQPEApp();
18.376 + _this->screen->pixels = NULL;
18.377 + }
18.378 +
18.379 +}; /* Extern C */
19.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
19.2 +++ b/src/video/qtopia/SDL_syswm.cc Sun May 19 20:06:01 2002 +0000
19.3 @@ -0,0 +1,39 @@
19.4 +/*
19.5 + SDL - Simple DirectMedia Layer
19.6 + Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002 Sam Lantinga
19.7 +
19.8 + This library is free software; you can redistribute it and/or
19.9 + modify it under the terms of the GNU Library General Public
19.10 + License as published by the Free Software Foundation; either
19.11 + version 2 of the License, or (at your option) any later version.
19.12 +
19.13 + This library is distributed in the hope that it will be useful,
19.14 + but WITHOUT ANY WARRANTY; without even the implied warranty of
19.15 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19.16 + Library General Public License for more details.
19.17 +
19.18 + You should have received a copy of the GNU Library General Public
19.19 + License along with this library; if not, write to the Free
19.20 + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19.21 +
19.22 + Sam Lantinga
19.23 + slouken@libsdl.org
19.24 +*/
19.25 +
19.26 +#ifdef SAVE_RCSID
19.27 +static char rcsid =
19.28 + "@(#) $Id$";
19.29 +#endif
19.30 +
19.31 +#include "SDL_QWin.h"
19.32 +
19.33 +extern "C" {
19.34 +
19.35 +#include "SDL_syswm_c.h"
19.36 +
19.37 +void QT_SetWMCaption(_THIS, const char *title, const char *icon)
19.38 +{
19.39 + SDL_Win->setCaption(title);
19.40 +}
19.41 +
19.42 +}; /* Extern C */
20.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
20.2 +++ b/src/video/qtopia/SDL_syswm_c.h Sun May 19 20:06:01 2002 +0000
20.3 @@ -0,0 +1,32 @@
20.4 +/*
20.5 + SDL - Simple DirectMedia Layer
20.6 + Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002 Sam Lantinga
20.7 +
20.8 + This library is free software; you can redistribute it and/or
20.9 + modify it under the terms of the GNU Library General Public
20.10 + License as published by the Free Software Foundation; either
20.11 + version 2 of the License, or (at your option) any later version.
20.12 +
20.13 + This library is distributed in the hope that it will be useful,
20.14 + but WITHOUT ANY WARRANTY; without even the implied warranty of
20.15 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20.16 + Library General Public License for more details.
20.17 +
20.18 + You should have received a copy of the GNU Library General Public
20.19 + License along with this library; if not, write to the Free
20.20 + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20.21 +
20.22 + Sam Lantinga
20.23 + slouken@libsdl.org
20.24 +*/
20.25 +
20.26 +#ifdef SAVE_RCSID
20.27 +static char rcsid =
20.28 + "@(#) $Id$";
20.29 +#endif
20.30 +
20.31 +#include "SDL_lowvideo.h"
20.32 +
20.33 +/* Functions to be exported */
20.34 +extern void QT_SetWMCaption(_THIS, const char *title, const char *icon);
20.35 +