Removed outdated OS/2 support
authorSam Lantinga <slouken@libsdl.org>
Sat, 19 Sep 2009 06:43:45 +0000
changeset 3269a67a961e2171
parent 3268 82ce350be859
child 3270 fb9b6b2924ba
Removed outdated OS/2 support
README
README.OS2
Watcom-OS2.zip
docs.html
include/SDL.h
include/SDL_config.h.default
include/SDL_config.h.in
include/SDL_config_os2.h
include/SDL_thread.h
include/begin_code.h
src/SDL.c
src/audio/dart/SDL_dart.c
src/audio/dart/SDL_dart.h
src/events/SDL_events.c
src/events/SDL_sysevents.h
src/joystick/os2/SDL_sysjoystick.c
src/joystick/os2/joyos2.h
src/loadso/os2/SDL_sysloadso.c
src/power/SDL_power.c
src/power/os2/SDL_syspower.c
src/thread/SDL_thread_c.h
src/thread/os2/SDL_syscond.c
src/thread/os2/SDL_syscond_c.h
src/thread/os2/SDL_sysmutex.c
src/thread/os2/SDL_syssem.c
src/thread/os2/SDL_systhread.c
src/thread/os2/SDL_systhread_c.h
src/timer/os2/SDL_systimer.c
src/video/SDL_sysvideo.h
src/video/SDL_video.c
src/video/os2fslib/SDL_os2fslib.c
src/video/os2fslib/SDL_os2fslib.h
src/video/os2fslib/SDL_vkeys.h
     1.1 --- a/README	Sat Sep 19 06:24:07 2009 +0000
     1.2 +++ b/README	Sat Sep 19 06:43:45 2009 +0000
     1.3 @@ -15,7 +15,7 @@
     1.4  The current version supports Linux, Windows, Windows CE, BeOS, MacOS,
     1.5  Mac OS X, FreeBSD, NetBSD, OpenBSD, BSD/OS, Solaris, IRIX, and QNX.
     1.6  The code contains support for Dreamcast, Atari, AIX, OSF/Tru64,
     1.7 -RISC OS, SymbianOS, and OS/2, but these are not officially supported.
     1.8 +RISC OS, SymbianOS, but these are not officially supported.
     1.9  
    1.10  SDL is written in C, but works with C++ natively, and has bindings to
    1.11  several other languages, including Ada, C#, Eiffel, Erlang, Euphoria,
     2.1 --- a/README.OS2	Sat Sep 19 06:24:07 2009 +0000
     2.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.3 @@ -1,278 +0,0 @@
     2.4 -
     2.5 -===========
     2.6 -SDL on OS/2
     2.7 -===========
     2.8 -
     2.9 -Last updated on May. 1, 2006.
    2.10 -
    2.11 -
    2.12 -1. How to compile?
    2.13 -------------------
    2.14 -
    2.15 -To compile this, you'll need the followings installed:
    2.16 -- The OS/2 Developer's Toolkit
    2.17 -- The OpenWatcom compiler 
    2.18 -  (http://www.openwatcom.org)
    2.19 -- The FSLib library
    2.20 -  (ftp://ftp.netlabs.org/pub/SDL)
    2.21 -
    2.22 -First of all, you have to unzip the Watcom-OS2.zip file. This will result in a 
    2.23 -file called "makefile" and a file called "setvars.cmd" in this folder (and some
    2.24 -more files...).
    2.25 -
    2.26 -Please edit the second, fourth and fifth lines of setvars.cmd file
    2.27 -to set the folders where the toolkit, the OW compiler and the FSLib are. 
    2.28 -You won't need NASM yet (The Netwide Assembler), you can leave that line.
    2.29 -Run setvars.cmd, and you should get a shell in which you can
    2.30 -compile SDL.
    2.31 -
    2.32 -Check the "makefile" file. There is a line in there which determines if the 
    2.33 -resulting SDL.DLL will be a 'debug' or a 'release' build. The 'debug' version 
    2.34 -is full of printf()'s, so if something goes wrong, its output can help a lot
    2.35 -for debugging.
    2.36 -
    2.37 -Then run "wmake".
    2.38 -This should create the SDL.DLL and the corresponding SDL.LIB file here.
    2.39 -
    2.40 -To test applications, it's a good idea to use the 'debug' build of SDL, and
    2.41 -redirect the standard output and standard error output to files, to see what
    2.42 -happens internally in SDL.
    2.43 -(like: testsprite >stdout.txt 2>stderr.txt)
    2.44 -
    2.45 -To rebuild SDL, use the following commands in this folder:
    2.46 -wmake clean
    2.47 -wmake
    2.48 -
    2.49 -
    2.50 -
    2.51 -2. How to compile the testapps?
    2.52 --------------------------------
    2.53 -
    2.54 -Once you have SDL.DLL compiled, navigate into the 'test' folder, copy in there
    2.55 -the newly built SDL.DLL, and copy in there FSLib.DLL.
    2.56 -
    2.57 -Then run "wmake" in there to compile some of the testapps.
    2.58 -
    2.59 -
    2.60 -
    2.61 -3. What is missing?
    2.62 --------------------
    2.63 -
    2.64 -The following things are missing from this SDL implementation:
    2.65 -- MMX, SSE and 3DNOW! optimized video blitters?
    2.66 -- HW Video surfaces
    2.67 -- OpenGL support
    2.68 -
    2.69 -
    2.70 -
    2.71 -4. Special Keys / Full-Screen support
    2.72 --------------------------------------
    2.73 -
    2.74 -There are two special hot-keys implemented:
    2.75 -- Alt+Home switches between fullscreen and windowed mode
    2.76 -- Alt+End simulates closing the window (can be used as a Panic key)
    2.77 -Only the LEFT Alt key will work.
    2.78 -
    2.79 -
    2.80 -
    2.81 -5. Joysticks on SDL/2
    2.82 ----------------------
    2.83 -
    2.84 -The Joystick detection only works for standard joysticks (2 buttons, 2 axes
    2.85 -and the like). Therefore, if you use a non-standard joystick, you should
    2.86 -specify its features in the SDL_OS2_JOYSTICK environment variable in a batch
    2.87 -file or CONFIG.SYS, so SDL applications can provide full capability to your
    2.88 -device. The syntax is:
    2.89 -
    2.90 -SET SDL_OS2_JOYSTICK=[JOYSTICK_NAME] [AXES] [BUTTONS] [HATS] [BALLS]
    2.91 -
    2.92 -So, it you have a Gravis GamePad with 4 axes, 2 buttons, 2 hats and 0 balls,
    2.93 -the line should be:
    2.94 -
    2.95 -SET SDL_OS2_JOYSTICK=Gravis_GamePad 4 2 2 0
    2.96 -
    2.97 -If you want to add spaces in your joystick name, just surround it with
    2.98 -quotes or double-quotes:
    2.99 -
   2.100 -SET SDL_OS2_JOYSTICK='Gravis GamePad' 4 2 2 0
   2.101 -
   2.102 -or
   2.103 -
   2.104 -SET SDL_OS2_JOYSTICK="Gravis GamePad" 4 2 2 0
   2.105 -
   2.106 -   Notive However that Balls and Hats are not supported under OS/2, and the
   2.107 -value will be ignored... but it is wise to define these correctly because 
   2.108 -in the future those can be supported.
   2.109 -   Also the number of buttons is limited to 2 when using two joysticks,
   2.110 -4 when using one joystick with 4 axes, 6 when using a joystick with 3 axes
   2.111 -and 8 when using a joystick with 2 axes. Notice however these are limitations 
   2.112 -of the Joystick Port hardware, not OS/2.
   2.113 -
   2.114 -
   2.115 -
   2.116 -6. Proportional windows
   2.117 ------------------------
   2.118 -
   2.119 -For some SDL applications it can be handy to have proportional windows, so
   2.120 -the windows will keep their aspect ratio when resized.
   2.121 -This can be achieved in two ways:
   2.122 -
   2.123 -- Before starting the given SDL application, set the
   2.124 -  SDL_USE_PROPORTIONAL_WINDOW environment variable to something, e.g.:
   2.125 -
   2.126 -  SET SDL_USE_PROPORTIONAL_WINDOW=1
   2.127 -  dosbox.exe
   2.128 -
   2.129 -- If you have a HOME environment variable set, then SDL will look for a file
   2.130 -  in there called ".sdl.proportionals". If that file contains the name of the
   2.131 -  currently running SDL executable, then that process will have proportional
   2.132 -  windows automatically.
   2.133 -
   2.134 -  Please note that this file is created automatically with default values
   2.135 -  at the first run.
   2.136 -
   2.137 -
   2.138 -
   2.139 -7. Audio in SDL applications
   2.140 -----------------------------
   2.141 -
   2.142 -Audio effects are one of the most important features in games. Creating audio
   2.143 -effects in sync with the game and without hickups and pauses in the audio are
   2.144 -very important things.
   2.145 -
   2.146 -However there are multithreaded SDL applications that have tight loops as their
   2.147 -main logic loop. This kills performance in OS/2, and takes too much CPU from
   2.148 -other threads in the same process, for example from the thread to create the 
   2.149 -sound effects.
   2.150 -
   2.151 -For this reason, the OS/2 port of SDL can be instructed to run the audio thread
   2.152 -in high priority, which makes sure that there will be enough time for the 
   2.153 -processing of the audio data.
   2.154 -
   2.155 -At default, SDL/2 runs the audio thread at ForegroundServer+0 priority. Well 
   2.156 -written and well behaving SDL applications should work well in this mode.
   2.157 -For other applications, you can tell SDL/2 to run the audio thread at 
   2.158 -TimeCritical priority by setting an env.variable before starting the SDL app:
   2.159 -
   2.160 -    SET SDL_USE_TIMECRITICAL_AUDIO=1
   2.161 -
   2.162 -Please note that this is a bit risky, because if the SDL application runs a
   2.163 -tight infinite loop in this thread, this will make the whole system 
   2.164 -unresponsive, so use it with care, and only for applications that need it!
   2.165 -
   2.166 -
   2.167 -
   2.168 -8. Next steps...
   2.169 -----------------
   2.170 -
   2.171 -Things to do:
   2.172 -- Implement missing stuffs (look for 'TODO' string in source code!)
   2.173 -- Finish video driver (the 'wincommon' can be a good example for missing
   2.174 -  things like application icon and so on...)
   2.175 -- Enable MMX/SSE/SSE2 acceleration functions
   2.176 -
   2.177 -
   2.178 -
   2.179 -9. Contacts
   2.180 ------------
   2.181 -
   2.182 -   You can contact the developers for bugs:
   2.183 -
   2.184 -   Area					Developer		email
   2.185 -   General (Audio/Video/System)		Doodle			doodle@scenergy.dfmk.hu
   2.186 -   CDROM and Joystick			Caetano			daniel@caetano.eng.br
   2.187 -
   2.188 -   Notice however that SDL/2 is 'in development' stage so ... if you want to help,
   2.189 -please, be our guest and contact us!
   2.190 -
   2.191 -
   2.192 -
   2.193 -10. Changelog of the OS/2 port
   2.194 -------------------------------
   2.195 -
   2.196 -Version 1.2 - 2006-05-01  - Doodle
   2.197 - - Modified makefile system to have only one makefile
   2.198 - - Included FSLib headers, DLL and LIB file
   2.199 -
   2.200 -Version 1.2 - 2006-02-26  - Doodle
   2.201 - - Updated the official SDL version with the OS/2 specific changes.
   2.202 - - Added support for real unicode keycode conversion.
   2.203 -
   2.204 -Version 1.2.7 - 2006-01-20  - Doodle
   2.205 - - Added support for selectively using timecritical priority for
   2.206 -   audio threads by SDL_USE_TIMECRITICAL_AUDIO environment variable.
   2.207 -   (e.g.: 
   2.208 -    SET SDL_USE_TIMECRITICAL_AUDIO=1
   2.209 -    dosbox.exe
   2.210 -   )
   2.211 -
   2.212 -Version 1.2.7 - 2005-12-22  - Doodle
   2.213 - - Added support for proportional SDL windows.
   2.214 -   There are two ways to have proportional (aspect-keeping) windows for
   2.215 -   a given SDL application: Either set the SDL_USE_PROPORTIONAL_WINDOW
   2.216 -   environment variable to something before starting the application
   2.217 -   (e.g.: 
   2.218 -    SET SDL_USE_PROPORTIONAL_WINDOW=1
   2.219 -    dosbox.exe
   2.220 -   )
   2.221 -   or, if you have the HOME environment variable set, then SDL.DLL will
   2.222 -   create a file in that directory called .sdl.proportionals, and you can
   2.223 -   put there the name of executable files that will be automatically made
   2.224 -   proportional.
   2.225 -
   2.226 -Version 1.2.7 - 2005-10-14  - Doodle
   2.227 - - Enabled Exception handler code in FSLib to be able to restore original
   2.228 -   desktop video mode in case the application crashes.
   2.229 - - Added the missing FSLib_Uninitialize() call into SDL.
   2.230 -   (The lack of it did not cause problems, but it's cleaner this way.)
   2.231 - - Fixed a mouse problem in Fullscreen mode where any mouse click
   2.232 -   re-centered the mouse.
   2.233 -
   2.234 -Version 1.2.7 - 2005-10-09  - Doodle
   2.235 - - Implemented window icon support
   2.236 -
   2.237 -Version 1.2.7 - 2005-10-03  - Doodle
   2.238 - - Reworked semaphore support again
   2.239 - - Tuned thread priorities
   2.240 -
   2.241 -Version 1.2.7 - 2005-10-02  - Doodle
   2.242 - - Added support for custom mouse pointers
   2.243 - - Fixed WM_CLOSE processing: give a chance to SDL app to ask user...
   2.244 - - Added support for MMX-accelerated audio mixers
   2.245 - - Other small fixes
   2.246 -
   2.247 -Version 1.2.7 - 2005-09-12  - Doodle
   2.248 - - Small fixes for DosBox incorporated into public release
   2.249 - - Fixed semaphore support (SDL_syssem.c)
   2.250 - - Fixed FSLib to have good clipping in scaled window mode,
   2.251 -   and to prevent occasional desktop freezes.
   2.252 -
   2.253 -Version 1.2.7 - 2004-09-08a - Caetano
   2.254 -	- Improved joystick support (general verifications about hardware).
   2.255 -	- Added support up to 8 buttons in 2 axes joysticks and 6 buttons in 3 axes joysticks.
   2.256 -	- Added support to environment variable SDL_OS2_JOYSTICK to specify a joystick.
   2.257 -	- Improved Joystick test to handle every type of joystick and display only relevant information.
   2.258 -	- Merged with Doodle 2004-09-08
   2.259 -	- Little tid up in README.OS2
   2.260 -	- Added explanation about SDL_OS2_JOYSTICK environment variable on README.OS2
   2.261 -
   2.262 -Version 1.2.7 - 2004-09-07 - Caetano
   2.263 -	- Merged with changes in headers for GCC compiling.
   2.264 -	- Added Joystick support using basic IBM GAME$ support, allowing it to work with all joystick drivers since OS/2 2.1.
   2.265 -	- Improved joystick detection (hacked!). OS/2 do not allow real joystick detection, so... 
   2.266 -	- Modified makefile in test to compile "testjoystick". Anyway, it's useless, since it seems to cause a lot of trouble in OS/2 (because os video routines, not Joystick support).
   2.267 -	- Created separated Joystick test program to test only joystick functions.
   2.268 -	- Improved joystick auto-centering.
   2.269 -	- Improved the coordinate correction routine to use two scale factors for each axis.
   2.270 -
   2.271 -Version 1.2.7 - 2004-07-05 - Caetano
   2.272 -	- Corrected the time returned by status in CDROM support (it was incorrect)
   2.273 -	- Added the testcdrom.c and corrected the linking directive (it was causing an error)
   2.274 -
   2.275 -Version 1.2.7 - 2004-07-02a - Caetano
   2.276 -	- Corrected a little problem in a comment at SDL-1.2.7\test\torturethread.c, line 18 (missing */, nested comment)
   2.277 -	- Added CDROM support to tree (SDL-1.2.7\src\cdrom\os2\SDL_syscdrom.c)
   2.278 -	- Modified makefile (SDL-1.2.7\src\makefiles.wat and SDL-1.2.7\watcom.mif) to build with CDROM support
   2.279 -	- Added the "extra" SDL_types.h forgotten in 2004-07-02 version.
   2.280 -
   2.281 -<End-Of-File>
     3.1 Binary file Watcom-OS2.zip has changed
     4.1 --- a/docs.html	Sat Sep 19 06:24:07 2009 +0000
     4.2 +++ b/docs.html	Sat Sep 19 06:43:45 2009 +0000
     4.3 @@ -163,13 +163,6 @@
     4.4  	Icons set with SDL_WM_SetIcon() now have the proper colors on Intel Macs.
     4.5  </BLOCKQUOTE>
     4.6  
     4.7 -<H3> OS/2 Notes </H3>
     4.8 -
     4.9 -<BLOCKQUOTE>
    4.10 -<P>
    4.11 -	Projects for building SDL on OS/2 with OpenWatcom have been contributed by Doodle.  See the file README.OS2 in the SDL source distribution for details.
    4.12 -</BLOCKQUOTE>
    4.13 -
    4.14  <IMG SRC="docs/images/rainbow.gif" ALT="[separator]" WIDTH="100%">
    4.15  
    4.16  </BODY>
     5.1 --- a/include/SDL.h	Sat Sep 19 06:24:07 2009 +0000
     5.2 +++ b/include/SDL.h	Sat Sep 19 06:43:45 2009 +0000
     5.3 @@ -39,7 +39,7 @@
     5.4  The current version supports Linux, Windows, Windows CE, BeOS, MacOS,
     5.5  Mac OS X, FreeBSD, NetBSD, OpenBSD, BSD/OS, Solaris, IRIX, and QNX.
     5.6  The code contains support for Dreamcast, Atari, AIX, OSF/Tru64,
     5.7 -RISC OS, SymbianOS, and OS/2, but these are not officially supported.
     5.8 +RISC OS, SymbianOS, but these are not officially supported.
     5.9  
    5.10  SDL is written in C, but works with C++ natively, and has bindings to
    5.11  several other languages, including Ada, C#, Eiffel, Erlang, Euphoria,
     6.1 --- a/include/SDL_config.h.default	Sat Sep 19 06:24:07 2009 +0000
     6.2 +++ b/include/SDL_config.h.default	Sat Sep 19 06:43:45 2009 +0000
     6.3 @@ -36,8 +36,6 @@
     6.4  #include "SDL_config_macosx.h"
     6.5  #elif defined(__WIN32__)
     6.6  #include "SDL_config_win32.h"
     6.7 -#elif defined(__OS2__)
     6.8 -#include "SDL_config_os2.h"
     6.9  #else
    6.10  #include "SDL_config_minimal.h"
    6.11  #endif /* platform config */
     7.1 --- a/include/SDL_config.h.in	Sat Sep 19 06:24:07 2009 +0000
     7.2 +++ b/include/SDL_config.h.in	Sat Sep 19 06:43:45 2009 +0000
     7.3 @@ -214,7 +214,6 @@
     7.4  #undef SDL_JOYSTICK_LINUX
     7.5  #undef SDL_JOYSTICK_MINT
     7.6  #undef SDL_JOYSTICK_NDS
     7.7 -#undef SDL_JOYSTICK_OS2
     7.8  #undef SDL_JOYSTICK_RISCOS
     7.9  #undef SDL_JOYSTICK_WINMM
    7.10  #undef SDL_JOYSTICK_USBHID
    7.11 @@ -230,14 +229,12 @@
    7.12  #undef SDL_LOADSO_DLOPEN
    7.13  #undef SDL_LOADSO_DUMMY
    7.14  #undef SDL_LOADSO_LDG
    7.15 -#undef SDL_LOADSO_OS2
    7.16  #undef SDL_LOADSO_WIN32
    7.17  
    7.18  /* Enable various threading systems */
    7.19  #undef SDL_THREAD_BEOS
    7.20  #undef SDL_THREAD_DC
    7.21  #undef SDL_THREAD_NDS
    7.22 -#undef SDL_THREAD_OS2
    7.23  #undef SDL_THREAD_PTH
    7.24  #undef SDL_THREAD_PTHREAD
    7.25  #undef SDL_THREAD_PTHREAD_RECURSIVE_MUTEX
    7.26 @@ -251,7 +248,6 @@
    7.27  #undef SDL_TIMER_DUMMY
    7.28  #undef SDL_TIMER_MINT
    7.29  #undef SDL_TIMER_NDS
    7.30 -#undef SDL_TIMER_OS2
    7.31  #undef SDL_TIMER_RISCOS
    7.32  #undef SDL_TIMER_UNIX
    7.33  #undef SDL_TIMER_WIN32
    7.34 @@ -268,7 +264,6 @@
    7.35  #undef SDL_VIDEO_DRIVER_GEM
    7.36  #undef SDL_VIDEO_DRIVER_NANOX
    7.37  #undef SDL_VIDEO_DRIVER_NDS
    7.38 -#undef SDL_VIDEO_DRIVER_OS2FS
    7.39  #undef SDL_VIDEO_DRIVER_PHOTON
    7.40  #undef SDL_VIDEO_DRIVER_QNXGF
    7.41  #undef SDL_VIDEO_DRIVER_PS2GS
    7.42 @@ -315,7 +310,6 @@
    7.43  #undef SDL_POWER_LINUX
    7.44  #undef SDL_POWER_WINDOWS
    7.45  #undef SDL_POWER_MACOSX
    7.46 -#undef SDL_POWER_OS2
    7.47  #undef SDL_POWER_BEOS
    7.48  #undef SDL_POWER_NINTENDODS
    7.49  #undef SDL_POWER_HARDWIRED
     8.1 --- a/include/SDL_config_os2.h	Sat Sep 19 06:24:07 2009 +0000
     8.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     8.3 @@ -1,145 +0,0 @@
     8.4 -/*
     8.5 -    SDL - Simple DirectMedia Layer
     8.6 -    Copyright (C) 1997-2009 Sam Lantinga
     8.7 -
     8.8 -    This library is free software; you can redistribute it and/or
     8.9 -    modify it under the terms of the GNU Lesser General Public
    8.10 -    License as published by the Free Software Foundation; either
    8.11 -    version 2.1 of the License, or (at your option) any later version.
    8.12 -
    8.13 -    This library is distributed in the hope that it will be useful,
    8.14 -    but WITHOUT ANY WARRANTY; without even the implied warranty of
    8.15 -    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    8.16 -    Lesser General Public License for more details.
    8.17 -
    8.18 -    You should have received a copy of the GNU Lesser General Public
    8.19 -    License along with this library; if not, write to the Free Software
    8.20 -    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
    8.21 -
    8.22 -    Sam Lantinga
    8.23 -    slouken@libsdl.org
    8.24 -*/
    8.25 -
    8.26 -#ifndef _SDL_config_os2_h
    8.27 -#define _SDL_config_os2_h
    8.28 -
    8.29 -#include "SDL_platform.h"
    8.30 -
    8.31 -/* This is a set of defines to configure the SDL features */
    8.32 -
    8.33 -#if !defined(_STDINT_H_) && (!defined(HAVE_STDINT_H) || !_HAVE_STDINT_H)
    8.34 -typedef signed char int8_t;
    8.35 -typedef unsigned char uint8_t;
    8.36 -typedef signed short int16_t;
    8.37 -typedef unsigned short uint16_t;
    8.38 -typedef signed int int32_t;
    8.39 -typedef unsigned int uint32_t;
    8.40 -typedef unsigned int size_t;
    8.41 -typedef unsigned long uintptr_t;
    8.42 -typedef signed long long int64_t;
    8.43 -typedef unsigned long long uint64_t;
    8.44 -#endif /* !_STDINT_H_ && !HAVE_STDINT_H */
    8.45 -
    8.46 -#define SIZEOF_VOIDP 4
    8.47 -#define SDL_HAS_64BIT_TYPE	1
    8.48 -
    8.49 -/* Use Watcom's LIBC */
    8.50 -#define HAVE_LIBC 1
    8.51 -
    8.52 -/* Useful headers */
    8.53 -#define HAVE_SYS_TYPES_H 1
    8.54 -#define HAVE_STDIO_H 1
    8.55 -#define STDC_HEADERS 1
    8.56 -#define HAVE_STDLIB_H 1
    8.57 -#define HAVE_STDARG_H 1
    8.58 -#define HAVE_MALLOC_H 1
    8.59 -#define HAVE_MEMORY_H 1
    8.60 -#define HAVE_STRING_H 1
    8.61 -#define HAVE_STRINGS_H 1
    8.62 -#define HAVE_INTTYPES_H 1
    8.63 -#define HAVE_STDINT_H 1
    8.64 -#define HAVE_CTYPE_H 1
    8.65 -#define HAVE_MATH_H 1
    8.66 -#define HAVE_SIGNAL_H 1
    8.67 -
    8.68 -/* C library functions */
    8.69 -#define HAVE_MALLOC 1
    8.70 -#define HAVE_CALLOC 1
    8.71 -#define HAVE_REALLOC 1
    8.72 -#define HAVE_FREE 1
    8.73 -#define HAVE_ALLOCA 1
    8.74 -#define HAVE_GETENV 1
    8.75 -#define HAVE_PUTENV 1
    8.76 -#define HAVE_UNSETENV 1
    8.77 -#define HAVE_QSORT 1
    8.78 -#define HAVE_ABS 1
    8.79 -#define HAVE_BCOPY 1
    8.80 -#define HAVE_MEMSET 1
    8.81 -#define HAVE_MEMCPY 1
    8.82 -#define HAVE_MEMMOVE 1
    8.83 -#define HAVE_MEMCMP 1
    8.84 -#define HAVE_STRLEN 1
    8.85 -#define HAVE_STRLCPY 1
    8.86 -#define HAVE_STRLCAT 1
    8.87 -#define HAVE_STRDUP 1
    8.88 -#define HAVE__STRREV 1
    8.89 -#define HAVE__STRUPR 1
    8.90 -#define HAVE__STRLWR 1
    8.91 -#define HAVE_INDEX 1
    8.92 -#define HAVE_RINDEX 1
    8.93 -#define HAVE_STRCHR 1
    8.94 -#define HAVE_STRRCHR 1
    8.95 -#define HAVE_STRSTR 1
    8.96 -#define HAVE_ITOA 1
    8.97 -#define HAVE__LTOA 1
    8.98 -#define HAVE__UITOA 1
    8.99 -#define HAVE__ULTOA 1
   8.100 -#define HAVE_STRTOL 1
   8.101 -#define HAVE__I64TOA 1
   8.102 -#define HAVE__UI64TOA 1
   8.103 -#define HAVE_STRTOLL 1
   8.104 -#define HAVE_STRTOD 1
   8.105 -#define HAVE_ATOI 1
   8.106 -#define HAVE_ATOF 1
   8.107 -#define HAVE_STRCMP 1
   8.108 -#define HAVE_STRNCMP 1
   8.109 -#define HAVE_STRICMP 1
   8.110 -#define HAVE_STRCASECMP 1
   8.111 -#define HAVE_SSCANF 1
   8.112 -#define HAVE_SNPRINTF 1
   8.113 -#define HAVE_VSNPRINTF 1
   8.114 -#define HAVE_SETJMP 1
   8.115 -#define HAVE_CLOCK_GETTIME 1
   8.116 -
   8.117 -/* Enable various audio drivers */
   8.118 -#define SDL_AUDIO_DRIVER_DART	1
   8.119 -#define SDL_AUDIO_DRIVER_DISK	1
   8.120 -#define SDL_AUDIO_DRIVER_DUMMY	1
   8.121 -
   8.122 -/* Enable various input drivers */
   8.123 -#define SDL_JOYSTICK_OS2	1
   8.124 -#define SDL_HAPTIC_DUMMY	1
   8.125 -
   8.126 -/* Enable various shared object loading systems */
   8.127 -#define SDL_LOADSO_OS2	1
   8.128 -
   8.129 -/* Enable various threading systems */
   8.130 -#define SDL_THREAD_OS2	1
   8.131 -
   8.132 -/* Enable various timer systems */
   8.133 -#define SDL_TIMER_OS2	1
   8.134 -
   8.135 -/* Enable various video drivers */
   8.136 -#define SDL_VIDEO_DRIVER_DUMMY	1
   8.137 -#define SDL_VIDEO_DRIVER_OS2FS	1
   8.138 -
   8.139 -/* Enable OpenGL support */
   8.140 -/* Nothing here yet for OS/2... :( */
   8.141 -
   8.142 -/* Enable system power support */
   8.143 -#define SDL_POWER_OS2 1
   8.144 -
   8.145 -/* Enable assembly routines where available */
   8.146 -#define SDL_ASSEMBLY_ROUTINES	1
   8.147 -
   8.148 -#endif /* _SDL_config_os2_h */
     9.1 --- a/include/SDL_thread.h	Sat Sep 19 06:24:07 2009 +0000
     9.2 +++ b/include/SDL_thread.h	Sat Sep 19 06:43:45 2009 +0000
     9.3 @@ -48,9 +48,9 @@
     9.4  typedef struct SDL_Thread SDL_Thread;
     9.5  
     9.6  /* Create a thread */
     9.7 -#if (defined(__WIN32__) && !defined(HAVE_LIBC)) || defined(__OS2__)
     9.8 +#if defined(__WIN32__) && !defined(HAVE_LIBC)
     9.9  /*
    9.10 -   We compile SDL into a DLL on OS/2. This means, that it's the DLL which
    9.11 +   We compile SDL into a DLL. This means, that it's the DLL which
    9.12     creates a new thread for the calling process with the SDL_CreateThread()
    9.13     API. There is a problem with this, that only the RTL of the SDL.DLL will
    9.14     be initialized for those threads, and not the RTL of the calling application!
    9.15 @@ -67,11 +67,7 @@
    9.16  #include <process.h>            /* This has _beginthread() and _endthread() defined! */
    9.17  #endif
    9.18  
    9.19 -#ifdef __OS2__
    9.20 -typedef int (*pfnSDL_CurrentBeginThread) (void (*func) (void *), void *,
    9.21 -                                          unsigned, void *arg);
    9.22 -typedef void (*pfnSDL_CurrentEndThread) (void);
    9.23 -#elif __GNUC__
    9.24 +#ifdef __GNUC__
    9.25  typedef unsigned long (__cdecl * pfnSDL_CurrentBeginThread) (void *, unsigned,
    9.26                                                               unsigned
    9.27                                                               (__stdcall *
    9.28 @@ -96,9 +92,7 @@
    9.29                   pfnSDL_CurrentBeginThread pfnBeginThread,
    9.30                   pfnSDL_CurrentEndThread pfnEndThread);
    9.31  
    9.32 -#ifdef __OS2__
    9.33 -#define SDL_CreateThread(fn, data) SDL_CreateThread(fn, data, _beginthread, _endthread)
    9.34 -#elif defined(_WIN32_WCE)
    9.35 +#if defined(_WIN32_WCE)
    9.36  #define SDL_CreateThread(fn, data) SDL_CreateThread(fn, data, NULL, NULL)
    9.37  #else
    9.38  #define SDL_CreateThread(fn, data) SDL_CreateThread(fn, data, _beginthreadex, _endthreadex)
    10.1 --- a/include/begin_code.h	Sat Sep 19 06:24:07 2009 +0000
    10.2 +++ b/include/begin_code.h	Sat Sep 19 06:43:45 2009 +0000
    10.3 @@ -49,16 +49,6 @@
    10.4  #  else
    10.5  #   define DECLSPEC	__declspec(dllexport)
    10.6  #  endif
    10.7 -# elif defined(__OS2__)
    10.8 -#  ifdef __WATCOMC__
    10.9 -#   ifdef BUILD_SDL
   10.10 -#    define DECLSPEC	__declspec(dllexport)
   10.11 -#   else
   10.12 -#    define DECLSPEC
   10.13 -#   endif
   10.14 -#  else
   10.15 -#   define DECLSPEC
   10.16 -#  endif
   10.17  # else
   10.18  #  if defined(__GNUC__) && __GNUC__ >= 4
   10.19  #   define DECLSPEC	__attribute__ ((visibility("default")))
   10.20 @@ -73,14 +63,8 @@
   10.21  #if defined(__WIN32__) && !defined(__GNUC__)
   10.22  #define SDLCALL __cdecl
   10.23  #else
   10.24 -#ifdef __OS2__
   10.25 -/* But on OS/2, we use the _System calling convention */
   10.26 -/* to be compatible with every compiler */
   10.27 -#define SDLCALL _System
   10.28 -#else
   10.29  #define SDLCALL
   10.30  #endif
   10.31 -#endif
   10.32  #endif /* SDLCALL */
   10.33  
   10.34  /* Removed DECLSPEC on Symbian OS because SDL cannot be a DLL in EPOC */
    11.1 --- a/src/SDL.c	Sat Sep 19 06:24:07 2009 +0000
    11.2 +++ b/src/SDL.c	Sat Sep 19 06:43:45 2009 +0000
    11.3 @@ -277,76 +277,7 @@
    11.4      return SDL_REVISION;
    11.5  }
    11.6  
    11.7 -#if defined(__OS2__)
    11.8 -/* Building for OS/2 */
    11.9 -#ifdef __WATCOMC__
   11.10 -
   11.11 -#define INCL_DOSERRORS
   11.12 -#define INCL_DOSEXCEPTIONS
   11.13 -#include <os2.h>
   11.14 -
   11.15 -/* Exception handler to prevent the Audio thread hanging, making a zombie process! */
   11.16 -ULONG _System
   11.17 -SDL_Main_ExceptionHandler(PEXCEPTIONREPORTRECORD pERepRec,
   11.18 -                          PEXCEPTIONREGISTRATIONRECORD pERegRec,
   11.19 -                          PCONTEXTRECORD pCtxRec, PVOID p)
   11.20 -{
   11.21 -    if (pERepRec->fHandlerFlags & EH_EXIT_UNWIND)
   11.22 -        return XCPT_CONTINUE_SEARCH;
   11.23 -    if (pERepRec->fHandlerFlags & EH_UNWINDING)
   11.24 -        return XCPT_CONTINUE_SEARCH;
   11.25 -    if (pERepRec->fHandlerFlags & EH_NESTED_CALL)
   11.26 -        return XCPT_CONTINUE_SEARCH;
   11.27 -
   11.28 -    /* Do cleanup at every fatal exception! */
   11.29 -    if (((pERepRec->ExceptionNum & XCPT_SEVERITY_CODE) ==
   11.30 -         XCPT_FATAL_EXCEPTION) && (pERepRec->ExceptionNum != XCPT_BREAKPOINT)
   11.31 -        && (pERepRec->ExceptionNum != XCPT_SINGLE_STEP)) {
   11.32 -        if (SDL_initialized & SDL_INIT_AUDIO) {
   11.33 -            /* This removes the zombie audio thread in case of emergency. */
   11.34 -#ifdef DEBUG_BUILD
   11.35 -            printf
   11.36 -                ("[SDL_Main_ExceptionHandler] : Calling SDL_CloseAudio()!\n");
   11.37 -#endif
   11.38 -            SDL_CloseAudio();
   11.39 -        }
   11.40 -    }
   11.41 -    return (XCPT_CONTINUE_SEARCH);
   11.42 -}
   11.43 -
   11.44 -
   11.45 -EXCEPTIONREGISTRATIONRECORD SDL_Main_xcpthand =
   11.46 -    { 0, SDL_Main_ExceptionHandler };
   11.47 -
   11.48 -/* The main DLL entry for DLL Initialization and Uninitialization: */
   11.49 -unsigned _System
   11.50 -LibMain(unsigned hmod, unsigned termination)
   11.51 -{
   11.52 -    if (termination) {
   11.53 -#ifdef DEBUG_BUILD
   11.54 -/*    printf("[SDL DLL Unintialization] : Removing exception handler\n"); */
   11.55 -#endif
   11.56 -        DosUnsetExceptionHandler(&SDL_Main_xcpthand);
   11.57 -        return 1;
   11.58 -    } else {
   11.59 -#ifdef DEBUG_BUILD
   11.60 -        /* Make stdout and stderr unbuffered! */
   11.61 -        setbuf(stdout, NULL);
   11.62 -        setbuf(stderr, NULL);
   11.63 -#endif
   11.64 -        /* Fire up exception handler */
   11.65 -#ifdef DEBUG_BUILD
   11.66 -/*    printf("[SDL DLL Initialization] : Setting exception handler\n"); */
   11.67 -#endif
   11.68 -        /* Set exception handler */
   11.69 -        DosSetExceptionHandler(&SDL_Main_xcpthand);
   11.70 -
   11.71 -        return 1;
   11.72 -    }
   11.73 -}
   11.74 -#endif /* __WATCOMC__ */
   11.75 -
   11.76 -#elif defined(__WIN32__)
   11.77 +#if defined(__WIN32__)
   11.78  
   11.79  #if !defined(HAVE_LIBC) || (defined(__WATCOMC__) && defined(BUILD_DLL))
   11.80  /* Need to include DllMain() on Watcom C for some reason.. */
   11.81 @@ -368,6 +299,6 @@
   11.82  }
   11.83  #endif /* building DLL with Watcom C */
   11.84  
   11.85 -#endif /* OS/2 elif __WIN32__ */
   11.86 +#endif /* __WIN32__ */
   11.87  
   11.88  /* vi: set ts=4 sw=4 expandtab: */
    12.1 --- a/src/audio/dart/SDL_dart.c	Sat Sep 19 06:24:07 2009 +0000
    12.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    12.3 @@ -1,448 +0,0 @@
    12.4 -/*
    12.5 -    SDL - Simple DirectMedia Layer
    12.6 -    Copyright (C) 1997-2009 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 Lesser General Public
   12.10 -    License as published by the Free Software Foundation; either
   12.11 -    version 2.1 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 -    Lesser General Public License for more details.
   12.17 -
   12.18 -    You should have received a copy of the GNU Lesser General Public
   12.19 -    License along with this library; if not, write to the Free Software
   12.20 -    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
   12.21 -
   12.22 -    Sam Lantinga
   12.23 -    slouken@libsdl.org
   12.24 -*/
   12.25 -#include "SDL_config.h"
   12.26 -
   12.27 -/* Allow access to a raw mixing buffer */
   12.28 -
   12.29 -#include "SDL_timer.h"
   12.30 -#include "SDL_audio.h"
   12.31 -#include "../SDL_audio_c.h"
   12.32 -#include "SDL_dart.h"
   12.33 -
   12.34 -// Buffer states:
   12.35 -#define BUFFER_EMPTY       0
   12.36 -#define BUFFER_USED        1
   12.37 -
   12.38 -typedef struct _tMixBufferDesc
   12.39 -{
   12.40 -    int iBufferUsage;           // BUFFER_EMPTY or BUFFER_USED
   12.41 -    SDL_AudioDevice *pSDLAudioDevice;
   12.42 -} tMixBufferDesc, *pMixBufferDesc;
   12.43 -
   12.44 -
   12.45 -//---------------------------------------------------------------------
   12.46 -// DARTEventFunc
   12.47 -//
   12.48 -// This function is called by DART, when an event occurs, like end of
   12.49 -// playback of a buffer, etc...
   12.50 -//---------------------------------------------------------------------
   12.51 -static LONG APIENTRY
   12.52 -DARTEventFunc(ULONG ulStatus, PMCI_MIX_BUFFER pBuffer, ULONG ulFlags)
   12.53 -{
   12.54 -    if (ulFlags && MIX_WRITE_COMPLETE) {        // Playback of buffer completed!
   12.55 -
   12.56 -        // Get pointer to buffer description
   12.57 -        pMixBufferDesc pBufDesc;
   12.58 -
   12.59 -        if (pBuffer) {
   12.60 -            pBufDesc = (pMixBufferDesc) (*pBuffer).ulUserParm;
   12.61 -
   12.62 -            if (pBufDesc) {
   12.63 -                SDL_AudioDevice *pSDLAudioDevice = pBufDesc->pSDLAudioDevice;
   12.64 -                // Set the buffer to be empty
   12.65 -                pBufDesc->iBufferUsage = BUFFER_EMPTY;
   12.66 -                // And notify DART feeder thread that it will have to work a bit.
   12.67 -                if (pSDLAudioDevice)
   12.68 -                    DosPostEventSem(pSDLAudioDevice->
   12.69 -                                    hidden->hevAudioBufferPlayed);
   12.70 -            }
   12.71 -        }
   12.72 -    }
   12.73 -    return TRUE;
   12.74 -}
   12.75 -
   12.76 -
   12.77 -static int
   12.78 -DART_OpenDevice(_THIS, const char *devname, int iscapture)
   12.79 -{
   12.80 -    SDL_AudioFormat test_format = SDL_FirstAudioFormat(_this->spec.format);
   12.81 -    int valid_datatype = 0;
   12.82 -    MCI_AMP_OPEN_PARMS AmpOpenParms;
   12.83 -    int iDeviceOrd = 0;         // Default device to be used
   12.84 -    int bOpenShared = 1;        // Try opening it shared
   12.85 -    int iBits = 16;             // Default is 16 bits signed
   12.86 -    int iFreq = 44100;          // Default is 44KHz
   12.87 -    int iChannels = 2;          // Default is 2 channels (Stereo)
   12.88 -    int iNumBufs = 2;           // Number of audio buffers: 2
   12.89 -    int iBufSize;
   12.90 -    int iOpenMode;
   12.91 -    int iSilence;
   12.92 -    int rc;
   12.93 -
   12.94 -    /* Initialize all variables that we clean on shutdown */
   12.95 -    _this->hidden = (struct SDL_PrivateAudioData *)
   12.96 -        SDL_malloc((sizeof *_this->hidden));
   12.97 -    if (_this->hidden == NULL) {
   12.98 -        SDL_OutOfMemory();
   12.99 -        return 0;
  12.100 -    }
  12.101 -    SDL_memset(_this->hidden, 0, (sizeof *_this->hidden));
  12.102 -
  12.103 -    // First thing is to try to open a given DART device!
  12.104 -    SDL_memset(&AmpOpenParms, 0, sizeof(MCI_AMP_OPEN_PARMS));
  12.105 -    // pszDeviceType should contain the device type in low word, and device ordinal in high word!
  12.106 -    AmpOpenParms.pszDeviceType =
  12.107 -        (PSZ) (MCI_DEVTYPE_AUDIO_AMPMIX | (iDeviceOrd << 16));
  12.108 -
  12.109 -    iOpenMode = MCI_WAIT | MCI_OPEN_TYPE_ID;
  12.110 -    if (bOpenShared)
  12.111 -        iOpenMode |= MCI_OPEN_SHAREABLE;
  12.112 -
  12.113 -    rc = mciSendCommand(0, MCI_OPEN, iOpenMode, (PVOID) & AmpOpenParms, 0);
  12.114 -    if (rc != MCIERR_SUCCESS) { // No audio available??
  12.115 -        DART_CloseDevice(_this);
  12.116 -        SDL_SetError("DART: Couldn't open audio device.");
  12.117 -        return 0;
  12.118 -    }
  12.119 -    // Save the device ID we got from DART!
  12.120 -    // We will use this in the next calls!
  12.121 -    _this->hidden->iCurrDeviceOrd = iDeviceOrd = AmpOpenParms.usDeviceID;
  12.122 -
  12.123 -    // Determine the audio parameters from the AudioSpec
  12.124 -    if (_this->spec.channels > 4)
  12.125 -        _this->spec.channels = 4;
  12.126 -
  12.127 -    while ((!valid_datatype) && (test_format)) {
  12.128 -        _this->spec.format = test_format;
  12.129 -        valid_datatype = 1;
  12.130 -        switch (test_format) {
  12.131 -        case AUDIO_U8:
  12.132 -            // Unsigned 8 bit audio data
  12.133 -            iSilence = 0x80;
  12.134 -            _this->hidden->iCurrBits = iBits = 8;
  12.135 -            break;
  12.136 -
  12.137 -        case AUDIO_S16LSB:
  12.138 -            // Signed 16 bit audio data
  12.139 -            iSilence = 0x00;
  12.140 -            _this->hidden->iCurrBits = iBits = 16;
  12.141 -            break;
  12.142 -
  12.143 -            // !!! FIXME: int32?
  12.144 -
  12.145 -        default:
  12.146 -            valid_datatype = 0;
  12.147 -            test_format = SDL_NextAudioFormat();
  12.148 -            break;
  12.149 -        }
  12.150 -    }
  12.151 -
  12.152 -    if (!valid_datatype) {      // shouldn't happen, but just in case...
  12.153 -        // Close DART, and exit with error code!
  12.154 -        DART_CloseDevice(_this);
  12.155 -        SDL_SetError("Unsupported audio format");
  12.156 -        return 0;
  12.157 -    }
  12.158 -
  12.159 -    _this->hidden->iCurrFreq = iFreq = _this->spec.freq;
  12.160 -    _this->hidden->iCurrChannels = iChannels = _this->spec.channels;
  12.161 -    /* Update the fragment size as size in bytes */
  12.162 -    SDL_CalculateAudioSpec(&_this->spec);
  12.163 -    _this->hidden->iCurrBufSize = iBufSize = _this->spec.size;
  12.164 -
  12.165 -    // Now query this device if it supports the given freq/bits/channels!
  12.166 -    SDL_memset(&(_this->hidden->MixSetupParms), 0,
  12.167 -               sizeof(MCI_MIXSETUP_PARMS));
  12.168 -    _this->hidden->MixSetupParms.ulBitsPerSample = iBits;
  12.169 -    _this->hidden->MixSetupParms.ulFormatTag = MCI_WAVE_FORMAT_PCM;
  12.170 -    _this->hidden->MixSetupParms.ulSamplesPerSec = iFreq;
  12.171 -    _this->hidden->MixSetupParms.ulChannels = iChannels;
  12.172 -    _this->hidden->MixSetupParms.ulFormatMode = MCI_PLAY;
  12.173 -    _this->hidden->MixSetupParms.ulDeviceType = MCI_DEVTYPE_WAVEFORM_AUDIO;
  12.174 -    _this->hidden->MixSetupParms.pmixEvent = DARTEventFunc;
  12.175 -    rc = mciSendCommand(iDeviceOrd, MCI_MIXSETUP,
  12.176 -                        MCI_WAIT | MCI_MIXSETUP_QUERYMODE,
  12.177 -                        &(_this->hidden->MixSetupParms), 0);
  12.178 -    if (rc != MCIERR_SUCCESS) { // The device cannot handle this format!
  12.179 -        // Close DART, and exit with error code!
  12.180 -        DART_CloseDevice(_this);
  12.181 -        SDL_SetError("Audio device doesn't support requested audio format");
  12.182 -        return 0;
  12.183 -    }
  12.184 -    // The device can handle this format, so initialize!
  12.185 -    rc = mciSendCommand(iDeviceOrd, MCI_MIXSETUP,
  12.186 -                        MCI_WAIT | MCI_MIXSETUP_INIT,
  12.187 -                        &(_this->hidden->MixSetupParms), 0);
  12.188 -    if (rc != MCIERR_SUCCESS) { // The device could not be opened!
  12.189 -        // Close DART, and exit with error code!
  12.190 -        DART_CloseDevice(_this);
  12.191 -        SDL_SetError("Audio device could not be set up");
  12.192 -        return 0;
  12.193 -    }
  12.194 -    // Ok, the device is initialized.
  12.195 -    // Now we should allocate buffers. For this, we need a place where
  12.196 -    // the buffer descriptors will be:
  12.197 -    _this->hidden->pMixBuffers =
  12.198 -        (MCI_MIX_BUFFER *) SDL_malloc(sizeof(MCI_MIX_BUFFER) * iNumBufs);
  12.199 -    if (!(_this->hidden->pMixBuffers)) {        // Not enough memory!
  12.200 -        // Close DART, and exit with error code!
  12.201 -        DART_CloseDevice(_this);
  12.202 -        SDL_OutOfMemory();
  12.203 -        return 0;
  12.204 -    }
  12.205 -    // Now that we have the place for buffer list, we can ask DART for the
  12.206 -    // buffers!
  12.207 -    _this->hidden->BufferParms.ulNumBuffers = iNumBufs; // Number of buffers
  12.208 -    _this->hidden->BufferParms.ulBufferSize = iBufSize; // each with this size
  12.209 -    _this->hidden->BufferParms.pBufList = _this->hidden->pMixBuffers;   // getting descriptorts into this list
  12.210 -    // Allocate buffers!
  12.211 -    rc = mciSendCommand(iDeviceOrd, MCI_BUFFER,
  12.212 -                        MCI_WAIT | MCI_ALLOCATE_MEMORY,
  12.213 -                        &(_this->hidden->BufferParms), 0);
  12.214 -    if ((rc != MCIERR_SUCCESS)
  12.215 -        || (iNumBufs != _this->hidden->BufferParms.ulNumBuffers)
  12.216 -        || (_this->hidden->BufferParms.ulBufferSize == 0)) {    // Could not allocate memory!
  12.217 -        // Close DART, and exit with error code!
  12.218 -        DART_CloseDevice(_this);
  12.219 -        SDL_SetError("DART could not allocate buffers");
  12.220 -        return 0;
  12.221 -    }
  12.222 -    _this->hidden->iCurrNumBufs = iNumBufs;
  12.223 -
  12.224 -    // Ok, we have all the buffers allocated, let's mark them!
  12.225 -    {
  12.226 -        int i;
  12.227 -        for (i = 0; i < iNumBufs; i++) {
  12.228 -            pMixBufferDesc pBufferDesc =
  12.229 -                (pMixBufferDesc) SDL_malloc(sizeof(tMixBufferDesc));;
  12.230 -            // Check if this buffer was really allocated by DART
  12.231 -            if ((!(_this->hidden->pMixBuffers[i].pBuffer))
  12.232 -                || (!pBufferDesc)) {    // Wrong buffer!
  12.233 -                DART_CloseDevice(_this);
  12.234 -                SDL_SetError("Error at internal buffer check");
  12.235 -                return 0;
  12.236 -            }
  12.237 -            pBufferDesc->iBufferUsage = BUFFER_EMPTY;
  12.238 -            pBufferDesc->pSDLAudioDevice = _this;
  12.239 -
  12.240 -            _this->hidden->pMixBuffers[i].ulBufferLength =
  12.241 -                _this->hidden->BufferParms.ulBufferSize;
  12.242 -            _this->hidden->pMixBuffers[i].ulUserParm = (ULONG) pBufferDesc;     // User parameter: Description of buffer
  12.243 -            _this->hidden->pMixBuffers[i].ulFlags = 0;  // Some stuff should be flagged here for DART, like end of
  12.244 -            // audio data, but as we will continously send
  12.245 -            // audio data, there will be no end.:)
  12.246 -            SDL_memset(_this->hidden->pMixBuffers[i].pBuffer, iSilence,
  12.247 -                       iBufSize);
  12.248 -        }
  12.249 -    }
  12.250 -    _this->hidden->iNextFreeBuffer = 0;
  12.251 -    _this->hidden->iLastPlayedBuf = -1;
  12.252 -    // Create event semaphore
  12.253 -    if (DosCreateEventSem
  12.254 -        (NULL, &(_this->hidden->hevAudioBufferPlayed), 0, FALSE) != NO_ERROR)
  12.255 -    {
  12.256 -        DART_CloseDevice(_this);
  12.257 -        SDL_SetError("Could not create event semaphore");
  12.258 -        return 0;
  12.259 -    }
  12.260 -
  12.261 -    return 1;
  12.262 -}
  12.263 -
  12.264 -static void
  12.265 -DART_ThreadInit(_THIS)
  12.266 -{
  12.267 -    /* Increase the priority of this thread to make sure that
  12.268 -       the audio will be continuous all the time! */
  12.269 -#ifdef USE_DOSSETPRIORITY
  12.270 -    if (SDL_getenv("SDL_USE_TIMECRITICAL_AUDIO")) {
  12.271 -#ifdef DEBUG_BUILD
  12.272 -        printf
  12.273 -            ("[DART_ThreadInit] : Setting priority to TimeCritical+0! (TID%d)\n",
  12.274 -             SDL_ThreadID());
  12.275 -#endif
  12.276 -        DosSetPriority(PRTYS_THREAD, PRTYC_TIMECRITICAL, 0, 0);
  12.277 -    } else {
  12.278 -#ifdef DEBUG_BUILD
  12.279 -        printf
  12.280 -            ("[DART_ThreadInit] : Setting priority to ForegroundServer+0! (TID%d)\n",
  12.281 -             SDL_ThreadID());
  12.282 -#endif
  12.283 -        DosSetPriority(PRTYS_THREAD, PRTYC_FOREGROUNDSERVER, 0, 0);
  12.284 -    }
  12.285 -#endif
  12.286 -}
  12.287 -
  12.288 -/* This function waits until it is possible to write a full sound buffer */
  12.289 -static void
  12.290 -DART_WaitDevice(_THIS)
  12.291 -{
  12.292 -    int i;
  12.293 -    pMixBufferDesc pBufDesc;
  12.294 -    ULONG ulPostCount;
  12.295 -
  12.296 -    DosResetEventSem(_this->hidden->hevAudioBufferPlayed, &ulPostCount);
  12.297 -    // If there is already an empty buffer, then return now!
  12.298 -    for (i = 0; i < _this->hidden->iCurrNumBufs; i++) {
  12.299 -        pBufDesc = (pMixBufferDesc) _this->hidden->pMixBuffers[i].ulUserParm;
  12.300 -        if (pBufDesc->iBufferUsage == BUFFER_EMPTY)
  12.301 -            return;
  12.302 -    }
  12.303 -    // If there is no empty buffer, wait for one to be empty!
  12.304 -    DosWaitEventSem(_this->hidden->hevAudioBufferPlayed, 1000); // Wait max 1 sec!!! Important!
  12.305 -    return;
  12.306 -}
  12.307 -
  12.308 -static void
  12.309 -DART_PlayDevice(_THIS)
  12.310 -{
  12.311 -    int iFreeBuf = _this->hidden->iNextFreeBuffer;
  12.312 -    pMixBufferDesc pBufDesc;
  12.313 -
  12.314 -    pBufDesc =
  12.315 -        (pMixBufferDesc) _this->hidden->pMixBuffers[iFreeBuf].ulUserParm;
  12.316 -    pBufDesc->iBufferUsage = BUFFER_USED;
  12.317 -    // Send it to DART to be queued
  12.318 -    _this->hidden->MixSetupParms.pmixWrite(_this->hidden->
  12.319 -                                           MixSetupParms.ulMixHandle,
  12.320 -                                           &(_this->
  12.321 -                                             hidden->pMixBuffers[iFreeBuf]),
  12.322 -                                           1);
  12.323 -
  12.324 -    _this->hidden->iLastPlayedBuf = iFreeBuf;
  12.325 -    iFreeBuf = (iFreeBuf + 1) % _this->hidden->iCurrNumBufs;
  12.326 -    _this->hidden->iNextFreeBuffer = iFreeBuf;
  12.327 -}
  12.328 -
  12.329 -static Uint8 *
  12.330 -DART_GetDeviceBuf(_THIS)
  12.331 -{
  12.332 -    int iFreeBuf;
  12.333 -    Uint8 *pResult;
  12.334 -    pMixBufferDesc pBufDesc;
  12.335 -
  12.336 -    if (_this) {
  12.337 -        if (_this->hidden) {
  12.338 -            iFreeBuf = _this->hidden->iNextFreeBuffer;
  12.339 -            pBufDesc =
  12.340 -                (pMixBufferDesc) _this->hidden->
  12.341 -                pMixBuffers[iFreeBuf].ulUserParm;
  12.342 -
  12.343 -            if (pBufDesc) {
  12.344 -                if (pBufDesc->iBufferUsage == BUFFER_EMPTY) {
  12.345 -                    pResult = _this->hidden->pMixBuffers[iFreeBuf].pBuffer;
  12.346 -                    return pResult;
  12.347 -                }
  12.348 -            } else
  12.349 -                printf("[DART_GetDeviceBuf] : ERROR! pBufDesc = %p\n",
  12.350 -                       pBufDesc);
  12.351 -        } else
  12.352 -            printf("[DART_GetDeviceBuf] : ERROR! _this->hidden = %p\n",
  12.353 -                   _this->hidden);
  12.354 -    } else
  12.355 -        printf("[DART_GetDeviceBuf] : ERROR! _this = %p\n", _this);
  12.356 -    return NULL;
  12.357 -}
  12.358 -
  12.359 -static void
  12.360 -DART_WaitDone(_THIS)
  12.361 -{
  12.362 -    pMixBufferDesc pBufDesc;
  12.363 -    ULONG ulPostCount = 0;
  12.364 -    APIRET rc = NO_ERROR;
  12.365 -
  12.366 -    pBufDesc = (pMixBufferDesc)
  12.367 -        _this->hidden->pMixBuffers[_this->hidden->iLastPlayedBuf].ulUserParm;
  12.368 -
  12.369 -    while ((pBufDesc->iBufferUsage != BUFFER_EMPTY) && (rc == NO_ERROR)) {
  12.370 -        DosResetEventSem(_this->hidden->hevAudioBufferPlayed, &ulPostCount);
  12.371 -        rc = DosWaitEventSem(_this->hidden->hevAudioBufferPlayed, 1000);        // 1 sec timeout! Important!
  12.372 -    }
  12.373 -}
  12.374 -
  12.375 -static void
  12.376 -DART_CloseDevice(_THIS)
  12.377 -{
  12.378 -    MCI_GENERIC_PARMS GenericParms;
  12.379 -    int rc;
  12.380 -    int i;
  12.381 -
  12.382 -    if (_this->hidden != NULL) {
  12.383 -        // Stop DART playback
  12.384 -        if (_this->hidden->iCurrDeviceOrd) {
  12.385 -            rc = mciSendCommand(_this->hidden->iCurrDeviceOrd, MCI_STOP,
  12.386 -                                MCI_WAIT, &GenericParms, 0);
  12.387 -#ifdef SFX_DEBUG_BUILD
  12.388 -            if (rc != MCIERR_SUCCESS) {
  12.389 -                printf("Could not stop DART playback!\n");
  12.390 -                fflush(stdout);
  12.391 -            }
  12.392 -#endif
  12.393 -        }
  12.394 -        // Close event semaphore
  12.395 -        if (_this->hidden->hevAudioBufferPlayed) {
  12.396 -            DosCloseEventSem(_this->hidden->hevAudioBufferPlayed);
  12.397 -            _this->hidden->hevAudioBufferPlayed = 0;
  12.398 -        }
  12.399 -        // Free memory of buffer descriptions
  12.400 -        for (i = 0; i < _this->hidden->iCurrNumBufs; i++) {
  12.401 -            SDL_free((void *) (_this->hidden->pMixBuffers[i].ulUserParm));
  12.402 -            _this->hidden->pMixBuffers[i].ulUserParm = 0;
  12.403 -        }
  12.404 -        _this->hidden->iCurrNumBufs = 0;
  12.405 -
  12.406 -        // Deallocate buffers
  12.407 -        if (_this->hidden->iCurrDeviceOrd) {
  12.408 -            rc = mciSendCommand(_this->hidden->iCurrDeviceOrd, MCI_BUFFER,
  12.409 -                                MCI_WAIT | MCI_DEALLOCATE_MEMORY,
  12.410 -                                &(_this->hidden->BufferParms), 0);
  12.411 -        }
  12.412 -        // Free bufferlist
  12.413 -        if (_this->hidden->pMixBuffers != NULL) {
  12.414 -            SDL_free(_this->hidden->pMixBuffers);
  12.415 -            _this->hidden->pMixBuffers = NULL;
  12.416 -        }
  12.417 -        // Close dart
  12.418 -        if (_this->hidden->iCurrDeviceOrd) {
  12.419 -            rc = mciSendCommand(_this->hidden->iCurrDeviceOrd, MCI_CLOSE,
  12.420 -                                MCI_WAIT, &(GenericParms), 0);
  12.421 -        }
  12.422 -        _this->hidden->iCurrDeviceOrd = 0;
  12.423 -
  12.424 -        SDL_free(_this->hidden);
  12.425 -        _this->hidden = NULL;
  12.426 -    }
  12.427 -}
  12.428 -
  12.429 -
  12.430 -static int
  12.431 -DART_Init(SDL_AudioDriverImpl * impl)
  12.432 -{
  12.433 -    /* Set the function pointers */
  12.434 -    impl->OpenDevice = DART_OpenDevice;
  12.435 -    impl->ThreadInit = DART_ThreadInit;
  12.436 -    impl->WaitDevice = DART_WaitDevice;
  12.437 -    impl->GetDeviceBuf = DART_GetDeviceBuf;
  12.438 -    impl->PlayDevice = DART_PlayDevice;
  12.439 -    impl->WaitDone = DART_WaitDone;
  12.440 -    impl->CloseDevice = DART_CloseDevice;
  12.441 -    impl->OnlyHasDefaultOutputDevice = 1;       /* !!! FIXME: is this right? */
  12.442 -
  12.443 -    return 1;
  12.444 -}
  12.445 -
  12.446 -
  12.447 -AudioBootStrap DART_bootstrap = {
  12.448 -    "dart", "OS/2 Direct Audio RouTines (DART)", DART_Init, 0
  12.449 -};
  12.450 -
  12.451 -/* vi: set ts=4 sw=4 expandtab: */
    13.1 --- a/src/audio/dart/SDL_dart.h	Sat Sep 19 06:24:07 2009 +0000
    13.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    13.3 @@ -1,66 +0,0 @@
    13.4 -/*
    13.5 -    SDL - Simple DirectMedia Layer
    13.6 -    Copyright (C) 1997-2009 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 Lesser General Public
   13.10 -    License as published by the Free Software Foundation; either
   13.11 -    version 2.1 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 -    Lesser General Public License for more details.
   13.17 -
   13.18 -    You should have received a copy of the GNU Lesser General Public
   13.19 -    License along with this library; if not, write to the Free Software
   13.20 -    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
   13.21 -
   13.22 -    Sam Lantinga
   13.23 -    slouken@libsdl.org
   13.24 -*/
   13.25 -#include "SDL_config.h"
   13.26 -
   13.27 -#ifndef _SDL_dart_h
   13.28 -#define _SDL_dart_h
   13.29 -
   13.30 -#define INCL_TYPES
   13.31 -#define INCL_DOSSEMAPHORES
   13.32 -#define INCL_DOSRESOURCES
   13.33 -#define INCL_DOSMISC
   13.34 -#define INCL_DOSERRORS
   13.35 -#define INCL_DOSPROCESS
   13.36 -
   13.37 -#define INCL_OS2MM
   13.38 -#define INCL_MMIOOS2
   13.39 -#define INCL_MCIOS2
   13.40 -#include <os2.h>
   13.41 -#include <os2me.h>              // DART stuff and MMIO stuff
   13.42 -
   13.43 -#include "../SDL_sysaudio.h"
   13.44 -
   13.45 -/* Hidden "this" pointer for the audio functions */
   13.46 -#define _THIS	SDL_AudioDevice *_this
   13.47 -
   13.48 -/* The DirectSound objects */
   13.49 -struct SDL_PrivateAudioData
   13.50 -{
   13.51 -    int iCurrDeviceOrd;
   13.52 -    int iCurrFreq;
   13.53 -    int iCurrBits;
   13.54 -    int iCurrChannels;
   13.55 -    int iCurrNumBufs;
   13.56 -    int iCurrBufSize;
   13.57 -
   13.58 -    int iLastPlayedBuf;
   13.59 -    int iNextFreeBuffer;
   13.60 -
   13.61 -    MCI_BUFFER_PARMS BufferParms;       // Sound buffer parameters
   13.62 -    MCI_MIX_BUFFER *pMixBuffers;        // Sound buffers
   13.63 -    MCI_MIXSETUP_PARMS MixSetupParms;   // Mixer setup parameters
   13.64 -    HEV hevAudioBufferPlayed;   // Event semaphore to indicate that an audio buffer has been played by DART
   13.65 -};
   13.66 -
   13.67 -#endif /* _SDL_dart_h */
   13.68 -
   13.69 -/* vi: set ts=4 sw=4 expandtab: */
    14.1 --- a/src/events/SDL_events.c	Sat Sep 19 06:24:07 2009 +0000
    14.2 +++ b/src/events/SDL_events.c	Sat Sep 19 06:43:45 2009 +0000
    14.3 @@ -84,29 +84,11 @@
    14.4      }
    14.5  }
    14.6  
    14.7 -#ifdef __OS2__
    14.8 -/*
    14.9 - * We'll increase the priority of GobbleEvents thread, so it will process
   14.10 - *  events in time for sure! For this, we need the DosSetPriority() API
   14.11 - *  from the os2.h include file.
   14.12 - */
   14.13 -#define INCL_DOSPROCESS
   14.14 -#include <os2.h>
   14.15 -#include <time.h>
   14.16 -#endif
   14.17 -
   14.18  static int SDLCALL
   14.19  SDL_GobbleEvents(void *unused)
   14.20  {
   14.21      event_thread = SDL_ThreadID();
   14.22  
   14.23 -#ifdef __OS2__
   14.24 -#ifdef USE_DOSSETPRIORITY
   14.25 -    /* Increase thread priority, so it will process events in time for sure! */
   14.26 -    DosSetPriority(PRTYS_THREAD, PRTYC_REGULAR, +16, 0);
   14.27 -#endif
   14.28 -#endif
   14.29 -
   14.30      while (SDL_EventQ.active) {
   14.31          SDL_VideoDevice *_this = SDL_GetVideoDevice();
   14.32  
    15.1 --- a/src/events/SDL_sysevents.h	Sat Sep 19 06:24:07 2009 +0000
    15.2 +++ b/src/events/SDL_sysevents.h	Sat Sep 19 06:43:45 2009 +0000
    15.3 @@ -33,8 +33,4 @@
    15.4  #define CANT_THREAD_EVENTS
    15.5  #endif
    15.6  
    15.7 -#ifdef __OS2__                  /* The OS/2 event loop runs in a separate thread */
    15.8 -#define MUST_THREAD_EVENTS
    15.9 -#endif
   15.10 -
   15.11  /* vi: set ts=4 sw=4 expandtab: */
    16.1 --- a/src/joystick/os2/SDL_sysjoystick.c	Sat Sep 19 06:24:07 2009 +0000
    16.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    16.3 @@ -1,698 +0,0 @@
    16.4 -/*
    16.5 -    SDL - Simple DirectMedia Layer
    16.6 -    Copyright (C) 1997-2009 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 Lesser General Public
   16.10 -    License as published by the Free Software Foundation; either
   16.11 -    version 2.1 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 -    Lesser General Public License for more details.
   16.17 -
   16.18 -    You should have received a copy of the GNU Lesser General Public
   16.19 -    License along with this library; if not, write to the Free Software
   16.20 -    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
   16.21 -
   16.22 -    Sam Lantinga
   16.23 -    slouken@libsdl.org
   16.24 -*/
   16.25 -#include "SDL_config.h"
   16.26 -
   16.27 -#ifdef SDL_JOYSTICK_OS2
   16.28 -
   16.29 -/* OS/2 Joystick driver, contributed by Daniel Caetano */
   16.30 -
   16.31 -#include <mem.h>
   16.32 -
   16.33 -#define INCL_DOSDEVICES
   16.34 -#define INCL_DOSDEVIOCTL
   16.35 -#define INCL_DOSMEMMGR
   16.36 -#include <os2.h>
   16.37 -#include "joyos2.h"
   16.38 -
   16.39 -#include "SDL_joystick.h"
   16.40 -#include "SDL_events.h"
   16.41 -#include "../SDL_sysjoystick.h"
   16.42 -#include "../SDL_joystick_c.h"
   16.43 -
   16.44 -HFILE hJoyPort = NULL;          /* Joystick GAME$ Port Address */
   16.45 -#define MAX_JOYSTICKS	2       /* Maximum of two joysticks */
   16.46 -#define MAX_AXES	4       /* each joystick can have up to 4 axes */
   16.47 -#define MAX_BUTTONS	8       /* 8 buttons */
   16.48 -#define MAX_HATS	0       /* 0 hats - OS/2 doesn't support it */
   16.49 -#define MAX_BALLS	0       /* and 0 balls - OS/2 doesn't support it */
   16.50 -#define AXIS_MIN -32768         /* minimum value for axes coordinate */
   16.51 -#define AXIS_MAX 32767          /* maximum value for axes coordinate */
   16.52 -#define MAX_JOYNAME	128     /* Joystick name may have 128 characters */
   16.53 -/* limit axes to 256 possible positions to filter out noise */
   16.54 -#define JOY_AXIS_THRESHOLD (((AXIS_MAX)-(AXIS_MIN))/256)
   16.55 -/* Calc Button Flag for buttons A to D */
   16.56 -#define JOY_BUTTON_FLAG(n) (1<<n)
   16.57 -
   16.58 -/* Joystick data... hold information about detected devices */
   16.59 -typedef struct SYS_JoyData_s
   16.60 -{
   16.61 -    Sint8 id;                   // Device ID
   16.62 -    char szDeviceName[MAX_JOYNAME];     // Device Name
   16.63 -    char axes;                  // Number of axes
   16.64 -    char buttons;               // Number of buttons
   16.65 -    char hats;                  // Number of buttons
   16.66 -    char balls;                 // Number of buttons
   16.67 -    int axes_min[MAX_AXES];     // minimum callibration value for axes
   16.68 -    int axes_med[MAX_AXES];     // medium callibration value for axes
   16.69 -    int axes_max[MAX_AXES];     // maximum callibration value for axes
   16.70 -    int buttoncalc[4];          // Used for buttons 5, 6, 7 and 8.
   16.71 -} SYS_JoyData_t, *SYS_JoyData_p;
   16.72 -
   16.73 -SYS_JoyData_t SYS_JoyData[MAX_JOYSTICKS];
   16.74 -
   16.75 -
   16.76 -/* Structure used to convert data from OS/2 driver format to SDL format */
   16.77 -struct joystick_hwdata
   16.78 -{
   16.79 -    Sint8 id;
   16.80 -    struct _transaxes
   16.81 -    {
   16.82 -        int offset;             /* Center Offset */
   16.83 -        float scale1;           /* Center to left/up Scale */
   16.84 -        float scale2;           /* Center to right/down Scale */
   16.85 -    } transaxes[MAX_AXES];
   16.86 -};
   16.87 -
   16.88 -/* Structure used to get values from Joystick Environment Variable */
   16.89 -struct _joycfg
   16.90 -{
   16.91 -    char name[MAX_JOYNAME];
   16.92 -    unsigned int axes;
   16.93 -    unsigned int buttons;
   16.94 -    unsigned int hats;
   16.95 -    unsigned int balls;
   16.96 -};
   16.97 -
   16.98 -/* OS/2 Implementation Function Prototypes */
   16.99 -APIRET joyPortOpen(HFILE * hGame);
  16.100 -void joyPortClose(HFILE * hGame);
  16.101 -int joyGetData(char *joyenv, char *name, char stopchar, size_t maxchars);
  16.102 -int joyGetEnv(struct _joycfg *joydata);
  16.103 -
  16.104 -
  16.105 -
  16.106 -/************************************************************************/
  16.107 -/* Function to scan the system for joysticks.									*/
  16.108 -/* This function should set SDL_numjoysticks to the number of available	*/
  16.109 -/* joysticks.  Joystick 0 should be the system default joystick.			*/
  16.110 -/* It should return 0, or -1 on an unrecoverable fatal error.				*/
  16.111 -/************************************************************************/
  16.112 -int
  16.113 -SDL_SYS_JoystickInit(void)
  16.114 -{
  16.115 -    APIRET rc;                  /* Generic OS/2 return code */
  16.116 -    GAME_PORT_STRUCT stJoyStatus;       /* Joystick Status Structure */
  16.117 -    GAME_PARM_STRUCT stGameParms;       /* Joystick Parameter Structure */
  16.118 -    GAME_CALIB_STRUCT stGameCalib;      /* Calibration Struct */
  16.119 -    ULONG ulDataLen;            /* Size of data */
  16.120 -    ULONG ulLastTick;           /* Tick Counter for timing operations */
  16.121 -    Uint8 maxdevs;              /* Maximum number of devices */
  16.122 -    Uint8 numdevs;              /* Number of present devices */
  16.123 -    Uint8 maxbut;               /* Maximum number of buttons... */
  16.124 -    Uint8 i;                    /* Temporary Count Vars */
  16.125 -    Uint8 ucNewJoystickMask;    /* Mask for Joystick Detection */
  16.126 -    struct _joycfg joycfg;      /* Joy Configuration from envvar */
  16.127 -
  16.128 -
  16.129 -/* Get Max Number of Devices */
  16.130 -    rc = joyPortOpen(&hJoyPort);        /* Open GAME$ port */
  16.131 -    if (rc != 0)
  16.132 -        return 0;               /* Cannot open... report no joystick */
  16.133 -    ulDataLen = sizeof(stGameParms);
  16.134 -    rc = DosDevIOCtl(hJoyPort, IOCTL_CAT_USER, GAME_GET_PARMS, NULL, 0, NULL, &stGameParms, ulDataLen, &ulDataLen);     /* Ask device info */
  16.135 -    if (rc != 0) {
  16.136 -        joyPortClose(&hJoyPort);
  16.137 -        SDL_SetError("Could not read joystick port.");
  16.138 -        return -1;
  16.139 -    }
  16.140 -    if (stGameParms.useA != 0)
  16.141 -        maxdevs++;
  16.142 -    if (stGameParms.useB != 0)
  16.143 -        maxdevs++;
  16.144 -    if (maxdevs > MAX_JOYSTICKS)
  16.145 -        maxdevs = MAX_JOYSTICKS;
  16.146 -
  16.147 -/* Defines min/max axes values (callibration) */
  16.148 -    ulDataLen = sizeof(stGameCalib);
  16.149 -    rc = DosDevIOCtl(hJoyPort, IOCTL_CAT_USER, GAME_GET_CALIB,
  16.150 -                     NULL, 0, NULL, &stGameCalib, ulDataLen, &ulDataLen);
  16.151 -    if (rc != 0) {
  16.152 -        joyPortClose(&hJoyPort);
  16.153 -        SDL_SetError("Could not read callibration data.");
  16.154 -        return -1;
  16.155 -    }
  16.156 -
  16.157 -/* Determine how many joysticks are active */
  16.158 -    numdevs = 0;                /* Points no device */
  16.159 -    ucNewJoystickMask = 0x0F;   /* read all 4 joystick axis */
  16.160 -    ulDataLen = sizeof(ucNewJoystickMask);
  16.161 -    rc = DosDevIOCtl(hJoyPort, IOCTL_CAT_USER, GAME_PORT_RESET,
  16.162 -                     &ucNewJoystickMask, ulDataLen, &ulDataLen, NULL, 0,
  16.163 -                     NULL);
  16.164 -    if (rc == 0) {
  16.165 -        ulDataLen = sizeof(stJoyStatus);
  16.166 -        rc = DosDevIOCtl(hJoyPort, IOCTL_CAT_USER, GAME_PORT_GET,
  16.167 -                         NULL, 0, NULL, &stJoyStatus, ulDataLen, &ulDataLen);
  16.168 -        if (rc != 0) {
  16.169 -            joyPortClose(&hJoyPort);
  16.170 -            SDL_SetError("Could not call joystick port.");
  16.171 -            return -1;
  16.172 -        }
  16.173 -        ulLastTick = stJoyStatus.ulJs_Ticks;
  16.174 -        while (stJoyStatus.ulJs_Ticks == ulLastTick) {
  16.175 -            rc = DosDevIOCtl(hJoyPort, IOCTL_CAT_USER, GAME_PORT_GET,
  16.176 -                             NULL, 0, NULL, &stJoyStatus, ulDataLen,
  16.177 -                             &ulDataLen);
  16.178 -        }
  16.179 -        if ((stJoyStatus.ucJs_JoyStickMask & 0x03) > 0)
  16.180 -            numdevs++;
  16.181 -        if (((stJoyStatus.ucJs_JoyStickMask >> 2) & 0x03) > 0)
  16.182 -            numdevs++;
  16.183 -    }
  16.184 -
  16.185 -    if (numdevs > maxdevs)
  16.186 -        numdevs = maxdevs;
  16.187 -
  16.188 -/* If *any* joystick was detected... Let's configure SDL for them */
  16.189 -    if (numdevs > 0) {
  16.190 -        /* Verify if it is a "user defined" joystick */
  16.191 -        if (joyGetEnv(&joycfg)) {
  16.192 -            GAME_3POS_STRUCT *axis[4];
  16.193 -            axis[0] = &stGameCalib.Ax;
  16.194 -            axis[1] = &stGameCalib.Ay;
  16.195 -            axis[2] = &stGameCalib.Bx;
  16.196 -            axis[3] = &stGameCalib.By;
  16.197 -            /* Say it has one device only (user defined is always one device only) */
  16.198 -            numdevs = 1;
  16.199 -            /* Define Device 0 as... */
  16.200 -            SYS_JoyData[0].id = 0;
  16.201 -            /* Define Number of Axes... up to 4 */
  16.202 -            if (joycfg.axes > MAX_AXES)
  16.203 -                joycfg.axes = MAX_AXES;
  16.204 -            SYS_JoyData[0].axes = joycfg.axes;
  16.205 -            /* Define number of buttons... 8 if 2 axes, 6 if 3 axes and 4 if 4 axes */
  16.206 -            maxbut = MAX_BUTTONS;
  16.207 -            if (joycfg.axes > 2)
  16.208 -                maxbut -= ((joycfg.axes - 2) << 1);     /* MAX_BUTTONS - 2*(axes-2) */
  16.209 -            if (joycfg.buttons > maxbut)
  16.210 -                joycfg.buttons = maxbut;
  16.211 -            SYS_JoyData[0].buttons = joycfg.buttons;
  16.212 -            /* Define number of hats */
  16.213 -            if (joycfg.hats > MAX_HATS)
  16.214 -                joycfg.hats = MAX_HATS;
  16.215 -            SYS_JoyData[0].hats = joycfg.hats;
  16.216 -            /* Define number of balls */
  16.217 -            if (joycfg.balls > MAX_BALLS)
  16.218 -                joycfg.balls = MAX_BALLS;
  16.219 -            SYS_JoyData[0].balls = joycfg.balls;
  16.220 -            /* Initialize Axes Callibration Values */
  16.221 -            for (i = 0; i < joycfg.axes; i++) {
  16.222 -                SYS_JoyData[0].axes_min[i] = axis[i]->lower;
  16.223 -                SYS_JoyData[0].axes_med[i] = axis[i]->centre;
  16.224 -                SYS_JoyData[0].axes_max[i] = axis[i]->upper;
  16.225 -            }
  16.226 -            /* Initialize Buttons 5 to 8 structures */
  16.227 -            if (joycfg.buttons >= 5)
  16.228 -                SYS_JoyData[0].buttoncalc[0] =
  16.229 -                    ((axis[2]->lower + axis[3]->centre) >> 1);
  16.230 -            if (joycfg.buttons >= 6)
  16.231 -                SYS_JoyData[0].buttoncalc[1] =
  16.232 -                    ((axis[3]->lower + axis[3]->centre) >> 1);
  16.233 -            if (joycfg.buttons >= 7)
  16.234 -                SYS_JoyData[0].buttoncalc[2] =
  16.235 -                    ((axis[2]->upper + axis[3]->centre) >> 1);
  16.236 -            if (joycfg.buttons >= 8)
  16.237 -                SYS_JoyData[0].buttoncalc[3] =
  16.238 -                    ((axis[3]->upper + axis[3]->centre) >> 1);
  16.239 -            /* Intialize Joystick Name */
  16.240 -            SDL_strlcpy(SYS_JoyData[0].szDeviceName, joycfg.name,
  16.241 -                        SDL_arraysize(SYS_JoyData[0].szDeviceName));
  16.242 -        }
  16.243 -        /* Default Init ... autoconfig */
  16.244 -        else {
  16.245 -            /* if two devices were detected... configure as Joy1 4 axis and Joy2 2 axis */
  16.246 -            if (numdevs == 2) {
  16.247 -                /* Define Device 0 as 4 axes, 4 buttons */
  16.248 -                SYS_JoyData[0].id = 0;
  16.249 -                SYS_JoyData[0].axes = 4;
  16.250 -                SYS_JoyData[0].buttons = 4;
  16.251 -                SYS_JoyData[0].hats = 0;
  16.252 -                SYS_JoyData[0].balls = 0;
  16.253 -                SYS_JoyData[0].axes_min[0] = stGameCalib.Ax.lower;
  16.254 -                SYS_JoyData[0].axes_med[0] = stGameCalib.Ax.centre;
  16.255 -                SYS_JoyData[0].axes_max[0] = stGameCalib.Ax.upper;
  16.256 -                SYS_JoyData[0].axes_min[1] = stGameCalib.Ay.lower;
  16.257 -                SYS_JoyData[0].axes_med[1] = stGameCalib.Ay.centre;
  16.258 -                SYS_JoyData[0].axes_max[1] = stGameCalib.Ay.upper;
  16.259 -                SYS_JoyData[0].axes_min[2] = stGameCalib.Bx.lower;
  16.260 -                SYS_JoyData[0].axes_med[2] = stGameCalib.Bx.centre;
  16.261 -                SYS_JoyData[0].axes_max[2] = stGameCalib.Bx.upper;
  16.262 -                SYS_JoyData[0].axes_min[3] = stGameCalib.By.lower;
  16.263 -                SYS_JoyData[0].axes_med[3] = stGameCalib.By.centre;
  16.264 -                SYS_JoyData[0].axes_max[3] = stGameCalib.By.upper;
  16.265 -                /* Define Device 1 as 2 axes, 2 buttons */
  16.266 -                SYS_JoyData[1].id = 1;
  16.267 -                SYS_JoyData[1].axes = 2;
  16.268 -                SYS_JoyData[1].buttons = 2;
  16.269 -                SYS_JoyData[1].hats = 0;
  16.270 -                SYS_JoyData[1].balls = 0;
  16.271 -                SYS_JoyData[1].axes_min[0] = stGameCalib.Bx.lower;
  16.272 -                SYS_JoyData[1].axes_med[0] = stGameCalib.Bx.centre;
  16.273 -                SYS_JoyData[1].axes_max[0] = stGameCalib.Bx.upper;
  16.274 -                SYS_JoyData[1].axes_min[1] = stGameCalib.By.lower;
  16.275 -                SYS_JoyData[1].axes_med[1] = stGameCalib.By.centre;
  16.276 -                SYS_JoyData[1].axes_max[1] = stGameCalib.By.upper;
  16.277 -            }
  16.278 -            /* One joystick only? */
  16.279 -            else {
  16.280 -                /* If it is joystick A... */
  16.281 -                if ((stJoyStatus.ucJs_JoyStickMask & 0x03) > 0) {
  16.282 -                    /* Define Device 0 as 2 axes, 4 buttons */
  16.283 -                    SYS_JoyData[0].id = 0;
  16.284 -                    SYS_JoyData[0].axes = 2;
  16.285 -                    SYS_JoyData[0].buttons = 4;
  16.286 -                    SYS_JoyData[0].hats = 0;
  16.287 -                    SYS_JoyData[0].balls = 0;
  16.288 -                    SYS_JoyData[0].axes_min[0] = stGameCalib.Ax.lower;
  16.289 -                    SYS_JoyData[0].axes_med[0] = stGameCalib.Ax.centre;
  16.290 -                    SYS_JoyData[0].axes_max[0] = stGameCalib.Ax.upper;
  16.291 -                    SYS_JoyData[0].axes_min[1] = stGameCalib.Ay.lower;
  16.292 -                    SYS_JoyData[0].axes_med[1] = stGameCalib.Ay.centre;
  16.293 -                    SYS_JoyData[0].axes_max[1] = stGameCalib.Ay.upper;
  16.294 -                }
  16.295 -                /* If not, it is joystick B */
  16.296 -                else {
  16.297 -                    /* Define Device 1 as 2 axes, 2 buttons */
  16.298 -                    SYS_JoyData[0].id = 1;
  16.299 -                    SYS_JoyData[0].axes = 2;
  16.300 -                    SYS_JoyData[0].buttons = 2;
  16.301 -                    SYS_JoyData[0].hats = 0;
  16.302 -                    SYS_JoyData[0].balls = 0;
  16.303 -                    SYS_JoyData[0].axes_min[0] = stGameCalib.Bx.lower;
  16.304 -                    SYS_JoyData[0].axes_med[0] = stGameCalib.Bx.centre;
  16.305 -                    SYS_JoyData[0].axes_max[0] = stGameCalib.Bx.upper;
  16.306 -                    SYS_JoyData[0].axes_min[1] = stGameCalib.By.lower;
  16.307 -                    SYS_JoyData[0].axes_med[1] = stGameCalib.By.centre;
  16.308 -                    SYS_JoyData[0].axes_max[1] = stGameCalib.By.upper;
  16.309 -                }
  16.310 -            }
  16.311 -            /* Hack to define Joystick Port Names */
  16.312 -            if (numdevs > maxdevs)
  16.313 -                numdevs = maxdevs;
  16.314 -            for (i = 0; i < numdevs; i++)
  16.315 -                SDL_snprintf(SYS_JoyData[i].szDeviceName,
  16.316 -                             SDL_arraysize(SYS_JoyData[i].szDeviceName),
  16.317 -                             "Default Joystick %c", 'A' + SYS_JoyData[i].id);
  16.318 -
  16.319 -        }
  16.320 -    }
  16.321 -/* Return the number of devices found */
  16.322 -    return (numdevs);
  16.323 -}
  16.324 -
  16.325 -
  16.326 -/***********************************************************/
  16.327 -/* Function to get the device-dependent name of a joystick */
  16.328 -/***********************************************************/
  16.329 -const char *
  16.330 -SDL_SYS_JoystickName(int index)
  16.331 -{
  16.332 -/* No need to verify if device exists, already done in upper layer */
  16.333 -    return (SYS_JoyData[index].szDeviceName);
  16.334 -}
  16.335 -
  16.336 -
  16.337 -
  16.338 -/******************************************************************************/
  16.339 -/* Function to open a joystick for use.													*/
  16.340 -/* The joystick to open is specified by the index field of the joystick.		*/
  16.341 -/* This should fill the nbuttons and naxes fields of the joystick structure.	*/
  16.342 -/* It returns 0, or -1 if there is an error.												*/
  16.343 -/******************************************************************************/
  16.344 -int
  16.345 -SDL_SYS_JoystickOpen(SDL_Joystick * joystick)
  16.346 -{
  16.347 -    int index;                  /* Index shortcut for index in joystick structure */
  16.348 -    int i;                      /* Generic Counter */
  16.349 -
  16.350 -/* allocate memory for system specific hardware data */
  16.351 -    joystick->hwdata =
  16.352 -        (struct joystick_hwdata *) SDL_malloc(sizeof(*joystick->hwdata));
  16.353 -    if (joystick->hwdata == NULL) {
  16.354 -        SDL_OutOfMemory();
  16.355 -        return (-1);
  16.356 -    }
  16.357 -/* Reset Hardware Data */
  16.358 -    SDL_memset(joystick->hwdata, 0, sizeof(*joystick->hwdata));
  16.359 -
  16.360 -/* ShortCut Pointer */
  16.361 -    index = joystick->index;
  16.362 -/* Define offsets and scales for all axes */
  16.363 -    joystick->hwdata->id = SYS_JoyData[index].id;
  16.364 -    for (i = 0; i < MAX_AXES; ++i) {
  16.365 -        if ((i < 2) || i < SYS_JoyData[index].axes) {
  16.366 -            joystick->hwdata->transaxes[i].offset =
  16.367 -                ((AXIS_MAX + AXIS_MIN) >> 1) - SYS_JoyData[index].axes_med[i];
  16.368 -            //joystick->hwdata->transaxes[i].scale = (float)((AXIS_MAX - AXIS_MIN)/(SYS_JoyData[index].axes_max[i]-SYS_JoyData[index].axes_min[i]));
  16.369 -            joystick->hwdata->transaxes[i].scale1 =
  16.370 -                (float) abs((AXIS_MIN / SYS_JoyData[index].axes_min[i]));
  16.371 -            joystick->hwdata->transaxes[i].scale2 =
  16.372 -                (float) abs((AXIS_MAX / SYS_JoyData[index].axes_max[i]));
  16.373 -        } else {
  16.374 -            joystick->hwdata->transaxes[i].offset = 0;
  16.375 -            //joystick->hwdata->transaxes[i].scale = 1.0; /* Just in case */
  16.376 -            joystick->hwdata->transaxes[i].scale1 = 1.0;        /* Just in case */
  16.377 -            joystick->hwdata->transaxes[i].scale2 = 1.0;        /* Just in case */
  16.378 -        }
  16.379 -    }
  16.380 -
  16.381 -/* fill nbuttons, naxes, and nhats fields */
  16.382 -    joystick->nbuttons = SYS_JoyData[index].buttons;
  16.383 -    joystick->naxes = SYS_JoyData[index].axes;
  16.384 -/* joystick->nhats = SYS_JoyData[index].hats; */
  16.385 -    joystick->nhats = 0;        /* No support for hats at this time */
  16.386 -/* joystick->nballs = SYS_JoyData[index].balls; */
  16.387 -    joystick->nballs = 0;       /* No support for balls at this time */
  16.388 -    return 0;
  16.389 -}
  16.390 -
  16.391 -
  16.392 -
  16.393 -/***************************************************************************/
  16.394 -/* Function to update the state of a joystick - called as a device poll.	*/
  16.395 -/* This function shouldn't update the joystick structure directly,			*/
  16.396 -/* but instead should call SDL_PrivateJoystick*() to deliver events			*/
  16.397 -/* and update joystick device state.													*/
  16.398 -/***************************************************************************/
  16.399 -void
  16.400 -SDL_SYS_JoystickUpdate(SDL_Joystick * joystick)
  16.401 -{
  16.402 -    APIRET rc;                  /* Generic OS/2 return code */
  16.403 -    int index;                  /* index shortcurt to joystick index */
  16.404 -    int i;                      /* Generic counter */
  16.405 -    int normbut;                /* Number of buttons reported by joystick */
  16.406 -    int corr;                   /* Correction for button names */
  16.407 -    Sint16 value, change;       /* Values used to update axis values */
  16.408 -    struct _transaxes *transaxes;       /* Shortcut for Correction structure */
  16.409 -    Uint32 pos[MAX_AXES];       /* Vector to inform the Axis status */
  16.410 -    ULONG ulDataLen;            /* Size of data */
  16.411 -    GAME_STATUS_STRUCT stGameStatus;    /* Joystick Status Structure */
  16.412 -
  16.413 -    ulDataLen = sizeof(stGameStatus);
  16.414 -    rc = DosDevIOCtl(hJoyPort, IOCTL_CAT_USER, GAME_GET_STATUS,
  16.415 -                     NULL, 0, NULL, &stGameStatus, ulDataLen, &ulDataLen);
  16.416 -    if (rc != 0) {
  16.417 -        SDL_SetError("Could not read joystick status.");
  16.418 -        return;                 /* Could not read data */
  16.419 -    }
  16.420 -
  16.421 -/* Shortcut pointer */
  16.422 -    index = joystick->index;
  16.423 -/* joystick motion events */
  16.424 -
  16.425 -    if (SYS_JoyData[index].id == 0) {
  16.426 -        pos[0] = stGameStatus.curdata.A.x;
  16.427 -        pos[1] = stGameStatus.curdata.A.y;
  16.428 -        if (SYS_JoyData[index].axes >= 3)
  16.429 -            pos[2] = stGameStatus.curdata.B.x;
  16.430 -        else
  16.431 -            pos[2] = 0;
  16.432 -        if (SYS_JoyData[index].axes >= 4)
  16.433 -            pos[3] = stGameStatus.curdata.B.y;
  16.434 -        else
  16.435 -            pos[3] = 0;
  16.436 -        pos[4] = 0;             /* OS/2 basic drivers do not support more than 4 axes joysticks */
  16.437 -        pos[5] = 0;
  16.438 -    } else if (SYS_JoyData[index].id == 1) {
  16.439 -        pos[0] = stGameStatus.curdata.B.x;
  16.440 -        pos[1] = stGameStatus.curdata.B.y;
  16.441 -        pos[2] = 0;
  16.442 -        pos[3] = 0;
  16.443 -        pos[4] = 0;
  16.444 -        pos[5] = 0;
  16.445 -    }
  16.446 -
  16.447 -/* Corrects the movements using the callibration */
  16.448 -    transaxes = joystick->hwdata->transaxes;
  16.449 -    for (i = 0; i < joystick->naxes; i++) {
  16.450 -        value = pos[i] + transaxes[i].offset;
  16.451 -        if (value < 0) {
  16.452 -            value *= transaxes[i].scale1;
  16.453 -            if (value > 0)
  16.454 -                value = AXIS_MIN;
  16.455 -        } else {
  16.456 -            value *= transaxes[i].scale2;
  16.457 -            if (value < 0)
  16.458 -                value = AXIS_MAX;
  16.459 -        }
  16.460 -        change = (value - joystick->axes[i]);
  16.461 -        if ((change < -JOY_AXIS_THRESHOLD) || (change > JOY_AXIS_THRESHOLD)) {
  16.462 -            SDL_PrivateJoystickAxis(joystick, (Uint8) i, (Sint16) value);
  16.463 -        }
  16.464 -    }
  16.465 -
  16.466 -/* joystick button A to D events */
  16.467 -    if (SYS_JoyData[index].id == 1)
  16.468 -        corr = 2;
  16.469 -    else
  16.470 -        corr = 0;
  16.471 -    normbut = 4;                /* Number of normal buttons */
  16.472 -    if (joystick->nbuttons < normbut)
  16.473 -        normbut = joystick->nbuttons;
  16.474 -    for (i = corr; (i - corr) < normbut; ++i) {
  16.475 -        /*
  16.476 -           Button A: 1110 0000
  16.477 -           Button B: 1101 0000
  16.478 -           Button C: 1011 0000
  16.479 -           Button D: 0111 0000
  16.480 -         */
  16.481 -        if ((~stGameStatus.curdata.butMask) >> 4 & JOY_BUTTON_FLAG(i)) {
  16.482 -            if (!joystick->buttons[i - corr]) {
  16.483 -                SDL_PrivateJoystickButton(joystick, (Uint8) (i - corr),
  16.484 -                                          SDL_PRESSED);
  16.485 -            }
  16.486 -        } else {
  16.487 -            if (joystick->buttons[i - corr]) {
  16.488 -                SDL_PrivateJoystickButton(joystick, (Uint8) (i - corr),
  16.489 -                                          SDL_RELEASED);
  16.490 -            }
  16.491 -        }
  16.492 -    }
  16.493 -
  16.494 -/* Joystick button E to H buttons */
  16.495 -    /*
  16.496 -       Button E: Axis 2 X Left
  16.497 -       Button F: Axis 2 Y Up
  16.498 -       Button G: Axis 2 X Right
  16.499 -       Button H: Axis 2 Y Down
  16.500 -     */
  16.501 -    if (joystick->nbuttons >= 5) {
  16.502 -        if (stGameStatus.curdata.B.x < SYS_JoyData[index].buttoncalc[0])
  16.503 -            SDL_PrivateJoystickButton(joystick, (Uint8) 4, SDL_PRESSED);
  16.504 -        else
  16.505 -            SDL_PrivateJoystickButton(joystick, (Uint8) 4, SDL_RELEASED);
  16.506 -    }
  16.507 -    if (joystick->nbuttons >= 6) {
  16.508 -        if (stGameStatus.curdata.B.y < SYS_JoyData[index].buttoncalc[1])
  16.509 -            SDL_PrivateJoystickButton(joystick, (Uint8) 5, SDL_PRESSED);
  16.510 -        else
  16.511 -            SDL_PrivateJoystickButton(joystick, (Uint8) 5, SDL_RELEASED);
  16.512 -    }
  16.513 -    if (joystick->nbuttons >= 7) {
  16.514 -        if (stGameStatus.curdata.B.x > SYS_JoyData[index].buttoncalc[2])
  16.515 -            SDL_PrivateJoystickButton(joystick, (Uint8) 6, SDL_PRESSED);
  16.516 -        else
  16.517 -            SDL_PrivateJoystickButton(joystick, (Uint8) 6, SDL_RELEASED);
  16.518 -    }
  16.519 -    if (joystick->nbuttons >= 8) {
  16.520 -        if (stGameStatus.curdata.B.y > SYS_JoyData[index].buttoncalc[3])
  16.521 -            SDL_PrivateJoystickButton(joystick, (Uint8) 7, SDL_PRESSED);
  16.522 -        else
  16.523 -            SDL_PrivateJoystickButton(joystick, (Uint8) 7, SDL_RELEASED);
  16.524 -    }
  16.525 -
  16.526 -/* joystick hat events */
  16.527 -/* Not Supported under OS/2 */
  16.528 -/* joystick ball events */
  16.529 -/* Not Supported under OS/2 */
  16.530 -}
  16.531 -
  16.532 -
  16.533 -
  16.534 -/******************************************/
  16.535 -/* Function to close a joystick after use */
  16.536 -/******************************************/
  16.537 -void
  16.538 -SDL_SYS_JoystickClose(SDL_Joystick * joystick)
  16.539 -{
  16.540 -    if (joystick->hwdata != NULL) {
  16.541 -        /* free system specific hardware data */
  16.542 -        SDL_free(joystick->hwdata);
  16.543 -    }
  16.544 -}
  16.545 -
  16.546 -
  16.547 -
  16.548 -/********************************************************************/
  16.549 -/* Function to perform any system-specific joystick related cleanup */
  16.550 -/********************************************************************/
  16.551 -void
  16.552 -SDL_SYS_JoystickQuit(void)
  16.553 -{
  16.554 -    joyPortClose(&hJoyPort);
  16.555 -}
  16.556 -
  16.557 -
  16.558 -
  16.559 -/************************/
  16.560 -/************************/
  16.561 -/* OS/2 Implementations */
  16.562 -/************************/
  16.563 -/************************/
  16.564 -
  16.565 -
  16.566 -/*****************************************/
  16.567 -/* Open Joystick Port, if not opened yet */
  16.568 -/*****************************************/
  16.569 -APIRET
  16.570 -joyPortOpen(HFILE * hGame)
  16.571 -{
  16.572 -    APIRET rc;                  /* Generic Return Code */
  16.573 -    ULONG ulAction;             /* ? */
  16.574 -    ULONG ulVersion;            /* Version of joystick driver */
  16.575 -    ULONG ulDataLen;            /* Size of version data */
  16.576 -
  16.577 -/* Verifies if joyport is not already open... */
  16.578 -    if (*hGame != NULL)
  16.579 -        return 0;
  16.580 -/* Open GAME$ for read */
  16.581 -    rc = DosOpen((PSZ) GAMEPDDNAME, hGame, &ulAction, 0, FILE_READONLY,
  16.582 -                 FILE_OPEN, OPEN_ACCESS_READONLY | OPEN_SHARE_DENYNONE, NULL);
  16.583 -    if (rc != 0) {
  16.584 -        SDL_SetError("Could not open Joystick Port.");
  16.585 -        return -1;
  16.586 -    }
  16.587 -
  16.588 -/* Get Joystick Driver Version... must be 2.0 or higher */
  16.589 -    ulVersion = 0;
  16.590 -    ulDataLen = sizeof(ulVersion);
  16.591 -    rc = DosDevIOCtl(*hGame, IOCTL_CAT_USER, GAME_GET_VERSION,
  16.592 -                     NULL, 0, NULL, &ulVersion, ulDataLen, &ulDataLen);
  16.593 -    if (rc != 0) {
  16.594 -        joyPortClose(hGame);
  16.595 -        SDL_SetError("Could not get Joystick Driver version.");
  16.596 -        return -1;
  16.597 -    }
  16.598 -    if (ulVersion < GAME_VERSION) {
  16.599 -        joyPortClose(hGame);
  16.600 -        SDL_SetError
  16.601 -            ("Driver too old. At least IBM driver version 2.0 required.");
  16.602 -        return -1;
  16.603 -    }
  16.604 -    return 0;
  16.605 -}
  16.606 -
  16.607 -
  16.608 -
  16.609 -/****************************/
  16.610 -/* Close JoyPort, if opened */
  16.611 -/****************************/
  16.612 -void
  16.613 -joyPortClose(HFILE * hGame)
  16.614 -{
  16.615 -    if (*hGame != NULL)
  16.616 -        DosClose(*hGame);
  16.617 -    *hGame = NULL;
  16.618 -}
  16.619 -
  16.620 -
  16.621 -
  16.622 -/***************************/
  16.623 -/* Get SDL Joystick EnvVar */
  16.624 -/***************************/
  16.625 -int
  16.626 -joyGetEnv(struct _joycfg *joydata)
  16.627 -{
  16.628 -    char *joyenv;               /* Pointer to tested character */
  16.629 -    char tempnumber[5];         /* Temporary place to put numeric texts */
  16.630 -
  16.631 -    joyenv = SDL_getenv("SDL_OS2_JOYSTICK");
  16.632 -    if (joyenv == NULL)
  16.633 -        return 0;
  16.634 -/* Joystick Environment is defined! */
  16.635 -    while (*joyenv == ' ' && *joyenv != 0)
  16.636 -        joyenv++;               /* jump spaces... */
  16.637 -/* If the string name starts with '... get if fully */
  16.638 -    if (*joyenv == '\'')
  16.639 -        joyenv +=
  16.640 -            joyGetData(++joyenv, joydata->name, '\'', sizeof(joydata->name));
  16.641 -/* If not, get it until the next space */
  16.642 -    else if (*joyenv == '\"')
  16.643 -        joyenv +=
  16.644 -            joyGetData(++joyenv, joydata->name, '\"', sizeof(joydata->name));
  16.645 -    else
  16.646 -        joyenv +=
  16.647 -            joyGetData(joyenv, joydata->name, ' ', sizeof(joydata->name));
  16.648 -/* Now get the number of axes */
  16.649 -    while (*joyenv == ' ' && *joyenv != 0)
  16.650 -        joyenv++;               /* jump spaces... */
  16.651 -    joyenv += joyGetData(joyenv, tempnumber, ' ', sizeof(tempnumber));
  16.652 -    joydata->axes = atoi(tempnumber);
  16.653 -/* Now get the number of buttons */
  16.654 -    while (*joyenv == ' ' && *joyenv != 0)
  16.655 -        joyenv++;               /* jump spaces... */
  16.656 -    joyenv += joyGetData(joyenv, tempnumber, ' ', sizeof(tempnumber));
  16.657 -    joydata->buttons = atoi(tempnumber);
  16.658 -/* Now get the number of hats */
  16.659 -    while (*joyenv == ' ' && *joyenv != 0)
  16.660 -        joyenv++;               /* jump spaces... */
  16.661 -    joyenv += joyGetData(joyenv, tempnumber, ' ', sizeof(tempnumber));
  16.662 -    joydata->hats = atoi(tempnumber);
  16.663 -/* Now get the number of balls */
  16.664 -    while (*joyenv == ' ' && *joyenv != 0)
  16.665 -        joyenv++;               /* jump spaces... */
  16.666 -    joyenv += joyGetData(joyenv, tempnumber, ' ', sizeof(tempnumber));
  16.667 -    joydata->balls = atoi(tempnumber);
  16.668 -    return 1;
  16.669 -}
  16.670 -
  16.671 -
  16.672 -
  16.673 -/************************************************************************/
  16.674 -/* Get a text from in the string starting in joyenv until it finds		*/
  16.675 -/* the stopchar or maxchars is reached. The result is placed in name.	*/
  16.676 -/************************************************************************/
  16.677 -int
  16.678 -joyGetData(char *joyenv, char *name, char stopchar, size_t maxchars)
  16.679 -{
  16.680 -    char *nameptr;              /* Pointer to the selected character */
  16.681 -    int chcnt = 0;              /* Count how many characters where copied */
  16.682 -
  16.683 -    nameptr = name;
  16.684 -    while (*joyenv != stopchar && *joyenv != 0) {
  16.685 -        if (nameptr < (name + (maxchars - 1))) {
  16.686 -            *nameptr = *joyenv; /* Only copy if smaller than maximum */
  16.687 -            nameptr++;
  16.688 -        }
  16.689 -        chcnt++;
  16.690 -        joyenv++;
  16.691 -    }
  16.692 -    if (*joyenv == stopchar) {
  16.693 -        joyenv++;               /* Jump stopchar */
  16.694 -        chcnt++;
  16.695 -    }
  16.696 -    *nameptr = 0;               /* Mark last byte */
  16.697 -    return chcnt;
  16.698 -}
  16.699 -
  16.700 -#endif /* SDL_JOYSTICK_OS2 */
  16.701 -/* vi: set ts=4 sw=4 expandtab: */
    17.1 --- a/src/joystick/os2/joyos2.h	Sat Sep 19 06:24:07 2009 +0000
    17.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    17.3 @@ -1,179 +0,0 @@
    17.4 -/*****************************************************************************/
    17.5 -/*                                                                           */
    17.6 -/* COPYRIGHT    Copyright (C) 1995 IBM Corporation                           */
    17.7 -/*                                                                           */
    17.8 -/*    The following IBM OS/2 source code is provided to you solely for       */
    17.9 -/*    the purpose of assisting you in your development of OS/2 device        */
   17.10 -/*    drivers. You may use this code in accordance with the IBM License      */
   17.11 -/*    Agreement provided in the IBM Device Driver Source Kit for OS/2. This  */
   17.12 -/*    Copyright statement may not be removed.                                */
   17.13 -/*                                                                           */
   17.14 -/*****************************************************************************/
   17.15 -#ifndef JOYOS2_H
   17.16 -#define JOYOS2_H
   17.17 -
   17.18 -/****** GAMEPORT.SYS joystick definitions, start *****************************/
   17.19 -#define GAME_VERSION    0x20    /* 2.0 First IBM version */
   17.20 -#define GAMEPDDNAME     "GAME$   "
   17.21 -#define IOCTL_CAT_USER	0x80
   17.22 -#define GAME_PORT_GET	0x20    /* read GAMEPORT.SYS values */
   17.23 -#define GAME_PORT_RESET 0x60    /* reset joystick mask with given value */
   17.24 -
   17.25 -#pragma pack(1)                 /* pack structure size is 1 byte */
   17.26 -typedef struct
   17.27 -{                               /* GAMEPORT.SYS structure */
   17.28 -    USHORT usJs_AxCnt;          /* Joystick_A X position */
   17.29 -    USHORT usJs_AyCnt;          /* Joystick_A Y position */
   17.30 -    USHORT usJs_BxCnt;          /* Joystick_B X position */
   17.31 -    USHORT usJs_ByCnt;          /* Joystick_B Y position */
   17.32 -    USHORT usJs_ButtonA1Cnt;    /* button A1 press count */
   17.33 -    USHORT usJs_ButtonA2Cnt;    /* button A2 press count */
   17.34 -    USHORT usJs_ButtonB1Cnt;    /* button B1 press count */
   17.35 -    USHORT usJs_ButtonB2Cnt;    /* button B2 press count */
   17.36 -    UCHAR ucJs_JoyStickMask;    /* mask of connected joystick pots */
   17.37 -    UCHAR ucJs_ButtonStatus;    /* bits of switches down */
   17.38 -    ULONG ulJs_Ticks;           /* joystick clock ticks */
   17.39 -} GAME_PORT_STRUCT;
   17.40 -#pragma pack()                  /*reset to normal pack size */
   17.41 -/****** GAMEPORT.SYS joystick definitions, end *******************************/
   17.42 -
   17.43 -
   17.44 -/****************************************************************************/
   17.45 -#define GAME_GET_VERSION                0x01
   17.46 -#define GAME_GET_PARMS                  0x02
   17.47 -#define GAME_SET_PARMS                  0x03
   17.48 -#define GAME_GET_CALIB                  0x04
   17.49 -#define GAME_SET_CALIB                  0x05
   17.50 -#define GAME_GET_DIGSET                 0x06
   17.51 -#define GAME_SET_DIGSET                 0x07
   17.52 -#define GAME_GET_STATUS                 0x10
   17.53 -#define GAME_GET_STATUS_BUTWAIT         0x11
   17.54 -#define GAME_GET_STATUS_SAMPWAIT        0x12
   17.55 -/****************************************************************************/
   17.56 -
   17.57 -/****************************************************************************/
   17.58 -// bit masks for each axis
   17.59 -#define JOY_AX_BIT      0x01
   17.60 -#define JOY_AY_BIT      0x02
   17.61 -#define JOY_A_BITS      (JOY_AX_BIT|JOY_AY_BIT)
   17.62 -#define JOY_BX_BIT      0x04
   17.63 -#define JOY_BY_BIT      0x08
   17.64 -#define JOY_B_BITS      (JOY_BX_BIT|JOY_BY_BIT)
   17.65 -#define JOY_ALLPOS_BITS (JOY_A_BITS|JOY_B_BITS)
   17.66 -
   17.67 -// bit masks for each button
   17.68 -#define JOY_BUT1_BIT    0x10
   17.69 -#define JOY_BUT2_BIT    0x20
   17.70 -#define JOY_BUT3_BIT    0x40
   17.71 -#define JOY_BUT4_BIT    0x80
   17.72 -#define JOY_ALL_BUTS    (JOY_BUT1_BIT|JOY_BUT2_BIT|JOY_BUT3_BIT|JOY_BUT4_BIT)
   17.73 -/****************************************************************************/
   17.74 -
   17.75 -/****************************************************************************/
   17.76 -// 1-D position struct used for each axis
   17.77 -typedef SHORT GAME_POS;         /* some data formats require signed values */
   17.78 -
   17.79 -// simple 2-D position for each joystick
   17.80 -typedef struct
   17.81 -{
   17.82 -    GAME_POS x;
   17.83 -    GAME_POS y;
   17.84 -}
   17.85 -GAME_2DPOS_STRUCT;
   17.86 -
   17.87 -// struct defining the instantaneous state of both sticks and all buttons
   17.88 -typedef struct
   17.89 -{
   17.90 -    GAME_2DPOS_STRUCT A;
   17.91 -    GAME_2DPOS_STRUCT B;
   17.92 -    USHORT butMask;
   17.93 -}
   17.94 -GAME_DATA_STRUCT;
   17.95 -
   17.96 -// struct to be used for calibration and digital response on each axis
   17.97 -typedef struct
   17.98 -{
   17.99 -    GAME_POS lower;
  17.100 -    GAME_POS centre;
  17.101 -    GAME_POS upper;
  17.102 -}
  17.103 -GAME_3POS_STRUCT;
  17.104 -/****************************************************************************/
  17.105 -
  17.106 -/****************************************************************************/
  17.107 -// status struct returned to OS/2 applications:
  17.108 -// current data for all sticks as well as button counts since last read
  17.109 -typedef struct
  17.110 -{
  17.111 -    GAME_DATA_STRUCT curdata;
  17.112 -    USHORT b1cnt;
  17.113 -    USHORT b2cnt;
  17.114 -    USHORT b3cnt;
  17.115 -    USHORT b4cnt;
  17.116 -}
  17.117 -GAME_STATUS_STRUCT;
  17.118 -/****************************************************************************/
  17.119 -
  17.120 -/****************************************************************************/
  17.121 -/* in use bitmasks originating in 0.2b */
  17.122 -#define GAME_USE_BOTH_OLDMASK   0x01    /* for backward compat with bool */
  17.123 -#define GAME_USE_X_NEWMASK      0x02
  17.124 -#define GAME_USE_Y_NEWMASK      0x04
  17.125 -#define GAME_USE_X_EITHERMASK   (GAME_USE_X_NEWMASK|GAME_USE_BOTH_OLDMASK)
  17.126 -#define GAME_USE_Y_EITHERMASK   (GAME_USE_Y_NEWMASK|GAME_USE_BOTH_OLDMASK)
  17.127 -#define GAME_USE_BOTH_NEWMASK   (GAME_USE_X_NEWMASK|GAME_USE_Y_NEWMASK)
  17.128 -
  17.129 -/* only timed sampling implemented in version 1.0 */
  17.130 -#define GAME_MODE_TIMED         1       /* timed sampling */
  17.131 -#define GAME_MODE_REQUEST       2       /* request driven sampling */
  17.132 -
  17.133 -/* only raw implemented in version 1.0 */
  17.134 -#define GAME_DATA_FORMAT_RAW    1       /* [l,c,r]   */
  17.135 -#define GAME_DATA_FORMAT_SIGNED 2       /* [-l,0,+r] */
  17.136 -#define GAME_DATA_FORMAT_BINARY 3       /* {-1,0,+1} */
  17.137 -#define GAME_DATA_FORMAT_SCALED 4       /* [-10,+10] */
  17.138 -
  17.139 -// parameters defining the operation of the driver
  17.140 -typedef struct
  17.141 -{
  17.142 -    USHORT useA;                /* new bitmasks: see above */
  17.143 -    USHORT useB;
  17.144 -    USHORT mode;                /* see consts above */
  17.145 -    USHORT format;              /* see consts above */
  17.146 -    USHORT sampDiv;             /* samp freq = 32 / n */
  17.147 -    USHORT scale;               /* scaling factor */
  17.148 -    USHORT res1;                /* must be 0 */
  17.149 -    USHORT res2;                /* must be 0 */
  17.150 -}
  17.151 -GAME_PARM_STRUCT;
  17.152 -/****************************************************************************/
  17.153 -
  17.154 -/****************************************************************************/
  17.155 -// calibration values for each axis:
  17.156 -//      - upper limit on value to be considered in lower range
  17.157 -//      - centre value
  17.158 -//      - lower limit on value to be considered in upper range
  17.159 -typedef struct
  17.160 -{
  17.161 -    GAME_3POS_STRUCT Ax;
  17.162 -    GAME_3POS_STRUCT Ay;
  17.163 -    GAME_3POS_STRUCT Bx;
  17.164 -    GAME_3POS_STRUCT By;
  17.165 -}
  17.166 -GAME_CALIB_STRUCT;
  17.167 -/****************************************************************************/
  17.168 -
  17.169 -/****************************************************************************/
  17.170 -// struct defining the digital response values for all axes
  17.171 -typedef struct
  17.172 -{
  17.173 -    GAME_3POS_STRUCT Ax;
  17.174 -    GAME_3POS_STRUCT Ay;
  17.175 -    GAME_3POS_STRUCT Bx;
  17.176 -    GAME_3POS_STRUCT By;
  17.177 -}
  17.178 -GAME_DIGSET_STRUCT;
  17.179 -/****************************************************************************/
  17.180 -
  17.181 -#endif
  17.182 -/* vi: set ts=4 sw=4 expandtab: */
    18.1 --- a/src/loadso/os2/SDL_sysloadso.c	Sat Sep 19 06:24:07 2009 +0000
    18.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    18.3 @@ -1,77 +0,0 @@
    18.4 -/*
    18.5 -    SDL - Simple DirectMedia Layer
    18.6 -    Copyright (C) 1997-2009 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 Lesser General Public
   18.10 -    License as published by the Free Software Foundation; either
   18.11 -    version 2.1 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 -    Lesser General Public License for more details.
   18.17 -
   18.18 -    You should have received a copy of the GNU Lesser General Public
   18.19 -    License along with this library; if not, write to the Free Software
   18.20 -    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
   18.21 -
   18.22 -    Sam Lantinga
   18.23 -    slouken@libsdl.org
   18.24 -*/
   18.25 -#include "SDL_config.h"
   18.26 -
   18.27 -#ifdef SDL_LOADSO_OS2
   18.28 -
   18.29 -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
   18.30 -/* System dependent library loading routines                           */
   18.31 -
   18.32 -#include <stdio.h>
   18.33 -#define INCL_DOSERRORS
   18.34 -#define INCL_DOSMODULEMGR
   18.35 -#include <os2.h>
   18.36 -
   18.37 -#include "SDL_loadso.h"
   18.38 -
   18.39 -void *
   18.40 -SDL_LoadObject(const char *sofile)
   18.41 -{
   18.42 -    HMODULE handle = NULL;
   18.43 -    char buf[512];
   18.44 -    APIRET ulrc = DosLoadModule(buf, sizeof(buf), (char *) sofile, &handle);
   18.45 -
   18.46 -    /* Generate an error message if all loads failed */
   18.47 -    if ((ulrc != NO_ERROR) || (handle == NULL))
   18.48 -        SDL_SetError("Failed loading %s: %s", sofile, buf);
   18.49 -
   18.50 -    return ((void *) handle);
   18.51 -}
   18.52 -
   18.53 -void *
   18.54 -SDL_LoadFunction(void *handle, const char *name)
   18.55 -{
   18.56 -    const char *loaderror = "Unknown error";
   18.57 -    void *symbol = NULL;
   18.58 -    APIRET ulrc =
   18.59 -        DosQueryProcAddr((HMODULE) handle, 0, (char *) name, &symbol);
   18.60 -    if (ulrc == ERROR_INVALID_HANDLE)
   18.61 -        loaderror = "Invalid module handle";
   18.62 -    else if (ulrc == ERROR_INVALID_NAME)
   18.63 -        loaderror = "Symbol not found";
   18.64 -
   18.65 -    if (symbol == NULL)
   18.66 -        SDL_SetError("Failed loading %s: %s", name, loaderror);
   18.67 -
   18.68 -    return (symbol);
   18.69 -}
   18.70 -
   18.71 -void
   18.72 -SDL_UnloadObject(void *handle)
   18.73 -{
   18.74 -    if (handle != NULL)
   18.75 -        DosFreeModule((HMODULE) handle);
   18.76 -}
   18.77 -
   18.78 -#endif /* SDL_LOADSO_OS2 */
   18.79 -
   18.80 -/* vi: set ts=4 sw=4 expandtab: */
    19.1 --- a/src/power/SDL_power.c	Sat Sep 19 06:24:07 2009 +0000
    19.2 +++ b/src/power/SDL_power.c	Sat Sep 19 06:43:45 2009 +0000
    19.3 @@ -34,7 +34,6 @@
    19.4  SDL_bool SDL_GetPowerInfo_Linux_proc_apm(SDL_PowerState *, int *, int *);
    19.5  SDL_bool SDL_GetPowerInfo_Windows(SDL_PowerState *, int *, int *);
    19.6  SDL_bool SDL_GetPowerInfo_MacOSX(SDL_PowerState *, int *, int *);
    19.7 -SDL_bool SDL_GetPowerInfo_OS2(SDL_PowerState *, int *, int *);
    19.8  SDL_bool SDL_GetPowerInfo_BeOS(SDL_PowerState *, int *, int *);
    19.9  SDL_bool SDL_GetPowerInfo_NintendoDS(SDL_PowerState *, int *, int *);
   19.10  
   19.11 @@ -65,9 +64,6 @@
   19.12  #ifdef SDL_POWER_MACOSX         /* handles Mac OS X, Darwin, iPhone. */
   19.13      SDL_GetPowerInfo_MacOSX,
   19.14  #endif
   19.15 -#ifdef SDL_POWER_OS2            /* handles OS/2, Warp, eComStation. */
   19.16 -    SDL_GetPowerInfo_OS2,
   19.17 -#endif
   19.18  #ifdef SDL_POWER_NINTENDODS     /* handles Nintendo DS. */
   19.19      SDL_GetPowerInfo_NintendoDS,
   19.20  #endif
    20.1 --- a/src/power/os2/SDL_syspower.c	Sat Sep 19 06:24:07 2009 +0000
    20.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    20.3 @@ -1,135 +0,0 @@
    20.4 -/*
    20.5 -    SDL - Simple DirectMedia Layer
    20.6 -    Copyright (C) 1997-2009 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 Lesser General Public
   20.10 -    License as published by the Free Software Foundation; either
   20.11 -    version 2.1 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 -    Lesser General Public License for more details.
   20.17 -
   20.18 -    You should have received a copy of the GNU Lesser General Public
   20.19 -    License along with this library; if not, write to the Free Software
   20.20 -    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
   20.21 -
   20.22 -    Sam Lantinga
   20.23 -    slouken@libsdl.org
   20.24 -*/
   20.25 -#include "SDL_config.h"
   20.26 -
   20.27 -/* !!! FIXME:
   20.28 - * Please note that this code has not been tested (or even compiled!). It
   20.29 - *  should, in theory, run on any version of OS/2, and work with any system
   20.30 - *  that has APM.SYS loaded. I don't know if ACPI.SYS works.
   20.31 - */
   20.32 -
   20.33 -#ifndef SDL_POWER_DISABLED
   20.34 -#ifdef SDL_POWER_OS2
   20.35 -
   20.36 -#define INCL_DOSFILEMGR
   20.37 -#define INCL_DOSDEVICES
   20.38 -#define INCL_DOSDEVIOCTL
   20.39 -#define INCL_DOSERRORS
   20.40 -#include <os2.h>
   20.41 -
   20.42 -#include "SDL_power.h"
   20.43 -
   20.44 -typedef struct
   20.45 -{
   20.46 -    USHORT len;
   20.47 -    USHORT flags;
   20.48 -    UCHAR ac_status;
   20.49 -    UCHAR battery_status;
   20.50 -    UCHAR battery_life;
   20.51 -    UCHAR battery_time_form;
   20.52 -    USHORT battery_time;
   20.53 -    UCHAR battery_flags;
   20.54 -} PowerStatus;
   20.55 -extern int CompilerAssertPowerStatus[(sizeof(PowerStatus) == 10) ? 1 : -1];
   20.56 -
   20.57 -
   20.58 -SDL_bool
   20.59 -SDL_GetPowerInfo_OS2(SDL_PowerState * state, int *seconds, int *percent)
   20.60 -{
   20.61 -    PowerStatus status;
   20.62 -    HFILE hfile = 0;
   20.63 -    ULONG action = 0;
   20.64 -    APIRET rc = 0;
   20.65 -
   20.66 -    *state = SDL_POWERSTATE_UNKNOWN;
   20.67 -    *percent = -1;
   20.68 -    *seconds = -1;
   20.69 -
   20.70 -    /* open the power management device */
   20.71 -    rc = DosOpen("APM$", &hfile, &action, 0, FILE_NORMAL, FILE_OPEN,
   20.72 -                 OPEN_ACCESS_READONLY | OPEN_SHARE_DENYNONE, 0);
   20.73 -
   20.74 -    if (rc == NO_ERROR) {
   20.75 -        USHORT iorc = 0;
   20.76 -        ULONG iorclen = sizeof(iorc);
   20.77 -        ULONG statuslen = sizeof(status);
   20.78 -
   20.79 -        SDL_memset(&status, '\0', sizeof(status));
   20.80 -        status.len = sizeof(status);
   20.81 -
   20.82 -        rc = DosDevIOCtl(hfile, IOCTL_POWER, POWER_GETPOWERSTATUS, &status,
   20.83 -                         statuslen, &statuslen, &iorc, iorclen, &iorclen);
   20.84 -        DosClose(hfile);
   20.85 -
   20.86 -        /* (status.flags & 0x1) == power subsystem enabled. */
   20.87 -        if ((rc == NO_ERROR) && (status.flags & 0x1)) {
   20.88 -            if (statuslen == 7) {       /* older OS/2 APM driver? Less fields. */
   20.89 -                status.battery_time_form = 0xFF;
   20.90 -                status.battery_time = 0;
   20.91 -                if (status.battery_status == 0xFF) {
   20.92 -                    status.battery_flags = 0xFF;
   20.93 -                } else {
   20.94 -                    status.battery_flags = (1 << status.battery_status);
   20.95 -                }
   20.96 -            }
   20.97 -
   20.98 -            if (status.battery_flags == 0xFF) { /* unknown state */
   20.99 -                *state = SDL_POWERSTATE_UNKNOWN;
  20.100 -            } else if (status.battery_flags & (1 << 7)) {       /* no battery */
  20.101 -                *state = SDL_POWERSTATE_NO_BATTERY;
  20.102 -            } else if (status.battery_flags & (1 << 3)) {       /* charging */
  20.103 -                *state = SDL_POWERSTATE_CHARGING;
  20.104 -                need_details = SDL_TRUE;
  20.105 -            } else if (status.ac_status == 1) {
  20.106 -                *state = SDL_POWERSTATE_CHARGED;        /* on AC, not charging. */
  20.107 -                need_details = SDL_TRUE;
  20.108 -            } else {
  20.109 -                *state = SDL_POWERSTATE_ON_BATTERY;     /* not on AC. */
  20.110 -                need_details = SDL_TRUE;
  20.111 -            }
  20.112 -
  20.113 -            if (need_details) {
  20.114 -                const int pct = (int) status.battery_life;
  20.115 -                const int secs = (int) status.battery_time;
  20.116 -
  20.117 -                if (pct != 0xFF) {      /* 255 == unknown */
  20.118 -                    *percent = (pct > 100) ? 100 : pct;
  20.119 -                }
  20.120 -
  20.121 -                if (status.battery_time_form == 0xFF) { /* unknown */
  20.122 -                    *seconds = -1;
  20.123 -                } else if (status.battery_time_form == 1) {     /* minutes */
  20.124 -                    *seconds = secs * 60;
  20.125 -                } else {
  20.126 -                    *seconds = secs;
  20.127 -                }
  20.128 -            }
  20.129 -        }
  20.130 -    }
  20.131 -
  20.132 -    return SDL_TRUE;            /* always the definitive answer on OS/2. */
  20.133 -}
  20.134 -
  20.135 -#endif /* SDL_POWER_OS2 */
  20.136 -#endif /* SDL_POWER_DISABLED */
  20.137 -
  20.138 -/* vi: set ts=4 sw=4 expandtab: */
    21.1 --- a/src/thread/SDL_thread_c.h	Sat Sep 19 06:24:07 2009 +0000
    21.2 +++ b/src/thread/SDL_thread_c.h	Sat Sep 19 06:43:45 2009 +0000
    21.3 @@ -33,8 +33,6 @@
    21.4  #include "dc/SDL_systhread_c.h"
    21.5  #elif SDL_THREAD_EPOC
    21.6  #include "epoc/SDL_systhread_c.h"
    21.7 -#elif SDL_THREAD_OS2
    21.8 -#include "os2/SDL_systhread_c.h"
    21.9  #elif SDL_THREAD_PTH
   21.10  #include "pth/SDL_systhread_c.h"
   21.11  #elif SDL_THREAD_PTHREAD
    22.1 --- a/src/thread/os2/SDL_syscond.c	Sat Sep 19 06:24:07 2009 +0000
    22.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    22.3 @@ -1,223 +0,0 @@
    22.4 -/*
    22.5 -    SDL - Simple DirectMedia Layer
    22.6 -    Copyright (C) 1997-2009 Sam Lantinga
    22.7 -
    22.8 -    This library is free software; you can redistribute it and/or
    22.9 -    modify it under the terms of the GNU Lesser General Public
   22.10 -    License as published by the Free Software Foundation; either
   22.11 -    version 2.1 of the License, or (at your option) any later version.
   22.12 -
   22.13 -    This library is distributed in the hope that it will be useful,
   22.14 -    but WITHOUT ANY WARRANTY; without even the implied warranty of
   22.15 -    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   22.16 -    Lesser General Public License for more details.
   22.17 -
   22.18 -    You should have received a copy of the GNU Lesser General Public
   22.19 -    License along with this library; if not, write to the Free Software
   22.20 -    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
   22.21 -
   22.22 -    Sam Lantinga
   22.23 -    slouken@libsdl.org
   22.24 -*/
   22.25 -#include "SDL_config.h"
   22.26 -
   22.27 -/* An implementation of condition variables using semaphores and mutexes */
   22.28 -/*
   22.29 -   This implementation borrows heavily from the BeOS condition variable
   22.30 -   implementation, written by Christopher Tate and Owen Smith.  Thanks!
   22.31 - */
   22.32 -
   22.33 -#include "SDL_thread.h"
   22.34 -
   22.35 -struct SDL_cond
   22.36 -{
   22.37 -    SDL_mutex *lock;
   22.38 -    int waiting;
   22.39 -    int signals;
   22.40 -    SDL_sem *wait_sem;
   22.41 -    SDL_sem *wait_done;
   22.42 -};
   22.43 -
   22.44 -/* Create a condition variable */
   22.45 -DECLSPEC SDL_cond *SDLCALL
   22.46 -SDL_CreateCond(void)
   22.47 -{
   22.48 -    SDL_cond *cond;
   22.49 -
   22.50 -    cond = (SDL_cond *) SDL_malloc(sizeof(SDL_cond));
   22.51 -    if (cond) {
   22.52 -        cond->lock = SDL_CreateMutex();
   22.53 -        cond->wait_sem = SDL_CreateSemaphore(0);
   22.54 -        cond->wait_done = SDL_CreateSemaphore(0);
   22.55 -        cond->waiting = cond->signals = 0;
   22.56 -        if (!cond->lock || !cond->wait_sem || !cond->wait_done) {
   22.57 -            SDL_DestroyCond(cond);
   22.58 -            cond = NULL;
   22.59 -        }
   22.60 -    } else {
   22.61 -        SDL_OutOfMemory();
   22.62 -    }
   22.63 -    return (cond);
   22.64 -}
   22.65 -
   22.66 -/* Destroy a condition variable */
   22.67 -DECLSPEC void SDLCALL
   22.68 -SDL_DestroyCond(SDL_cond * cond)
   22.69 -{
   22.70 -    if (cond) {
   22.71 -        if (cond->wait_sem) {
   22.72 -            SDL_DestroySemaphore(cond->wait_sem);
   22.73 -        }
   22.74 -        if (cond->wait_done) {
   22.75 -            SDL_DestroySemaphore(cond->wait_done);
   22.76 -        }
   22.77 -        if (cond->lock) {
   22.78 -            SDL_DestroyMutex(cond->lock);
   22.79 -        }
   22.80 -        SDL_free(cond);
   22.81 -    }
   22.82 -}
   22.83 -
   22.84 -/* Restart one of the threads that are waiting on the condition variable */
   22.85 -DECLSPEC int SDLCALL
   22.86 -SDL_CondSignal(SDL_cond * cond)
   22.87 -{
   22.88 -    if (!cond) {
   22.89 -        SDL_SetError("Passed a NULL condition variable");
   22.90 -        return -1;
   22.91 -    }
   22.92 -
   22.93 -    /* If there are waiting threads not already signalled, then
   22.94 -       signal the condition and wait for the thread to respond.
   22.95 -     */
   22.96 -    SDL_LockMutex(cond->lock);
   22.97 -    if (cond->waiting > cond->signals) {
   22.98 -        ++cond->signals;
   22.99 -        SDL_SemPost(cond->wait_sem);
  22.100 -        SDL_UnlockMutex(cond->lock);
  22.101 -        SDL_SemWait(cond->wait_done);
  22.102 -    } else {
  22.103 -        SDL_UnlockMutex(cond->lock);
  22.104 -    }
  22.105 -
  22.106 -    return 0;
  22.107 -}
  22.108 -
  22.109 -/* Restart all threads that are waiting on the condition variable */
  22.110 -DECLSPEC int SDLCALL
  22.111 -SDL_CondBroadcast(SDL_cond * cond)
  22.112 -{
  22.113 -    if (!cond) {
  22.114 -        SDL_SetError("Passed a NULL condition variable");
  22.115 -        return -1;
  22.116 -    }
  22.117 -
  22.118 -    /* If there are waiting threads not already signalled, then
  22.119 -       signal the condition and wait for the thread to respond.
  22.120 -     */
  22.121 -    SDL_LockMutex(cond->lock);
  22.122 -    if (cond->waiting > cond->signals) {
  22.123 -        int i, num_waiting;
  22.124 -
  22.125 -        num_waiting = (cond->waiting - cond->signals);
  22.126 -        cond->signals = cond->waiting;
  22.127 -        for (i = 0; i < num_waiting; ++i) {
  22.128 -            SDL_SemPost(cond->wait_sem);
  22.129 -        }
  22.130 -        /* Now all released threads are blocked here, waiting for us.
  22.131 -           Collect them all (and win fabulous prizes!) :-)
  22.132 -         */
  22.133 -        SDL_UnlockMutex(cond->lock);
  22.134 -        for (i = 0; i < num_waiting; ++i) {
  22.135 -            SDL_SemWait(cond->wait_done);
  22.136 -        }
  22.137 -    } else {
  22.138 -        SDL_UnlockMutex(cond->lock);
  22.139 -    }
  22.140 -
  22.141 -    return 0;
  22.142 -}
  22.143 -
  22.144 -/* Wait on the condition variable for at most 'ms' milliseconds.
  22.145 -   The mutex must be locked before entering this function!
  22.146 -   The mutex is unlocked during the wait, and locked again after the wait.
  22.147 -
  22.148 -Typical use:
  22.149 -
  22.150 -Thread A:
  22.151 -	SDL_LockMutex(lock);
  22.152 -	while ( ! condition ) {
  22.153 -		SDL_CondWait(cond);
  22.154 -	}
  22.155 -	SDL_UnlockMutex(lock);
  22.156 -
  22.157 -Thread B:
  22.158 -	SDL_LockMutex(lock);
  22.159 -	...
  22.160 -	condition = true;
  22.161 -	...
  22.162 -	SDL_UnlockMutex(lock);
  22.163 - */
  22.164 -DECLSPEC int SDLCALL
  22.165 -SDL_CondWaitTimeout(SDL_cond * cond, SDL_mutex * mutex, Uint32 ms)
  22.166 -{
  22.167 -    int retval;
  22.168 -
  22.169 -    if (!cond) {
  22.170 -        SDL_SetError("Passed a NULL condition variable");
  22.171 -        return -1;
  22.172 -    }
  22.173 -
  22.174 -    /* Obtain the protection mutex, and increment the number of waiters.
  22.175 -       This allows the signal mechanism to only perform a signal if there
  22.176 -       are waiting threads.
  22.177 -     */
  22.178 -    SDL_LockMutex(cond->lock);
  22.179 -    ++cond->waiting;
  22.180 -    SDL_UnlockMutex(cond->lock);
  22.181 -
  22.182 -    /* Unlock the mutex, as is required by condition variable semantics */
  22.183 -    SDL_UnlockMutex(mutex);
  22.184 -
  22.185 -    /* Wait for a signal */
  22.186 -    if (ms == SDL_MUTEX_MAXWAIT) {
  22.187 -        retval = SDL_SemWait(cond->wait_sem);
  22.188 -    } else {
  22.189 -        retval = SDL_SemWaitTimeout(cond->wait_sem, ms);
  22.190 -    }
  22.191 -
  22.192 -    /* Let the signaler know we have completed the wait, otherwise
  22.193 -       the signaler can race ahead and get the condition semaphore
  22.194 -       if we are stopped between the mutex unlock and semaphore wait,
  22.195 -       giving a deadlock.  See the following URL for details:
  22.196 -       http://www-classic.be.com/aboutbe/benewsletter/volume_III/Issue40.html
  22.197 -     */
  22.198 -    SDL_LockMutex(cond->lock);
  22.199 -    if (cond->signals > 0) {
  22.200 -        /* If we timed out, we need to eat a condition signal */
  22.201 -        if (retval > 0) {
  22.202 -            SDL_SemWait(cond->wait_sem);
  22.203 -        }
  22.204 -        /* We always notify the signal thread that we are done */
  22.205 -        SDL_SemPost(cond->wait_done);
  22.206 -
  22.207 -        /* Signal handshake complete */
  22.208 -        --cond->signals;
  22.209 -    }
  22.210 -    --cond->waiting;
  22.211 -    SDL_UnlockMutex(cond->lock);
  22.212 -
  22.213 -    /* Lock the mutex, as is required by condition variable semantics */
  22.214 -    SDL_LockMutex(mutex);
  22.215 -
  22.216 -    return retval;
  22.217 -}
  22.218 -
  22.219 -/* Wait on the condition variable forever */
  22.220 -DECLSPEC int SDLCALL
  22.221 -SDL_CondWait(SDL_cond * cond, SDL_mutex * mutex)
  22.222 -{
  22.223 -    return SDL_CondWaitTimeout(cond, mutex, SDL_MUTEX_MAXWAIT);
  22.224 -}
  22.225 -
  22.226 -/* vi: set ts=4 sw=4 expandtab: */
    23.1 --- a/src/thread/os2/SDL_syscond_c.h	Sat Sep 19 06:24:07 2009 +0000
    23.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    23.3 @@ -1,23 +0,0 @@
    23.4 -/*
    23.5 -    SDL - Simple DirectMedia Layer
    23.6 -    Copyright (C) 1997-2009 Sam Lantinga
    23.7 -
    23.8 -    This library is free software; you can redistribute it and/or
    23.9 -    modify it under the terms of the GNU Lesser General Public
   23.10 -    License as published by the Free Software Foundation; either
   23.11 -    version 2.1 of the License, or (at your option) any later version.
   23.12 -
   23.13 -    This library is distributed in the hope that it will be useful,
   23.14 -    but WITHOUT ANY WARRANTY; without even the implied warranty of
   23.15 -    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   23.16 -    Lesser General Public License for more details.
   23.17 -
   23.18 -    You should have received a copy of the GNU Lesser General Public
   23.19 -    License along with this library; if not, write to the Free Software
   23.20 -    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
   23.21 -
   23.22 -    Sam Lantinga
   23.23 -    slouken@libsdl.org
   23.24 -*/
   23.25 -#include "SDL_config.h"
   23.26 -/* vi: set ts=4 sw=4 expandtab: */
    24.1 --- a/src/thread/os2/SDL_sysmutex.c	Sat Sep 19 06:24:07 2009 +0000
    24.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    24.3 @@ -1,107 +0,0 @@
    24.4 -/*
    24.5 -    SDL - Simple DirectMedia Layer
    24.6 -    Copyright (C) 1997-2009 Sam Lantinga
    24.7 -
    24.8 -    This library is free software; you can redistribute it and/or
    24.9 -    modify it under the terms of the GNU Lesser General Public
   24.10 -    License as published by the Free Software Foundation; either
   24.11 -    version 2.1 of the License, or (at your option) any later version.
   24.12 -
   24.13 -    This library is distributed in the hope that it will be useful,
   24.14 -    but WITHOUT ANY WARRANTY; without even the implied warranty of
   24.15 -    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   24.16 -    Lesser General Public License for more details.
   24.17 -
   24.18 -    You should have received a copy of the GNU Lesser General Public
   24.19 -    License along with this library; if not, write to the Free Software
   24.20 -    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
   24.21 -
   24.22 -    Sam Lantinga
   24.23 -    slouken@libsdl.org
   24.24 -*/
   24.25 -#include "SDL_config.h"
   24.26 -
   24.27 -/* Mutex functions using the OS/2 API */
   24.28 -
   24.29 -#define INCL_DOSERRORS
   24.30 -#define INCL_DOSSEMAPHORES
   24.31 -#include <os2.h>
   24.32 -
   24.33 -#include "SDL_mutex.h"
   24.34 -
   24.35 -
   24.36 -struct SDL_mutex
   24.37 -{
   24.38 -    HMTX hmtxID;
   24.39 -};
   24.40 -
   24.41 -/* Create a mutex */
   24.42 -DECLSPEC SDL_mutex *SDLCALL
   24.43 -SDL_CreateMutex(void)
   24.44 -{
   24.45 -    SDL_mutex *mutex;
   24.46 -    APIRET ulrc;
   24.47 -
   24.48 -    /* Allocate mutex memory */
   24.49 -    mutex = (SDL_mutex *) SDL_malloc(sizeof(*mutex));
   24.50 -    if (mutex) {
   24.51 -        /* Create the mutex, with initial value signaled */
   24.52 -        ulrc = DosCreateMutexSem(NULL,  // Create unnamed semaphore
   24.53 -                                 &(mutex->hmtxID),      // Pointer to handle
   24.54 -                                 0L,    // Flags: create it private (not shared)
   24.55 -                                 FALSE);        // Initial value: unowned
   24.56 -        if (ulrc != NO_ERROR) {
   24.57 -            SDL_SetError("Couldn't create mutex");
   24.58 -            SDL_free(mutex);
   24.59 -            mutex = NULL;
   24.60 -        }
   24.61 -    } else {
   24.62 -        SDL_OutOfMemory();
   24.63 -    }
   24.64 -    return (mutex);
   24.65 -}
   24.66 -
   24.67 -/* Free the mutex */
   24.68 -DECLSPEC void SDLCALL
   24.69 -SDL_DestroyMutex(SDL_mutex * mutex)
   24.70 -{
   24.71 -    if (mutex) {
   24.72 -        if (mutex->hmtxID) {
   24.73 -            DosCloseMutexSem(mutex->hmtxID);
   24.74 -            mutex->hmtxID = 0;
   24.75 -        }
   24.76 -        SDL_free(mutex);
   24.77 -    }
   24.78 -}
   24.79 -
   24.80 -/* Lock the mutex */
   24.81 -DECLSPEC int SDLCALL
   24.82 -SDL_mutexP(SDL_mutex * mutex)
   24.83 -{
   24.84 -    if (mutex == NULL) {
   24.85 -        SDL_SetError("Passed a NULL mutex");
   24.86 -        return -1;
   24.87 -    }
   24.88 -    if (DosRequestMutexSem(mutex->hmtxID, SEM_INDEFINITE_WAIT) != NO_ERROR) {
   24.89 -        SDL_SetError("Couldn't wait on mutex");
   24.90 -        return -1;
   24.91 -    }
   24.92 -    return (0);
   24.93 -}
   24.94 -
   24.95 -/* Unlock the mutex */
   24.96 -DECLSPEC int SDLCALL
   24.97 -SDL_mutexV(SDL_mutex * mutex)
   24.98 -{
   24.99 -    if (mutex == NULL) {
  24.100 -        SDL_SetError("Passed a NULL mutex");
  24.101 -        return -1;
  24.102 -    }
  24.103 -    if (DosReleaseMutexSem(mutex->hmtxID) != NO_ERROR) {
  24.104 -        SDL_SetError("Couldn't release mutex");
  24.105 -        return -1;
  24.106 -    }
  24.107 -    return (0);
  24.108 -}
  24.109 -
  24.110 -/* vi: set ts=4 sw=4 expandtab: */
    25.1 --- a/src/thread/os2/SDL_syssem.c	Sat Sep 19 06:24:07 2009 +0000
    25.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    25.3 @@ -1,194 +0,0 @@
    25.4 -/*
    25.5 -    SDL - Simple DirectMedia Layer
    25.6 -    Copyright (C) 1997-2009 Sam Lantinga
    25.7 -
    25.8 -    This library is free software; you can redistribute it and/or
    25.9 -    modify it under the terms of the GNU Lesser General Public
   25.10 -    License as published by the Free Software Foundation; either
   25.11 -    version 2.1 of the License, or (at your option) any later version.
   25.12 -
   25.13 -    This library is distributed in the hope that it will be useful,
   25.14 -    but WITHOUT ANY WARRANTY; without even the implied warranty of
   25.15 -    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   25.16 -    Lesser General Public License for more details.
   25.17 -
   25.18 -    You should have received a copy of the GNU Lesser General Public
   25.19 -    License along with this library; if not, write to the Free Software
   25.20 -    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
   25.21 -
   25.22 -    Sam Lantinga
   25.23 -    slouken@libsdl.org
   25.24 -*/
   25.25 -#include "SDL_config.h"
   25.26 -
   25.27 -/* Semaphore functions using the OS/2 API */
   25.28 -
   25.29 -#define INCL_DOS
   25.30 -#define INCL_DOSERRORS
   25.31 -#define INCL_DOSSEMAPHORES
   25.32 -#include <os2.h>
   25.33 -
   25.34 -#include "SDL_thread.h"
   25.35 -#include "SDL_timer.h"
   25.36 -
   25.37 -
   25.38 -struct SDL_semaphore
   25.39 -{
   25.40 -    HMTX id;
   25.41 -    HEV changed;
   25.42 -    Uint32 value;
   25.43 -};
   25.44 -
   25.45 -
   25.46 -/* Create a semaphore */
   25.47 -DECLSPEC SDL_sem *SDLCALL
   25.48 -SDL_CreateSemaphore(Uint32 initial_value)
   25.49 -{
   25.50 -    SDL_sem *sem;
   25.51 -    ULONG ulrc;
   25.52 -
   25.53 -    /* Allocate sem memory */
   25.54 -    sem = (SDL_sem *) SDL_malloc(sizeof(*sem));
   25.55 -    if (sem) {
   25.56 -        /* Create the mutex semaphore */
   25.57 -        ulrc = DosCreateMutexSem(NULL, &(sem->id), 0, TRUE);
   25.58 -        if (ulrc) {
   25.59 -            SDL_SetError("Couldn't create semaphore");
   25.60 -            SDL_free(sem);
   25.61 -            sem = NULL;
   25.62 -        } else {
   25.63 -            DosCreateEventSem(NULL, &(sem->changed), 0, FALSE);
   25.64 -            sem->value = initial_value;
   25.65 -            DosReleaseMutexSem(sem->id);
   25.66 -        }
   25.67 -    } else {
   25.68 -        SDL_OutOfMemory();
   25.69 -    }
   25.70 -    return (sem);
   25.71 -}
   25.72 -
   25.73 -/* Free the semaphore */
   25.74 -DECLSPEC void SDLCALL
   25.75 -SDL_DestroySemaphore(SDL_sem * sem)
   25.76 -{
   25.77 -    if (sem) {
   25.78 -        if (sem->id) {
   25.79 -            DosCloseEventSem(sem->changed);
   25.80 -            DosCloseMutexSem(sem->id);
   25.81 -            sem->id = 0;
   25.82 -        }
   25.83 -        SDL_free(sem);
   25.84 -    }
   25.85 -}
   25.86 -
   25.87 -DECLSPEC int SDLCALL
   25.88 -SDL_SemWaitTimeout(SDL_sem * sem, Uint32 timeout)
   25.89 -{
   25.90 -    ULONG ulrc;
   25.91 -
   25.92 -    if (!sem) {
   25.93 -        SDL_SetError("Passed a NULL sem");
   25.94 -        return -1;
   25.95 -    }
   25.96 -
   25.97 -    if (timeout == SDL_MUTEX_MAXWAIT) {
   25.98 -        while (1) {
   25.99 -            ulrc = DosRequestMutexSem(sem->id, SEM_INDEFINITE_WAIT);
  25.100 -            if (ulrc) {
  25.101 -                /* if error waiting mutex */
  25.102 -                SDL_SetError("DosRequestMutexSem() failed");
  25.103 -                return -1;
  25.104 -            } else if (sem->value) {
  25.105 -                sem->value--;
  25.106 -                DosReleaseMutexSem(sem->id);
  25.107 -                return 0;
  25.108 -            } else {
  25.109 -                ULONG ulPostCount;
  25.110 -                DosResetEventSem(sem->changed, &ulPostCount);
  25.111 -                DosReleaseMutexSem(sem->id);
  25.112 -                /* continue waiting until somebody posts the semaphore */
  25.113 -                DosWaitEventSem(sem->changed, SEM_INDEFINITE_WAIT);
  25.114 -            }
  25.115 -        }
  25.116 -    } else if (timeout == 0) {
  25.117 -        ulrc = DosRequestMutexSem(sem->id, SEM_INDEFINITE_WAIT);
  25.118 -        if (ulrc == NO_ERROR) {
  25.119 -            if (sem->value) {
  25.120 -                sem->value--;
  25.121 -                DosReleaseMutexSem(sem->id);
  25.122 -                return 0;
  25.123 -            } else {
  25.124 -                DosReleaseMutexSem(sem->id);
  25.125 -                return SDL_MUTEX_TIMEDOUT;
  25.126 -            }
  25.127 -        } else {
  25.128 -            SDL_SetError("DosRequestMutexSem() failed");
  25.129 -            return -1;
  25.130 -        }
  25.131 -    } else {
  25.132 -        ulrc = DosRequestMutexSem(sem->id, SEM_INDEFINITE_WAIT);
  25.133 -        if (ulrc) {
  25.134 -            /* if error waiting mutex */
  25.135 -            SDL_SetError("DosRequestMutexSem() failed");
  25.136 -            return -1;
  25.137 -        } else if (sem->value) {
  25.138 -            sem->value--;
  25.139 -            DosReleaseMutexSem(sem->id);
  25.140 -            return 0;
  25.141 -        } else {
  25.142 -            ULONG ulPostCount;
  25.143 -            DosResetEventSem(sem->changed, &ulPostCount);
  25.144 -            DosReleaseMutexSem(sem->id);
  25.145 -            /* continue waiting until somebody posts the semaphore */
  25.146 -            ulrc = DosWaitEventSem(sem->changed, timeout);
  25.147 -            if (ulrc == NO_ERROR)
  25.148 -                return 0;
  25.149 -            else
  25.150 -                return SDL_MUTEX_TIMEDOUT;
  25.151 -        }
  25.152 -    }
  25.153 -    /* never reached */
  25.154 -    return -1;
  25.155 -}
  25.156 -
  25.157 -DECLSPEC int SDLCALL
  25.158 -SDL_SemTryWait(SDL_sem * sem)
  25.159 -{
  25.160 -    return SDL_SemWaitTimeout(sem, 0);
  25.161 -}
  25.162 -
  25.163 -DECLSPEC int SDLCALL
  25.164 -SDL_SemWait(SDL_sem * sem)
  25.165 -{
  25.166 -    return SDL_SemWaitTimeout(sem, SDL_MUTEX_MAXWAIT);
  25.167 -}
  25.168 -
  25.169 -/* Returns the current count of the semaphore */
  25.170 -DECLSPEC Uint32 SDLCALL
  25.171 -SDL_SemValue(SDL_sem * sem)
  25.172 -{
  25.173 -    if (!sem) {
  25.174 -        SDL_SetError("Passed a NULL sem");
  25.175 -        return 0;
  25.176 -    }
  25.177 -    return sem->value;
  25.178 -}
  25.179 -
  25.180 -DECLSPEC int SDLCALL
  25.181 -SDL_SemPost(SDL_sem * sem)
  25.182 -{
  25.183 -    if (!sem) {
  25.184 -        SDL_SetError("Passed a NULL sem");
  25.185 -        return -1;
  25.186 -    }
  25.187 -    if (DosRequestMutexSem(sem->id, SEM_INDEFINITE_WAIT)) {
  25.188 -        SDL_SetError("DosRequestMutexSem() failed");
  25.189 -        return -1;
  25.190 -    }
  25.191 -    sem->value++;
  25.192 -    DosPostEventSem(sem->changed);
  25.193 -    DosReleaseMutexSem(sem->id);
  25.194 -    return 0;
  25.195 -}
  25.196 -
  25.197 -/* vi: set ts=4 sw=4 expandtab: */
    26.1 --- a/src/thread/os2/SDL_systhread.c	Sat Sep 19 06:24:07 2009 +0000
    26.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    26.3 @@ -1,105 +0,0 @@
    26.4 -/*
    26.5 -    SDL - Simple DirectMedia Layer
    26.6 -    Copyright (C) 1997-2009 Sam Lantinga
    26.7 -
    26.8 -    This library is free software; you can redistribute it and/or
    26.9 -    modify it under the terms of the GNU Lesser General Public
   26.10 -    License as published by the Free Software Foundation; either
   26.11 -    version 2.1 of the License, or (at your option) any later version.
   26.12 -
   26.13 -    This library is distributed in the hope that it will be useful,
   26.14 -    but WITHOUT ANY WARRANTY; without even the implied warranty of
   26.15 -    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   26.16 -    Lesser General Public License for more details.
   26.17 -
   26.18 -    You should have received a copy of the GNU Lesser General Public
   26.19 -    License along with this library; if not, write to the Free Software
   26.20 -    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
   26.21 -
   26.22 -    Sam Lantinga
   26.23 -    slouken@libsdl.org
   26.24 -*/
   26.25 -#include "SDL_config.h"
   26.26 -
   26.27 -/* OS/2 thread management routines for SDL */
   26.28 -
   26.29 -#include <process.h>
   26.30 -#define INCL_DOSERRORS
   26.31 -#define INCL_DOSPROCESS
   26.32 -#include <os2.h>
   26.33 -
   26.34 -#include "SDL_thread.h"
   26.35 -#include "../SDL_systhread.h"
   26.36 -#include "../SDL_thread_c.h"
   26.37 -
   26.38 -typedef struct ThreadStartParms
   26.39 -{
   26.40 -    void *args;
   26.41 -    pfnSDL_CurrentEndThread pfnCurrentEndThread;
   26.42 -} tThreadStartParms, *pThreadStartParms;
   26.43 -
   26.44 -static void
   26.45 -threadfunc(void *pparm)
   26.46 -{
   26.47 -    pThreadStartParms pThreadParms = pparm;
   26.48 -    pfnSDL_CurrentEndThread pfnCurrentEndThread = NULL;
   26.49 -
   26.50 -    // Call the thread function!
   26.51 -    SDL_RunThread(pThreadParms->args);
   26.52 -
   26.53 -    // Get the current endthread we have to use!
   26.54 -    if (pThreadParms) {
   26.55 -        pfnCurrentEndThread = pThreadParms->pfnCurrentEndThread;
   26.56 -        SDL_free(pThreadParms);
   26.57 -    }
   26.58 -    // Call endthread!
   26.59 -    if (pfnCurrentEndThread)
   26.60 -        (*pfnCurrentEndThread) ();
   26.61 -}
   26.62 -
   26.63 -int
   26.64 -SDL_SYS_CreateThread(SDL_Thread * thread, void *args,
   26.65 -                     pfnSDL_CurrentBeginThread pfnBeginThread,
   26.66 -                     pfnSDL_CurrentEndThread pfnEndThread)
   26.67 -{
   26.68 -    pThreadStartParms pThreadParms = SDL_malloc(sizeof(tThreadStartParms));
   26.69 -    if (!pThreadParms) {
   26.70 -        SDL_SetError("Not enough memory to create thread");
   26.71 -        return (-1);
   26.72 -    }
   26.73 -    // Save the function which we will have to call to clear the RTL of calling app!
   26.74 -    pThreadParms->pfnCurrentEndThread = pfnEndThread;
   26.75 -    // Also save the real parameters we have to pass to thread function
   26.76 -    pThreadParms->args = args;
   26.77 -    // Start the thread using the runtime library of calling app!
   26.78 -    thread->threadid = thread->handle =
   26.79 -        (*pfnBeginThread) (threadfunc, NULL, 512 * 1024, pThreadParms);
   26.80 -    if ((int) thread->threadid <= 0) {
   26.81 -        SDL_SetError("Not enough resources to create thread");
   26.82 -        return (-1);
   26.83 -    }
   26.84 -    return (0);
   26.85 -}
   26.86 -
   26.87 -void
   26.88 -SDL_SYS_SetupThread(void)
   26.89 -{
   26.90 -    return;
   26.91 -}
   26.92 -
   26.93 -DECLSPEC Uint32 SDLCALL
   26.94 -SDL_ThreadID(void)
   26.95 -{
   26.96 -    PTIB tib;
   26.97 -    DosGetInfoBlocks(&tib, NULL);
   26.98 -    return ((Uint32) (tib->tib_ptib2->tib2_ultid));
   26.99 -}
  26.100 -
  26.101 -void
  26.102 -SDL_SYS_WaitThread(SDL_Thread * thread)
  26.103 -{
  26.104 -    TID tid = thread->handle;
  26.105 -    DosWaitThread(&tid, DCWW_WAIT);
  26.106 -}
  26.107 -
  26.108 -/* vi: set ts=4 sw=4 expandtab: */
    27.1 --- a/src/thread/os2/SDL_systhread_c.h	Sat Sep 19 06:24:07 2009 +0000
    27.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    27.3 @@ -1,28 +0,0 @@
    27.4 -/*
    27.5 -    SDL - Simple DirectMedia Layer
    27.6 -    Copyright (C) 1997-2009 Sam Lantinga
    27.7 -
    27.8 -    This library is free software; you can redistribute it and/or
    27.9 -    modify it under the terms of the GNU Library General Public
   27.10 -    License as published by the Free Software Foundation; either
   27.11 -    version 2 of the License, or (at your option) any later version.
   27.12 -
   27.13 -    This library is distributed in the hope that it will be useful,
   27.14 -    but WITHOUT ANY WARRANTY; without even the implied warranty of
   27.15 -    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   27.16 -    Library General Public License for more details.
   27.17 -
   27.18 -    You should have received a copy of the GNU Library General Public
   27.19 -    License along with this library; if not, write to the Free
   27.20 -    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   27.21 -
   27.22 -    Sam Lantinga
   27.23 -    slouken@libsdl.org
   27.24 -*/
   27.25 -#include "SDL_config.h"
   27.26 -
   27.27 -#define INCL_DOSPROCESS
   27.28 -#include <os2.h>
   27.29 -
   27.30 -typedef TID SYS_ThreadHandle;
   27.31 -/* vi: set ts=4 sw=4 expandtab: */
    28.1 --- a/src/timer/os2/SDL_systimer.c	Sat Sep 19 06:24:07 2009 +0000
    28.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    28.3 @@ -1,235 +0,0 @@
    28.4 -/*
    28.5 -    SDL - Simple DirectMedia Layer
    28.6 -    Copyright (C) 1997-2009 Sam Lantinga
    28.7 -
    28.8 -    This library is free software; you can redistribute it and/or
    28.9 -    modify it under the terms of the GNU Lesser General Public
   28.10 -    License as published by the Free Software Foundation; either
   28.11 -    version 2.1 of the License, or (at your option) any later version.
   28.12 -
   28.13 -    This library is distributed in the hope that it will be useful,
   28.14 -    but WITHOUT ANY WARRANTY; without even the implied warranty of
   28.15 -    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   28.16 -    Lesser General Public License for more details.
   28.17 -
   28.18 -    You should have received a copy of the GNU Lesser General Public
   28.19 -    License along with this library; if not, write to the Free Software
   28.20 -    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
   28.21 -
   28.22 -    Sam Lantinga
   28.23 -    slouken@libsdl.org
   28.24 -*/
   28.25 -#include "SDL_config.h"
   28.26 -
   28.27 -#ifdef SDL_TIMER_OS2
   28.28 -
   28.29 -#define INCL_DOSMISC
   28.30 -#define INCL_DOSERRORS
   28.31 -#define INCL_DOSSEMAPHORES
   28.32 -#define INCL_DOSDATETIME
   28.33 -#define INCL_DOSPROCESS
   28.34 -#define INCL_DOSPROFILE
   28.35 -#define INCL_DOSEXCEPTIONS
   28.36 -#include <os2.h>
   28.37 -
   28.38 -#include "SDL_thread.h"
   28.39 -#include "SDL_timer.h"
   28.40 -#include "../SDL_timer_c.h"
   28.41 -
   28.42 -
   28.43 -#define TIME_WRAP_VALUE (~(DWORD)0)
   28.44 -
   28.45 -/* The first high-resolution ticks value of the application */
   28.46 -static long long hires_start_ticks;
   28.47 -/* The number of ticks per second of the high-resolution performance counter */
   28.48 -static ULONG hires_ticks_per_second;
   28.49 -
   28.50 -void
   28.51 -SDL_StartTicks(void)
   28.52 -{
   28.53 -    DosTmrQueryFreq(&hires_ticks_per_second);
   28.54 -    DosTmrQueryTime((PQWORD) & hires_start_ticks);
   28.55 -}
   28.56 -
   28.57 -DECLSPEC Uint32 SDLCALL
   28.58 -SDL_GetTicks(void)
   28.59 -{
   28.60 -    long long hires_now;
   28.61 -    ULONG ticks = ticks;
   28.62 -
   28.63 -    DosTmrQueryTime((PQWORD) & hires_now);
   28.64 -/*
   28.65 -        hires_now -= hires_start_ticks;
   28.66 -        hires_now *= 1000;
   28.67 -        hires_now /= hires_ticks_per_second;
   28.68 -*/
   28.69 -    /* inline asm to avoid runtime inclusion */
   28.70 -    /* *INDENT-OFF* */
   28.71 -    _asm {
   28.72 -        push edx
   28.73 -        push eax
   28.74 -        mov eax, dword ptr hires_now
   28.75 -        mov edx, dword ptr hires_now + 4
   28.76 -        sub eax, dword ptr hires_start_ticks
   28.77 -        sbb edx, dword ptr hires_start_ticks + 4
   28.78 -        mov ebx, 1000
   28.79 -        mov ecx, edx
   28.80 -        mul ebx
   28.81 -        push eax
   28.82 -        push edx
   28.83 -        mov eax, ecx
   28.84 -        mul ebx
   28.85 -        pop eax
   28.86 -        add edx, eax
   28.87 -        pop eax
   28.88 -        mov ebx, dword ptr hires_ticks_per_second
   28.89 -        div ebx
   28.90 -        mov dword ptr ticks, eax
   28.91 -        pop edx
   28.92 -        pop eax
   28.93 -    }
   28.94 -    /* *INDENT-ON* */
   28.95 -
   28.96 -    return ticks;
   28.97 -
   28.98 -}
   28.99 -
  28.100 -/* High resolution sleep, originally made by Ilya Zakharevich */
  28.101 -DECLSPEC void SDLCALL
  28.102 -SDL_Delay(Uint32 ms)
  28.103 -{
  28.104 -    /* This is similar to DosSleep(), but has 8ms granularity in time-critical
  28.105 -       threads even on Warp3. */
  28.106 -    HEV hevEvent1 = 0;          /* Event semaphore handle    */
  28.107 -    HTIMER htimerEvent1 = 0;    /* Timer handle              */
  28.108 -    APIRET rc = NO_ERROR;       /* Return code               */
  28.109 -    int ret = 1;
  28.110 -    ULONG priority = 0, nesting;        /* Shut down the warnings */
  28.111 -    PPIB pib;
  28.112 -    PTIB tib;
  28.113 -    char *e = NULL;
  28.114 -    APIRET badrc;
  28.115 -    int switch_priority = 50;
  28.116 -
  28.117 -    DosCreateEventSem(NULL,     /* Unnamed */
  28.118 -                      &hevEvent1,       /* Handle of semaphore returned */
  28.119 -                      DC_SEM_SHARED,    /* Shared needed for DosAsyncTimer */
  28.120 -                      FALSE);   /* Semaphore is in RESET state  */
  28.121 -
  28.122 -    if (ms >= switch_priority)
  28.123 -        switch_priority = 0;
  28.124 -    if (switch_priority) {
  28.125 -        if (DosGetInfoBlocks(&tib, &pib) != NO_ERROR)
  28.126 -            switch_priority = 0;
  28.127 -        else {
  28.128 -            /* In Warp3, to switch scheduling to 8ms step, one needs to do 
  28.129 -               DosAsyncTimer() in time-critical thread.  On laters versions,
  28.130 -               more and more cases of wait-for-something are covered.
  28.131 -
  28.132 -               It turns out that on Warp3fp42 it is the priority at the time
  28.133 -               of DosAsyncTimer() which matters.  Let's hope that this works
  28.134 -               with later versions too...  XXXX
  28.135 -             */
  28.136 -            priority = (tib->tib_ptib2->tib2_ulpri);
  28.137 -            if ((priority & 0xFF00) == 0x0300)  /* already time-critical */
  28.138 -                switch_priority = 0;
  28.139 -            /* Make us time-critical.  Just modifying TIB is not enough... */
  28.140 -            /* tib->tib_ptib2->tib2_ulpri = 0x0300; */
  28.141 -            /* We do not want to run at high priority if a signal causes us
  28.142 -               to longjmp() out of this section... */
  28.143 -            if (DosEnterMustComplete(&nesting))
  28.144 -                switch_priority = 0;
  28.145 -            else
  28.146 -                DosSetPriority(PRTYS_THREAD, PRTYC_TIMECRITICAL, 0, 0);
  28.147 -        }
  28.148 -    }
  28.149 -
  28.150 -    if ((badrc = DosAsyncTimer(ms, (HSEM) hevEvent1,    /* Semaphore to post        */
  28.151 -                               &htimerEvent1))) /* Timer handler (returned) */
  28.152 -        e = "DosAsyncTimer";
  28.153 -
  28.154 -    if (switch_priority && tib->tib_ptib2->tib2_ulpri == 0x0300) {
  28.155 -        /* Nobody switched priority while we slept...  Ignore errors... */
  28.156 -        /* tib->tib_ptib2->tib2_ulpri = priority; *//* Get back... */
  28.157 -        if (!
  28.158 -            (rc = DosSetPriority(PRTYS_THREAD, (priority >> 8) & 0xFF, 0, 0)))
  28.159 -            rc = DosSetPriority(PRTYS_THREAD, 0, priority & 0xFF, 0);
  28.160 -    }
  28.161 -    if (switch_priority)
  28.162 -        rc = DosExitMustComplete(&nesting);     /* Ignore errors */
  28.163 -
  28.164 -    /* The actual blocking call is made with "normal" priority.  This way we
  28.165 -       should not bother with DosSleep(0) etc. to compensate for us interrupting
  28.166 -       higher-priority threads.  The goal is to prohibit the system spending too
  28.167 -       much time halt()ing, not to run us "no matter what". */
  28.168 -    if (!e)                     /* Wait for AsyncTimer event */
  28.169 -        badrc = DosWaitEventSem(hevEvent1, SEM_INDEFINITE_WAIT);
  28.170 -
  28.171 -    if (e);                     /* Do nothing */
  28.172 -    else if (badrc == ERROR_INTERRUPT)
  28.173 -        ret = 0;
  28.174 -    else if (badrc)
  28.175 -        e = "DosWaitEventSem";
  28.176 -    if ((rc = DosCloseEventSem(hevEvent1)) && !e) {     /* Get rid of semaphore */
  28.177 -        e = "DosCloseEventSem";
  28.178 -        badrc = rc;
  28.179 -    }
  28.180 -    if (e) {
  28.181 -        SDL_SetError("[SDL_Delay] : Had error in %s(), rc is 0x%x\n", e,
  28.182 -                     badrc);
  28.183 -    }
  28.184 -}
  28.185 -
  28.186 -/* Data to handle a single periodic alarm */
  28.187 -static int timer_alive = 0;
  28.188 -static SDL_Thread *timer = NULL;
  28.189 -
  28.190 -static int SDLCALL
  28.191 -RunTimer(void *unused)
  28.192 -{
  28.193 -    DosSetPriority(PRTYS_THREAD, PRTYC_TIMECRITICAL, 0, 0);
  28.194 -    while (timer_alive) {
  28.195 -        if (SDL_timer_running) {
  28.196 -            SDL_ThreadedTimerCheck();
  28.197 -        }
  28.198 -        SDL_Delay(10);
  28.199 -    }
  28.200 -    return (0);
  28.201 -}
  28.202 -
  28.203 -/* This is only called if the event thread is not running */
  28.204 -int
  28.205 -SDL_SYS_TimerInit(void)
  28.206 -{
  28.207 -    timer_alive = 1;
  28.208 -    timer = SDL_CreateThread(RunTimer, NULL);
  28.209 -    if (timer == NULL)
  28.210 -        return (-1);
  28.211 -    return (SDL_SetTimerThreaded(1));
  28.212 -}
  28.213 -
  28.214 -void
  28.215 -SDL_SYS_TimerQuit(void)
  28.216 -{
  28.217 -    timer_alive = 0;
  28.218 -    if (timer) {
  28.219 -        SDL_WaitThread(timer, NULL);
  28.220 -        timer = NULL;
  28.221 -    }
  28.222 -}
  28.223 -
  28.224 -int
  28.225 -SDL_SYS_StartTimer(void)
  28.226 -{
  28.227 -    SDL_SetError("Internal logic error: OS/2 uses threaded timer");
  28.228 -    return (-1);
  28.229 -}
  28.230 -
  28.231 -void
  28.232 -SDL_SYS_StopTimer(void)
  28.233 -{
  28.234 -    return;
  28.235 -}
  28.236 -
  28.237 -#endif /* SDL_TIMER_OS2 */
  28.238 -/* vi: set ts=4 sw=4 expandtab: */
    29.1 --- a/src/video/SDL_sysvideo.h	Sat Sep 19 06:24:07 2009 +0000
    29.2 +++ b/src/video/SDL_sysvideo.h	Sat Sep 19 06:43:45 2009 +0000
    29.3 @@ -395,9 +395,6 @@
    29.4  #if SDL_VIDEO_DRIVER_RISCOS
    29.5  extern VideoBootStrap RISCOS_bootstrap;
    29.6  #endif
    29.7 -#if SDL_VIDEO_DRIVER_OS2FS
    29.8 -extern VideoBootStrap OS2FSLib_bootstrap;
    29.9 -#endif
   29.10  #if SDL_VIDEO_DRIVER_UIKIT
   29.11  extern VideoBootStrap UIKIT_bootstrap;
   29.12  #endif
    30.1 --- a/src/video/SDL_video.c	Sat Sep 19 06:24:07 2009 +0000
    30.2 +++ b/src/video/SDL_video.c	Sat Sep 19 06:43:45 2009 +0000
    30.3 @@ -109,9 +109,6 @@
    30.4  #if SDL_VIDEO_DRIVER_RISCOS
    30.5      &RISCOS_bootstrap,
    30.6  #endif
    30.7 -#if SDL_VIDEO_DRIVER_OS2FS
    30.8 -    &OS2FSLib_bootstrap,
    30.9 -#endif
   30.10  #if SDL_VIDEO_DRIVER_NDS
   30.11      &NDS_bootstrap,
   30.12  #endif
    31.1 --- a/src/video/os2fslib/SDL_os2fslib.c	Sat Sep 19 06:24:07 2009 +0000
    31.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    31.3 @@ -1,3122 +0,0 @@
    31.4 -/*
    31.5 -    SDL - Simple DirectMedia Layer
    31.6 -    Copyright (C) 1997-2009 Sam Lantinga
    31.7 -
    31.8 -    This library is free software; you can redistribute it and/or
    31.9 -    modify it under the terms of the GNU Library General Public
   31.10 -    License as published by the Free Software Foundation; either
   31.11 -    version 2 of the License, or (at your option) any later version.
   31.12 -
   31.13 -    This library is distributed in the hope that it will be useful,
   31.14 -    but WITHOUT ANY WARRANTY; without even the implied warranty of
   31.15 -    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   31.16 -    Library General Public License for more details.
   31.17 -
   31.18 -    You should have received a copy of the GNU Library General Public
   31.19 -    License along with this library; if not, write to the Free
   31.20 -    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   31.21 -
   31.22 -    Sam Lantinga
   31.23 -    slouken@libsdl.org
   31.24 -*/
   31.25 -#include "SDL_config.h"
   31.26 -
   31.27 -#define _ULS_CALLCONV_
   31.28 -#define CALLCONV _System
   31.29 -#include <unidef.h>             // Unicode API
   31.30 -#include <uconv.h>              // Unicode API (codepage conversion)
   31.31 -
   31.32 -#include <process.h>
   31.33 -#include <time.h>
   31.34 -
   31.35 -#include "SDL_video.h"
   31.36 -#include "SDL_mouse.h"
   31.37 -#include "../SDL_sysvideo.h"
   31.38 -#include "../SDL_pixels_c.h"
   31.39 -#include "../../events/SDL_events_c.h"
   31.40 -
   31.41 -#include "SDL_os2fslib.h"
   31.42 -
   31.43 -static ULONG ulFCFToUse =
   31.44 -    FCF_TITLEBAR |
   31.45 -    FCF_SYSMENU |
   31.46 -    FCF_MINBUTTON |
   31.47 -    FCF_MAXBUTTON | FCF_NOBYTEALIGN | FCF_SIZEBORDER | FCF_TASKLIST;
   31.48 -
   31.49 -static int bMouseCaptured = 0;
   31.50 -static int bMouseCapturable = 0;
   31.51 -static HPOINTER hptrGlobalPointer = NULL;
   31.52 -static HPOINTER hptrCurrentIcon = NULL;
   31.53 -static int iWindowSizeX = 320;
   31.54 -static int iWindowSizeY = 200;
   31.55 -static int bWindowResized = 0;
   31.56 -
   31.57 -#pragma pack(1)
   31.58 -typedef struct BMPINFO
   31.59 -{
   31.60 -    BITMAPINFO;
   31.61 -    RGB clr;
   31.62 -} BMPINFO, *PBMPINFO;
   31.63 -#pragma pack()
   31.64 -
   31.65 -
   31.66 -// Backdoors:
   31.67 -DECLSPEC void SDLCALL
   31.68 -SDL_OS2FSLIB_SetFCFToUse(ULONG ulFCF)
   31.69 -{
   31.70 -    ulFCFToUse = ulFCF;
   31.71 -}
   31.72 -
   31.73 -// Configuration defines:
   31.74 -
   31.75 -// We have to report empty alpha mask, otherwise SDL will select
   31.76 -// alpha blitters, and this will have unwanted results, as we don't
   31.77 -// support alpha channel in FSLib yet.
   31.78 -#define REPORT_EMPTY_ALPHA_MASK
   31.79 -
   31.80 -// Experimental: Move every FSLib_BitBlt() call into window message
   31.81 -// processing function.
   31.82 -// This may fix dirt left on desktop. Or not.
   31.83 -//#define BITBLT_IN_WINMESSAGEPROC
   31.84 -
   31.85 -// Experimental-2: Use WinLockWindowUpdate() in around bitblts!
   31.86 -// This is not enabled, because it seems to cause more problems
   31.87 -// than good.
   31.88 -//#define USE_WINLOCKWINDOWUPDATE_AROUND_BITBLTS
   31.89 -
   31.90 -// Use the following to show resized image instead of black stuff
   31.91 -// even if the surface is resizable.
   31.92 -//#define RESIZE_EVEN_IF_RESIZABLE
   31.93 -
   31.94 -/* The translation table from a VK keysym to a SDL keysym */
   31.95 -static SDLKey HWScanKeyMap[256];
   31.96 -static SDL_keysym *TranslateKey(int vkey, int chcode, int scancode,
   31.97 -                                SDL_keysym * keysym, int iPressed);
   31.98 -static int iShiftIsPressed;
   31.99 -
  31.100 -#ifdef BITBLT_IN_WINMESSAGEPROC
  31.101 -#define WM_UPDATERECTSREQUEST   WM_USER+50
  31.102 -#endif
  31.103 -
  31.104 -#ifdef USE_WINLOCKWINDOWUPDATE_AROUND_BITBLTS
  31.105 -#define FSLIB_BITBLT(hwnd, buffer, top, left, width, height) \
  31.106 -    { \
  31.107 -      WinLockWindowUpdate(HWND_DESKTOP, HWND_DESKTOP); \
  31.108 -      FSLib_BitBlt(hwnd, buffer, top, left, width, height); \
  31.109 -      WinLockWindowUpdate(HWND_DESKTOP, NULL); \
  31.110 -    }
  31.111 -#else
  31.112 -#define FSLIB_BITBLT(hwnd, buffer, top, left, width, height) \
  31.113 -    FSLib_BitBlt(hwnd, buffer, top, left, width, height);
  31.114 -#endif
  31.115 -
  31.116 -/////////////////////////////////////////////////////////////////////
  31.117 -//
  31.118 -// SetAccessableWindowPos
  31.119 -//
  31.120 -// Same as WinSetWindowPos(), but takes care for the window to be
  31.121 -// always on the screen, the titlebar will be accessable everytime.
  31.122 -//
  31.123 -/////////////////////////////////////////////////////////////////////
  31.124 -static BOOL
  31.125 -SetAccessableWindowPos(HWND hwnd, HWND hwndInsertBehind,
  31.126 -                       LONG x, LONG y, LONG cx, LONG cy, ULONG fl)
  31.127 -{
  31.128 -    SWP swpDesktop, swp;
  31.129 -    // Get desktop area
  31.130 -    WinQueryWindowPos(HWND_DESKTOP, &swpDesktop);
  31.131 -
  31.132 -    if ((fl & SWP_MOVE) && (fl & SWP_SIZE)) {
  31.133 -        // If both moving and sizing, then change size and pos now!!
  31.134 -        if (x + cx > swpDesktop.cx)
  31.135 -            x = swpDesktop.cx - cx;
  31.136 -        if (x < 0)
  31.137 -            x = 0;
  31.138 -        if (y < 0)
  31.139 -            y = 0;
  31.140 -        if (y + cy > swpDesktop.cy)
  31.141 -            y = swpDesktop.cy - cy;
  31.142 -        return WinSetWindowPos(hwnd, hwndInsertBehind, x, y, cx, cy, fl);
  31.143 -    } else if (fl & SWP_MOVE) {
  31.144 -        // Just moving
  31.145 -        WinQueryWindowPos(hwnd, &swp);
  31.146 -        if (x + swp.cx > swpDesktop.cx)
  31.147 -            x = swpDesktop.cx - swp.cx;
  31.148 -        if (x < 0)
  31.149 -            x = 0;
  31.150 -        if (y < 0)
  31.151 -            y = 0;
  31.152 -        if (y + swp.cy > swpDesktop.cy)
  31.153 -            y = swpDesktop.cy - swp.cy;
  31.154 -        return WinSetWindowPos(hwnd, hwndInsertBehind, x, y, cx, cy, fl);
  31.155 -    } else if (fl & SWP_SIZE) {
  31.156 -        // Just sizing
  31.157 -        WinQueryWindowPos(hwnd, &swp);
  31.158 -        x = swp.x;
  31.159 -        y = swp.y;
  31.160 -        if (x + cx > swpDesktop.cx)
  31.161 -            x = swpDesktop.cx - cx;
  31.162 -        if (x < 0)
  31.163 -            x = 0;
  31.164 -        if (y < 0)
  31.165 -            y = 0;
  31.166 -        if (y + cy > swpDesktop.cy)
  31.167 -            y = swpDesktop.cy - cy;
  31.168 -        return WinSetWindowPos(hwnd, hwndInsertBehind, x, y, cx, cy,
  31.169 -                               fl | SWP_MOVE);
  31.170 -    } else
  31.171 -        return WinSetWindowPos(hwnd, hwndInsertBehind, x, y, cx, cy, fl);
  31.172 -}
  31.173 -
  31.174 -static UniChar
  31.175 -NativeCharToUniChar(int chcode)
  31.176 -{
  31.177 -    UniChar ucResult = (UniChar) chcode;
  31.178 -    int rc;
  31.179 -    UconvObject ucoTemp;
  31.180 -    char achFrom[2];
  31.181 -    char *pchFrom;
  31.182 -    size_t iFromCount;
  31.183 -    UniChar aucTo[10];
  31.184 -    UniChar *pucTo;
  31.185 -    size_t iToCount;
  31.186 -    size_t iNonIdentical;
  31.187 -
  31.188 -    // Create unicode convert object
  31.189 -    rc = UniCreateUconvObject(L"", &ucoTemp);
  31.190 -    if (rc != ULS_SUCCESS) {
  31.191 -        // Could not create convert object!
  31.192 -        return ucResult;
  31.193 -    }
  31.194 -    // Convert language code string to unicode string
  31.195 -    achFrom[0] = (char) chcode;
  31.196 -    achFrom[1] = 0;
  31.197 -    iFromCount = sizeof(char) * 2;
  31.198 -    iToCount = sizeof(UniChar) * 2;
  31.199 -    pucTo = &(aucTo[0]);
  31.200 -    pchFrom = &(achFrom[0]);
  31.201 -
  31.202 -    rc = UniUconvToUcs(ucoTemp,
  31.203 -                       &pchFrom,
  31.204 -                       &iFromCount, &pucTo, &iToCount, &iNonIdentical);
  31.205 -
  31.206 -    if (rc != ULS_SUCCESS) {
  31.207 -        // Could not convert language code to UCS string!
  31.208 -        UniFreeUconvObject(ucoTemp);
  31.209 -        return ucResult;
  31.210 -    }
  31.211 -
  31.212 -    UniFreeUconvObject(ucoTemp);
  31.213 -
  31.214 -#ifdef DEBUG_BUILD
  31.215 -    printf("%02x converted to %02x\n", (int) chcode, (int) (aucTo[0]));
  31.216 -#endif
  31.217 -
  31.218 -    return aucTo[0];
  31.219 -}
  31.220 -
  31.221 -/////////////////////////////////////////////////////////////////////
  31.222 -//
  31.223 -// TranslateKey
  31.224 -//
  31.225 -// This creates SDL Keycodes from VK_ and hardware scan codes
  31.226 -//
  31.227 -/////////////////////////////////////////////////////////////////////
  31.228 -static SDL_keysym *
  31.229 -TranslateKey(int vkey, int chcode, int scancode, SDL_keysym * keysym,
  31.230 -             int iPressed)
  31.231 -{
  31.232 -    keysym->scancode = (unsigned char) scancode;
  31.233 -    keysym->mod = KMOD_NONE;
  31.234 -    keysym->unicode = 0;
  31.235 -
  31.236 -    if (iPressed && SDL_TranslateUNICODE) {
  31.237 -        if (chcode)
  31.238 -            keysym->unicode = NativeCharToUniChar(chcode);
  31.239 -        else
  31.240 -            keysym->unicode = vkey;
  31.241 -    }
  31.242 -
  31.243 -    keysym->sym = HWScanKeyMap[scancode];
  31.244 -
  31.245 -    // Now stuffs based on state of shift key(s)!
  31.246 -    if (vkey == VK_SHIFT) {
  31.247 -        iShiftIsPressed = iPressed;
  31.248 -    }
  31.249 -
  31.250 -    if ((iShiftIsPressed) && (SDL_TranslateUNICODE)) {
  31.251 -        // Change syms, if Unicode stuff is required
  31.252 -        // I think it's silly, but it's SDL...
  31.253 -        switch (keysym->sym) {
  31.254 -        case SDLK_BACKQUOTE:
  31.255 -            keysym->sym = '~';
  31.256 -            break;
  31.257 -        case SDLK_1:
  31.258 -            keysym->sym = SDLK_EXCLAIM;
  31.259 -            break;
  31.260 -        case SDLK_2:
  31.261 -            keysym->sym = SDLK_AT;
  31.262 -            break;
  31.263 -        case SDLK_3:
  31.264 -            keysym->sym = SDLK_HASH;
  31.265 -            break;
  31.266 -        case SDLK_4:
  31.267 -            keysym->sym = SDLK_DOLLAR;
  31.268 -            break;
  31.269 -        case SDLK_5:
  31.270 -            keysym->sym = '%';
  31.271 -            break;
  31.272 -        case SDLK_6:
  31.273 -            keysym->sym = SDLK_CARET;
  31.274 -            break;
  31.275 -        case SDLK_7:
  31.276 -            keysym->sym = SDLK_AMPERSAND;
  31.277 -            break;
  31.278 -        case SDLK_8:
  31.279 -            keysym->sym = SDLK_ASTERISK;
  31.280 -            break;
  31.281 -        case SDLK_9:
  31.282 -            keysym->sym = SDLK_LEFTPAREN;
  31.283 -            break;
  31.284 -        case SDLK_0:
  31.285 -            keysym->sym = SDLK_RIGHTPAREN;
  31.286 -            break;
  31.287 -        case SDLK_MINUS:
  31.288 -            keysym->sym = SDLK_UNDERSCORE;
  31.289 -            break;
  31.290 -        case SDLK_PLUS:
  31.291 -            keysym->sym = SDLK_EQUALS;
  31.292 -            break;
  31.293 -
  31.294 -        case SDLK_LEFTBRACKET:
  31.295 -            keysym->sym = '{';
  31.296 -            break;
  31.297 -        case SDLK_RIGHTBRACKET:
  31.298 -            keysym->sym = '}';
  31.299 -            break;
  31.300 -
  31.301 -        case SDLK_SEMICOLON:
  31.302 -            keysym->sym = SDLK_COLON;
  31.303 -            break;
  31.304 -        case SDLK_QUOTE:
  31.305 -            keysym->sym = SDLK_QUOTEDBL;
  31.306 -            break;
  31.307 -        case SDLK_BACKSLASH:
  31.308 -            keysym->sym = '|';
  31.309 -            break;
  31.310 -
  31.311 -        case SDLK_COMMA:
  31.312 -            keysym->sym = SDLK_LESS;
  31.313 -            break;
  31.314 -        case SDLK_PERIOD:
  31.315 -            keysym->sym = SDLK_GREATER;
  31.316 -            break;
  31.317 -        case SDLK_SLASH:
  31.318 -            keysym->sym = SDLK_QUESTION;
  31.319 -            break;
  31.320 -
  31.321 -        default:
  31.322 -            break;
  31.323 -        }
  31.324 -    }
  31.325 -    return keysym;
  31.326 -}
  31.327 -
  31.328 -#define CONVERTMOUSEPOSITION()  \
  31.329 -        /* We have to inverse the mouse position, because every non-os/2 system */                                                \
  31.330 -        /* has a coordinate system where the (0;0) is the top-left corner,      */                                                \
  31.331 -        /* while on os/2 it's the bottom left corner!                           */                                                \
  31.332 -        if (FSLib_QueryFSMode(hwnd))                                                                                              \
  31.333 -        {                                                                                                                         \
  31.334 -          /* We're in FS mode!                                                        */                                          \
  31.335 -          /* In FS mode our window is as big as fullscreen mode, but not necessary as */                                          \
  31.336 -          /* big as the source buffer (can be bigger)                                 */                                          \
  31.337 -          /* So, limit mouse pos to source buffer size!                               */                                          \
  31.338 -          if (ppts->x<0) ppts->x = 0;                                                                                             \
  31.339 -          if (ppts->y<0) ppts->y = 0;                                                                                             \
  31.340 -          if (ppts->x>=pVideo->hidden->SrcBufferDesc.uiXResolution) ppts->x = pVideo->hidden->SrcBufferDesc.uiXResolution-1;      \
  31.341 -          if (ppts->y>=pVideo->hidden->SrcBufferDesc.uiYResolution) ppts->y = pVideo->hidden->SrcBufferDesc.uiYResolution-1;      \
  31.342 -          pVideo->hidden->iSkipWMMOUSEMOVE++; /* Don't take next WM_MOUSEMOVE into account!  */                                   \
  31.343 -          ptl.x = ppts->x; ptl.y = ppts->y;                                                                                       \
  31.344 -          WinMapWindowPoints(pVideo->hidden->hwndClient, HWND_DESKTOP, &ptl, 1);                                                  \
  31.345 -          WinSetPointerPos(HWND_DESKTOP, ptl.x, ptl.y);                                                                           \
  31.346 -          /* Then convert OS/2 position to SDL position */                                                                        \
  31.347 -          ppts->y = pVideo->hidden->SrcBufferDesc.uiYResolution - ppts->y - 1;                                                    \
  31.348 -        } else                                                                                                                    \
  31.349 -        {                                                                                                                         \
  31.350 -          SWP swpClient;                                                                                                          \
  31.351 -          /* We're in windowed mode! */                                                                                           \
  31.352 -          WinQueryWindowPos(pVideo->hidden->hwndClient, &swpClient);                                                              \
  31.353 -          /* Convert OS/2 mouse position to SDL position, and also scale it! */                                                   \
  31.354 -          (ppts->x) = (ppts->x) * pVideo->hidden->SrcBufferDesc.uiXResolution / swpClient.cx;                                       \
  31.355 -          (ppts->y) = (ppts->y) * pVideo->hidden->SrcBufferDesc.uiYResolution / swpClient.cy;                                       \
  31.356 -          (ppts->y) = pVideo->hidden->SrcBufferDesc.uiYResolution - (ppts->y)  - 1;                                                 \
  31.357 -        }
  31.358 -
  31.359 -
  31.360 -
  31.361 -/////////////////////////////////////////////////////////////////////
  31.362 -//
  31.363 -// WndProc
  31.364 -//
  31.365 -// This is the message processing window procedure for the
  31.366 -// SDLWindowClass, which is the client window in our application.
  31.367 -// It handles switching back and away from the app (taking care of
  31.368 -// going out and back to and from fullscreen mode), sending keystrokes
  31.369 -// and mouse events to where it has to be sent, etc...
  31.370 -//
  31.371 -/////////////////////////////////////////////////////////////////////
  31.372 -static MRESULT EXPENTRY
  31.373 -WndProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
  31.374 -{
  31.375 -    HPS ps;
  31.376 -    RECTL rcl;
  31.377 -    SDL_VideoDevice *pVideo = NULL;
  31.378 -
  31.379 -    switch (msg) {
  31.380 -    case WM_CHAR:              // Keypress notification
  31.381 -#ifdef DEBUG_BUILD
  31.382 -//      printf("WM_CHAR\n"); fflush(stdout);
  31.383 -#endif
  31.384 -        pVideo = WinQueryWindowPtr(hwnd, 0);
  31.385 -        if (pVideo) {
  31.386 -            /*
  31.387 -               // We skip repeated keys:
  31.388 -               if (CHARMSG(&msg)->cRepeat>1)
  31.389 -               {
  31.390 -               #ifdef DEBUG_BUILD
  31.391 -               //          printf("Repeated key (%d), skipping...\n", CHARMSG(&msg)->cRepeat); fflush(stdout);
  31.392 -               #endif
  31.393 -               return (MRESULT) TRUE;
  31.394 -               }
  31.395 -             */
  31.396 -
  31.397 -            // If it's not repeated, then let's see if its pressed or released!
  31.398 -            if (SHORT1FROMMP(mp1) & KC_KEYUP) {
  31.399 -                // A key has been released
  31.400 -                SDL_keysym keysym;
  31.401 -
  31.402 -#ifdef DEBUG_BUILD
  31.403 -//          printf("WM_CHAR, keyup, code is [0x%0x]\n", CHAR4FROMMP(mp1)); // HW scan code
  31.404 -#endif
  31.405 -
  31.406 -                // One problem is with F1, which gets only the keyup message because
  31.407 -                // it is a system key.
  31.408 -                // So, when we get keyup message, we simulate keydown too!
  31.409 -                // UPDATE:
  31.410 -                //  This problem should be solved now, that the accelerator keys are
  31.411 -                //  disabled for this window!
  31.412 -                /*
  31.413 -                   if (SHORT2FROMMP(mp2)==VK_F1)
  31.414 -                   {
  31.415 -                   SDL_PrivateKeyboard(SDL_PRESSED, TranslateKey(SHORT2FROMMP(mp2), // VK_ code
  31.416 -                   SHORT1FROMMP(mp2), // Character code
  31.417 -                   CHAR4FROMMP(mp1),  // HW Scan code
  31.418 -                   &keysym,0));
  31.419 -                   } */
  31.420 -
  31.421 -                SDL_PrivateKeyboard(SDL_RELEASED, TranslateKey(SHORT2FROMMP(mp2),       // VK_ code
  31.422 -                                                               SHORT1FROMMP(mp2),       // Character code
  31.423 -                                                               CHAR4FROMMP(mp1),        // HW Scan code
  31.424 -                                                               &keysym, 0));
  31.425 -
  31.426 -            } else {
  31.427 -                // A key has been pressed
  31.428 -                SDL_keysym keysym;
  31.429 -
  31.430 -#ifdef DEBUG_BUILD
  31.431 -//          printf("WM_CHAR, keydown, code is [0x%0x]\n", CHAR4FROMMP(mp1)); // HW scan code
  31.432 -#endif
  31.433 -                // Check for fastkeys: ALT+HOME to toggle FS mode
  31.434 -                //                     ALT+END to close app
  31.435 -                if ((SHORT1FROMMP(mp1) & KC_ALT) &&
  31.436 -                    (SHORT2FROMMP(mp2) == VK_HOME)) {
  31.437 -#ifdef DEBUG_BUILD
  31.438 -                    printf(" Pressed ALT+HOME!\n");
  31.439 -                    fflush(stdout);
  31.440 -#endif
  31.441 -                    // Only switch between fullscreen and back if it's not
  31.442 -                    // a resizable mode!
  31.443 -                    if ((!pVideo->hidden->pSDLSurface) ||
  31.444 -                        ((pVideo->hidden->pSDLSurface)
  31.445 -                         &&
  31.446 -                         ((pVideo->hidden->
  31.447 -                           pSDLSurface->flags & SDL_RESIZABLE) == 0)))
  31.448 -                        FSLib_ToggleFSMode(hwnd, !FSLib_QueryFSMode(hwnd));
  31.449 -#ifdef DEBUG_BUILD
  31.450 -                    else
  31.451 -                        printf(" Resizable mode, so discarding ALT+HOME!\n");
  31.452 -                    fflush(stdout);
  31.453 -#endif
  31.454 -                } else if ((SHORT1FROMMP(mp1) & KC_ALT) &&
  31.455 -                           (SHORT2FROMMP(mp2) == VK_END)) {
  31.456 -#ifdef DEBUG_BUILD
  31.457 -                    printf(" Pressed ALT+END!\n");
  31.458 -                    fflush(stdout);
  31.459 -#endif
  31.460 -                    // Close window, and get out of loop!
  31.461 -                    // Also send event to SDL application, but we won't
  31.462 -                    // wait for it to be processed!
  31.463 -                    SDL_PrivateQuit();
  31.464 -                    WinPostMsg(hwnd, WM_QUIT, 0, 0);
  31.465 -                } else {
  31.466 -
  31.467 -                    SDL_PrivateKeyboard(SDL_PRESSED, TranslateKey(SHORT2FROMMP(mp2),    // VK_ code
  31.468 -                                                                  SHORT1FROMMP(mp2),    // Character code
  31.469 -                                                                  CHAR4FROMMP(mp1),     // HW Scan code
  31.470 -                                                                  &keysym,
  31.471 -                                                                  1));
  31.472 -
  31.473 -                }
  31.474 -            }
  31.475 -        }
  31.476 -        return (MRESULT) TRUE;
  31.477 -
  31.478 -    case WM_TRANSLATEACCEL:
  31.479 -        {
  31.480 -            PQMSG pqmsg;
  31.481 -            pqmsg = (PQMSG) mp1;
  31.482 -            if (mp1) {
  31.483 -                if (pqmsg->msg == WM_CHAR) {
  31.484 -                    // WM_CHAR message!
  31.485 -                    // Let's filter the ALT keypress and all other acceleration keys!
  31.486 -                    return (MRESULT) FALSE;
  31.487 -                }
  31.488 -            }
  31.489 -            break;              // Default processing (pass to parent until frame control)
  31.490 -        }
  31.491 -
  31.492 -    case WM_PAINT:             // Window redraw!
  31.493 -#ifdef DEBUG_BUILD
  31.494 -        printf("WM_PAINT (0x%x)\n", hwnd);
  31.495 -        fflush(stdout);
  31.496 -#endif
  31.497 -        ps = WinBeginPaint(hwnd, 0, &rcl);
  31.498 -        pVideo = FSLib_GetUserParm(hwnd);
  31.499 -        if (pVideo) {
  31.500 -            if (!pVideo->hidden->pSDLSurface) {
  31.501 -                RECTL rclRect;
  31.502 -                // So, don't blit now!
  31.503 -#ifdef DEBUG_BUILD
  31.504 -                printf("WM_PAINT : Skipping blit while resizing (Pre!)!\n");
  31.505 -                fflush(stdout);
  31.506 -#endif
  31.507 -                WinQueryWindowRect(hwnd, &rclRect);
  31.508 -                // Fill with black
  31.509 -                WinFillRect(ps, &rclRect, CLR_BLACK);
  31.510 -            } else {
  31.511 -                if (DosRequestMutexSem
  31.512 -                    (pVideo->hidden->hmtxUseSrcBuffer, 1000) == NO_ERROR) {
  31.513 -                    int iTop, iLeft, iWidth, iHeight;
  31.514 -                    int iXScaleError, iYScaleError;
  31.515 -                    int iXScaleError2, iYScaleError2;
  31.516 -                    SWP swp;
  31.517 -
  31.518 -                    // Re-blit the modified area!
  31.519 -                    // For this, we have to calculate the points, scaled!
  31.520 -                    WinQueryWindowPos(hwnd, &swp);
  31.521 -#ifdef DEBUG_BUILD
  31.522 -                    printf
  31.523 -                        ("WM_PAINT : WinSize: %d %d, BufSize: %d %d\n",
  31.524 -                         swp.cx, swp.cy,
  31.525 -                         pVideo->hidden->SrcBufferDesc.uiXResolution,
  31.526 -                         pVideo->hidden->SrcBufferDesc.uiYResolution);
  31.527 -                    fflush(stdout);
  31.528 -#endif
  31.529 -
  31.530 -#ifndef RESIZE_EVEN_IF_RESIZABLE
  31.531 -                    // But only blit if the window is not resizable, or if
  31.532 -                    // the window is resizable and the source buffer size is the
  31.533 -                    // same as the destination buffer size!
  31.534 -                    if ((!pVideo->hidden->pSDLSurface) ||
  31.535 -                        ((pVideo->hidden->pSDLSurface) &&
  31.536 -                         (pVideo->hidden->pSDLSurface->flags & SDL_RESIZABLE)
  31.537 -                         &&
  31.538 -                         ((swp.cx !=
  31.539 -                           pVideo->hidden->SrcBufferDesc.uiXResolution)
  31.540 -                          || (swp.cy !=
  31.541 -                              pVideo->hidden->SrcBufferDesc.uiYResolution))
  31.542 -                         && (!FSLib_QueryFSMode(hwnd)))) {
  31.543 -                        RECTL rclRect;
  31.544 -                        // Resizable surface and in resizing!
  31.545 -                        // So, don't blit now!
  31.546 -#ifdef DEBUG_BUILD
  31.547 -                        printf("WM_PAINT : Skipping blit while resizing!\n");
  31.548 -                        fflush(stdout);
  31.549 -#endif
  31.550 -                        WinQueryWindowRect(hwnd, &rclRect);
  31.551 -                        // Fill with black
  31.552 -                        WinFillRect(ps, &rclRect, CLR_BLACK);
  31.553 -                    } else
  31.554 -#endif
  31.555 -                    {
  31.556 -
  31.557 -                        iXScaleError =
  31.558 -                            (pVideo->hidden->SrcBufferDesc.uiXResolution -
  31.559 -                             1) / swp.cx;
  31.560 -                        iYScaleError =
  31.561 -                            (pVideo->hidden->SrcBufferDesc.uiYResolution -
  31.562 -                             1) / swp.cy;
  31.563 -                        if (iXScaleError < 0)
  31.564 -                            iXScaleError = 0;
  31.565 -                        if (iYScaleError < 0)
  31.566 -                            iYScaleError = 0;
  31.567 -                        iXScaleError2 =
  31.568 -                            (swp.cx -
  31.569 -                             1) /
  31.570 -                            (pVideo->hidden->SrcBufferDesc.uiXResolution);
  31.571 -                        iYScaleError2 =
  31.572 -                            (swp.cy -
  31.573 -                             1) /
  31.574 -                            (pVideo->hidden->SrcBufferDesc.uiYResolution);
  31.575 -                        if (iXScaleError2 < 0)
  31.576 -                            iXScaleError2 = 0;
  31.577 -                        if (iYScaleError2 < 0)
  31.578 -                            iYScaleError2 = 0;
  31.579 -
  31.580 -                        iTop =
  31.581 -                            (swp.cy -
  31.582 -                             rcl.yTop) *
  31.583 -                            pVideo->hidden->SrcBufferDesc.uiYResolution /
  31.584 -                            swp.cy - iYScaleError;
  31.585 -                        iLeft =
  31.586 -                            rcl.xLeft *
  31.587 -                            pVideo->hidden->SrcBufferDesc.uiXResolution /
  31.588 -                            swp.cx - iXScaleError;
  31.589 -                        iWidth =
  31.590 -                            ((rcl.xRight -
  31.591 -                              rcl.xLeft) *
  31.592 -                             pVideo->hidden->SrcBufferDesc.uiXResolution +
  31.593 -                             swp.cx - 1) / swp.cx + 2 * iXScaleError;
  31.594 -                        iHeight =
  31.595 -                            ((rcl.yTop -
  31.596 -                              rcl.yBottom) *
  31.597 -                             pVideo->hidden->SrcBufferDesc.uiYResolution +
  31.598 -                             swp.cy - 1) / swp.cy + 2 * iYScaleError;
  31.599 -
  31.600 -                        iWidth += iXScaleError2;
  31.601 -                        iHeight += iYScaleError2;
  31.602 -
  31.603 -                        if (iTop < 0)
  31.604 -                            iTop = 0;
  31.605 -                        if (iLeft < 0)
  31.606 -                            iLeft = 0;
  31.607 -                        if (iTop + iHeight >
  31.608 -                            pVideo->hidden->SrcBufferDesc.uiYResolution)
  31.609 -                            iHeight =
  31.610 -                                pVideo->hidden->SrcBufferDesc.uiYResolution -
  31.611 -                                iTop;
  31.612 -                        if (iLeft + iWidth >
  31.613 -                            pVideo->hidden->SrcBufferDesc.uiXResolution)
  31.614 -                            iWidth =
  31.615 -                                pVideo->hidden->SrcBufferDesc.uiXResolution -
  31.616 -                                iLeft;
  31.617 -
  31.618 -#ifdef DEBUG_BUILD
  31.619 -                        printf
  31.620 -                            ("WM_PAINT : BitBlt: %d %d -> %d %d (Buf %d x %d)\n",
  31.621 -                             iTop, iLeft, iWidth, iHeight,
  31.622 -                             pVideo->hidden->SrcBufferDesc.uiXResolution,
  31.623 -                             pVideo->hidden->SrcBufferDesc.uiYResolution);
  31.624 -                        fflush(stdout);
  31.625 -#endif
  31.626 -
  31.627 -                        FSLIB_BITBLT(hwnd,
  31.628 -                                     pVideo->hidden->pchSrcBuffer,
  31.629 -                                     iTop, iLeft, iWidth, iHeight);
  31.630 -                    }
  31.631 -
  31.632 -                    DosReleaseMutexSem(pVideo->hidden->hmtxUseSrcBuffer);
  31.633 -                }
  31.634 -            }
  31.635 -        }
  31.636 -#ifdef DEBUG_BUILD
  31.637 -        else {
  31.638 -            printf("WM_PAINT : No pVideo!\n");
  31.639 -            fflush(stdout);
  31.640 -        }
  31.641 -#endif
  31.642 -        WinEndPaint(ps);
  31.643 -#ifdef DEBUG_BUILD
  31.644 -        printf("WM_PAINT : Done.\n");
  31.645 -        fflush(stdout);
  31.646 -#endif
  31.647 -        return 0;
  31.648 -
  31.649 -    case WM_SIZE:
  31.650 -        {
  31.651 -#ifdef DEBUG_BUILD
  31.652 -            printf("WM_SIZE : (%d %d)\n",
  31.653 -                   SHORT1FROMMP(mp2), SHORT2FROMMP(mp2));
  31.654 -            fflush(stdout);
  31.655 -#endif
  31.656 -            iWindowSizeX = SHORT1FROMMP(mp2);
  31.657 -            iWindowSizeY = SHORT2FROMMP(mp2);
  31.658 -            bWindowResized = 1;
  31.659 -
  31.660 -            // Make sure the window will be redrawn
  31.661 -            WinInvalidateRegion(hwnd, NULL, TRUE);
  31.662 -        }
  31.663 -        break;
  31.664 -
  31.665 -    case WM_FSLIBNOTIFICATION:
  31.666 -#ifdef DEBUG_BUILD
  31.667 -        printf("WM_FSLIBNOTIFICATION\n");
  31.668 -        fflush(stdout);
  31.669 -#endif
  31.670 -        if ((int) mp1 == FSLN_TOGGLEFSMODE) {
  31.671 -            // FS mode changed, reblit image!
  31.672 -            pVideo = FSLib_GetUserParm(hwnd);
  31.673 -            if (pVideo) {
  31.674 -                if (!pVideo->hidden->pSDLSurface) {
  31.675 -                    // Resizable surface and in resizing!
  31.676 -                    // So, don't blit now!
  31.677 -#ifdef DEBUG_BUILD
  31.678 -                    printf
  31.679 -                        ("WM_FSLIBNOTIFICATION : Can not blit if there is no surface, doing nothing.\n");
  31.680 -                    fflush(stdout);
  31.681 -#endif
  31.682 -                } else {
  31.683 -                    if (DosRequestMutexSem
  31.684 -                        (pVideo->hidden->hmtxUseSrcBuffer,
  31.685 -                         1000) == NO_ERROR) {
  31.686 -                        if (pVideo->hidden->pSDLSurface) {
  31.687 -#ifndef RESIZE_EVEN_IF_RESIZABLE
  31.688 -                            SWP swp;
  31.689 -
  31.690 -                            // But only blit if the window is not resizable, or if
  31.691 -                            // the window is resizable and the source buffer size is the
  31.692 -                            // same as the destination buffer size!
  31.693 -                            WinQueryWindowPos(hwnd, &swp);
  31.694 -                            if ((!pVideo->hidden->pSDLSurface) ||
  31.695 -                                ((pVideo->hidden->pSDLSurface) &&
  31.696 -                                 (pVideo->hidden->
  31.697 -                                  pSDLSurface->flags & SDL_RESIZABLE)
  31.698 -                                 &&
  31.699 -                                 ((swp.cx !=
  31.700 -                                   pVideo->hidden->
  31.701 -                                   SrcBufferDesc.uiXResolution)
  31.702 -                                  || (swp.cy !=
  31.703 -                                      pVideo->hidden->SrcBufferDesc.
  31.704 -                                      uiYResolution))
  31.705 -                                 && (!FSLib_QueryFSMode(hwnd)))) {
  31.706 -                                // Resizable surface and in resizing!
  31.707 -                                // So, don't blit now!
  31.708 -#ifdef DEBUG_BUILD
  31.709 -                                printf
  31.710 -                                    ("WM_FSLIBNOTIFICATION : Cannot blit while resizing, doing nothing.\n");
  31.711 -                                fflush(stdout);
  31.712 -#endif
  31.713 -                            } else
  31.714 -#endif
  31.715 -                            {
  31.716 -#ifdef DEBUG_BUILD
  31.717 -                                printf("WM_FSLIBNOTIFICATION : Blitting!\n");
  31.718 -                                fflush(stdout);
  31.719 -#endif
  31.720 -                                FSLIB_BITBLT(hwnd,
  31.721 -                                             pVideo->hidden->pchSrcBuffer, 0,
  31.722 -                                             0,
  31.723 -                                             pVideo->hidden->
  31.724 -                                             SrcBufferDesc.uiXResolution,
  31.725 -                                             pVideo->hidden->SrcBufferDesc.
  31.726 -                                             uiYResolution);
  31.727 -                            }
  31.728 -                        }
  31.729 -#ifdef DEBUG_BUILD
  31.730 -                        else
  31.731 -                            printf
  31.732 -                                ("WM_FSLIBNOTIFICATION : No public surface!\n");
  31.733 -                        fflush(stdout);
  31.734 -#endif
  31.735 -
  31.736 -                        DosReleaseMutexSem(pVideo->hidden->hmtxUseSrcBuffer);
  31.737 -                    }
  31.738 -                }
  31.739 -            }
  31.740 -        }
  31.741 -        return (MPARAM) 1;
  31.742 -
  31.743 -    case WM_ACTIVATE:
  31.744 -#ifdef DEBUG_BUILD
  31.745 -        printf("WM_ACTIVATE\n");
  31.746 -        fflush(stdout);
  31.747 -#endif
  31.748 -
  31.749 -        pVideo = FSLib_GetUserParm(hwnd);
  31.750 -        if (pVideo) {
  31.751 -            pVideo->hidden->fInFocus = (int) mp1;
  31.752 -            if (pVideo->hidden->fInFocus) {
  31.753 -                // Went into focus
  31.754 -                if ((pVideo->hidden->iMouseVisible)
  31.755 -                    && (!bMouseCaptured))
  31.756 -                    WinSetPointer(HWND_DESKTOP,
  31.757 -                                  WinQuerySysPointer(HWND_DESKTOP,
  31.758 -                                                     SPTR_ARROW, FALSE));
  31.759 -                else
  31.760 -                    WinSetPointer(HWND_DESKTOP, NULL);
  31.761 -
  31.762 -                if (bMouseCapturable) {
  31.763 -                    // Re-capture the mouse, if we captured it before!
  31.764 -                    WinSetCapture(HWND_DESKTOP, hwnd);
  31.765 -                    bMouseCaptured = 1;
  31.766 -                    {
  31.767 -                        SWP swpClient;
  31.768 -                        POINTL ptl;
  31.769 -                        // Center the mouse to the middle of the window!
  31.770 -                        WinQueryWindowPos(pVideo->hidden->hwndClient,
  31.771 -                                          &swpClient);
  31.772 -                        ptl.x = 0;
  31.773 -                        ptl.y = 0;
  31.774 -                        WinMapWindowPoints(pVideo->hidden->hwndClient,
  31.775 -                                           HWND_DESKTOP, &ptl, 1);
  31.776 -                        pVideo->hidden->iSkipWMMOUSEMOVE++;     /* Don't take next WM_MOUSEMOVE into account!  */
  31.777 -                        WinSetPointerPos(HWND_DESKTOP,
  31.778 -                                         ptl.x + swpClient.cx / 2,
  31.779 -                                         ptl.y + swpClient.cy / 2);
  31.780 -                    }
  31.781 -                }
  31.782 -            } else {
  31.783 -                // Went out of focus
  31.784 -                WinSetPointer(HWND_DESKTOP,
  31.785 -                              WinQuerySysPointer(HWND_DESKTOP,
  31.786 -                                                 SPTR_ARROW, FALSE));
  31.787 -
  31.788 -                if (bMouseCaptured) {
  31.789 -                    // Release the mouse
  31.790 -                    WinSetCapture(HWND_DESKTOP, hwnd);
  31.791 -                    bMouseCaptured = 0;
  31.792 -                }
  31.793 -            }
  31.794 -        }
  31.795 -#ifdef DEBUG_BUILD
  31.796 -        printf("WM_ACTIVATE done\n");
  31.797 -        fflush(stdout);
  31.798 -#endif
  31.799 -
  31.800 -        break;
  31.801 -
  31.802 -    case WM_BUTTON1DOWN:
  31.803 -#ifdef DEBUG_BUILD
  31.804 -        printf("WM_BUTTON1DOWN\n");
  31.805 -        fflush(stdout);
  31.806 -#endif
  31.807 -
  31.808 -        pVideo = FSLib_GetUserParm(hwnd);
  31.809 -        if (pVideo) {
  31.810 -            SDL_PrivateMouseButton(SDL_PRESSED, SDL_BUTTON_LEFT, 0, 0); // Don't report mouse movement!
  31.811 -
  31.812 -            if (bMouseCapturable) {
  31.813 -                // We should capture the mouse!
  31.814 -                if (!bMouseCaptured) {
  31.815 -                    WinSetCapture(HWND_DESKTOP, hwnd);
  31.816 -                    WinSetPointer(HWND_DESKTOP, NULL);
  31.817 -                    bMouseCaptured = 1;
  31.818 -                    {
  31.819 -                        SWP swpClient;
  31.820 -                        POINTL ptl;
  31.821 -                        // Center the mouse to the middle of the window!
  31.822 -                        WinQueryWindowPos(pVideo->hidden->hwndClient,
  31.823 -                                          &swpClient);
  31.824 -                        ptl.x = 0;
  31.825 -                        ptl.y = 0;
  31.826 -                        WinMapWindowPoints(pVideo->hidden->hwndClient,
  31.827 -                                           HWND_DESKTOP, &ptl, 1);
  31.828 -                        pVideo->hidden->iSkipWMMOUSEMOVE++;     /* Don't take next WM_MOUSEMOVE into account!  */
  31.829 -                        WinSetPointerPos(HWND_DESKTOP,
  31.830 -                                         ptl.x + swpClient.cx / 2,
  31.831 -                                         ptl.y + swpClient.cy / 2);
  31.832 -                    }
  31.833 -                }
  31.834 -            }
  31.835 -        }
  31.836 -        break;
  31.837 -    case WM_BUTTON1UP:
  31.838 -#ifdef DEBUG_BUILD
  31.839 -        printf("WM_BUTTON1UP\n");
  31.840 -        fflush(stdout);
  31.841 -#endif
  31.842 -        SDL_PrivateMouseButton(SDL_RELEASED, SDL_BUTTON_LEFT, 0, 0);    // Don't report mouse movement!
  31.843 -        break;
  31.844 -    case WM_BUTTON2DOWN:
  31.845 -#ifdef DEBUG_BUILD
  31.846 -        printf("WM_BUTTON2DOWN\n");
  31.847 -        fflush(stdout);
  31.848 -#endif
  31.849 -
  31.850 -        pVideo = FSLib_GetUserParm(hwnd);
  31.851 -        if (pVideo) {
  31.852 -            SDL_PrivateMouseButton(SDL_PRESSED, SDL_BUTTON_RIGHT, 0, 0);        // Don't report mouse movement!
  31.853 -
  31.854 -            if (bMouseCapturable) {
  31.855 -                // We should capture the mouse!
  31.856 -                if (!bMouseCaptured) {
  31.857 -                    WinSetCapture(HWND_DESKTOP, hwnd);
  31.858 -                    WinSetPointer(HWND_DESKTOP, NULL);
  31.859 -                    bMouseCaptured = 1;
  31.860 -                    {
  31.861 -                        SWP swpClient;
  31.862 -                        POINTL ptl;
  31.863 -                        // Center the mouse to the middle of the window!
  31.864 -                        WinQueryWindowPos(pVideo->hidden->hwndClient,
  31.865 -                                          &swpClient);
  31.866 -                        ptl.x = 0;
  31.867 -                        ptl.y = 0;
  31.868 -                        WinMapWindowPoints(pVideo->hidden->hwndClient,
  31.869 -                                           HWND_DESKTOP, &ptl, 1);
  31.870 -                        pVideo->hidden->iSkipWMMOUSEMOVE++;     /* Don't take next WM_MOUSEMOVE into account!  */
  31.871 -                        WinSetPointerPos(HWND_DESKTOP,
  31.872 -                                         ptl.x + swpClient.cx / 2,
  31.873 -                                         ptl.y + swpClient.cy / 2);
  31.874 -                    }
  31.875 -                }
  31.876 -            }
  31.877 -
  31.878 -        }
  31.879 -        break;
  31.880 -    case WM_BUTTON2UP:
  31.881 -#ifdef DEBUG_BUILD
  31.882 -        printf("WM_BUTTON2UP\n");
  31.883 -        fflush(stdout);
  31.884 -#endif
  31.885 -        SDL_PrivateMouseButton(SDL_RELEASED, SDL_BUTTON_RIGHT, 0, 0);   // Don't report mouse movement!
  31.886 -        break;
  31.887 -    case WM_BUTTON3DOWN:
  31.888 -#ifdef DEBUG_BUILD
  31.889 -        printf("WM_BUTTON3DOWN\n");
  31.890 -        fflush(stdout);
  31.891 -#endif
  31.892 -
  31.893 -        pVideo = FSLib_GetUserParm(hwnd);
  31.894 -        if (pVideo) {
  31.895 -            SDL_PrivateMouseButton(SDL_PRESSED, SDL_BUTTON_MIDDLE, 0, 0);       // Don't report mouse movement!
  31.896 -
  31.897 -            if (bMouseCapturable) {
  31.898 -                // We should capture the mouse!
  31.899 -                if (!bMouseCaptured) {
  31.900 -                    WinSetCapture(HWND_DESKTOP, hwnd);
  31.901 -                    WinSetPointer(HWND_DESKTOP, NULL);
  31.902 -                    bMouseCaptured = 1;
  31.903 -                    {
  31.904 -                        SWP swpClient;
  31.905 -                        POINTL ptl;
  31.906 -                        // Center the mouse to the middle of the window!
  31.907 -                        WinQueryWindowPos(pVideo->hidden->hwndClient,
  31.908 -                                          &swpClient);
  31.909 -                        ptl.x = 0;
  31.910 -                        ptl.y = 0;
  31.911 -                        WinMapWindowPoints(pVideo->hidden->hwndClient,
  31.912 -                                           HWND_DESKTOP, &ptl, 1);
  31.913 -                        pVideo->hidden->iSkipWMMOUSEMOVE++;     /* Don't take next WM_MOUSEMOVE into account!  */
  31.914 -                        WinSetPointerPos(HWND_DESKTOP,
  31.915 -                                         ptl.x + swpClient.cx / 2,
  31.916 -                                         ptl.y + swpClient.cy / 2);
  31.917 -                    }
  31.918 -                }
  31.919 -            }
  31.920 -        }
  31.921 -        break;
  31.922 -    case WM_BUTTON3UP:
  31.923 -#ifdef DEBUG_BUILD
  31.924 -        printf("WM_BUTTON3UP\n");
  31.925 -        fflush(stdout);
  31.926 -#endif
  31.927 -        SDL_PrivateMouseButton(SDL_RELEASED, SDL_BUTTON_MIDDLE, 0, 0);  // Don't report mouse movement!
  31.928 -        break;
  31.929 -    case WM_MOUSEMOVE:
  31.930 -#ifdef DEBUG_BUILD
  31.931 -//      printf("WM_MOUSEMOVE\n"); fflush(stdout);
  31.932 -#endif
  31.933 -
  31.934 -        pVideo = FSLib_GetUserParm(hwnd);
  31.935 -        if (pVideo) {
  31.936 -            if (pVideo->hidden->iSkipWMMOUSEMOVE) {
  31.937 -                pVideo->hidden->iSkipWMMOUSEMOVE--;
  31.938 -            } else {
  31.939 -                POINTS *ppts = (POINTS *) (&mp1);
  31.940 -                POINTL ptl;
  31.941 -
  31.942 -                if (bMouseCaptured) {
  31.943 -                    SWP swpClient;
  31.944 -
  31.945 -                    WinQueryWindowPos(pVideo->hidden->hwndClient, &swpClient);
  31.946 -
  31.947 -                    // Send relative mouse position, and re-center the mouse
  31.948 -                    // Reposition the mouse to the center of the screen/window
  31.949 -                    SDL_PrivateMouseMotion(0,   // Buttons not changed
  31.950 -                                           1,   // Relative position
  31.951 -                                           ppts->x -
  31.952 -                                           (swpClient.cx / 2),
  31.953 -                                           (swpClient.cy / 2) - ppts->y);
  31.954 -
  31.955 -                    ptl.x = 0;
  31.956 -                    ptl.y = 0;
  31.957 -                    WinMapWindowPoints(pVideo->hidden->hwndClient,
  31.958 -                                       HWND_DESKTOP, &ptl, 1);
  31.959 -                    pVideo->hidden->iSkipWMMOUSEMOVE++; /* Don't take next WM_MOUSEMOVE into account!  */
  31.960 -                    // Center the mouse to the middle of the window!
  31.961 -                    WinSetPointerPos(HWND_DESKTOP,
  31.962 -                                     ptl.x + swpClient.cx / 2,
  31.963 -                                     ptl.y + swpClient.cy / 2);
  31.964 -                } else {
  31.965 -                    CONVERTMOUSEPOSITION();
  31.966 -
  31.967 -                    // Send absolute mouse position
  31.968 -                    SDL_PrivateMouseMotion(0,   // Buttons not changed
  31.969 -                                           0,   // Absolute position
  31.970 -                                           ppts->x, ppts->y);
  31.971 -                }
  31.972 -            }
  31.973 -            if ((pVideo->hidden->iMouseVisible) && (!bMouseCaptured)) {
  31.974 -#ifdef DEBUG_BUILD
  31.975 -//          printf("WM_MOUSEMOVE : ptr = %p\n", hptrGlobalPointer); fflush(stdout);
  31.976 -#endif
  31.977 -
  31.978 -                if (hptrGlobalPointer)
  31.979 -                    WinSetPointer(HWND_DESKTOP, hptrGlobalPointer);
  31.980 -                else
  31.981 -                    WinSetPointer(HWND_DESKTOP,
  31.982 -                                  WinQuerySysPointer(HWND_DESKTOP,
  31.983 -                                                     SPTR_ARROW, FALSE));
  31.984 -            } else {
  31.985 -                WinSetPointer(HWND_DESKTOP, NULL);
  31.986 -            }
  31.987 -        }
  31.988 -#ifdef DEBUG_BUILD
  31.989 -//      printf("WM_MOUSEMOVE done\n"); fflush(stdout);
  31.990 -#endif
  31.991 -
  31.992 -        return (MRESULT) FALSE;
  31.993 -    case WM_CLOSE:             // Window close
  31.994 -#ifdef DEBUG_BUILD
  31.995 -        printf("WM_CLOSE\n");
  31.996 -        fflush(stdout);
  31.997 -#endif
  31.998 -
  31.999 -        pVideo = FSLib_GetUserParm(hwnd);
 31.1000 -        if (pVideo) {
 31.1001 -            // Send Quit message to the SDL application!
 31.1002 -            SDL_PrivateQuit();
 31.1003 -            return 0;
 31.1004 -        }
 31.1005 -        break;
 31.1006 -
 31.1007 -#ifdef BITBLT_IN_WINMESSAGEPROC
 31.1008 -    case WM_UPDATERECTSREQUEST:
 31.1009 -        pVideo = FSLib_GetUserParm(hwnd);
 31.1010 -        if ((pVideo) && (pVideo->hidden->pSDLSurface)) {
 31.1011 -            if (DosRequestMutexSem
 31.1012 -                (pVideo->hidden->hmtxUseSrcBuffer,
 31.1013 -                 SEM_INDEFINITE_WAIT) == NO_ERROR) {
 31.1014 -                int numrects;
 31.1015 -                SDL_Rect *rects;
 31.1016 -                int i;
 31.1017 -                SWP swp;
 31.1018 -
 31.1019 -                numrects = (int) mp1;
 31.1020 -                rects = (SDL_Rect *) mp2;
 31.1021 -
 31.1022 -                WinQueryWindowPos(hwnd, &swp);
 31.1023 -#ifndef RESIZE_EVEN_IF_RESIZABLE
 31.1024 -                if ((!pVideo->hidden->pSDLSurface) ||
 31.1025 -                    ((pVideo->hidden->pSDLSurface) &&
 31.1026 -                     (pVideo->hidden->pSDLSurface->flags & SDL_RESIZABLE)
 31.1027 -                     &&
 31.1028 -                     ((swp.cx != pVideo->hidden->SrcBufferDesc.uiXResolution)
 31.1029 -                      || (swp.cy !=
 31.1030 -                          pVideo->hidden->SrcBufferDesc.uiYResolution))
 31.1031 -                     && (!FSLib_QueryFSMode(hwnd)))) {
 31.1032 -                    // Resizable surface and in resizing!
 31.1033 -                    // So, don't blit now!
 31.1034 -#ifdef DEBUG_BUILD
 31.1035 -                    printf
 31.1036 -                        ("[WM_UPDATERECTSREQUEST] : Skipping blit while resizing!\n");
 31.1037 -                    fflush(stdout);
 31.1038 -#endif
 31.1039 -                } else
 31.1040 -#endif
 31.1041 -                {
 31.1042 -#ifdef DEBUG_BUILD
 31.1043 -                    printf("[WM_UPDATERECTSREQUEST] : Blitting!\n");
 31.1044 -                    fflush(stdout);
 31.1045 -#endif
 31.1046 -
 31.1047 -                    // Blit the changed areas
 31.1048 -                    for (i = 0; i < numrects; i++)
 31.1049 -                        FSLIB_BITBLT(hwnd,
 31.1050 -                                     pVideo->hidden->pchSrcBuffer,
 31.1051 -                                     rects[i].y, rects[i].x,
 31.1052 -                                     rects[i].w, rects[i].h);
 31.1053 -                }
 31.1054 -                DosReleaseMutexSem(pVideo->hidden->hmtxUseSrcBuffer);
 31.1055 -            }
 31.1056 -        }
 31.1057 -        return 0;
 31.1058 -#endif
 31.1059 -
 31.1060 -    default:
 31.1061 -#ifdef DEBUG_BUILD
 31.1062 -        printf("Unhandled: %x\n", msg);
 31.1063 -        fflush(stdout);
 31.1064 -#endif
 31.1065 -
 31.1066 -        break;
 31.1067 -    }
 31.1068 -    // Run the default window procedure for unhandled stuffs
 31.1069 -    return WinDefWindowProc(hwnd, msg, mp1, mp2);
 31.1070 -}
 31.1071 -
 31.1072 -/////////////////////////////////////////////////////////////////////
 31.1073 -//
 31.1074 -// FrameWndProc
 31.1075 -//
 31.1076 -// This is the message processing window procedure for the
 31.1077 -// frame window of SDLWindowClass.
 31.1078 -//
 31.1079 -/////////////////////////////////////////////////////////////////////
 31.1080 -static MRESULT EXPENTRY
 31.1081 -FrameWndProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
 31.1082 -{
 31.1083 -    PFNWP pOldFrameProc;
 31.1084 -    MRESULT result;
 31.1085 -    PTRACKINFO ti;
 31.1086 -    int cx, cy, ncx, ncy;
 31.1087 -    RECTL rclTemp;
 31.1088 -    PSWP pswpTemp;
 31.1089 -
 31.1090 -    SDL_VideoDevice *pVideo = NULL;
 31.1091 -
 31.1092 -    pVideo = (SDL_VideoDevice *) WinQueryWindowULong(hwnd, QWL_USER);
 31.1093 -
 31.1094 -    pOldFrameProc = pVideo->hidden->pfnOldFrameProc;
 31.1095 -
 31.1096 -    if ((pVideo->hidden->bProportionalResize) &&
 31.1097 -        (msg == WM_ADJUSTWINDOWPOS) &&
 31.1098 -        (!FSLib_QueryFSMode(pVideo->hidden->hwndClient))) {
 31.1099 -        pswpTemp = (PSWP) mp1;
 31.1100 -
 31.1101 -        /* Resizing? */
 31.1102 -        if (pswpTemp->fl & SWP_SIZE) {
 31.1103 -            /* Calculate client size */
 31.1104 -            rclTemp.xLeft = pswpTemp->x;
 31.1105 -            rclTemp.xRight = pswpTemp->x + pswpTemp->cx;
 31.1106 -            rclTemp.yBottom = pswpTemp->y;
 31.1107 -            rclTemp.yTop = pswpTemp->y + pswpTemp->cy;
 31.1108 -            WinCalcFrameRect(hwnd, &rclTemp, TRUE);
 31.1109 -
 31.1110 -            ncx = cx = rclTemp.xRight - rclTemp.xLeft;
 31.1111 -            ncy = cy = rclTemp.yTop - rclTemp.yBottom;
 31.1112 -
 31.1113 -            /* Calculate new size to keep it proportional */
 31.1114 -
 31.1115 -            if ((pVideo->hidden->ulResizingFlag & TF_LEFT)
 31.1116 -                || (pVideo->hidden->ulResizingFlag & TF_RIGHT)) {
 31.1117 -                /* The window is resized horizontally */
 31.1118 -                ncy =
 31.1119 -                    pVideo->hidden->SrcBufferDesc.uiYResolution * cx /
 31.1120 -                    pVideo->hidden->SrcBufferDesc.uiXResolution;
 31.1121 -            } else if ((pVideo->hidden->ulResizingFlag & TF_TOP)
 31.1122 -                       || (pVideo->hidden->ulResizingFlag & TF_BOTTOM)) {
 31.1123 -                /* The window is resized vertically */
 31.1124 -                ncx =
 31.1125 -                    pVideo->hidden->SrcBufferDesc.uiXResolution * cy /
 31.1126 -                    pVideo->hidden->SrcBufferDesc.uiYResolution;
 31.1127 -            }
 31.1128 -
 31.1129 -            /* Calculate back frame coordinates */
 31.1130 -            rclTemp.xLeft = pswpTemp->x;
 31.1131 -            rclTemp.xRight = pswpTemp->x + ncx;
 31.1132 -            rclTemp.yBottom = pswpTemp->y;
 31.1133 -            rclTemp.yTop = pswpTemp->y + ncy;
 31.1134 -            WinCalcFrameRect(hwnd, &rclTemp, FALSE);
 31.1135 -
 31.1136 -            /* Store new size/position info */
 31.1137 -            pswpTemp->cx = rclTemp.xRight - rclTemp.xLeft;
 31.1138 -
 31.1139 -            if (!(pVideo->hidden->ulResizingFlag & TF_TOP)) {
 31.1140 -                pswpTemp->y =
 31.1141 -                    pswpTemp->y + pswpTemp->cy - (rclTemp.yTop -
 31.1142 -                                                  rclTemp.yBottom);
 31.1143 -                pswpTemp->cy = rclTemp.yTop - rclTemp.yBottom;
 31.1144 -            } else {
 31.1145 -                pswpTemp->cy = rclTemp.yTop - rclTemp.yBottom;
 31.1146 -            }
 31.1147 -        }
 31.1148 -    }
 31.1149 -
 31.1150 -    result = (*pOldFrameProc) (hwnd, msg, mp1, mp2);
 31.1151 -
 31.1152 -    if ((pVideo->hidden->bProportionalResize) && (msg == WM_QUERYTRACKINFO)) {
 31.1153 -        ti = (PTRACKINFO) mp2;
 31.1154 -
 31.1155 -        /* Store the direction of resizing */
 31.1156 -        if ((ti->fs & TF_LEFT) || (ti->fs & TF_RIGHT) ||
 31.1157 -            (ti->fs & TF_TOP) || (ti->fs & TF_BOTTOM))
 31.1158 -            pVideo->hidden->ulResizingFlag = ti->fs;
 31.1159 -    }
 31.1160 -
 31.1161 -    return result;
 31.1162 -}
 31.1163 -
 31.1164 -/////////////////////////////////////////////////////////////////////
 31.1165 -//
 31.1166 -// PMThreadFunc
 31.1167 -//
 31.1168 -// This function implements the PM-Thread, which initializes the
 31.1169 -// application window itself, the DIVE, and start message processing.
 31.1170 -//
 31.1171 -/////////////////////////////////////////////////////////////////////
 31.1172 -int iNumOfPMThreadInstances = 0;        // Global!
 31.1173 -static void
 31.1174 -PMThreadFunc(void *pParm)
 31.1175 -{
 31.1176 -    SDL_VideoDevice *pVideo = pParm;
 31.1177 -    HAB hab;
 31.1178 -    HMQ hmq;
 31.1179 -    QMSG msg;
 31.1180 -    ULONG fcf;
 31.1181 -
 31.1182 -#ifdef DEBUG_BUILD
 31.1183 -    printf("[PMThreadFunc] : Starting\n");
 31.1184 -    fflush(stdout);
 31.1185 -#endif
 31.1186 -
 31.1187 -    iNumOfPMThreadInstances++;
 31.1188 -
 31.1189 -    // Initialize PM, create a message queue.
 31.1190 -
 31.1191 -    hab = WinInitialize(0);
 31.1192 -    hmq = WinCreateMsgQueue(hab, 0);
 31.1193 -    if (hmq == 0) {
 31.1194 -#ifdef DEBUG_BUILD
 31.1195 -        printf("[PMThreadFunc] : Could not create message queue!\n");
 31.1196 -        printf
 31.1197 -            ("                 It might be that the application using SDL is not a PM app!\n");
 31.1198 -        fflush(stdout);
 31.1199 -#endif
 31.1200 -        pVideo->hidden->iPMThreadStatus = 2;
 31.1201 -    } else {
 31.1202 -        int rc;
 31.1203 -        RECTL rectl;
 31.1204 -
 31.1205 -        fcf = ulFCFToUse;       // Get from global setting
 31.1206 -
 31.1207 -#ifdef DEBUG_BUILD
 31.1208 -        printf("[PMThreadFunc] : FSLib_CreateWindow()!\n");
 31.1209 -        fflush(stdout);
 31.1210 -#endif
 31.1211 -
 31.1212 -        rc = FSLib_CreateWindow(HWND_DESKTOP, 0, &fcf,
 31.1213 -                                "SDL Application",
 31.1214 -                                NULLHANDLE, 0,
 31.1215 -                                &(pVideo->hidden->SrcBufferDesc),
 31.1216 -                                WndProc,
 31.1217 -                                &(pVideo->hidden->hwndClient),
 31.1218 -                                &(pVideo->hidden->hwndFrame));
 31.1219 -
 31.1220 -#ifdef DEBUG_BUILD
 31.1221 -        printf("[PMThreadFunc] : FSLib_CreateWindow() rc = %d\n", rc);
 31.1222 -        fflush(stdout);
 31.1223 -#endif
 31.1224 -
 31.1225 -        if (!rc) {
 31.1226 -#ifdef DEBUG_BUILD
 31.1227 -            printf("[PMThreadFunc] : Could not create FSLib window!\n");
 31.1228 -            fflush(stdout);
 31.1229 -#endif
 31.1230 -            pVideo->hidden->iPMThreadStatus = 3;
 31.1231 -        } else {
 31.1232 -#ifdef DEBUG_BUILD
 31.1233 -            printf("[PMThreadFunc] : FSLib_AddUserParm()!\n");
 31.1234 -            fflush(stdout);
 31.1235 -#endif
 31.1236 -
 31.1237 -            // Store pVideo pointer in window data for client window, so
 31.1238 -            // it will know the instance to which it belongs to.
 31.1239 -            FSLib_AddUserParm(pVideo->hidden->hwndClient, pVideo);
 31.1240 -
 31.1241 -            // Now set default image width height and fourcc!
 31.1242 -#ifdef DEBUG_BUILD
 31.1243 -            printf("[PMThreadFunc] : SetWindowPos()!\n");
 31.1244 -            fflush(stdout);
 31.1245 -#endif
 31.1246 -
 31.1247 -            // Set the position and size of the main window,
 31.1248 -            // and make it visible!
 31.1249 -            // Calculate frame window size from client window size
 31.1250 -            rectl.xLeft = 0;
 31.1251 -            rectl.yBottom = 0;
 31.1252 -            rectl.xRight = pVideo->hidden->SrcBufferDesc.uiXResolution; // Noninclusive
 31.1253 -            rectl.yTop = pVideo->hidden->SrcBufferDesc.uiYResolution;   // Noninclusive
 31.1254 -            WinCalcFrameRect(pVideo->hidden->hwndFrame, &rectl, FALSE);
 31.1255 -
 31.1256 -            SetAccessableWindowPos(pVideo->hidden->hwndFrame,
 31.1257 -                                   HWND_TOP,
 31.1258 -                                   (WinQuerySysValue
 31.1259 -                                    (HWND_DESKTOP,
 31.1260 -                                     SV_CXSCREEN) - (rectl.xRight -
 31.1261 -                                                     rectl.xLeft)) / 2,
 31.1262 -                                   (WinQuerySysValue
 31.1263 -                                    (HWND_DESKTOP,
 31.1264 -                                     SV_CYSCREEN) - (rectl.yTop -
 31.1265 -                                                     rectl.yBottom)) / 2,
 31.1266 -                                   (rectl.xRight - rectl.xLeft),
 31.1267 -                                   (rectl.yTop - rectl.yBottom),
 31.1268 -                                   SWP_SIZE | SWP_ACTIVATE | SWP_SHOW |
 31.1269 -                                   SWP_MOVE);
 31.1270 -
 31.1271 -            // Subclass frame procedure and store old window proc address
 31.1272 -            pVideo->hidden->pfnOldFrameProc =
 31.1273 -                WinSubclassWindow(pVideo->hidden->hwndFrame, FrameWndProc);
 31.1274 -            WinSetWindowULong(pVideo->hidden->hwndFrame, QWL_USER,
 31.1275 -                              (ULONG) pVideo);
 31.1276 -
 31.1277 -#ifdef DEBUG_BUILD
 31.1278 -            printf("[PMThreadFunc] : Entering message loop\n");
 31.1279 -            fflush(stdout);
 31.1280 -#endif
 31.1281 -            pVideo->hidden->iPMThreadStatus = 1;
 31.1282 -
 31.1283 -            while (WinGetMsg(hab, (PQMSG) & msg, 0, 0, 0))
 31.1284 -                WinDispatchMsg(hab, (PQMSG) & msg);
 31.1285 -
 31.1286 -#ifdef DEBUG_BUILD
 31.1287 -            printf("[PMThreadFunc] : Leaving message loop\n");
 31.1288 -            fflush(stdout);
 31.1289 -#endif
 31.1290 -            // We should release the captured the mouse!
 31.1291 -            if (bMouseCaptured) {
 31.1292 -                WinSetCapture(HWND_DESKTOP, NULLHANDLE);
 31.1293 -                bMouseCaptured = 0;
 31.1294 -            }
 31.1295 -            // Destroy our window
 31.1296 -            WinDestroyWindow(pVideo->hidden->hwndFrame);
 31.1297 -            pVideo->hidden->hwndFrame = NULL;
 31.1298 -            // Show pointer to make sure it will not be left hidden.
 31.1299 -            WinSetPointer(HWND_DESKTOP,
 31.1300 -                          WinQuerySysPointer(HWND_DESKTOP, SPTR_ARROW,
 31.1301 -                                             FALSE));
 31.1302 -            WinShowPointer(HWND_DESKTOP, TRUE);
 31.1303 -        }
 31.1304 -        // Uninitialize PM
 31.1305 -        WinDestroyMsgQueue(hmq);
 31.1306 -        // All done!
 31.1307 -        pVideo->hidden->iPMThreadStatus = 0;
 31.1308 -    }
 31.1309 -    WinTerminate(hab);
 31.1310 -    /* Commented out, should not be needed anymore, because we send it
 31.1311 -       from WM_CLOSE.
 31.1312 -       // Notify SDL that it should really die now...
 31.1313 -       SDL_PrivateQuit(); SDL_PrivateQuit(); SDL_PrivateQuit(); //... :))
 31.1314 -     */
 31.1315 -#ifdef DEBUG_BUILD
 31.1316 -    printf("[PMThreadFunc] : End, status is %d!\n",
 31.1317 -           pVideo->hidden->iPMThreadStatus);
 31.1318 -    fflush(stdout);
 31.1319 -#endif
 31.1320 -
 31.1321 -    iNumOfPMThreadInstances--;
 31.1322 -
 31.1323 -    // HACK to prevent zombie and hanging SDL applications, which does not take
 31.1324 -    // care of closing the window for some reason:
 31.1325 -    // There are some apps which do not process messages, so do a lot of things
 31.1326 -    // without noticing that the application should close. To close these,
 31.1327 -    // I've thought about the following:
 31.1328 -    // If the window is closed (the execution came here), I wait a bit to
 31.1329 -    // give time to the app to finish its execution. If it does not, I kill it
 31.1330 -    // using DosExit(). Brute force, but should work.
 31.1331 -    if (pVideo->hidden->iPMThreadStatus == 0) {
 31.1332 -        DosSleep(5000);         // Wait 5 secs
 31.1333 -        // If a new PM thread has been spawned (reinitializing video mode), then all right.
 31.1334 -        // Otherwise, we have a problem, the app doesn't want to stop. Kill!
 31.1335 -        if (iNumOfPMThreadInstances == 0) {
 31.1336 -#ifdef DEBUG_BUILD
 31.1337 -            printf
 31.1338 -                ("[PMThreadFunc] : It seems that the application haven't terminated itself\n");
 31.1339 -            fflush(stdout);
 31.1340 -            printf
 31.1341 -                ("[PMThreadFunc] : in the last 5 seconds, so we go berserk.\n");
 31.1342 -            fflush(stdout);
 31.1343 -            printf
 31.1344 -                ("[PMThreadFunc] : Brute force mode. :) Killing process! Dieeeee...\n");
 31.1345 -            fflush(stdout);
 31.1346 -#endif
 31.1347 -            DosExit(EXIT_PROCESS, -1);
 31.1348 -        }
 31.1349 -    }
 31.1350 -    _endthread();
 31.1351 -}
 31.1352 -
 31.1353 -struct WMcursor
 31.1354 -{
 31.1355 -    HBITMAP hbm;
 31.1356 -    HPOINTER hptr;
 31.1357 -    char *pchData;
 31.1358 -};
 31.1359 -
 31.1360 -/* Free a window manager cursor */
 31.1361 -void
 31.1362 -os2fslib_FreeWMCursor(_THIS, WMcursor * cursor)
 31.1363 -{
 31.1364 -    if (cursor) {
 31.1365 -        GpiDeleteBitmap(cursor->hbm);
 31.1366 -        WinDestroyPointer(cursor->hptr);
 31.1367 -        SDL_free(cursor->pchData);
 31.1368 -        SDL_free(cursor);
 31.1369 -    }
 31.1370 -}
 31.1371 -
 31.1372 -/* Local functions to convert the SDL cursor mask into OS/2 format */
 31.1373 -static void
 31.1374 -memnot(Uint8 * dst, Uint8 * src, int len)
 31.1375 -{
 31.1376 -    while (len-- > 0)
 31.1377 -        *dst++ = ~*src++;
 31.1378 -}
 31.1379 -
 31.1380 -static void
 31.1381 -memxor(Uint8 * dst, Uint8 * src1, Uint8 * src2, int len)
 31.1382 -{
 31.1383 -    while (len-- > 0)
 31.1384 -        *dst++ = (*src1++) ^ (*src2++);
 31.1385 -}
 31.1386 -
 31.1387 -/* Create a black/white window manager cursor */
 31.1388 -WMcursor *
 31.1389 -os2fslib_CreateWMCursor_Win(_THIS, Uint8 * data, Uint8 * mask,
 31.1390 -                            int w, int h, int hot_x, int hot_y)
 31.1391 -{
 31.1392 -    HPOINTER hptr;
 31.1393 -    HBITMAP hbm;
 31.1394 -    BITMAPINFOHEADER bmih;
 31.1395 -    BMPINFO bmi;
 31.1396 -    HPS hps;
 31.1397 -    char *pchTemp;
 31.1398 -    char *xptr, *aptr;
 31.1399 -    int maxx, maxy;
 31.1400 -    int i, run, pad;
 31.1401 -    WMcursor *pResult;
 31.1402 -
 31.1403 -    maxx = WinQuerySysValue(HWND_DESKTOP, SV_CXPOINTER);
 31.1404 -    maxy = WinQuerySysValue(HWND_DESKTOP, SV_CYPOINTER);
 31.1405 -
 31.1406 -    // Check for max size!
 31.1407 -    if ((w > maxx) || (h > maxy))
 31.1408 -        return (WMcursor *) NULL;
 31.1409 -
 31.1410 -    pResult = (WMcursor *) SDL_malloc(sizeof(WMcursor));
 31.1411 -    if (!pResult)
 31.1412 -        return (WMcursor *) NULL;
 31.1413 -
 31.1414 -    pchTemp = (char *) SDL_malloc((maxx + 7) / 8 * maxy * 2);
 31.1415 -    if (!pchTemp) {
 31.1416 -        SDL_free(pResult);
 31.1417 -        return (WMcursor *) NULL;
 31.1418 -    }
 31.1419 -
 31.1420 -    SDL_memset(pchTemp, 0, (maxx + 7) / 8 * maxy * 2);
 31.1421 -
 31.1422 -    hps = WinGetPS(_this->hidden->hwndClient);
 31.1423 -
 31.1424 -    bmi.cbFix = sizeof(BITMAPINFOHEADER);
 31.1425 -    bmi.cx = maxx;
 31.1426 -    bmi.cy = 2 * maxy;
 31.1427 -    bmi.cPlanes = 1;
 31.1428 -    bmi.cBitCount = 1;
 31.1429 -    bmi.argbColor[0].bBlue = 0x00;
 31.1430 -    bmi.argbColor[0].bGreen = 0x00;
 31.1431 -    bmi.argbColor[0].bRed = 0x00;
 31.1432 -    bmi.argbColor[1].bBlue = 0x00;
 31.1433 -    bmi.argbColor[1].bGreen = 0x00;
 31.1434 -    bmi.argbColor[1].bRed = 0xff;
 31.1435 -
 31.1436 -    SDL_memset(&bmih, 0, sizeof(BITMAPINFOHEADER));
 31.1437 -    bmih.cbFix = sizeof(BITMAPINFOHEADER);
 31.1438 -    bmih.cx = maxx;
 31.1439 -    bmih.cy = 2 * maxy;
 31.1440 -    bmih.cPlanes = 1;
 31.1441 -    bmih.cBitCount = 1;
 31.1442 -
 31.1443 -    run = (w + 7) / 8;
 31.1444 -    pad = (maxx + 7) / 8 - run;
 31.1445 -
 31.1446 -    for (i = 0; i < h; i++) {
 31.1447 -        xptr = pchTemp + (maxx + 7) / 8 * (maxy - 1 - i);
 31.1448 -        aptr = pchTemp + (maxx + 7) / 8 * (maxy + maxy - 1 - i);
 31.1449 -        memxor(xptr, data, mask, run);
 31.1450 -        xptr += run;
 31.1451 -        data += run;
 31.1452 -        memnot(aptr, mask, run);
 31.1453 -        mask += run;
 31.1454 -        aptr += run;
 31.1455 -        SDL_memset(xptr, 0, pad);
 31.1456 -        xptr += pad;
 31.1457 -        SDL_memset(aptr, ~0, pad);
 31.1458 -        aptr += pad;
 31.1459 -    }
 31.1460 -    pad += run;
 31.1461 -    for (i = h; i < maxy; i++) {
 31.1462 -        xptr = pchTemp + (maxx + 7) / 8 * (maxy - 1 - i);
 31.1463 -        aptr = pchTemp + (maxx + 7) / 8 * (maxy + maxy - 1 - i);
 31.1464 -
 31.1465 -        SDL_memset(xptr, 0, (maxx + 7) / 8);
 31.1466 -        xptr += (maxx + 7) / 8;
 31.1467 -        SDL_memset(aptr, ~0, (maxx + 7) / 8);
 31.1468 -        aptr += (maxx + 7) / 8;
 31.1469 -    }
 31.1470 -
 31.1471 -    hbm =
 31.1472 -        GpiCreateBitmap(hps, (PBITMAPINFOHEADER2) & bmih, CBM_INIT,
 31.1473 -                        (PBYTE) pchTemp, (PBITMAPINFO2) & bmi);
 31.1474 -    hptr = WinCreatePointer(HWND_DESKTOP, hbm, TRUE, hot_x, maxy - hot_y - 1);
 31.1475 -
 31.1476 -#ifdef DEBUG_BUILD
 31.1477 -    printf("HotSpot          : %d ; %d\n", hot_x, hot_y);
 31.1478 -    printf("HPS returned     : %x\n", (ULONG) hps);
 31.1479 -    printf("HBITMAP returned : %x\n", (ULONG) hbm);
 31.1480 -    printf("HPOINTER returned: %x\n", (ULONG) hptr);
 31.1481 -#endif
 31.1482 -
 31.1483 -    WinReleasePS(hps);
 31.1484 -
 31.1485 -#ifdef DEBUG_BUILD
 31.1486 -    printf("[CreateWMCursor] : ptr = %p\n", hptr);
 31.1487 -    fflush(stdout);
 31.1488 -#endif
 31.1489 -
 31.1490 -    pResult->hptr = hptr;
 31.1491 -    pResult->hbm = hbm;
 31.1492 -    pResult->pchData = pchTemp;
 31.1493 -
 31.1494 -#ifdef DEBUG_BUILD
 31.1495 -    printf("[CreateWMCursor] : ptr = %p return.\n", hptr);
 31.1496 -    fflush(stdout);
 31.1497 -#endif
 31.1498 -
 31.1499 -    return (WMcursor *) pResult;
 31.1500 -}
 31.1501 -
 31.1502 -WMcursor *
 31.1503 -os2fslib_CreateWMCursor_FS(_THIS, Uint8 * data, Uint8 * mask,
 31.1504 -                           int w, int h, int hot_x, int hot_y)
 31.1505 -{
 31.1506 -#ifdef DEBUG_BUILD
 31.1507 -    printf("[CreateWMCursor_FS] : returning pointer NULL\n");
 31.1508 -    fflush(stdout);
 31.1509 -#endif
 31.1510 -
 31.1511 -    // In FS mode we'll use software cursor
 31.1512 -    return (WMcursor *) NULL;
 31.1513 -}
 31.1514 -
 31.1515 -/* Show the specified cursor, or hide if cursor is NULL */
 31.1516 -int
 31.1517 -os2fslib_ShowWMCursor(_THIS, WMcursor * cursor)
 31.1518 -{
 31.1519 -#ifdef DEBUG_BUILD
 31.1520 -    printf("[ShowWMCursor] : ptr = %p\n", cursor);
 31.1521 -    fflush(stdout);
 31.1522 -#endif
 31.1523 -
 31.1524 -    if (cursor) {
 31.1525 -        WinSetPointer(HWND_DESKTOP, cursor->hptr);
 31.1526 -        hptrGlobalPointer = cursor->hptr;
 31.1527 -        _this->hidden->iMouseVisible = 1;
 31.1528 -    } else {
 31.1529 -        WinSetPointer(HWND_DESKTOP, FALSE);
 31.1530 -        hptrGlobalPointer = NULL;
 31.1531 -        _this->hidden->iMouseVisible = 0;
 31.1532 -    }
 31.1533 -
 31.1534 -#ifdef DEBUG_BUILD
 31.1535 -    printf("[ShowWMCursor] : ptr = %p, DONE\n", cursor);
 31.1536 -    fflush(stdout);
 31.1537 -#endif
 31.1538 -
 31.1539 -    return 1;
 31.1540 -}
 31.1541 -
 31.1542 -/* Warp the window manager cursor to (x,y)
 31.1543 - If NULL, a mouse motion event is posted internally.
 31.1544 - */
 31.1545 -void
 31.1546 -os2fslib_WarpWMCursor(_THIS, Uint16 x, Uint16 y)
 31.1547 -{
 31.1548 -    LONG lx, ly;
 31.1549 -    SWP swpClient;
 31.1550 -    POINTL ptlPoints;
 31.1551 -    WinQueryWindowPos(_this->hidden->hwndClient, &swpClient);
 31.1552 -    ptlPoints.x = swpClient.x;
 31.1553 -    ptlPoints.y = swpClient.y;
 31.1554 -    WinMapWindowPoints(_this->hidden->hwndFrame, HWND_DESKTOP, &ptlPoints, 1);
 31.1555 -    lx = ptlPoints.x +
 31.1556 -        (x * swpClient.cx) / _this->hidden->SrcBufferDesc.uiXResolution;
 31.1557 -    ly = ptlPoints.y + swpClient.cy -
 31.1558 -        ((y * swpClient.cy) / _this->hidden->SrcBufferDesc.uiYResolution) - 1;
 31.1559 -
 31.1560 -    SDL_PrivateMouseMotion(0,   // Buttons not changed
 31.1561 -                           0,   // Absolute position
 31.1562 -                           x, y);
 31.1563 -
 31.1564 -    WinSetPointerPos(HWND_DESKTOP, lx, ly);
 31.1565 -
 31.1566 -}
 31.1567 -
 31.1568 -/* If not NULL, this is called when a mouse motion event occurs */
 31.1569 -void
 31.1570 -os2fslib_MoveWMCursor(_THIS, int x, int y)
 31.1571 -{
 31.1572 -    /*
 31.1573 -       SDL_Rect rect;
 31.1574 -
 31.1575 -       #ifdef DEBUG_BUILD
 31.1576 -       printf("[MoveWMCursor] : at %d ; %d\n", x, y); fflush(stdout);
 31.1577 -       #endif
 31.1578 -
 31.1579 -       rect.x = x;
 31.1580 -       rect.y = y;
 31.1581 -       rect.w = 32;
 31.1582 -       rect.h = 32;
 31.1583 -       os2fslib_UpdateRects(_this, 1, &rect);
 31.1584 -       // TODO!
 31.1585 -     */
 31.1586 -}
 31.1587 -
 31.1588 -/* Determine whether the mouse should be in relative mode or not.
 31.1589 - This function is called when the input grab state or cursor
 31.1590 - visibility state changes.
 31.1591 - If the cursor is not visible, and the input is grabbed, the
 31.1592 - driver can place the mouse in relative mode, which may result
 31.1593 - in higher accuracy sampling of the pointer motion.
 31.1594 - */
 31.1595 -void
 31.1596 -os2fslib_CheckMouseMode(_THIS)
 31.1597 -{
 31.1598 -}
 31.1599 -
 31.1600 -static void
 31.1601 -os2fslib_PumpEvents(_THIS)
 31.1602 -{
 31.1603 -    // Notify SDL that if window has been resized!
 31.1604 -    if ((_this->hidden->pSDLSurface) &&
 31.1605 -        (_this->hidden->pSDLSurface->flags & SDL_RESIZABLE) &&
 31.1606 -        ((_this->hidden->SrcBufferDesc.uiXResolution != iWindowSizeX) ||
 31.1607 -         (_this->hidden->SrcBufferDesc.uiYResolution != iWindowSizeY)) &&
 31.1608 -        (iWindowSizeX > 0) && (iWindowSizeY > 0)) {
 31.1609 -        static time_t prev_time;
 31.1610 -        time_t curr_time;
 31.1611 -
 31.1612 -        curr_time = time(NULL);
 31.1613 -        if ((difftime(curr_time, prev_time) >= 0.25) || (bWindowResized)) {
 31.1614 -            // Make sure we won't flood the event queue with resize events,
 31.1615 -            // only send them at 250 msecs!
 31.1616 -            // (or when the window is resized)
 31.1617 -#ifdef DEBUG_BUILD
 31.1618 -            printf
 31.1619 -                ("[os2fslib_PumpEvents] : Calling PrivateResize (%d %d).\n",
 31.1620 -                 iWindowSizeX, iWindowSizeY);
 31.1621 -            fflush(stdout);
 31.1622 -#endif
 31.1623 -            // Tell SDL the new size
 31.1624 -            SDL_PrivateResize(iWindowSizeX, iWindowSizeY);
 31.1625 -            prev_time = curr_time;
 31.1626 -            bWindowResized = 0;
 31.1627 -        }
 31.1628 -    }
 31.1629 -}
 31.1630 -
 31.1631 -/* We don't actually allow hardware surfaces other than the main one */
 31.1632 -static int
 31.1633 -os2fslib_AllocHWSurface(_THIS, SDL_Surface * surface)
 31.1634 -{
 31.1635 -    return (-1);
 31.1636 -}
 31.1637 -
 31.1638 -static void
 31.1639 -os2fslib_FreeHWSurface(_THIS, SDL_Surface * surface)
 31.1640 -{
 31.1641 -    return;
 31.1642 -}
 31.1643 -
 31.1644 -/* We need to wait for vertical retrace on page flipped displays */
 31.1645 -static int
 31.1646 -os2fslib_LockHWSurface(_THIS, SDL_Surface * surface)
 31.1647 -{
 31.1648 -    return (0);
 31.1649 -}
 31.1650 -
 31.1651 -static void
 31.1652 -os2fslib_UnlockHWSurface(_THIS, SDL_Surface * surface)
 31.1653 -{
 31.1654 -    return;
 31.1655 -}
 31.1656 -
 31.1657 -static int
 31.1658 -os2fslib_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color * colors)
 31.1659 -{
 31.1660 -    printf("[os2fslib_SetColors] : TODO!\n");
 31.1661 -    fflush(stdout);
 31.1662 -    // TODO: Implement paletted modes
 31.1663 -    return (1);
 31.1664 -}
 31.1665 -
 31.1666 -static void
 31.1667 -os2fslib_DestroyIcon(HWND hwndFrame)
 31.1668 -{
 31.1669 -    if (hptrCurrentIcon) {
 31.1670 -        WinDestroyPointer(hptrCurrentIcon);
 31.1671 -        hptrCurrentIcon = NULL;
 31.1672 -
 31.1673 -        WinSendMsg(hwndFrame, WM_SETICON, NULL, NULL);
 31.1674 -    }
 31.1675 -
 31.1676 -}
 31.1677 -
 31.1678 -/* Set the window icon image */
 31.1679 -void
 31.1680 -os2fslib_SetIcon(_THIS, SDL_Surface * icon, Uint8 * mask)
 31.1681 -{
 31.1682 -    HWND hwndFrame;
 31.1683 -    SDL_Surface *icon_rgb;
 31.1684 -    HPOINTER hptrIcon;
 31.1685 -    HBITMAP hbm;
 31.1686 -    BITMAPINFOHEADER bmih;
 31.1687 -    BMPINFO bmi;
 31.1688 -    HPS hps;
 31.1689 -    char *pchTemp;
 31.1690 -    char *pptr, *mptr, *dptr, *dmptr;
 31.1691 -    int maxx, maxy, w, h, x, y;
 31.1692 -    SDL_Rect bounds;
 31.1693 -
 31.1694 -#ifdef DEBUG_BUILD
 31.1695 -    printf("[os2fslib_SetIcon] : Creating and setting new icon\n");
 31.1696 -    fflush(stdout);
 31.1697 -#endif
 31.1698 -
 31.1699 -    hwndFrame = WinQueryWindow(_this->hidden->hwndClient, QW_PARENT);
 31.1700 -
 31.1701 -    // Make sure the old icon resource will be free'd!
 31.1702 -    os2fslib_DestroyIcon(hwndFrame);
 31.1703 -
 31.1704 -    if ((!icon) || (!mask))
 31.1705 -        return;
 31.1706 -
 31.1707 -    w = icon->w;
 31.1708 -    h = icon->h;
 31.1709 -
 31.1710 -    maxx = WinQuerySysValue(HWND_DESKTOP, SV_CXICON);
 31.1711 -    maxy = WinQuerySysValue(HWND_DESKTOP, SV_CYICON);
 31.1712 -
 31.1713 -    // Check for max size!
 31.1714 -    if ((w > maxx) || (h > maxy))
 31.1715 -        return;
 31.1716 -
 31.1717 -    pchTemp = (char *) SDL_malloc(w * h * 2 * 4);
 31.1718 -    if (!pchTemp)
 31.1719 -        return;
 31.1720 -
 31.1721 -    SDL_memset(pchTemp, 0, w * h * 2 * 4);
 31.1722 -
 31.1723 -    // Convert surface to RGB, if it's not RGB yet!
 31.1724 -    icon_rgb = SDL_CreateRGBSurface(SDL_SWSURFACE, icon->w, icon->h,
 31.1725 -                                    32, 0, 0, 0, 0);
 31.1726 -    if (icon_rgb == NULL) {
 31.1727 -        SDL_free(pchTemp);
 31.1728 -        return;
 31.1729 -    }
 31.1730 -    bounds.x = 0;
 31.1731 -    bounds.y = 0;
 31.1732 -    bounds.w = icon->w;
 31.1733 -    bounds.h = icon->h;
 31.1734 -    if (SDL_LowerBlit(icon, &bounds, icon_rgb, &bounds) < 0) {
 31.1735 -        SDL_FreeSurface(icon_rgb);
 31.1736 -        SDL_free(pchTemp);
 31.1737 -        return;
 31.1738 -    }
 31.1739 -
 31.1740 -    /* Copy pixels upside-down from RGB surface into BMP, masked with the icon mask */
 31.1741 -
 31.1742 -    // Pixels
 31.1743 -    pptr = (char *) (icon_rgb->pixels);
 31.1744 -    // Mask
 31.1745 -    mptr = mask;
 31.1746 -
 31.1747 -    for (y = 0; y < h; y++) {
 31.1748 -        unsigned char uchMaskByte;
 31.1749 -
 31.1750 -        // Destination
 31.1751 -        dptr = pchTemp + w * 4 * (h - y - 1);
 31.1752 -        // Destination mask
 31.1753 -        dmptr = pchTemp + w * h * 4 + w * 4 * (h - y - 1);
 31.1754 -
 31.1755 -        for (x = 0; x < w; x++) {
 31.1756 -            if (x % 8 == 0) {
 31.1757 -                uchMaskByte = (unsigned char) (*mptr);
 31.1758 -                mptr++;
 31.1759 -            } else
 31.1760 -                uchMaskByte <<= 1;
 31.1761 -
 31.1762 -            if (uchMaskByte & 0x80) {
 31.1763 -                // Copy RGB
 31.1764 -                *dptr++ = *pptr++;
 31.1765 -                *dptr++ = *pptr++;
 31.1766 -                *dptr++ = *pptr++;
 31.1767 -                *dptr++ = *pptr++;
 31.1768 -
 31.1769 -                *dmptr++ = 0;
 31.1770 -                *dmptr++ = 0;
 31.1771 -                *dmptr++ = 0;
 31.1772 -                *dmptr++ = 0;
 31.1773 -            } else {
 31.1774 -                // Set pixels to fully transparent
 31.1775 -                *dptr++ = 0;
 31.1776 -                pptr++;
 31.1777 -                *dptr++ = 0;
 31.1778 -                pptr++;
 31.1779 -                *dptr++ = 0;
 31.1780 -                pptr++;
 31.1781 -                *dptr++ = 0;
 31.1782 -                pptr++;
 31.1783 -
 31.1784 -                *dmptr++ = 255;
 31.1785 -                *dmptr++ = 255;
 31.1786 -                *dmptr++ = 255;
 31.1787 -                *dmptr++ = 255;
 31.1788 -            }
 31.1789 -        }
 31.1790 -    }
 31.1791 -
 31.1792 -    // There is no more need for the RGB surface
 31.1793 -    SDL_FreeSurface(icon_rgb);
 31.1794 -
 31.1795 -    hps = WinGetPS(_this->hidden->hwndClient);
 31.1796 -
 31.1797 -    bmi.cbFix = sizeof(BITMAPINFOHEADER);
 31.1798 -    bmi.cx = w;
 31.1799 -    bmi.cy = 2 * h;
 31.1800 -    bmi.cPlanes = 1;
 31.1801 -    bmi.cBitCount = 32;
 31.1802 -
 31.1803 -    SDL_memset(&bmih, 0, sizeof(BITMAPINFOHEADER));
 31.1804 -    bmih.cbFix = sizeof(BITMAPINFOHEADER);
 31.1805 -    bmih.cx = w;
 31.1806 -    bmih.cy = 2 * h;
 31.1807 -    bmih.cPlanes = 1;
 31.1808 -    bmih.cBitCount = 32;
 31.1809 -
 31.1810 -    hbm =
 31.1811 -        GpiCreateBitmap(hps, (PBITMAPINFOHEADER2) & bmih, CBM_INIT,
 31.1812 -                        (PBYTE) pchTemp, (PBITMAPINFO2) & bmi);
 31.1813 -    hptrIcon = WinCreatePointer(HWND_DESKTOP, hbm, FALSE, 0, 0);
 31.1814 -
 31.1815 -    WinReleasePS(hps);
 31.1816 -
 31.1817 -    // Free pixel array
 31.1818 -    SDL_free(pchTemp);
 31.1819 -
 31.1820 -    // Change icon in frame window
 31.1821 -    WinSendMsg(hwndFrame, WM_SETICON, (MPARAM) hptrIcon, NULL);
 31.1822 -
 31.1823 -    /*
 31.1824 -       // Change icon in switchlist
 31.1825 -       // Seems like it's not needed, the WM_SETICON already does it.
 31.1826 -       {
 31.1827 -       PID pidFrame;
 31.1828 -       HSWITCH hswitchFrame;
 31.1829 -       SWCNTRL swctl;
 31.1830 -
 31.1831 -       WinQueryWindowProcess(hwndFrame, &pidFrame, NULL);
 31.1832 -       hswitchFrame = WinQuerySwitchHandle(hwndFrame, pidFrame);
 31.1833 -       WinQuerySwitchEntry(hswitchFrame, &swctl);
 31.1834 -
 31.1835 -       swctl.hwndIcon = hptrIcon;
 31.1836 -
 31.1837 -       WinChangeSwitchEntry(hswitchFrame, &swctl);
 31.1838 -       }
 31.1839 -     */
 31.1840 -
 31.1841 -    // Store icon handle in global variable
 31.1842 -    hptrCurrentIcon = hptrIcon;
 31.1843 -}
 31.1844 -
 31.1845 -// ------------------------ REAL FUNCTIONS -----------------
 31.1846 -
 31.1847 -
 31.1848 -static void
 31.1849 -os2fslib_SetCursorManagementFunctions(_THIS, int iForWindowedMode)
 31.1850 -{
 31.1851 -    if (iForWindowedMode) {
 31.1852 -        _this->FreeWMCursor = os2fslib_FreeWMCursor;
 31.1853 -        _this->CreateWMCursor = os2fslib_CreateWMCursor_Win;
 31.1854 -        _this->ShowWMCursor = os2fslib_ShowWMCursor;
 31.1855 -        _this->WarpWMCursor = os2fslib_WarpWMCursor;
 31.1856 -        _this->MoveWMCursor = os2fslib_MoveWMCursor;
 31.1857 -        _this->CheckMouseMode = NULL;   //os2fslib_CheckMouseMode;
 31.1858 -    } else {
 31.1859 -        // We'll have software mouse cursor in FS mode!
 31.1860 -        _this->FreeWMCursor = os2fslib_FreeWMCursor;
 31.1861 -        _this->CreateWMCursor = os2fslib_CreateWMCursor_FS;
 31.1862 -        _this->ShowWMCursor = os2fslib_ShowWMCursor;
 31.1863 -        _this->WarpWMCursor = os2fslib_WarpWMCursor;
 31.1864 -        _this->MoveWMCursor = os2fslib_MoveWMCursor;
 31.1865 -        _this->CheckMouseMode = NULL;   //os2fslib_CheckMouseMode;
 31.1866 -    }
 31.1867 -}
 31.1868 -
 31.1869 -static void
 31.1870 -os2fslib_InitOSKeymap(_THIS)
 31.1871 -{
 31.1872 -    int i;
 31.1873 -
 31.1874 -    iShiftIsPressed = 0;
 31.1875 -
 31.1876 -    /* Map the VK and CH keysyms */
 31.1877 -    for (i = 0; i <= 255; ++i)
 31.1878 -        HWScanKeyMap[i] = SDLK_UNKNOWN;
 31.1879 -
 31.1880 -    // First line of keyboard:
 31.1881 -    HWScanKeyMap[0x1] = SDLK_ESCAPE;
 31.1882 -    HWScanKeyMap[0x3b] = SDLK_F1;
 31.1883 -    HWScanKeyMap[0x3c] = SDLK_F2;
 31.1884 -    HWScanKeyMap[0x3d] = SDLK_F3;
 31.1885 -    HWScanKeyMap[0x3e] = SDLK_F4;
 31.1886 -    HWScanKeyMap[0x3f] = SDLK_F5;
 31.1887 -    HWScanKeyMap[0x40] = SDLK_F6;
 31.1888 -    HWScanKeyMap[0x41] = SDLK_F7;
 31.1889 -    HWScanKeyMap[0x42] = SDLK_F8;
 31.1890 -    HWScanKeyMap[0x43] = SDLK_F9;
 31.1891 -    HWScanKeyMap[0x44] = SDLK_F10;
 31.1892 -    HWScanKeyMap[0x57] = SDLK_F11;
 31.1893 -    HWScanKeyMap[0x58] = SDLK_F12;
 31.1894 -    HWScanKeyMap[0x5d] = SDLK_PRINT;
 31.1895 -    HWScanKeyMap[0x46] = SDLK_SCROLLOCK;
 31.1896 -    HWScanKeyMap[0x5f] = SDLK_PAUSE;
 31.1897 -
 31.1898 -    // Second line of keyboard:
 31.1899 -    HWScanKeyMap[0x29] = SDLK_BACKQUOTE;
 31.1900 -    HWScanKeyMap[0x2] = SDLK_1;
 31.1901 -    HWScanKeyMap[0x3] = SDLK_2;
 31.1902 -    HWScanKeyMap[0x4] = SDLK_3;
 31.1903 -    HWScanKeyMap[0x5] = SDLK_4;
 31.1904 -    HWScanKeyMap[0x6] = SDLK_5;
 31.1905 -    HWScanKeyMap[0x7] = SDLK_6;
 31.1906 -    HWScanKeyMap[0x8] = SDLK_7;
 31.1907 -    HWScanKeyMap[0x9] = SDLK_8;
 31.1908 -    HWScanKeyMap[0xa] = SDLK_9;
 31.1909 -    HWScanKeyMap[0xb] = SDLK_0;
 31.1910 -    HWScanKeyMap[0xc] = SDLK_MINUS;
 31.1911 -    HWScanKeyMap[0xd] = SDLK_EQUALS;
 31.1912 -    HWScanKeyMap[0xe] = SDLK_BACKSPACE;
 31.1913 -    HWScanKeyMap[0x68] = SDLK_INSERT;
 31.1914 -    HWScanKeyMap[0x60] = SDLK_HOME;
 31.1915 -    HWScanKeyMap[0x62] = SDLK_PAGEUP;
 31.1916 -    HWScanKeyMap[0x45] = SDLK_NUMLOCK;
 31.1917 -    HWScanKeyMap[0x5c] = SDLK_KP_DIVIDE;
 31.1918 -    HWScanKeyMap[0x37] = SDLK_KP_MULTIPLY;
 31.1919 -    HWScanKeyMap[0x4a] = SDLK_KP_MINUS;
 31.1920 -
 31.1921 -    // Third line of keyboard:
 31.1922 -    HWScanKeyMap[0xf] = SDLK_TAB;
 31.1923 -    HWScanKeyMap[0x10] = SDLK_q;
 31.1924 -    HWScanKeyMap[0x11] = SDLK_w;
 31.1925 -    HWScanKeyMap[0x12] = SDLK_e;
 31.1926 -    HWScanKeyMap[0x13] = SDLK_r;
 31.1927 -    HWScanKeyMap[0x14] = SDLK_t;
 31.1928 -    HWScanKeyMap[0x15] = SDLK_y;
 31.1929 -    HWScanKeyMap[0x16] = SDLK_u;
 31.1930 -    HWScanKeyMap[0x17] = SDLK_i;
 31.1931 -    HWScanKeyMap[0x18] = SDLK_o;
 31.1932 -    HWScanKeyMap[0x19] = SDLK_p;
 31.1933 -    HWScanKeyMap[0x1a] = SDLK_LEFTBRACKET;
 31.1934 -    HWScanKeyMap[0x1b] = SDLK_RIGHTBRACKET;
 31.1935 -    HWScanKeyMap[0x1c] = SDLK_RETURN;
 31.1936 -    HWScanKeyMap[0x69] = SDLK_DELETE;
 31.1937 -    HWScanKeyMap[0x65] = SDLK_END;
 31.1938 -    HWScanKeyMap[0x67] = SDLK_PAGEDOWN;
 31.1939 -    HWScanKeyMap[0x47] = SDLK_KP7;
 31.1940 -    HWScanKeyMap[0x48] = SDLK_KP8;
 31.1941 -    HWScanKeyMap[0x49] = SDLK_KP9;
 31.1942 -    HWScanKeyMap[0x4e] = SDLK_KP_PLUS;
 31.1943 -
 31.1944 -    // Fourth line of keyboard:
 31.1945 -    HWScanKeyMap[0x3a] = SDLK_CAPSLOCK;
 31.1946 -    HWScanKeyMap[0x1e] = SDLK_a;
 31.1947 -    HWScanKeyMap[0x1f] = SDLK_s;
 31.1948 -    HWScanKeyMap[0x20] = SDLK_d;
 31.1949 -    HWScanKeyMap[0x21] = SDLK_f;
 31.1950 -    HWScanKeyMap[0x22] = SDLK_g;
 31.1951 -    HWScanKeyMap[0x23] = SDLK_h;
 31.1952 -    HWScanKeyMap[0x24] = SDLK_j;
 31.1953 -    HWScanKeyMap[0x25] = SDLK_k;
 31.1954 -    HWScanKeyMap[0x26] = SDLK_l;
 31.1955 -    HWScanKeyMap[0x27] = SDLK_SEMICOLON;
 31.1956 -    HWScanKeyMap[0x28] = SDLK_QUOTE;
 31.1957 -    HWScanKeyMap[0x2b] = SDLK_BACKSLASH;
 31.1958 -    HWScanKeyMap[0x4b] = SDLK_KP4;
 31.1959 -    HWScanKeyMap[0x4c] = SDLK_KP5;
 31.1960 -    HWScanKeyMap[0x4d] = SDLK_KP6;
 31.1961 -
 31.1962 -    // Fifth line of keyboard:
 31.1963 -    HWScanKeyMap[0x2a] = SDLK_LSHIFT;
 31.1964 -    HWScanKeyMap[0x56] = SDLK_WORLD_1;  // Code 161, letter i' on hungarian keyboard
 31.1965 -    HWScanKeyMap[0x2c] = SDLK_z;
 31.1966 -    HWScanKeyMap[0x2d] = SDLK_x;
 31.1967 -    HWScanKeyMap[0x2e] = SDLK_c;
 31.1968 -    HWScanKeyMap[0x2f] = SDLK_v;
 31.1969 -    HWScanKeyMap[0x30] = SDLK_b;
 31.1970 -    HWScanKeyMap[0x31] = SDLK_n;
 31.1971 -    HWScanKeyMap[0x32] = SDLK_m;
 31.1972 -    HWScanKeyMap[0x33] = SDLK_COMMA;
 31.1973 -    HWScanKeyMap[0x34] = SDLK_PERIOD;
 31.1974 -    HWScanKeyMap[0x35] = SDLK_SLASH;
 31.1975 -    HWScanKeyMap[0x36] = SDLK_RSHIFT;
 31.1976 -    HWScanKeyMap[0x61] = SDLK_UP;
 31.1977 -    HWScanKeyMap[0x4f] = SDLK_KP1;
 31.1978 -    HWScanKeyMap[0x50] = SDLK_KP2;
 31.1979 -    HWScanKeyMap[0x51] = SDLK_KP3;
 31.1980 -    HWScanKeyMap[0x5a] = SDLK_KP_ENTER;
 31.1981 -
 31.1982 -    // Sixth line of keyboard:
 31.1983 -    HWScanKeyMap[0x1d] = SDLK_LCTRL;
 31.1984 -    HWScanKeyMap[0x7e] = SDLK_LSUPER;   // Windows key
 31.1985 -    HWScanKeyMap[0x38] = SDLK_LALT;
 31.1986 -    HWScanKeyMap[0x39] = SDLK_SPACE;
 31.1987 -    HWScanKeyMap[0x5e] = SDLK_RALT;     // Actually, altgr on my keyboard...
 31.1988 -    HWScanKeyMap[0x7f] = SDLK_RSUPER;
 31.1989 -    HWScanKeyMap[0x7c] = SDLK_MENU;
 31.1990 -    HWScanKeyMap[0x5b] = SDLK_RCTRL;
 31.1991 -    HWScanKeyMap[0x63] = SDLK_LEFT;
 31.1992 -    HWScanKeyMap[0x66] = SDLK_DOWN;
 31.1993 -    HWScanKeyMap[0x64] = SDLK_RIGHT;
 31.1994 -    HWScanKeyMap[0x52] = SDLK_KP0;
 31.1995 -    HWScanKeyMap[0x53] = SDLK_KP_PERIOD;
 31.1996 -}
 31.1997 -
 31.1998 -
 31.1999 -/* Iconify the window.
 31.2000 - This function returns 1 if there is a window manager and the
 31.2001 - window was actually iconified, it returns 0 otherwise.
 31.2002 - */
 31.2003 -int
 31.2004 -os2fslib_IconifyWindow(_THIS)
 31.2005 -{
 31.2006 -    HAB hab;
 31.2007 -    HMQ hmq;
 31.2008 -    ERRORID hmqerror;
 31.2009 -
 31.2010 -    // If there is no more window, nothing we can do!
 31.2011 -    if (_this->hidden->iPMThreadStatus != 1)
 31.2012 -        return 0;
 31.2013 -
 31.2014 -    // Cannot do anything in fullscreen mode!
 31.2015 -    if (FSLib_QueryFSMode(_this->hidden->hwndClient))
 31.2016 -        return 0;
 31.2017 -
 31.2018 -    // Make sure this thread is prepared for using the Presentation Manager!
 31.2019 -    hab = WinInitialize(0);
 31.2020 -    hmq = WinCreateMsgQueue(hab, 0);
 31.2021 -    // Remember if there was an error at WinCreateMsgQueue(), because we don't
 31.2022 -    // want to destroy somebody else's queue later. :)
 31.2023 -    hmqerror = WinGetLastError(hab);
 31.2024 -
 31.2025 -    WinSetWindowPos(_this->hidden->hwndFrame, HWND_TOP,
 31.2026 -                    0, 0, 0, 0, SWP_MINIMIZE);
 31.2027 -
 31.2028 -    // Now destroy the message queue, if we've created it!
 31.2029 -    if (ERRORIDERROR(hmqerror) == 0)
 31.2030 -        WinDestroyMsgQueue(hmq);
 31.2031 -
 31.2032 -    return 1;
 31.2033 -}
 31.2034 -
 31.2035 -static SDL_GrabMode
 31.2036 -os2fslib_GrabInput(_THIS, SDL_GrabMode mode)
 31.2037 -{
 31.2038 -    HAB hab;
 31.2039 -    HMQ hmq;
 31.2040 -    ERRORID hmqerror;
 31.2041 -
 31.2042 -
 31.2043 -    // If there is no more window, nothing we can do!
 31.2044 -    if (_this->hidden->iPMThreadStatus != 1)
 31.2045 -        return SDL_GRAB_OFF;
 31.2046 -
 31.2047 -    // Make sure this thread is prepared for using the Presentation Manager!
 31.2048 -    hab = WinInitialize(0);
 31.2049 -    hmq = WinCreateMsgQueue(hab, 0);
 31.2050 -    // Remember if there was an error at WinCreateMsgQueue(), because we don't
 31.2051 -    // want to destroy somebody else's queue later. :)
 31.2052 -    hmqerror = WinGetLastError(hab);
 31.2053 -
 31.2054 -
 31.2055 -    if (mode == SDL_GRAB_OFF) {
 31.2056 -#ifdef DEBUG_BUILD
 31.2057 -        printf("[os2fslib_GrabInput] : Releasing mouse\n");
 31.2058 -        fflush(stdout);
 31.2059 -#endif
 31.2060 -
 31.2061 -        // Release the mouse
 31.2062 -        bMouseCapturable = 0;
 31.2063 -        if (bMouseCaptured) {
 31.2064 -            WinSetCapture(HWND_DESKTOP, NULLHANDLE);
 31.2065 -            bMouseCaptured = 0;
 31.2066 -        }
 31.2067 -    } else {
 31.2068 -#ifdef DEBUG_BUILD
 31.2069 -        printf("[os2fslib_GrabInput] : Capturing mouse\n");
 31.2070 -        fflush(stdout);
 31.2071 -#endif
 31.2072 -
 31.2073 -        // Capture the mouse
 31.2074 -        bMouseCapturable = 1;
 31.2075 -        if (WinQueryFocus(HWND_DESKTOP) == _this->hidden->hwndClient) {
 31.2076 -            WinSetCapture(HWND_DESKTOP, _this->hidden->hwndClient);
 31.2077 -            bMouseCaptured = 1;
 31.2078 -            {
 31.2079 -                SWP swpClient;
 31.2080 -                POINTL ptl;
 31.2081 -                // Center the mouse to the middle of the window!
 31.2082 -                WinQueryWindowPos(_this->hidden->hwndClient, &swpClient);
 31.2083 -                ptl.x = 0;
 31.2084 -                ptl.y = 0;
 31.2085 -                WinMapWindowPoints(_this->hidden->hwndClient,
 31.2086 -                                   HWND_DESKTOP, &ptl, 1);
 31.2087 -                _this->hidden->iSkipWMMOUSEMOVE++;      /* Don't take next WM_MOUSEMOVE into account!  */
 31.2088 -                WinSetPointerPos(HWND_DESKTOP,
 31.2089 -                                 ptl.x + swpClient.cx / 2,
 31.2090 -                                 ptl.y + swpClient.cy / 2);
 31.2091 -            }
 31.2092 -        }
 31.2093 -    }
 31.2094 -
 31.2095 -    // Now destroy the message queue, if we've created it!
 31.2096 -    if (ERRORIDERROR(hmqerror) == 0)
 31.2097 -        WinDestroyMsgQueue(hmq);
 31.2098 -
 31.2099 -    return mode;
 31.2100 -}
 31.2101 -
 31.2102 -/* Set the title and icon text */
 31.2103 -static void
 31.2104 -os2fslib_SetCaption(_THIS, const char *title, const char *icon)
 31.2105 -{
 31.2106 -    HAB hab;
 31.2107 -    HMQ hmq;
 31.2108 -    ERRORID hmqerror;
 31.2109 -
 31.2110 -    // If there is no more window, nothing we can do!
 31.2111 -    if (_this->hidden->iPMThreadStatus != 1)
 31.2112 -        return;
 31.2113 -
 31.2114 -    // Make sure this thread is prepared for using the Presentation Manager!
 31.2115 -    hab = WinInitialize(0);
 31.2116 -    hmq = WinCreateMsgQueue(hab, 0);
 31.2117 -    // Remember if there was an error at WinCreateMsgQueue(), because we don't
 31.2118 -    // want to destroy somebody else's queue later. :)
 31.2119 -    hmqerror = WinGetLastError(hab);
 31.2120 -
 31.2121 -    WinSetWindowText(_this->hidden->hwndFrame, (char *) title);
 31.2122 -
 31.2123 -    // Now destroy the message queue, if we've created it!
 31.2124 -    if (ERRORIDERROR(hmqerror) == 0)
 31.2125 -        WinDestroyMsgQueue(hmq);
 31.2126 -}
 31.2127 -
 31.2128 -static int
 31.2129 -os2fslib_ToggleFullScreen(_THIS, int on)
 31.2130 -{
 31.2131 -#ifdef DEBUG_BUILD
 31.2132 -    printf("[os2fslib_ToggleFullScreen] : %d\n", on);
 31.2133 -    fflush(stdout);
 31.2134 -#endif
 31.2135 -    // If there is no more window, nothing we can do!
 31.2136 -    if (_this->hidden->iPMThreadStatus != 1)
 31.2137 -        return 0;
 31.2138 -
 31.2139 -    FSLib_ToggleFSMode(_this->hidden->hwndClient, on);
 31.2140 -    /* Cursor manager functions to Windowed/FS mode */
 31.2141 -    os2fslib_SetCursorManagementFunctions(_this, !on);
 31.2142 -    return 1;
 31.2143 -}
 31.2144 -
 31.2145 -/* This is called after the video mode has been set, to get the
 31.2146 - initial mouse state.  It should queue events as necessary to
 31.2147 - properly represent the current mouse focus and position.
 31.2148 - */
 31.2149 -static void
 31.2150 -os2fslib_UpdateMouse(_THIS)
 31.2151 -{
 31.2152 -    POINTL ptl;
 31.2153 -    HAB hab;
 31.2154 -    HMQ hmq;
 31.2155 -    ERRORID hmqerror;
 31.2156 -    SWP swpClient;
 31.2157 -
 31.2158 -    // If there is no more window, nothing we can do!
 31.2159 -    if (_this->hidden->iPMThreadStatus != 1)
 31.2160 -        return;
 31.2161 -
 31.2162 -
 31.2163 -    // Make sure this thread is prepared for using the Presentation Manager!
 31.2164 -    hab = WinInitialize(0);
 31.2165 -    hmq = WinCreateMsgQueue(hab, 0);
 31.2166 -    // Remember if there was an error at WinCreateMsgQueue(), because we don't
 31.2167 -    // want to destroy somebody else's queue later. :)
 31.2168 -    hmqerror = WinGetLastError(hab);
 31.2169 -
 31.2170 -
 31.2171 -
 31.2172 -    if (_this->hidden->fInFocus) {
 31.2173 -        // If our app is in focus
 31.2174 -        SDL_PrivateAppActive(1, SDL_APPMOUSEFOCUS);
 31.2175 -        SDL_PrivateAppActive(1, SDL_APPINPUTFOCUS);
 31.2176 -        SDL_PrivateAppActive(1, SDL_APPACTIVE);
 31.2177 -        WinQueryPointerPos(HWND_DESKTOP, &ptl);
 31.2178 -        WinMapWindowPoints(HWND_DESKTOP, _this->hidden->hwndClient, &ptl, 1);
 31.2179 -        WinQueryWindowPos(_this->hidden->hwndClient, &swpClient);
 31.2180 -        // Convert OS/2 mouse position to SDL position, and also scale it!
 31.2181 -        ptl.x =
 31.2182 -            ptl.x * _this->hidden->SrcBufferDesc.uiXResolution / swpClient.cx;
 31.2183 -        ptl.y =
 31.2184 -            ptl.y * _this->hidden->SrcBufferDesc.uiYResolution / swpClient.cy;
 31.2185 -        ptl.y = _this->hidden->SrcBufferDesc.uiYResolution - ptl.y - 1;
 31.2186 -        SDL_PrivateMouseMotion(0, 0, (Sint16) (ptl.x), (Sint16) (ptl.y));
 31.2187 -    } else {
 31.2188 -        // If we're not in focus
 31.2189 -        SDL_PrivateAppActive(0, SDL_APPMOUSEFOCUS);
 31.2190 -        SDL_PrivateAppActive(0, SDL_APPINPUTFOCUS);
 31.2191 -        SDL_PrivateAppActive(0, SDL_APPACTIVE);
 31.2192 -        SDL_PrivateMouseMotion(0, 0, (Sint16) - 1, (Sint16) - 1);
 31.2193 -    }
 31.2194 -
 31.2195 -    // Now destroy the message queue, if we've created it!
 31.2196 -    if (ERRORIDERROR(hmqerror) == 0)
 31.2197 -        WinDestroyMsgQueue(hmq);
 31.2198 -
 31.2199 -}
 31.2200 -
 31.2201 -/* This pointer should exist in the native video subsystem and should
 31.2202 - point to an appropriate update function for the current video mode
 31.2203 - */
 31.2204 -static void
 31.2205 -os2fslib_UpdateRects(_THIS, int numrects, SDL_Rect * rects)
 31.2206 -{
 31.2207 -    // If there is no more window, nothing we can do!
 31.2208 -    if (_this->hidden->iPMThreadStatus != 1)
 31.2209 -        return;
 31.2210 -
 31.2211 -#ifdef BITBLT_IN_WINMESSAGEPROC
 31.2212 -    WinSendMsg(_this->hidden->hwndClient,
 31.2213 -               WM_UPDATERECTSREQUEST, (MPARAM) numrects, (MPARAM) rects);
 31.2214 -#else
 31.2215 -    if (DosRequestMutexSem
 31.2216 -        (_this->hidden->hmtxUseSrcBuffer, SEM_INDEFINITE_WAIT) == NO_ERROR) {
 31.2217 -        int i;
 31.2218 -
 31.2219 -        if (_this->hidden->pSDLSurface) {
 31.2220 -#ifndef RESIZE_EVEN_IF_RESIZABLE
 31.2221 -            SWP swp;
 31.2222 -            // But only blit if the window is not resizable, or if
 31.2223 -            // the window is resizable and the source buffer size is the
 31.2224 -            // same as the destination buffer size!
 31.2225 -            WinQueryWindowPos(_this->hidden->hwndClient, &swp);
 31.2226 -            if ((_this->hidden->pSDLSurface) &&
 31.2227 -                (_this->hidden->pSDLSurface->flags & SDL_RESIZABLE) &&
 31.2228 -                ((swp.cx != _this->hidden->SrcBufferDesc.uiXResolution) ||
 31.2229 -                 (swp.cy != _this->hidden->SrcBufferDesc.uiYResolution))
 31.2230 -                && (!FSLib_QueryFSMode(_this->hidden->hwndClient))) {
 31.2231 -                // Resizable surface and in resizing!
 31.2232 -                // So, don't blit now!
 31.2233 -#ifdef DEBUG_BUILD
 31.2234 -                printf("[UpdateRects] : Skipping blit while resizing!\n");
 31.2235 -                fflush(stdout);
 31.2236 -#endif
 31.2237 -            } else
 31.2238 -#endif
 31.2239 -            {
 31.2240 -                /*
 31.2241 -                   // Blit the whole window
 31.2242 -                   FSLIB_BITBLT(_this->hidden->hwndClient, _this->hidden->pchSrcBuffer,
 31.2243 -                   0, 0,
 31.2244 -                   _this->hidden->SrcBufferDesc.uiXResolution,
 31.2245 -                   _this->hidden->SrcBufferDesc.uiYResolution);
 31.2246 -                 */
 31.2247 -#ifdef DEBUG_BUILD
 31.2248 -                printf("[os2fslib_UpdateRects] : Blitting!\n");
 31.2249 -                fflush(stdout);
 31.2250 -#endif
 31.2251 -
 31.2252 -                // Blit the changed areas
 31.2253 -                for (i = 0; i < numrects; i++)
 31.2254 -                    FSLIB_BITBLT(_this->hidden->hwndClient,
 31.2255 -                                 _this->hidden->pchSrcBuffer,
 31.2256 -                                 rects[i].y, rects[i].x, rects[i].w,
 31.2257 -                                 rects[i].h);
 31.2258 -            }
 31.2259 -        }
 31.2260 -#ifdef DEBUG_BUILD
 31.2261 -        else
 31.2262 -            printf("[os2fslib_UpdateRects] : No public surface!\n");
 31.2263 -        fflush(stdout);
 31.2264 -#endif
 31.2265 -        DosReleaseMutexSem(_this->hidden->hmtxUseSrcBuffer);
 31.2266 -    }
 31.2267 -#ifdef DEBUG_BUILD
 31.2268 -    else
 31.2269 -        printf("[os2fslib_UpdateRects] : Error in mutex!\n");
 31.2270 -    fflush(stdout);
 31.2271 -#endif
 31.2272 -#endif
 31.2273 -}
 31.2274 -
 31.2275 -
 31.2276 -/* Reverse the effects VideoInit() -- called if VideoInit() fails
 31.2277 - or if the application is shutting down the video subsystem.
 31.2278 - */
 31.2279 -static void
 31.2280 -os2fslib_VideoQuit(_THIS)
 31.2281 -{
 31.2282 -#ifdef DEBUG_BUILD
 31.2283 -    printf("[os2fslib_VideoQuit]\n");
 31.2284 -    fflush(stdout);
 31.2285 -#endif
 31.2286 -    // Close PM stuff if running!
 31.2287 -    if (_this->hidden->iPMThreadStatus == 1) {
 31.2288 -        int iTimeout;
 31.2289 -        WinPostMsg(_this->hidden->hwndFrame, WM_QUIT, (MPARAM) 0, (MPARAM) 0);
 31.2290 -        // HACK: We had this line before:
 31.2291 -        //DosWaitThread((TID *) &(_this->hidden->tidPMThread), DCWW_WAIT);
 31.2292 -        // We don't use it, because the PMThread will never stop, or if it stops,
 31.2293 -        // it will kill the whole process as a emergency fallback.
 31.2294 -        // So, we only check for the iPMThreadStatus stuff!
 31.2295 -#ifdef DEBUG_BUILD
 31.2296 -        printf("[os2fslib_VideoQuit] : Waiting for PM thread to die\n");
 31.2297 -        fflush(stdout);
 31.2298 -#endif
 31.2299 -
 31.2300 -        iTimeout = 0;
 31.2301 -        while ((_this->hidden->iPMThreadStatus == 1) && (iTimeout < 100)) {
 31.2302 -            iTimeout++;
 31.2303 -            DosSleep(64);
 31.2304 -        }
 31.2305 -
 31.2306 -#ifdef DEBUG_BUILD
 31.2307 -        printf("[os2fslib_VideoQuit] : End of wait.\n");
 31.2308 -        fflush(stdout);
 31.2309 -#endif
 31.2310 -
 31.2311 -        if (_this->hidden->iPMThreadStatus == 1) {
 31.2312 -#ifdef DEBUG_BUILD
 31.2313 -            printf("[os2fslib_VideoQuit] : Killing PM thread!\n");
 31.2314 -            fflush(stdout);
 31.2315 -#endif
 31.2316 -
 31.2317 -            _this->hidden->iPMThreadStatus = 0;
 31.2318 -            DosKillThread(_this->hidden->tidPMThread);
 31.2319 -
 31.2320 -            if (_this->hidden->hwndFrame) {
 31.2321 -#ifdef DEBUG_BUILD
 31.2322 -                printf("[os2fslib_VideoQuit] : Destroying PM window!\n");
 31.2323 -                fflush(stdout);
 31.2324 -#endif
 31.2325 -
 31.2326 -                WinDestroyWindow(_this->hidden->hwndFrame);
 31.2327 -                _this->hidden->hwndFrame = NULL;
 31.2328 -            }
 31.2329 -        }
 31.2330 -
 31.2331 -    }
 31.2332 -    // Free result of an old ListModes() call, because there is
 31.2333 -    // no FreeListModes() call in SDL!
 31.2334 -    if (_this->hidden->pListModesResult) {
 31.2335 -        SDL_free(_this->hidden->pListModesResult);
 31.2336 -        _this->hidden->pListModesResult = NULL;
 31.2337 -    }
 31.2338 -    // Free list of available fullscreen modes
 31.2339 -    if (_this->hidden->pAvailableFSLibVideoModes) {
 31.2340 -        FSLib_FreeVideoModeList(_this->hidden->pAvailableFSLibVideoModes);
 31.2341 -        _this->hidden->pAvailableFSLibVideoModes = NULL;
 31.2342 -    }
 31.2343 -    // Free application icon if we had one
 31.2344 -    if (hptrCurrentIcon) {
 31.2345 -        WinDestroyPointer(hptrCurrentIcon);
 31.2346 -        hptrCurrentIcon = NULL;
 31.2347 -    }
 31.2348 -}
 31.2349 -
 31.2350 -/* Set the requested video mode, returning a surface which will be
 31.2351 - set to the SDL_VideoSurface.  The width and height will already
 31.2352 - be verified by ListModes(), and the video subsystem is free to
 31.2353 - set the mode to a supported bit depth different from the one
 31.2354 - specified -- the desired bpp will be emulated with a shadow
 31.2355 - surface if necessary.  If a new mode is returned, this function
 31.2356 - should take care of cleaning up the current mode.
 31.2357 - */
 31.2358 -static SDL_Surface *
 31.2359 -os2fslib_SetVideoMode(_THIS, SDL_Surface * current,
 31.2360 -                      int width, int height, int bpp, Uint32 flags)
 31.2361 -{
 31.2362 -    static int bFirstCall = 1;
 31.2363 -    FSLib_VideoMode_p pModeInfo, pModeInfoFound;
 31.2364 -    FSLib_VideoMode TempModeInfo;
 31.2365 -    HAB hab;
 31.2366 -    HMQ hmq;
 31.2367 -    ERRORID hmqerror;
 31.2368 -    RECTL rectl;
 31.2369 -    SDL_Surface *pResult;
 31.2370 -
 31.2371 -    // If there is no more window, nothing we can do!
 31.2372 -    if (_this->hidden->iPMThreadStatus != 1)
 31.2373 -        return NULL;
 31.2374 -
 31.2375 -#ifdef DEBUG_BUILD
 31.2376 -    printf
 31.2377 -        ("[os2fslib_SetVideoMode] : Request for %dx%d @ %dBPP, flags=0x%x\n",
 31.2378 -         width, height, bpp, flags);
 31.2379 -    fflush(stdout);
 31.2380 -#endif
 31.2381 -
 31.2382 -    // We don't support palette modes!
 31.2383 -    if (bpp == 8)
 31.2384 -        bpp = 32;
 31.2385 -
 31.2386 -    // Also, we don't support resizable modes in fullscreen mode.
 31.2387 -    if (flags & SDL_RESIZABLE)
 31.2388 -        flags &= ~SDL_FULLSCREEN;
 31.2389 -
 31.2390 -    // No double buffered mode
 31.2391 -    if (flags & SDL_DOUBLEBUF)
 31.2392 -        flags &= ~SDL_DOUBLEBUF;
 31.2393 -
 31.2394 -    // And, we don't support HWSURFACE yet.
 31.2395 -    if (flags & SDL_HWSURFACE) {
 31.2396 -        flags &= ~SDL_HWSURFACE;
 31.2397 -        flags |= SDL_SWSURFACE;
 31.2398 -    }
 31.2399 -#ifdef DEBUG_BUILD
 31.2400 -    printf
 31.2401 -        ("[os2fslib_SetVideoMode] : Changed request to %dx%d @ %dBPP, flags=0x%x\n",
 31.2402 -         width, height, bpp, flags);
 31.2403 -    fflush(stdout);
 31.2404 -#endif
 31.2405 -
 31.2406 -    // First check if there is such a video mode they want!
 31.2407 -    pModeInfoFound = NULL;
 31.2408 -
 31.2409 -    // For fullscreen mode we don't support every resolution!
 31.2410 -    // So, go through the video modes, and check for such a resolution!
 31.2411 -    pModeInfoFound = NULL;
 31.2412 -    pModeInfo = _this->hidden->pAvailableFSLibVideoModes;
 31.2413 -
 31.2414 -    while (pModeInfo) {
 31.2415 -        // Check all available fullscreen modes for this resolution
 31.2416 -        if ((pModeInfo->uiXResolution == width) && (pModeInfo->uiYResolution == height) && (pModeInfo->uiBPP != 8))     // palettized modes not yet supported
 31.2417 -        {
 31.2418 -            // If good resolution, try to find the exact BPP, or at least
 31.2419 -            // something similar...
 31.2420 -            if (!pModeInfoFound)
 31.2421 -                pModeInfoFound = pModeInfo;
 31.2422 -            else if ((pModeInfoFound->uiBPP != bpp) &&
 31.2423 -                     (pModeInfoFound->uiBPP < pModeInfo->uiBPP))
 31.2424 -                pModeInfoFound = pModeInfo;
 31.2425 -        }
 31.2426 -        pModeInfo = pModeInfo->pNext;
 31.2427 -    }
 31.2428 -
 31.2429 -    // If we did not find a good fullscreen mode, then try a similar
 31.2430 -    if (!pModeInfoFound) {
 31.2431 -#ifdef DEBUG_BUILD
 31.2432 -        printf
 31.2433 -            ("[os2fslib_SetVideoMode] : Requested video mode not found, looking for a similar one!\n");
 31.2434 -        fflush(stdout);
 31.2435 -#endif
 31.2436 -        // Go through the video modes again, and find a similar resolution!
 31.2437 -        pModeInfo = _this->hidden->pAvailableFSLibVideoModes;
 31.2438 -        while (pModeInfo) {
 31.2439 -            // Check all available fullscreen modes for this resolution
 31.2440 -            if ((pModeInfo->uiXResolution >= width) &&
 31.2441 -                (pModeInfo->uiYResolution >= height) &&
 31.2442 -                (pModeInfo->uiBPP == bpp)) {
 31.2443 -                if (!pModeInfoFound)
 31.2444 -                    pModeInfoFound = pModeInfo;
 31.2445 -                else if (((pModeInfoFound->uiXResolution -
 31.2446 -                           width) * (pModeInfoFound->uiYResolution -
 31.2447 -                                     height)) >
 31.2448 -                         ((pModeInfo->uiXResolution -
 31.2449 -                           width) * (pModeInfo->uiYResolution - height))) {
 31.2450 -                    // Found a mode which is closer than the current one
 31.2451 -                    pModeInfoFound = pModeInfo;
 31.2452 -                }
 31.2453 -            }
 31.2454 -            pModeInfo = pModeInfo->pNext;
 31.2455 -        }
 31.2456 -    }
 31.2457 -    // If we did not find a good fullscreen mode, then return NULL
 31.2458 -    if (!pModeInfoFound) {
 31.2459 -#ifdef DEBUG_BUILD
 31.2460 -        printf("[os2fslib_SetVideoMode] : Requested video mode not found!\n");
 31.2461 -        fflush(stdout);
 31.2462 -#endif
 31.2463 -        return NULL;
 31.2464 -    }
 31.2465 -#ifdef DEBUG_BUILD
 31.2466 -    printf("[os2fslib_SetVideoMode] : Found mode!\n");
 31.2467 -    fflush(stdout);
 31.2468 -#endif
 31.2469 -
 31.2470 -    // We'll possibly adjust the structure, so copy out the values
 31.2471 -    // into TempModeInfo!
 31.2472 -    SDL_memcpy(&TempModeInfo, pModeInfoFound, sizeof(TempModeInfo));
 31.2473 -    pModeInfoFound = &TempModeInfo;
 31.2474 -
 31.2475 -    if (flags & SDL_RESIZABLE) {
 31.2476 -#ifdef DEBUG_BUILD
 31.2477 -        printf
 31.2478 -            ("[os2fslib_SetVideoMode] : Requested mode is resizable, changing width/height\n");
 31.2479 -        fflush(stdout);
 31.2480 -#endif
 31.2481 -        // Change width and height to requested one!
 31.2482 -        TempModeInfo.uiXResolution = width;
 31.2483 -        TempModeInfo.uiYResolution = height;
 31.2484 -        TempModeInfo.uiScanLineSize = width * ((TempModeInfo.uiBPP + 7) / 8);
 31.2485 -    }
 31.2486 -    // We can try create new surface!
 31.2487 -
 31.2488 -    // Make sure this thread is prepared for using the Presentation Manager!
 31.2489 -    hab = WinInitialize(0);
 31.2490 -    hmq = WinCreateMsgQueue(hab, 0);
 31.2491 -    // Remember if there was an error at WinCreateMsgQueue(), because we don't
 31.2492 -    // want to destroy somebody else's queue later. :)
 31.2493 -    hmqerror = WinGetLastError(hab);
 31.2494 -
 31.2495 -
 31.2496 -
 31.2497 -    if (DosRequestMutexSem
 31.2498 -        (_this->hidden->hmtxUseSrcBuffer, SEM_INDEFINITE_WAIT) == NO_ERROR) {
 31.2499 -#ifdef DEBUG_BUILD
 31.2500 -        printf("[os2fslib_SetVideoMode] : Creating new SW surface\n");
 31.2501 -        fflush(stdout);
 31.2502 -#endif
 31.2503 -
 31.2504 -        // Create new software surface!
 31.2505 -        pResult = SDL_CreateRGBSurface(SDL_SWSURFACE,
 31.2506 -                                       pModeInfoFound->uiXResolution,
 31.2507 -                                       pModeInfoFound->uiYResolution,
 31.2508 -                                       pModeInfoFound->uiBPP, ((unsigned int)
 31.2509 -                                                               pModeInfoFound->
 31.2510 -                                                               PixelFormat.
 31.2511 -                                                               ucRedMask)
 31.2512 -                                       << pModeInfoFound->PixelFormat.
 31.2513 -                                       ucRedPosition, ((unsigned int)
 31.2514 -                                                       pModeInfoFound->
 31.2515 -                                                       PixelFormat.
 31.2516 -                                                       ucGreenMask)
 31.2517 -                                       << pModeInfoFound->PixelFormat.
 31.2518 -                                       ucGreenPosition, ((unsigned int)
 31.2519 -                                                         pModeInfoFound->
 31.2520 -                                                         PixelFormat.
 31.2521 -                                                         ucBlueMask)
 31.2522 -                                       << pModeInfoFound->PixelFormat.
 31.2523 -                                       ucBluePosition, ((unsigned int)
 31.2524 -                                                        pModeInfoFound->
 31.2525 -                                                        PixelFormat.
 31.2526 -                                                        ucAlphaMask)
 31.2527 -                                       << pModeInfoFound->PixelFormat.
 31.2528 -                                       ucAlphaPosition);
 31.2529 -
 31.2530 -        if (pResult == NULL) {
 31.2531 -            DosReleaseMutexSem(_this->hidden->hmtxUseSrcBuffer);
 31.2532 -            SDL_OutOfMemory();
 31.2533 -            return NULL;
 31.2534 -        }
 31.2535 -#ifdef DEBUG_BUILD
 31.2536 -        printf("[os2fslib_SetVideoMode] : Adjusting pixel format\n");
 31.2537 -        fflush(stdout);
 31.2538 -#endif
 31.2539 -
 31.2540 -        // Adjust pixel format mask!
 31.2541 -        pResult->format->Rmask =
 31.2542 -            ((unsigned int) pModeInfoFound->
 31.2543 -             PixelFormat.ucRedMask) << pModeInfoFound->PixelFormat.
 31.2544 -            ucRedPosition;
 31.2545 -        pResult->format->Rshift = pModeInfoFound->PixelFormat.ucRedPosition;
 31.2546 -        pResult->format->Rloss = pModeInfoFound->PixelFormat.ucRedAdjust;
 31.2547 -        pResult->format->Gmask =
 31.2548 -            ((unsigned int) pModeInfoFound->
 31.2549 -             PixelFormat.ucGreenMask) << pModeInfoFound->PixelFormat.
 31.2550 -            ucGreenPosition;
 31.2551 -        pResult->format->Gshift = pModeInfoFound->PixelFormat.ucGreenPosition;
 31.2552 -        pResult->format->Gloss = pModeInfoFound->PixelFormat.ucGreenAdjust;
 31.2553 -        pResult->format->Bmask =
 31.2554 -            ((unsigned int) pModeInfoFound->
 31.2555 -             PixelFormat.ucBlueMask) << pModeInfoFound->PixelFormat.
 31.2556 -            ucBluePosition;
 31.2557 -        pResult->format->Bshift = pModeInfoFound->PixelFormat.ucBluePosition;
 31.2558 -        pResult->format->Bloss = pModeInfoFound->PixelFormat.ucBlueAdjust;
 31.2559 -        pResult->format->Amask =
 31.2560 -            ((unsigned int) pModeInfoFound->
 31.2561 -             PixelFormat.ucAlphaMask) << pModeInfoFound->PixelFormat.
 31.2562 -            ucAlphaPosition;
 31.2563 -        pResult->format->Ashift = pModeInfoFound->PixelFormat.ucAlphaPosition;
 31.2564 -        pResult->format->Aloss = pModeInfoFound->PixelFormat.ucAlphaAdjust;
 31.2565 -
 31.2566 -#ifdef REPORT_EMPTY_ALPHA_MASK
 31.2567 -        pResult->format->Amask =
 31.2568 -            pResult->format->Ashift = pResult->format->Aloss = 0;
 31.2569 -#endif
 31.2570 -
 31.2571 -        // Adjust surface flags
 31.2572 -        pResult->flags |= (flags & SDL_FULLSCREEN);
 31.2573 -        pResult->flags |= (flags & SDL_RESIZABLE);
 31.2574 -
 31.2575 -        // It might be that the software surface pitch is not the same as
 31.2576 -        // the pitch we have, so adjust that!
 31.2577 -        pModeInfoFound->uiScanLineSize = pResult->pitch;
 31.2578 -
 31.2579 -        // Store new source buffer parameters!
 31.2580 -        SDL_memcpy(&(_this->hidden->SrcBufferDesc), pModeInfoFound,
 31.2581 -                   sizeof(*pModeInfoFound));
 31.2582 -        _this->hidden->pchSrcBuffer = pResult->pixels;
 31.2583 -
 31.2584 -#ifdef DEBUG_BUILD
 31.2585 -        printf("[os2fslib_SetVideoMode] : Telling FSLib the stuffs\n");
 31.2586 -        fflush(stdout);
 31.2587 -#endif
 31.2588 -
 31.2589 -        // Tell the FSLib window the new source image format
 31.2590 -        FSLib_SetSrcBufferDesc(_this->hidden->hwndClient,
 31.2591 -                               &(_this->hidden->SrcBufferDesc));
 31.2592 -
 31.2593 -        if (((flags & SDL_RESIZABLE) == 0) || (bFirstCall)) {
 31.2594 -            bFirstCall = 0;
 31.2595 -#ifdef DEBUG_BUILD
 31.2596 -            printf("[os2fslib_SetVideoMode] : Modifying window size\n");
 31.2597 -            fflush(stdout);
 31.2598 -#endif
 31.2599 -
 31.2600 -            // Calculate frame window size from client window size
 31.2601 -            rectl.xLeft = 0;
 31.2602 -            rectl.yBottom = 0;
 31.2603 -            rectl.xRight = pModeInfoFound->uiXResolution;       // Noninclusive
 31.2604 -            rectl.yTop = pModeInfoFound->uiYResolution; // Noninclusive
 31.2605 -            WinCalcFrameRect(_this->hidden->hwndFrame, &rectl, FALSE);
 31.2606 -
 31.2607 -            // Set the new size of the main window
 31.2608 -            SetAccessableWindowPos(_this->hidden->hwndFrame,
 31.2609 -                                   HWND_TOP,
 31.2610 -                                   0, 0,
 31.2611 -                                   (rectl.xRight - rectl.xLeft),
 31.2612 -                                   (rectl.yTop - rectl.yBottom),
 31.2613 -                                   SWP_SIZE | SWP_ACTIVATE | SWP_SHOW);
 31.2614 -        }
 31.2615 -        // Set fullscreen mode flag, and switch to fullscreen if needed!
 31.2616 -        if (flags & SDL_FULLSCREEN) {
 31.2617 -#ifdef DEBUG_BUILD
 31.2618 -            printf
 31.2619 -                ("[os2fslib_SetVideoMode] : Also trying to switch to fullscreen\n");
 31.2620 -            fflush(stdout);
 31.2621 -#endif
 31.2622 -            FSLib_ToggleFSMode(_this->hidden->hwndClient, 1);
 31.2623 -            /* Cursor manager functions to FS mode */
 31.2624 -            os2fslib_SetCursorManagementFunctions(_this, 0);
 31.2625 -        } else {
 31.2626 -#ifdef DEBUG_BUILD
 31.2627 -            printf
 31.2628 -                ("[os2fslib_SetVideoMode] : Also trying to switch to desktop mode\n");
 31.2629 -            fflush(stdout);
 31.2630 -#endif
 31.2631 -            FSLib_ToggleFSMode(_this->hidden->hwndClient, 0);
 31.2632 -            /* Cursor manager functions to Windowed mode */
 31.2633 -            os2fslib_SetCursorManagementFunctions(_this, 1);
 31.2634 -        }
 31.2635 -
 31.2636 -        _this->hidden->pSDLSurface = pResult;
 31.2637 -
 31.2638 -        DosReleaseMutexSem(_this->hidden->hmtxUseSrcBuffer);
 31.2639 -    } else {
 31.2640 -#ifdef DEBUG_BUILD
 31.2641 -        printf("[os2fslib_SetVideoMode] : Could not get hmtxUseSrcBuffer!\n");
 31.2642 -        fflush(stdout);
 31.2643 -#endif
 31.2644 -
 31.2645 -        pResult = NULL;
 31.2646 -    }
 31.2647 -
 31.2648 -    // As we have the new surface, we don't need the current one anymore!
 31.2649 -    if ((pResult) && (current)) {
 31.2650 -#ifdef DEBUG_BUILD
 31.2651 -        printf("[os2fslib_SetVideoMode] : Freeing old surface\n");
 31.2652 -        fflush(stdout);
 31.2653 -#endif
 31.2654 -        SDL_FreeSurface(current);
 31.2655 -    }
 31.2656 -    // Redraw window
 31.2657 -    WinInvalidateRegion(_this->hidden->hwndClient, NULL, TRUE);
 31.2658 -
 31.2659 -    // Now destroy the message queue, if we've created it!
 31.2660 -    if (ERRORIDERROR(hmqerror) == 0) {
 31.2661 -#ifdef DEBUG_BUILD
 31.2662 -        printf("[os2fslib_SetVideoMode] : Destroying message queue\n");
 31.2663 -        fflush(stdout);
 31.2664 -#endif
 31.2665 -        WinDestroyMsgQueue(hmq);
 31.2666 -    }
 31.2667 -#ifdef DEBUG_BUILD
 31.2668 -    printf("[os2fslib_SetVideoMode] : Done\n");
 31.2669 -    fflush(stdout);
 31.2670 -#endif
 31.2671 -
 31.2672 -    /* We're done */
 31.2673 -
 31.2674 -    // Return with the new surface!
 31.2675 -    return pResult;
 31.2676 -}
 31.2677 -
 31.2678 -/* List the available video modes for the given pixel format, sorted
 31.2679 - from largest to smallest.
 31.2680 - */
 31.2681 -static SDL_Rect **
 31.2682 -os2fslib_ListModes(_THIS, SDL_PixelFormat * format, Uint32 flags)
 31.2683 -{
 31.2684 -#ifdef DEBUG_BUILD
 31.2685 -    printf("[os2fslib_ListModes] : ListModes of %d Bpp\n",
 31.2686 -           format->BitsPerPixel);
 31.2687 -#endif
 31.2688 -    // Destroy result of previous call, if there is any
 31.2689 -    if (_this->hidden->pListModesResult) {
 31.2690 -        SDL_free(_this->hidden->pListModesResult);
 31.2691 -        _this->hidden->pListModesResult = NULL;
 31.2692 -    }
 31.2693 -    // For resizable and windowed mode we support every resolution!
 31.2694 -    if ((flags & SDL_RESIZABLE) && ((flags & SDL_FULLSCREEN) == 0))
 31.2695 -        return (SDL_Rect **) - 1;
 31.2696 -
 31.2697 -    // Check if they need fullscreen or non-fullscreen video modes!
 31.2698 -    if ((flags & SDL_FULLSCREEN) == 0) {
 31.2699 -        // For windowed mode we support every resolution!
 31.2700 -        return (SDL_Rect **) - 1;
 31.2701 -    } else {
 31.2702 -        FSLib_VideoMode_p pFSMode;
 31.2703 -        // For fullscreen mode we don't support every resolution!
 31.2704 -        // Now create a new list
 31.2705 -        pFSMode = _this->hidden->pAvailableFSLibVideoModes;
 31.2706 -        while (pFSMode) {
 31.2707 -            if (pFSMode->uiBPP == format->BitsPerPixel) {
 31.2708 -                SDL_Rect *pRect = (SDL_Rect *) SDL_malloc(sizeof(SDL_Rect));
 31.2709 -                if (pRect) {
 31.2710 -                    // Fill description
 31.2711 -                    pRect->x = 0;
 31.2712 -                    pRect->y = 0;
 31.2713 -                    pRect->w = pFSMode->uiXResolution;
 31.2714 -                    pRect->h = pFSMode->uiYResolution;
 31.2715 -#ifdef DEBUG_BUILD
 31.2716 -//          printf("!!! Seems to be good!\n");
 31.2717 -//        printf("F: %dx%d\n", pRect->w, pRect->h);
 31.2718 -#endif
 31.2719 -                    // And insert into list of pRects
 31.2720 -                    if (!(_this->hidden->pListModesResult)) {
 31.2721 -#ifdef DEBUG_BUILD
 31.2722 -//            printf("!!! Inserting to beginning\n");
 31.2723 -#endif
 31.2724 -
 31.2725 -                        // We're the first one to be inserted!
 31.2726 -                        _this->hidden->pListModesResult =
 31.2727 -                            (SDL_Rect **) SDL_malloc(2 * sizeof(SDL_Rect *));
 31.2728 -                        if (_this->hidden->pListModesResult) {
 31.2729 -                            _this->hidden->pListModesResult[0] = pRect;
 31.2730 -                            _this->hidden->pListModesResult[1] = NULL;
 31.2731 -                        } else {
 31.2732 -                            SDL_free(pRect);
 31.2733 -                        }
 31.2734 -                    } else {
 31.2735 -                        // We're not the first ones, so find the place where we
 31.2736 -                        // have to insert ourselves
 31.2737 -                        SDL_Rect **pNewList;
 31.2738 -                        int iPlace, iNumOfSlots, i;
 31.2739 -
 31.2740 -#ifdef DEBUG_BUILD
 31.2741 -//            printf("!!! Searching where to insert\n");
 31.2742 -#endif
 31.2743 -
 31.2744 -                        iPlace = -1;
 31.2745 -                        iNumOfSlots = 1;        // Count the last NULL too!
 31.2746 -                        for (i = 0; _this->hidden->pListModesResult[i]; i++) {
 31.2747 -                            iNumOfSlots++;
 31.2748 -                            if (iPlace == -1) {
 31.2749 -                                if ((_this->hidden->pListModesResult[i]->w *
 31.2750 -                                     _this->hidden->pListModesResult[i]->h) <
 31.2751 -                                    (pRect->w * pRect->h)) {
 31.2752 -                                    iPlace = i;
 31.2753 -                                }
 31.2754 -                            }
 31.2755 -                        }
 31.2756 -                        if (iPlace == -1)
 31.2757 -                            iPlace = iNumOfSlots - 1;
 31.2758 -
 31.2759 -#ifdef DEBUG_BUILD
 31.2760 -//            printf("!!! From %d slots, it will be at %d\n", iNumOfSlots, iPlace);
 31.2761 -#endif
 31.2762 -
 31.2763 -                        pNewList = (SDL_Rect **)
 31.2764 -                            SDL_realloc(_this->hidden->pListModesResult,
 31.2765 -                                        (iNumOfSlots +
 31.2766 -                                         1) * sizeof(SDL_Rect *));
 31.2767 -                        if (pNewList) {
 31.2768 -                            for (i = iNumOfSlots; i > iPlace; i--)
 31.2769 -                                pNewList[i] = pNewList[i - 1];
 31.2770 -                            pNewList[iPlace] = pRect;
 31.2771 -                            _this->hidden->pListModesResult = pNewList;
 31.2772 -                        } else {
 31.2773 -                            SDL_free(pRect);
 31.2774 -                        }
 31.2775 -                    }
 31.2776 -                }
 31.2777 -            }
 31.2778 -            pFSMode = pFSMode->pNext;
 31.2779 -        }
 31.2780 -    }
 31.2781 -#ifdef DEBUG_BUILD
 31.2782 -//  printf("Returning list\n");
 31.2783 -#endif
 31.2784 -    return _this->hidden->pListModesResult;
 31.2785 -}
 31.2786 -
 31.2787 -/* Initialize the native video subsystem, filling 'vformat' with the
 31.2788 - "best" display pixel format, returning 0 or -1 if there's an error.
 31.2789 - */
 31.2790 -static int
 31.2791 -os2fslib_VideoInit(_THIS, SDL_PixelFormat * vformat)
 31.2792 -{
 31.2793 -    FSLib_VideoMode_p pDesktopMode;
 31.2794 -
 31.2795 -#ifdef DEBUG_BUILD
 31.2796 -    printf("[os2fslib_VideoInit] : Enter\n");
 31.2797 -    fflush(stdout);
 31.2798 -#endif
 31.2799 -
 31.2800 -    // Report the best pixel format. For this,
 31.2801 -    // we'll use the current desktop format.
 31.2802 -    pDesktopMode = FSLib_GetDesktopVideoMode();
 31.2803 -    if (!pDesktopMode) {
 31.2804 -        SDL_SetError("Could not query desktop video mode!");
 31.2805 -#ifdef DEBUG_BUILD
 31.2806 -        printf
 31.2807 -            ("[os2fslib_VideoInit] : Could not query desktop video mode!\n");
 31.2808 -#endif
 31.2809 -        return -1;
 31.2810 -    }
 31.2811 -
 31.2812 -    /* Determine the current screen size */
 31.2813 -    _this->info.current_w = pDesktopMode->uiXResolution;
 31.2814 -    _this->info.current_h = pDesktopMode->uiYResolution;
 31.2815 -
 31.2816 -    /* Determine the screen depth */
 31.2817 -    vformat->BitsPerPixel = pDesktopMode->uiBPP;
 31.2818 -    vformat->BytesPerPixel = (vformat->BitsPerPixel + 7) / 8;
 31.2819 -
 31.2820 -    vformat->Rmask =
 31.2821 -        ((unsigned int) pDesktopMode->PixelFormat.
 31.2822 -         ucRedMask) << pDesktopMode->PixelFormat.ucRedPosition;
 31.2823 -    vformat->Rshift = pDesktopMode->PixelFormat.ucRedPosition;
 31.2824 -    vformat->Rloss = pDesktopMode->PixelFormat.ucRedAdjust;
 31.2825 -    vformat->Gmask =
 31.2826 -        ((unsigned int) pDesktopMode->
 31.2827 -         PixelFormat.ucGreenMask) << pDesktopMode->PixelFormat.
 31.2828 -        ucGreenPosition;
 31.2829 -    vformat->Gshift = pDesktopMode->PixelFormat.ucGreenPosition;
 31.2830 -    vformat->Gloss = pDesktopMode->PixelFormat.ucGreenAdjust;
 31.2831 -    vformat->Bmask =
 31.2832 -        ((unsigned int) pDesktopMode->
 31.2833 -         PixelFormat.ucBlueMask) << pDesktopMode->PixelFormat.ucBluePosition;
 31.2834 -    vformat->Bshift = pDesktopMode->PixelFormat.ucBluePosition;
 31.2835 -    vformat->Bloss = pDesktopMode->PixelFormat.ucBlueAdjust;
 31.2836 -    vformat->Amask =
 31.2837 -        ((unsigned int) pDesktopMode->
 31.2838 -         PixelFormat.ucAlphaMask) << pDesktopMode->PixelFormat.
 31.2839 -        ucAlphaPosition;
 31.2840 -    vformat->Ashift = pDesktopMode->PixelFormat.ucAlphaPosition;
 31.2841 -    vformat->Aloss = pDesktopMode->PixelFormat.ucAlphaAdjust;
 31.2842 -
 31.2843 -#ifdef REPORT_EMPTY_ALPHA_MASK
 31.2844 -    vformat->Amask = vformat->Ashift = vformat->Aloss = 0;
 31.2845 -#endif
 31.2846 -
 31.2847 -    // Fill in some window manager capabilities
 31.2848 -    _this->info.wm_available = 1;
 31.2849 -
 31.2850 -    // Initialize some internal variables
 31.2851 -    _this->hidden->pListModesResult = NULL;
 31.2852 -    _this->hidden->fInFocus = 0;
 31.2853 -    _this->hidden->iSkipWMMOUSEMOVE = 0;
 31.2854 -    _this->hidden->iMouseVisible = 1;
 31.2855 -
 31.2856 -    if (getenv("SDL_USE_PROPORTIONAL_WINDOW"))
 31.2857 -        _this->hidden->bProportionalResize = 1;
 31.2858 -    else {
 31.2859 -        PPIB pib;
 31.2860 -        PTIB tib;
 31.2861 -        char *pchFileName, *pchTemp;
 31.2862 -        char achConfigFile[CCHMAXPATH];
 31.2863 -        FILE *hFile;
 31.2864 -
 31.2865 -        /* No environment variable to have proportional window.
 31.2866 -         * Ok, let's check if this executable is in config file!
 31.2867 -         */
 31.2868 -        _this->hidden->bProportionalResize = 0;
 31.2869 -
 31.2870 -        DosGetInfoBlocks(&tib, &pib);
 31.2871 -        pchTemp = pchFileName = pib->pib_pchcmd;
 31.2872 -        while (*pchTemp) {
 31.2873 -            if (*pchTemp == '\\')
 31.2874 -                pchFileName = pchTemp + 1;
 31.2875 -            pchTemp++;
 31.2876 -        }
 31.2877 -        if (getenv("HOME")) {
 31.2878 -            sprintf(achConfigFile, "%s\\.sdl.proportionals", getenv("HOME"));
 31.2879 -            hFile = fopen(achConfigFile, "rt");
 31.2880 -            if (!hFile) {
 31.2881 -                /* Seems like the file cannot be opened or does not exist.
 31.2882 -                 * Let's try to create it with defaults!
 31.2883 -                 */
 31.2884 -                hFile = fopen(achConfigFile, "wt");
 31.2885 -                if (hFile) {
 31.2886 -                    fprintf(hFile,
 31.2887 -                            "; This file is a config file of SDL/2, containing\n");
 31.2888 -                    fprintf(hFile,
 31.2889 -                            "; the list of executables that must have proportional\n");
 31.2890 -                    fprintf(hFile, "; windows.\n");
 31.2891 -                    fprintf(hFile, ";\n");
 31.2892 -                    fprintf(hFile,
 31.2893 -                            "; You can add executable filenames into this file,\n");
 31.2894 -                    fprintf(hFile,
 31.2895 -                            "; one under the other. If SDL finds that a given\n");
 31.2896 -                    fprintf(hFile,
 31.2897 -                            "; program is in this list, then that application\n");
 31.2898 -                    fprintf(hFile,
 31.2899 -                            "; will have proportional windows, just like if\n");
 31.2900 -                    fprintf(hFile,
 31.2901 -                            "; the SET SDL_USE_PROPORTIONAL_WINDOW env. variable\n");
 31.2902 -                    fprintf(hFile,
 31.2903 -                            "; would have been set for that process.\n");
 31.2904 -                    fprintf(hFile, ";\n");
 31.2905 -                    fprintf(hFile, "\n");
 31.2906 -                    fprintf(hFile, "dosbox.exe\n");
 31.2907 -                    fclose(hFile);
 31.2908 -                }
 31.2909 -
 31.2910 -                hFile = fopen(achConfigFile, "rt");
 31.2911 -            }
 31.2912 -
 31.2913 -            if (hFile) {
 31.2914 -                while (fgets(achConfigFile, sizeof(achConfigFile), hFile)) {
 31.2915 -                    /* Cut \n from end of string */
 31.2916 -
 31.2917 -                    while (achConfigFile[strlen(achConfigFile) - 1]
 31.2918 -                           == '\n')
 31.2919 -                        achConfigFile[strlen(achConfigFile) - 1] = 0;
 31.2920 -
 31.2921 -                    /* Compare... */
 31.2922 -                    if (stricmp(achConfigFile, pchFileName) == 0) {
 31.2923 -                        /* Found it in config file! */
 31.2924 -                        _this->hidden->bProportionalResize = 1;
 31.2925 -                        break;
 31.2926 -                    }
 31.2927 -                }
 31.2928 -                fclose(hFile);
 31.2929 -            }
 31.2930 -        }
 31.2931 -    }
 31.2932 -
 31.2933 -    DosCreateMutexSem(NULL, &(_this->hidden->hmtxUseSrcBuffer), 0, FALSE);
 31.2934 -
 31.2935 -    // Now create our window with a default size
 31.2936 -
 31.2937 -    // For this, we select the first available fullscreen mode as
 31.2938 -    // current window size!
 31.2939 -    SDL_memcpy(&(_this->hidden->SrcBufferDesc),
 31.2940 -               _this->hidden->pAvailableFSLibVideoModes,
 31.2941 -               sizeof(_this->hidden->SrcBufferDesc));
 31.2942 -    // Allocate new video buffer!
 31.2943 -    _this->hidden->pchSrcBuffer =
 31.2944 -        (char *) SDL_malloc(_this->hidden->
 31.2945 -                            pAvailableFSLibVideoModes->uiScanLineSize *
 31.2946 -                            _this->hidden->
 31.2947 -                            pAvailableFSLibVideoModes->uiYResolution);
 31.2948 -    if (!_this->hidden->pchSrcBuffer) {
 31.2949 -#ifdef DEBUG_BUILD
 31.2950 -        printf
 31.2951 -            ("[os2fslib_VideoInit] : Yikes, not enough memory for new video buffer!\n");
 31.2952 -        fflush(stdout);
 31.2953 -#endif
 31.2954 -        SDL_SetError("Not enough memory for new video buffer!\n");
 31.2955 -        return -1;
 31.2956 -    }
 31.2957 -    // For this, we need a message processing thread.
 31.2958 -    // We'll create a new thread for this, which will do everything
 31.2959 -    // what is related to PM
 31.2960 -    _this->hidden->iPMThreadStatus = 0;
 31.2961 -    _this->hidden->tidPMThread =
 31.2962 -        _beginthread(PMThreadFunc, NULL, 65536, (void *) _this);
 31.2963 -    if (_this->hidden->tidPMThread <= 0) {
 31.2964 -#ifdef DEBUG_BUILD
 31.2965 -        printf("[os2fslib_VideoInit] : Could not create PM thread!\n");
 31.2966 -#endif
 31.2967 -        SDL_SetError("Could not create PM thread");
 31.2968 -        return -1;
 31.2969 -    }
 31.2970 -#ifdef USE_DOSSETPRIORITY
 31.2971 -    // Burst the priority of PM Thread!
 31.2972 -    DosSetPriority(PRTYS_THREAD, PRTYC_TIMECRITICAL, 0,
 31.2973 -                   _this->hidden->tidPMThread);
 31.2974 -#endif
 31.2975 -    // Wait for the PM thread to initialize!
 31.2976 -    while (_this->hidden->iPMThreadStatus == 0)
 31.2977 -        DosSleep(32);
 31.2978 -    // If the PM thread could not set up everything, then
 31.2979 -    // report an error!
 31.2980 -    if (_this->hidden->iPMThreadStatus != 1) {
 31.2981 -#ifdef DEBUG_BUILD
 31.2982 -        printf("[os2fslib_VideoInit] : PMThread reported an error : %d\n",
 31.2983 -               _this->hidden->iPMThreadStatus);
 31.2984 -#endif
 31.2985 -        SDL_SetError("Error initializing PM thread");
 31.2986 -        return -1;
 31.2987 -    }
 31.2988 -
 31.2989 -    return 0;
 31.2990 -}
 31.2991 -
 31.2992 -
 31.2993 -static void
 31.2994 -os2fslib_DeleteDevice(_THIS)
 31.2995 -{
 31.2996 -#ifdef DEBUG_BUILD
 31.2997 -    printf("[os2fslib_DeleteDevice]\n");
 31.2998 -    fflush(stdout);
 31.2999 -#endif
 31.3000 -    // Free used memory
 31.3001 -    FSLib_FreeVideoModeList(_this->hidden->pAvailableFSLibVideoModes);
 31.3002 -    if (_this->hidden->pListModesResult)
 31.3003 -        SDL_free(_this->hidden->pListModesResult);
 31.3004 -    if (_this->hidden->pchSrcBuffer)
 31.3005 -        SDL_free(_this->hidden->pchSrcBuffer);
 31.3006 -    DosCloseMutexSem(_this->hidden->hmtxUseSrcBuffer);
 31.3007 -    SDL_free(_this->hidden);
 31.3008 -    SDL_free(_this);
 31.3009 -    FSLib_Uninitialize();
 31.3010 -}
 31.3011 -
 31.3012 -static int
 31.3013 -os2fslib_Available(void)
 31.3014 -{
 31.3015 -
 31.3016 -    // If we can run, it means that we could load FSLib,
 31.3017 -    // so we assume that it's available then!
 31.3018 -    return 1;
 31.3019 -}
 31.3020 -
 31.3021 -static void
 31.3022 -os2fslib_MorphToPM()
 31.3023 -{
 31.3024 -    PPIB pib;
 31.3025 -    PTIB tib;
 31.3026 -
 31.3027 -    DosGetInfoBlocks(&tib, &pib);
 31.3028 -
 31.3029 -    // Change flag from VIO to PM:
 31.3030 -    if (pib->pib_ultype == 2)
 31.3031 -        pib->pib_ultype = 3;
 31.3032 -}
 31.3033 -
 31.3034 -static SDL_VideoDevice *
 31.3035 -os2fslib_CreateDevice(int devindex)
 31.3036 -{
 31.3037 -    SDL_VideoDevice *device;
 31.3038 -
 31.3039 -#ifdef DEBUG_BUILD
 31.3040 -    printf("[os2fslib_CreateDevice] : Enter\n");
 31.3041 -    fflush(stdout);
 31.3042 -#endif
 31.3043 -
 31.3044 -    /* Initialize all variables that we clean on shutdown */
 31.3045 -    device = (SDL_VideoDevice *) SDL_malloc(sizeof(SDL_VideoDevice));
 31.3046 -    if (device) {
 31.3047 -        SDL_memset(device, 0, (sizeof *device));
 31.3048 -        // Also allocate memory for private data
 31.3049 -        device->hidden = (struct SDL_PrivateVideoData *)
 31.3050 -            SDL_malloc((sizeof(struct SDL_PrivateVideoData)));
 31.3051 -    }
 31.3052 -    if ((device == NULL) || (device->hidden == NULL)) {
 31.3053 -        SDL_OutOfMemory();
 31.3054 -        if (device)
 31.3055 -            SDL_free(device);
 31.3056 -        return NULL;
 31.3057 -    }
 31.3058 -    SDL_memset(device->hidden, 0, (sizeof *device->hidden));
 31.3059 -
 31.3060 -    /* Set the function pointers */
 31.3061 -#ifdef DEBUG_BUILD
 31.3062 -    printf("[os2fslib_CreateDevice] : VideoInit is %p\n", os2fslib_VideoInit);
 31.3063 -    fflush(stdout);
 31.3064 -#endif
 31.3065 -
 31.3066 -    /* Initialization/Query functions */
 31.3067 -    device->VideoInit = os2fslib_VideoInit;
 31.3068 -    device->ListModes = os2fslib_ListModes;
 31.3069 -    device->SetVideoMode = os2fslib_SetVideoMode;
 31.3070 -    device->ToggleFullScreen = os2fslib_ToggleFullScreen;
 31.3071 -    device->UpdateMouse = os2fslib_UpdateMouse;
 31.3072 -    device->CreateYUVOverlay = NULL;
 31.3073 -    device->SetColors = os2fslib_SetColors;
 31.3074 -    device->UpdateRects = os2fslib_UpdateRects;
 31.3075 -    device->VideoQuit = os2fslib_VideoQuit;
 31.3076 -    /* Hardware acceleration functions */
 31.3077 -    device->AllocHWSurface = os2fslib_AllocHWSurface;
 31.3078 -    device->CheckHWBlit = NULL;
 31.3079 -    device->FillHWRect = NULL;
 31.3080 -    device->SetHWColorKey = NULL;
 31.3081 -    device->SetHWAlpha = NULL;
 31.3082 -    device->LockHWSurface = os2fslib_LockHWSurface;
 31.3083 -    device->UnlockHWSurface = os2fslib_UnlockHWSurface;
 31.3084 -    device->FlipHWSurface = NULL;
 31.3085 -    device->FreeHWSurface = os2fslib_FreeHWSurface;
 31.3086 -    /* Window manager functions */
 31.3087 -    device->SetCaption = os2fslib_SetCaption;
 31.3088 -    device->SetIcon = os2fslib_SetIcon;
 31.3089 -    device->IconifyWindow = os2fslib_IconifyWindow;
 31.3090 -    device->GrabInput = os2fslib_GrabInput;
 31.3091 -    device->GetWMInfo = NULL;
 31.3092 -    /* Cursor manager functions to Windowed mode */
 31.3093 -    os2fslib_SetCursorManagementFunctions(device, 1);
 31.3094 -    /* Event manager functions */
 31.3095 -    device->InitOSKeymap = os2fslib_InitOSKeymap;
 31.3096 -    device->PumpEvents = os2fslib_PumpEvents;
 31.3097 -    /* The function used to dispose of this structure */
 31.3098 -    device->free = os2fslib_DeleteDevice;
 31.3099 -
 31.3100 -    // Make sure we'll be able to use Win* API even if the application
 31.3101 -    // was linked to be a VIO application!
 31.3102 -    os2fslib_MorphToPM();
 31.3103 -
 31.3104 -    // Now initialize FSLib, and query available video modes!
 31.3105 -    if (!FSLib_Initialize()) {
 31.3106 -        // Could not initialize FSLib!
 31.3107 -#ifdef DEBUG_BUILD
 31.3108 -        printf("[os2fslib_CreateDevice] : Could not initialize FSLib!\n");
 31.3109 -#endif
 31.3110 -        SDL_SetError("Could not initialize FSLib!");
 31.3111 -        SDL_free(device->hidden);
 31.3112 -        SDL_free(device);
 31.3113 -        return NULL;
 31.3114 -    }
 31.3115 -    device->hidden->pAvailableFSLibVideoModes = FSLib_GetVideoModeList();
 31.3116 -
 31.3117 -    return device;
 31.3118 -}
 31.3119 -
 31.3120 -VideoBootStrap OS2FSLib_bootstrap = {
 31.3121 -    "os2fslib", "OS/2 Video Output using FSLib",
 31.3122 -    os2fslib_Available, os2fslib_CreateDevice
 31.3123 -};
 31.3124 -
 31.3125 -/* vi: set ts=4 sw=4 expandtab: */
    32.1 --- a/src/video/os2fslib/SDL_os2fslib.h	Sat Sep 19 06:24:07 2009 +0000
    32.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    32.3 @@ -1,72 +0,0 @@
    32.4 -/*
    32.5 -    SDL - Simple DirectMedia Layer
    32.6 -    Copyright (C) 1997-2009 Sam Lantinga
    32.7 -
    32.8 -    This library is free software; you can redistribute it and/or
    32.9 -    modify it under the terms of the GNU Library General Public
   32.10 -    License as published by the Free Software Foundation; either
   32.11 -    version 2 of the License, or (at your option) any later version.
   32.12 -
   32.13 -    This library is distributed in the hope that it will be useful,
   32.14 -    but WITHOUT ANY WARRANTY; without even the implied warranty of
   32.15 -    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   32.16 -    Library General Public License for more details.
   32.17 -
   32.18 -    You should have received a copy of the GNU Library General Public
   32.19 -    License along with this library; if not, write to the Free
   32.20 -    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   32.21 -
   32.22 -    Sam Lantinga
   32.23 -    slouken@libsdl.org
   32.24 -*/
   32.25 -#include "SDL_config.h"
   32.26 -
   32.27 -#ifndef _SDL_os2fslib_h
   32.28 -#define _SDL_os2fslib_h
   32.29 -
   32.30 -
   32.31 -// OS2 specific includes
   32.32 -#define INCL_TYPES
   32.33 -#define INCL_DOS
   32.34 -#define INCL_DOSERRORS
   32.35 -#define INCL_DOSPROCESS
   32.36 -#define INCL_WIN
   32.37 -#define INCL_GPI
   32.38 -#include <os2.h>
   32.39 -
   32.40 -#include <FSLib.h>
   32.41 -
   32.42 -/* Hidden "this" pointer for the video functions */
   32.43 -#define _THIS	SDL_VideoDevice *_this
   32.44 -
   32.45 -/* Private display data */
   32.46 -struct SDL_PrivateVideoData
   32.47 -{
   32.48 -    FSLib_VideoMode_p pAvailableFSLibVideoModes;
   32.49 -    SDL_Rect **pListModesResult;        // Allocated memory to return list of modes for os2fslib_ListModes() API
   32.50 -
   32.51 -    FSLib_VideoMode SrcBufferDesc;      // Description of current source image buffer
   32.52 -    char *pchSrcBuffer;         // The source image buffer itself
   32.53 -    SDL_Surface *pSDLSurface;   // The SDL surface describing the buffer
   32.54 -    HMTX hmtxUseSrcBuffer;      // Mutex semaphore to manipulate src buffer
   32.55 -    HWND hwndFrame, hwndClient; // Window handle of frame and client
   32.56 -    int iPMThreadStatus;        // 0: Not running
   32.57 -    // 1: Running
   32.58 -    // Other: Not running, had an error
   32.59 -    int tidPMThread;            // Thread ID of PM Thread
   32.60 -    int fInFocus;               // True if we're in focus!
   32.61 -    int iSkipWMMOUSEMOVE;       // Number of WM_MOUSEMOVE messages to skip!
   32.62 -    int iMouseVisible;          //
   32.63 -
   32.64 -    PFNWP pfnOldFrameProc;      // Old window frame procedure
   32.65 -    int bProportionalResize;    // 0: No proportional resizing
   32.66 -    // 1: Do proportional resizing
   32.67 -    ULONG ulResizingFlag;       // First resizing flag value
   32.68 -};
   32.69 -
   32.70 -/* OS/2 specific backdoor function to be able to set FrameControlFlags of */
   32.71 -/* the SDL window before creating it. */
   32.72 -extern DECLSPEC void SDLCALL SDL_OS2FSLIB_SetFCFToUse(ULONG ulFCF);
   32.73 -
   32.74 -#endif /* _SDL_os2fslib_h */
   32.75 -/* vi: set ts=4 sw=4 expandtab: */
    33.1 --- a/src/video/os2fslib/SDL_vkeys.h	Sat Sep 19 06:24:07 2009 +0000
    33.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    33.3 @@ -1,75 +0,0 @@
    33.4 -/*
    33.5 -    SDL - Simple DirectMedia Layer
    33.6 -    Copyright (C) 1997-2009 Sam Lantinga
    33.7 -
    33.8 -    This library is free software; you can redistribute it and/or
    33.9 -    modify it under the terms of the GNU Lesser General Public
   33.10 -    License as published by the Free Software Foundation; either
   33.11 -    version 2.1 of the License, or (at your option) any later version.
   33.12 -
   33.13 -    This library is distributed in the hope that it will be useful,
   33.14 -    but WITHOUT ANY WARRANTY; without even the implied warranty of
   33.15 -    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   33.16 -    Lesser General Public License for more details.
   33.17 -
   33.18 -    You should have received a copy of the GNU Lesser General Public
   33.19 -    License along with this library; if not, write to the Free Software
   33.20 -    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
   33.21 -
   33.22 -    Sam Lantinga
   33.23 -    slouken@libsdl.org
   33.24 -*/
   33.25 -
   33.26 -#ifndef VK_0
   33.27 -#define VK_0	'0'
   33.28 -#define VK_1	'1'
   33.29 -#define VK_2	'2'
   33.30 -#define VK_3	'3'
   33.31 -#define VK_4	'4'
   33.32 -#define VK_5	'5'
   33.33 -#define VK_6	'6'
   33.34 -#define VK_7	'7'
   33.35 -#define VK_8	'8'
   33.36 -#define VK_9	'9'
   33.37 -#define VK_A	'A'
   33.38 -#define VK_B	'B'
   33.39 -#define VK_C	'C'
   33.40 -#define VK_D	'D'
   33.41 -#define VK_E	'E'
   33.42 -#define VK_F	'F'
   33.43 -#define VK_G	'G'
   33.44 -#define VK_H	'H'
   33.45 -#define VK_I	'I'
   33.46 -#define VK_J	'J'
   33.47 -#define VK_K	'K'
   33.48 -#define VK_L	'L'
   33.49 -#define VK_M	'M'
   33.50 -#define VK_N	'N'
   33.51 -#define VK_O	'O'
   33.52 -#define VK_P	'P'
   33.53 -#define VK_Q	'Q'
   33.54 -#define VK_R	'R'
   33.55 -#define VK_S	'S'
   33.56 -#define VK_T	'T'
   33.57 -#define VK_U	'U'
   33.58 -#define VK_V	'V'
   33.59 -#define VK_W	'W'
   33.60 -#define VK_X	'X'
   33.61 -#define VK_Y	'Y'
   33.62 -#define VK_Z	'Z'
   33.63 -#endif /* VK_0 */
   33.64 -
   33.65 -/* These keys haven't been defined, but were experimentally determined */
   33.66 -#define VK_SEMICOLON	0xBA
   33.67 -#define VK_EQUALS	0xBB
   33.68 -#define VK_COMMA	0xBC
   33.69 -#define VK_MINUS	0xBD
   33.70 -#define VK_PERIOD	0xBE
   33.71 -#define VK_SLASH	0xBF
   33.72 -#define VK_GRAVE	0xC0
   33.73 -#define VK_LBRACKET	0xDB
   33.74 -#define VK_BACKSLASH	0xDC
   33.75 -#define VK_RBRACKET	0xDD
   33.76 -#define VK_APOSTROPHE	0xDE
   33.77 -#define VK_BACKTICK	0xDF
   33.78 -/* vi: set ts=4 sw=4 expandtab: */