author Sam Lantinga <>
Thu, 02 Apr 2009 04:43:36 +0000
changeset 4167 a6f635e5eaa6
parent 4160 ef781fa00223
child 4176 d19539d96198
permissions -rw-r--r--
Fixed bug #611

From Tim Angus 2008-08-12 11:18:06

I'm one of the maintainers of, an updated version of the
Quake 3 engine. Relatively recently, we moved ioq3 to use SDL as a
replacement for 95% of the platform specific code that was there. On the
whole it's doing a great job but unfortunately since the move we've been
getting complaints about the quality of the mouse input on the Windows
platform to the point where for many the game is unplayable. Put in
other terms, the current stable SDL 1.2 is basically not fit for purpose
if you need high quality mouse input as you do in a first person shooter.

Over the weekend I decided to pull my finger out and actually figure out
what's going on. There are basically two major problems. Firstly, when
using the "windib" driver, mouse input is gathered via the WM_MOUSEMOVE
message. Googling for this indicates that often this is known to result
in "spurious" and/or "missing" mouse movement events; this is the
primary cause of the poor mouse input. The second problem is that the
"directx" driver does not work at all in combination with OpenGL meaning
that you can't use DirectInput if your application also uses OpenGL. In
other words you're locked into using the "windib" driver and its poor
mouse input.

In order to address these problems I've done the following:

* Remove WM_MOUSEMOVE based motion event generation and replace with
calls to GetCursorPos which seems much more reliable. In order to
achieve this I've moved mouse motion out into a separate function that
is called once per DIB_PumpEvents.

