]> Shamusworld >> Repos - virtualjaguar/commitdiff
Added logging to Gamepad::CheckButtonPressed().
authorShamus Hammons <jlhamm@acm.org>
Wed, 8 Oct 2014 20:32:43 +0000 (15:32 -0500)
committerShamus Hammons <jlhamm@acm.org>
Wed, 8 Oct 2014 20:32:43 +0000 (15:32 -0500)
docs/INSTALL
src/gui/gamepad.cpp
src/gui/gamepad.h
src/gui/profile.cpp

index 3709f0dd8c880047d1c69a2905c87025376072bf..c81b0a5d3f2041e74e16cae1c26189c6a7ef8bda 100644 (file)
@@ -13,7 +13,7 @@ The minimum requirements for compiling Virtual Jaguar from source are:
  o  zlib v1.2.5
  o  libcdio v0.90 or higher (optional, for Jaguar CD support)
  o  OpenGL libraries
- o  Qt 4.7.3 or higher
+ o  Qt 4.7.3 or higher (but not Qt 5!)
  o  supported OS (BeOS, Linux, FreeBSD and WIN32 through mingw, MacOS); other
     OSs may work to but you may need to change some items in the Makefile.
 
index b8ebdde5c21a8bf9827d906b2ac92508c2e0c3b2..4615c82e0880ac8fa1cbab06c75a6f1fd32fbfe6 100644 (file)
@@ -137,9 +137,10 @@ bool Gamepad::GetState(int joystickID, int buttonID)
 }
 
 
-//UNUSED
 int Gamepad::CheckButtonPressed(void)
 {
+       DumpJoystickStatesToLog();
+
        // This translates the hat direction to a mask index.
        int hatNum[16] = { -1, 0, 1, -1, 2, -1, -1, -1,
                3, -1, -1, -1, -1, -1, -1, -1 };
@@ -211,6 +212,83 @@ void Gamepad::Update(void)
 }
 
 
+void Gamepad::DumpJoystickStatesToLog(void)
+{
+       bool pressed = false;
+
+       for(int i=0; i<numJoysticks; i++)
+       {
+               for(int j=0; j<numButtons[i]; j++)
+               {
+                       if (button[i][j])
+                       {
+                               pressed = true;
+                               break;
+                               break;
+                       }
+               }
+
+               for(int j=0; j<numHats[i]; j++)
+               {
+                       if (hat[i][j])
+                       {
+                               pressed = true;
+                               break;
+                               break;
+                       }
+               }
+
+               for(int j=0; j<numAxes[i]; j++)
+               {
+                       // We encode these as axis # (in bits 1-15), up or down in bit 0.
+                       if (axis[i][j] > 32000)
+                       {
+                               pressed = true;
+                               break;
+                               break;
+                       }
+
+                       if (axis[i][j] < -32000)
+                       {
+                               pressed = true;
+                               break;
+                               break;
+                       }
+               }
+       }
+
+       if (!pressed)
+               return;
+
+       WriteLog("Gamepad: CheckButtonPressed...\n");
+
+       for(int i=0; i<numJoysticks; i++)
+       {
+               for(int j=0; j<numButtons[i]; j++)
+               {
+                       if (button[i][j])
+                               WriteLog("Gamepad: Pad #%i, button %i down...\n", i, j);
+               }
+
+               for(int j=0; j<numHats[i]; j++)
+               {
+                       if (hat[i][j])
+                               WriteLog("Gamepad: Pad #%i, hat %i pushed...\n", i, j);
+               }
+
+               for(int j=0; j<numAxes[i]; j++)
+               {
+                       // We encode these as axis # (in bits 1-15), up or down in bit 0.
+                       if (axis[i][j] > 32000)
+                               WriteLog("Gamepad: Pad #%i, axis %i pushed down...\n", i, j);
+
+                       if (axis[i][j] < -32000)
+                               WriteLog("Gamepad: Pad #%i, axis %i pushed up...\n", i, j);
+               }
+       }
+}
+
+
 // However, SDL 2 *does* support hot-plugging! :-D
 #if 0
 // Need to test this. It may be that the only time joysticks are detected is
index 73aaef8261554f3566df3f29b8b804efeeb07628..902dae128b2694ec888c83355a6ccd6948039046 100644 (file)
@@ -44,6 +44,7 @@ class Gamepad
                static int GetButtonID(void);
                static int GetJoystickID(void);
                static void Update(void);
+               static void DumpJoystickStatesToLog(void);
 
                // Support up to 8 gamepads
                static int numJoysticks;
index a4d8e57141661974025670a7b769047cadb1e54e..434d01d8ac0918d7d183cb96ab816a3fae99de94 100644 (file)
@@ -357,7 +357,7 @@ One more stab at this...
 */
 void AutoConnectProfiles(void)
 {
-       int foundProfiles[MAX_PROFILES];
+//     int foundProfiles[MAX_PROFILES];
        controller1Profile = -1;
        controller2Profile = -1;
        gamepadIDSlot1 = -1;