Win32 joystick driver issue (SDL 1.2.0 & MinGW)

I apologize if this has already been reported, and maybe it is
already fixed. I haven’t followed the sdl@ discussions lately.

I’m shipping a version of Heroes compiled for MinGW32 [1] with
SDL 1.2.0 (cross-compiled for MinGW too). Someone recently
filled a bug [2] against it, reporting that neither the up nor
the left directions of his joystick worked.

I could reproduce it, and discovered that SDL_JoystickGetAxis
did always return >=0 values. I managed to fix this by
patching SDL as shown below (where pos[i]' has type DWORD which is unsigned, andoffset’ is an int).

— src/joystick/win32/SDL_mmjoystick.c Sun Jun 3 17:45:37 2001
+++ src/joystick/win32/SDL_mmjoystick.c Sun Jun 3 17:47:13 2001
@@ -235,7 +235,7 @@
transaxis = joystick->hwdata->transaxis;
for (i = 0; i < joystick->naxes; i++) {
if (joyinfo.dwFlags & flags[i]) {

  •   	value = (int)((float)(pos[i] + transaxis[i].offset) * transaxis[i].scale);
    
  •   	value = (int)(((float)pos[i] + transaxis[i].offset) * transaxis[i].scale);
      	change = (value - joystick->axes[i]);
      	if ( (change < -JOY_AXIS_THRESHOLD) || (change > JOY_AXIS_THRESHOLD) ) {
      		SDL_PrivateJoystickAxis(joystick, (Uint8)i, (Sint16)value);
    

[1] http://heroes.sf.net/download.html
[2] http://sourceforge.net/tracker/index.php?func=detail&aid=427937&group_id=7982&atid=107982--
Alexandre Duret-Lutz

I apologize if this has already been reported, and maybe it is
already fixed. I haven’t followed the sdl@ discussions lately.

I’m shipping a version of Heroes compiled for MinGW32 [1] with
SDL 1.2.0 (cross-compiled for MinGW too). Someone recently
filled a bug [2] against it, reporting that neither the up nor
the left directions of his joystick worked.

I could reproduce it, and discovered that SDL_JoystickGetAxis
did always return >=0 values. I managed to fix this by
patching SDL as shown below (where pos[i]' has type DWORD which is unsigned, andoffset’ is an int).

Thanks! This patch is now in CVS.

See ya,
-Sam Lantinga, Lead Programmer, Loki Software, Inc.