* Remove the restriction on the "directx" driver being inoperable in
combination with OpenGL. There is a bug for this issues that I've
hijacked to a certain extent
( I'm the first to admit
I don't really understand why this restriction is there in the first
place. The commit message for the bug fix that introduced this
restriction (r581) isn't very elaborate and I couldn't see any other bug
tracking the issue. If anyone has more information on the bug that was
avoided by r581 it would be helpful as I/someone could then look into
addressing the problem without disabling the "directx" driver.

* I've also removed the restriction on not being allowed to use
DirectInput in windowed mode. I couldn't see any reason for this, at
least not from our perspective. I have my suspicions that it'll be
something like matching up the cursor with the mouse coordinates...

* I bumped up the DirectInput API used to version 7 in order to get
access to mouse buttons 4-7. I've had to inject a little bit of the DX7
headers into SDL there as the MinGW ones aren't up to date in this respect.
     1 ==============================================================================
     2 Using the Simple DirectMedia Layer on Atari
     3 ==============================================================================
     6     If you want to build SDL from sources to create SDL programs on Atari:
     7         see sections I - II.
     9     If you want to create SDL programs on Atari using SDL binary build,
    10         download it from my web site (URL at end of this file).
    12     If you want to configure a program using SDL on Atari,
    13 	    see sections IV - VI.
    16 ==============================================================================
    17 I.  Building the Simple DirectMedia Layer libraries:
    18     (This step isn't necessary if you have the SDL binary distribution)
    20   Do the classic configure, with --disable-shared --enable-static and:
    22     Tos version (should run everywhere):
    23       --disable-threads
    24     Tos does not support threads.
    26     MiNT version (maybe Magic, only for multitasking OS):
    27       --disable-pthreads --enable-pth
    28     Mint and Magic may supports threads, so audio can be used with current
    29     devices, like Sun audio, or disk-writing support. Like Tos, interrupt
    30     audio without threads is more suited for Atari machines.
    32   Then you can make ; make install it.
    34 ==============================================================================
    35 II. Building the Simple DirectMedia Layer test programs:
    37   Do the classic configure, then make.
    39   Run them !
    41 ==============================================================================
    42 III.  Enjoy! :)
    44   If you have a project you'd like me to know about, or want to ask questions,
    45   go ahead and join the SDL developer's mailing list by sending e-mail to:
    49   and put "subscribe" into the subject of the message. Or alternatively you
    50   can use the web interface:
    54 ==============================================================================
    55 IV.  What is supported:
    57 Keyboard (GEMDOS, BIOS, GEM, Ikbd)
    58 Mouse (XBIOS, GEM, Ikbd, /dev/mouse (non working atm, disabled))
    59 Video (XBIOS (Fullscreen), GEM (Windowed and Fullscreen))
    60 Timer (VBL vector, GNU pth library)
    61 Joysticks and joypads (Ikbd, Hardware)
    62 Audio (Hardware, XBIOS, GSXB, MCSN, STFA, /dev/audio if threads enabled)
    63 Threads (Multitasking OS only via GNU pth library)
    64 Shared object loader (using LDG library from
    65 Audio CD (MetaDOS)
    66 OpenGL (using Mesa offscreen rendering driver)
    68 - Dependent driver combinations:
    69 Video   Kbd     Mouse   Timer   Joysticks
    70 xbios   ikbd    ikbd    vbl(2)  ikbd
    71 xbios   gemdos  xbios   vbl(2)  xbios
    72 xbios   bios    xbios   vbl(2)  xbios
    73 gem     gem     gem(1)  vbl(2)  xbios
    75 Audio   O/S     Misc
    76 dma8    All     Uses MFP Timer A interrupt
    77 xbios	TOS     Uses MFP Timer A interrupt
    78 xbios   MiNT    Uses MFP Timer A interrupt
    79 xbios   Magic   Disabled
    80 stfa    All     Uses MFP interrupt
    81 mcsn	TOS     Uses MFP Timer A interrupt
    82 mcsn    MiNT    Uses MiNT thread
    83 mcsn    Magic   Disabled
    84 gsxb    All     Uses GSXB callback
    86 Joypad driver always uses hardware access.
    87 OpenGL driver always uses OSMesa.
    89 (1) GEM does not report relative mouse motion, so xbios mouse driver is used
    90 to report this type event.
    91 A preliminary driver for /dev/mouse device driver is present, but is disabled
    92 till it can be used with other applications simultaneously.
    94 (2) If you build SDL with threads using the GNU pth library, timers are
    95 supported via the pth library.
    97 ==============================================================================
    98 V.  Environment variables:
   101 	Set to 'xbios' to force xbios video driver
   102 	Set to 'gem' to force gem video driver
   105 	Set to filename to load as OpenGL library, if you use SDL_GL_LoadLibrary()
   108 	Set to 'mint_gsxb' to force Atari GSXB audio driver
   109 	Set to 'mint_mcsn' to force Atari MCSN audio driver
   110 	Set to 'mint_stfa' to force Atari STFA audio driver
   111 	Set to 'mint_xbios' to force Atari Xbios audio driver
   112 	Set to 'mint_dma8' to force Atari 8 bits DMA audio driver
   113 	Set to 'audio' to force Sun /dev/audio audio driver
   114 	Set to 'disk' to force disk-writing audio driver
   117 	Set to 'ikbd' to force IKBD 6301 keyboard driver
   118 	Set to 'gemdos' to force gemdos keyboard driver
   119 	Set to 'bios' to force bios keyboard driver
   122 	Use any of these strings in the environment variable to enable or
   123 	disable a joystick:
   125 	'ikbd-joy1-[on|off]' for IKBD joystick on port 1 (hardware access)
   126 	'xbios-joy1-[on|off]' for IKBD joystick on port 1 (xbios access)
   127 	'porta-pad-[on|off]' for joypad and/or teamtap on port A
   128 	'porta-joy0-[on|off]' for joystick 0 on port A
   129 	'porta-joy1-[on|off]' for joystick 1 on port A
   130 	'porta-lp-[on|off]' for lightpen on port A
   131 	'porta-anpad-[on|off]' for analog paddle on port A
   132 	'portb-pad-[on|off]' for joypad and/or teamtap on port B
   133 	'portb-joy0-[on|off]' for joystick 0 on port B
   134 	'portb-joy1-[on|off]' for joystick 1 on port B
   135 	'portb-anpad-[on|off]' for analog paddle on port B
   137 	Default configuration is:
   138 		'ikbd-joy1-on' (if IKBD events driver enabled)
   139 		'xbios-joy1-on' (if gemdos/bios/gem events driver enabled)
   140 		'porta-pad-on portb-pad-on' (if available on the machine)
   142 	port[a|b]-[pad|joy?|lp|anpad]-* strings are mutually exclusives.
   143 	On such a port, you can only use a joypad OR 1 or 2 joysticks OR
   144 	a lightpen OR an analog paddle. You must disable joypad before
   145 	setting another controller.
   147 	The second joystick port on IKBD is used by the mouse, so not usable.
   148 	Another problem with the IKBD: mouse buttons and joystick fire buttons
   149 	are wired together at the hardware level, it means:
   150 		port 0                port 0           port 1
   151 		mouse left button  = joystick fire 0 = joystick fire 1
   152 		mouse right button = joystick fire 1 = joystick fire 0
   154 	Descriptions of joysticks/joypads:
   155 	- Joypads: 1 hat, 17 buttons (Atari Jaguar console-like).
   156 	- Joysticks: 1 hat, 1 button.
   157 	- Lightpen, analog paddles: 2 axis, 2 buttons. The 2 buttons are those
   158 	  affected to 1 button joysticks on the same port.
   160 ==============================================================================
   161 VI.  More informations about drivers:
   163 OpenGL:
   164 	The default is to use the Mesa offscreen driver (osmesa.ldg). If you want
   165 	to use an older OpenGL implementation, like mesa_gl.ldg or tiny_gl.ldg,
   166 	your program must use SDL_GL_LoadLibrary() to do so, and retrieve the
   167 	needed function pointers with SDL_LoadFunction(). In all cases, the OpenGL
   168 	context is taken care of by SDL itself, you just have to use gl* functions.
   170 	However, there is one OpenGL call that has a different prototype in the old
   171 	implementations: glOrtho(). In the old implementations, it has 6 float as
   172 	parameters, in the standard one, it has 6 double parameters. If you want
   173 	to compile testdyngl, or any other SDL program that loads its OpenGL
   174 	library, you must change the glOrtho() prototype used in this program. In
   175 	osmesa.ldg, you can retrieve a glOrtho() with double parameters, by
   176 	searching for the function "glOrtho6d".
   178 Xbios video:
   179 	Video chip is detected using the _VDO cookie.
   180 	Screen enhancers are not supported, but could be if you know how to
   181 	use them.
   183 	ST, STE, Mega ST, Mega STE:
   184 		320x200x4 bits, shades of grey, available only for the purpose
   185 		of testing SDL.
   186 	TT:
   187 		320x480x8 and 320x240x8 (software double-lined mode).
   188 	Falcon:
   189 		All modes supported by the current monitor (RVB or VGA).
   190 		BlowUp and Centscreen extended modes, ScreenBlaster 3 current mode.
   191 	Clones and any machine with monochrome monitor:
   192 		Not supported.
   194 Gem video:
   195 	Automatically used if xbios not available.
   197 	All machines:
   198 		Only the current resolution, if 8 bits or higher depth.
   200 IKBD keyboard, mouse and joystick driver:
   201 	Available if _MCH cookie is ST, Mega ST, STE, Mega STE, TT or Falcon.
   203 	Hades has an IKBD, but xbios is not available for video, so IKBD
   204 	driver is disabled.
   206 Gemdos and bios keyboard driver:
   207 	Available on all machines.
   209 Mouse and joystick xbios driver:
   210 	Available on all machines (I think).
   212 Joypad driver:
   213 	Available if _MCH cookie is STE or Falcon. Supports teamtap.
   215 PTH timer driver:
   216 	Available with multitasking OS.
   218 VBL timer driver:
   219 	Available on all machines (I think).
   221 Audio drivers:
   222 	Cookies _SND, MCSN, STFA and GSXB used to detect supported audio
   223 	capabilities.
   225 	STE, Mega STE, TT:
   226 		8 bits DMA (hardware access)
   227 		STFA, MCSN or GSXB driver if installed
   228 	Falcon:
   229 		8 bits DMA (hardware access)
   230 		Xbios functions
   231 		STFA, MCSN or GSXB driver if installed
   232 	Other machines:
   233 		STFA, MCSN or GSXB driver if installed
   235 	STFA driver:
   237 	GSXB driver:
   239 	MacSound driver:
   241 	MagicSound driver (MCSN,GSXB compatible):
   243 	X-Sound driver (GSXB compatible):
   246 -- 
   247 Patrice Mandin <>