fix phantom hat when used with a joystick without one, since the code ignored the...
authorBradley Bell <btb@icculus.org>
Sat, 22 May 2004 08:00:04 +0000 (08:00 +0000)
committerBradley Bell <btb@icculus.org>
Sat, 22 May 2004 08:00:04 +0000 (08:00 +0000)
ChangeLog
arch/win32/joyhh.c

index 45d4140..3a95e70 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
 2004-05-22  Matthew Mueller  <donut@dakotacom.net>
 
+       * arch/win32/joyhh.c: fix phantom hat when used with a joystick
+       without one, since the code ignored the JOYCAPS_HASPOV flag (d1x
+       r1.5)
+
        * arch/ogl/gr.c: fix possibility of saving incomplete .tga
        screenshots if the entire thing wasn't written in one call to
        write() (d1x r1.35)
index e2c4fe8..728effe 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: joyhh.c,v 1.4 2004-05-20 23:10:17 btb Exp $ */
+/* $Id: joyhh.c,v 1.5 2004-05-22 08:00:04 btb Exp $ */
 //JOYC.C for D1_3Dfx and D1OpenGL
 //D1_3Dfx is a Win32 executable using Glide and DirectX 3
 //D1OpenGL is a Win32 executable using OpenGL and DirectX 3
@@ -67,6 +67,7 @@ typedef struct Button_info {
 typedef struct Joy_info {
        int                     joyid;
        ubyte                   present_mask;
+       ubyte       hat_present;
        ubyte                   slow_read;
        int                     max_timer;
        int                     read_count;
@@ -160,7 +161,7 @@ ubyte joy_read_raw_buttons()
 
         /* Hat stuff */
 
-        if (joy.dwPOV != JOY_POVCENTERED)
+        if (joystick.hat_present && joy.dwPOV != JOY_POVCENTERED)
          {
            joystick.buttons[19].state = (joy.dwPOV < JOY_POVRIGHT || joy.dwPOV > JOY_POVLEFT);
            joystick.buttons[15].state = (joy.dwPOV < JOY_POVBACKWARD && joy.dwPOV > JOY_POVFORWARD);
@@ -307,7 +308,7 @@ int joy_init(int joyid) //HH: added joyid parameter
 
        joystick.present_mask = JOY_1_X_AXIS | JOY_1_Y_AXIS;
        if (pjc.wCaps & JOYCAPS_HASZ)   joystick.present_mask |= JOY_1_Z_AXIS;
-//        if (pjc.wCaps & JOYCAPS_HASPOV) joystick.present_mask |= JOY_1_POV;
+       joystick.hat_present = (pjc.wCaps & JOYCAPS_HASPOV) > 0;
        if (pjc.wCaps & JOYCAPS_HASR)   joystick.present_mask |= JOY_1_R_AXIS;
        if (pjc.wCaps & JOYCAPS_HASU)   joystick.present_mask |= JOY_1_U_AXIS;
        if (pjc.wCaps & JOYCAPS_HASV)   joystick.present_mask |= JOY_1_V_AXIS;