]> Shamusworld >> Repos - virtualjaguar/blobdiff - src/gui/gamepad.cpp
Fixes for fullscreen mode, initial stab at multiple controller configs
[virtualjaguar] / src / gui / gamepad.cpp
index 62a6d7a9bef851d932aba79f87c305fc3a2aa36b..8706e17643667499b39d8fe78caed6190898181a 100644 (file)
@@ -18,6 +18,7 @@
 // Class member initialization
 /*static*/ int Gamepad::numJoysticks = 0;
 /*static*/ SDL_Joystick * Gamepad::pad[8];
+/*static*/ const char * Gamepad::padName[8];
 /*static*/ int Gamepad::numButtons[8];
 /*static*/ int Gamepad::numHats[8];
 /*static*/ int Gamepad::numAxes[8];
@@ -50,6 +51,7 @@ void Gamepad::AllocateJoysticks(void)
        for(int i=0; i<numJoysticks; i++)
        {
                pad[i] = SDL_JoystickOpen(i);
+               padName[i] = SDL_JoystickName(i);
                numButtons[i] = numHats[i] = 0;
 
                if (pad[i])
@@ -71,6 +73,16 @@ void Gamepad::DeallocateJoysticks(void)
 }
 
 
+const char * Gamepad::GetJoystickName(int joystickID)
+{
+       // Sanity check
+       if (joystickID >= 8)
+               return NULL;
+
+       return padName[joystickID];
+}
+
+
 bool Gamepad::GetState(int joystickID, int buttonID)
 {
        uint8_t hatMask[8] = { 1, 2, 4, 8, 16, 32, 64, 128 };