소스 검색

API Changes to Gamepad, Game and Platform for Gamepad API.
Regenerated Lua script bindings.

setaylor 13 년 전
부모
커밋
c0e67fd388

+ 2 - 2
gameplay/src/Game.cpp

@@ -564,8 +564,8 @@ void Game::triggerGamepadEvents()
 {
     for (std::vector<Gamepad*>::iterator itr = _gamepads->begin(); itr != _gamepads->end(); itr++)
     {
-        if ((*itr)->isAttached())
-            gamepadEvent(Gamepad::ATTACHED_EVENT, (*itr));
+        if ((*itr)->isConnected())
+            gamepadEvent(Gamepad::CONNECTED_EVENT, (*itr));
     }
 }
 

+ 5 - 5
gameplay/src/Game.h

@@ -352,8 +352,8 @@ public:
     inline bool isCursorVisible();
 
     /**
-     * Gamepad callback on gamepad events. Override to receive Gamepad::ATTACHED_EVENT 
-     * and Gamepad::DETACHED_EVENT.
+     * Gamepad callback on gamepad events. Override to receive Gamepad::CONNECTED_EVENT 
+     * and Gamepad::DISCONNECTED_EVENT.
      *
      * @param evt The gamepad event that occurred.
      * @param gamepad the gamepad the event occurred on
@@ -368,12 +368,12 @@ public:
     inline unsigned int getGamepadCount() const;
 
     /**
-     * Gets the number of gamepad's connected to the game.
+     * Gets the number of physical gamepad's attached/connected to the game.
      * Can be called to detects if any gamepads have been attached or detached.
      * 
      * @return The number of gamepads attached to the Platform.
      */
-    inline unsigned int getAttachedGamepads();
+    inline unsigned int getGamepadsConnected();
 
     /**
      * Gets the gamepad at the specified index.
@@ -572,7 +572,7 @@ private:
     unsigned int createGamepad(const char* id, unsigned int handle, unsigned int buttonCount, unsigned int joystickCount, unsigned int triggerCount);
 
     /**
-     * Triggers any Gamepad::ATTACHED_EVENTS after initialization.
+     * Triggers any Gamepad::CONNECTED_EVENTS after initialization.
      */
     void triggerGamepadEvents();
 

+ 4 - 14
gameplay/src/Game.inl

@@ -111,24 +111,14 @@ inline void Game::displayKeyboard(bool display)
     Platform::displayKeyboard(display);
 }
 
-inline unsigned int Game::getAttachedGamepads()
+inline unsigned int Game::getGamepadCount() const
 {
-    Platform::getGamepadCount();
-    unsigned int gamepadCount = 0;
-
-    for (std::vector<Gamepad*>::iterator itr = _gamepads->begin(); itr != _gamepads->end(); itr++)
-    {
-        Gamepad* gamepad = (*itr);
-        if (gamepad->isAttached())
-            gamepadCount++;
-    }
-    
-    return gamepadCount;
+    return _gamepads->size();
 }
 
-inline unsigned int Game::getGamepadCount() const
+inline unsigned int Game::getGamepadsConnected()
 {
-    return _gamepads->size();
+    return Platform::getGamepadsConnected();
 }
 
 inline Gamepad* Game::getGamepad(unsigned int index) const

+ 9 - 9
gameplay/src/Gamepad.cpp

@@ -101,7 +101,7 @@ void Gamepad::update(float elapsedTime)
     }
     else
     {
-        isAttached();
+        isConnected();
     }
 }
 
@@ -155,7 +155,7 @@ bool Gamepad::isJoystickActive(unsigned int joystickId) const
     }
 }
 
-void Gamepad::getJoystickValue(unsigned int joystickId, Vector2* outValue) const
+void Gamepad::getJoystickAxisValues(unsigned int joystickId, Vector2* outValue) const
 {
     GP_ASSERT(joystickId < _joystickCount);
 
@@ -173,18 +173,18 @@ void Gamepad::getJoystickValue(unsigned int joystickId, Vector2* outValue) const
     }
     else
     {
-        Platform::getGamepadJoystickValue(_handle, joystickId, outValue);
+        Platform::getGamepadJoystickAxisValues(_handle, joystickId, outValue);
     }
 }
 
-float Gamepad::getJoystickXAxis(unsigned int joystickId) const
+float Gamepad::getJoystickAxisX(unsigned int joystickId) const
 {
-    return Platform::getGamepadJoystickXAxis(_handle, joystickId);
+    return Platform::getGamepadJoystickAxisX(_handle, joystickId);
 }
 
-float Gamepad::getJoystickYAxis(unsigned int joystickId) const
+float Gamepad::getJoystickAxisY(unsigned int joystickId) const
 {
-    return Platform::getGamepadJoystickYAxis(_handle, joystickId);
+    return Platform::getGamepadJoystickAxisY(_handle, joystickId);
 }
 
 bool Gamepad::isVirtual() const
@@ -197,7 +197,7 @@ Form* Gamepad::getForm() const
     return _gamepadForm;
 }
 
-bool Gamepad::isAttached() const
+bool Gamepad::isConnected() const
 {
     if (_gamepadForm)
     {
@@ -205,7 +205,7 @@ bool Gamepad::isAttached() const
     }
     else
     {
-        return Platform::isGamepadAttached(_handle);
+        return Platform::isGamepadConnected(_handle);
     }
 }
 

+ 7 - 7
gameplay/src/Gamepad.h

@@ -24,8 +24,8 @@ public:
      */
     enum GamepadEvent
     {
-        ATTACHED_EVENT,
-        DETACHED_EVENT
+        CONNECTED_EVENT,
+        DISCONNECTED_EVENT
     };
 
     /**
@@ -78,9 +78,9 @@ public:
      * Returns the specified joystick's value as a Vector2.
      *
      * @param joystickId The index of the joystick to get the value for.
-     * @param outValue The current displacement of the joystick.
+     * @param outValue The current x-axis and y-asix value displacement of the joystick.
      */
-    void getJoystickValue(unsigned int joystickId, Vector2* outValue) const;
+    void getJoystickAxisValues(unsigned int joystickId, Vector2* outValues) const;
 
     /**
      * Returns the specified joystick's x-axis value.
@@ -88,7 +88,7 @@ public:
      * @param joystickId The index of the joystick to get the x-axis value for.
      * @return The current value of the joystick's x-axis value.
      */
-    float getJoystickXAxis(unsigned int joystickId) const;
+    float getJoystickAxisX(unsigned int joystickId) const;
     
     /**
      * Returns the specified joystick's y-axis value.
@@ -96,7 +96,7 @@ public:
      * @param joystickId The index of the joystick to get the y-axis value for.
      * @return The current value of the joystick's y-axis value.
      */
-    float getJoystickYAxis(unsigned int joystickId) const;
+    float getJoystickAxisY(unsigned int joystickId) const;
 
     /**
      * Returns whether the gamepad is currently represented with a UI form or not.
@@ -163,7 +163,7 @@ private:
     /**
      * Gets whether the Gamepad is currently connected to the Platform.
      */
-    bool isAttached() const;
+    bool isConnected() const;
         
     std::string _id;              // ID of the Gamepad
     unsigned int _handle;         // The handle of the Gamepad.

+ 6 - 6
gameplay/src/Platform.h

@@ -185,14 +185,14 @@ public:
      *
      * @return the number of gamepads connected to the Platform.
      */
-    static unsigned int getGamepadCount();
+    static unsigned int getGamepadsConnected();
 
     /**
-     * Gets whether the specified gamepad is attached to the Platform.
+     * Gets whether the specified gamepad is connected to the Platform.
      *
      * @param gamepadHandle the handle to the gamepad.
      */
-    static bool isGamepadAttached(unsigned int gamepadHandle);
+    static bool isGamepadConnected(unsigned int gamepadHandle);
 
     /**
      * Gets the specified gamepad's ID.
@@ -242,7 +242,7 @@ public:
      * @param joystickIndex The index of the joystick.
      * @return the value of the joystick's x-axis.
      */
-    static float getGamepadJoystickXAxis(unsigned int gamepadHandle, unsigned int joystickIndex);
+    static float getGamepadJoystickAxisX(unsigned int gamepadHandle, unsigned int joystickIndex);
 
     /**
      * Gets the value of the joystick's x-axis on the specified joystick.
@@ -251,7 +251,7 @@ public:
      * @param joystickIndex The index of the joystick.
      * @return the value of the joystick's x-axis.
      */
-    static float getGamepadJoystickYAxis(unsigned int gamepadHandle, unsigned int joystickIndex);
+    static float getGamepadJoystickAxisY(unsigned int gamepadHandle, unsigned int joystickIndex);
 
     /**
      * Gets the values for the specified gamepad and joystick index.
@@ -260,7 +260,7 @@ public:
      * @param joystickIndex the index to the joystick to retrieve the value for.
      * @param outValue will be populated with the current value of the specified joystick.
      */
-    static void getGamepadJoystickValue(unsigned int gamepadHandle, unsigned int joystickIndex, Vector2* value);
+    static void getGamepadJoystickAxisValues(unsigned int gamepadHandle, unsigned int joystickIndex, Vector2* outValue);
 
     /**
      * Gets the number of triggers on the specified gamepad.

+ 5 - 5
gameplay/src/PlatformAndroid.cpp

@@ -1000,12 +1000,12 @@ void Platform::sleep(long ms)
     usleep(ms * 1000);
 }
 
-unsigned int Platform::getGamepadCount()
+unsigned int Platform::getGamepadsConnected()
 {
     return 0;
 }
 
-bool Platform::isGamepadAttached(unsigned int gamepadHandle)
+bool Platform::isGamepadConnected(unsigned int gamepadHandle)
 {
     return false;
 }
@@ -1035,17 +1035,17 @@ bool Platform::isGamepadJoystickActive(unsigned int gamepadHandle, unsigned int
     return false;
 }
 
-float Platform::getGamepadJoystickXAxis(unsigned int gamepadHandle, unsigned int joystickIndex)
+float Platform::getGamepadJoystickAxisX(unsigned int gamepadHandle, unsigned int joystickIndex)
 {
     return 0.0f;
 }
 
-float Platform::getGamepadJoystickYAxis(unsigned int gamepadHandle, unsigned int joystickIndex)
+float Platform::getGamepadJoystickAxisX(unsigned int gamepadHandle, unsigned int joystickIndex)
 {
     return 0.0f;
 }
 
-void Platform::getGamepadJoystickValue(unsigned int gamepadHandle, unsigned int joystickIndex, Vector2* value)
+void Platform::getGamepadJoystickAxisValues(unsigned int gamepadHandle, unsigned int joystickIndex, Vector2* outValue)
 {
 
 }

+ 5 - 6
gameplay/src/PlatformMacOSX.mm

@@ -879,12 +879,12 @@ void Platform::sleep(long ms)
     usleep(ms * 1000);
 }
 
-unsigned int Platform::getGamepadCount()
+unsigned int Platform::getGamepadsConnected()
 {
     return 0;
 }
 
-bool Platform::isGamepadAttached(unsigned int gamepadHandle)
+bool Platform::isGamepadConnected(unsigned int gamepadHandle)
 {
     return false;
 }
@@ -914,19 +914,18 @@ bool Platform::isGamepadJoystickActive(unsigned int gamepadHandle, unsigned int
     return false;
 }
 
-float Platform::getGamepadJoystickXAxis(unsigned int gamepadHandle, unsigned int joystickIndex)
+float Platform::getGamepadJoystickAxisY(unsigned int gamepadHandle, unsigned int joystickIndex)
 {
     return 0.0f;
 }
 
-float Platform::getGamepadJoystickYAxis(unsigned int gamepadHandle, unsigned int joystickIndex)
+float Platform::getGamepadJoystickAxisY(unsigned int gamepadHandle, unsigned int joystickIndex)
 {
     return 0.0f;
 }
 
-void Platform::getGamepadJoystickValue(unsigned int gamepadHandle, unsigned int joystickIndex, Vector2* value)
+void Platform::getGamepadJoystickAxisValues(unsigned int gamepadHandle, unsigned int joystickIndex, Vector2* outValue)
 {
-
 }
 
 unsigned int Platform::getGamepadTriggerCount(unsigned int gamepadHandle)

+ 5 - 6
gameplay/src/PlatformQNX.cpp

@@ -1196,12 +1196,12 @@ void Platform::sleep(long ms)
     usleep(ms * 1000);
 }
 
-unsigned int Platform::getGamepadCount()
+unsigned int Platform::getGamepadsConnected()
 {
     return 0;
 }
 
-bool Platform::isGamepadAttached(unsigned int gamepadHandle)
+bool Platform::isGamepadConnected(unsigned int gamepadHandle)
 {
     return false;
 }
@@ -1231,19 +1231,18 @@ bool Platform::isGamepadJoystickActive(unsigned int gamepadHandle, unsigned int
     return false;
 }
 
-float Platform::getGamepadJoystickXAxis(unsigned int gamepadHandle, unsigned int joystickIndex)
+float Platform::getGamepadJoystickAxisX(unsigned int gamepadHandle, unsigned int joystickIndex)
 {
     return 0.0f;
 }
 
-float Platform::getGamepadJoystickYAxis(unsigned int gamepadHandle, unsigned int joystickIndex)
+float Platform::getGamepadJoystickAxisY(unsigned int gamepadHandle, unsigned int joystickIndex)
 {
     return 0.0f;
 }
 
-void Platform::getGamepadJoystickValue(unsigned int gamepadHandle, unsigned int joystickIndex, Vector2* value)
+void Platform::getGamepadJoystickAxisValues(unsigned int gamepadHandle, unsigned int joystickIndex, Vector2* outValues)
 {
-
 }
 
 unsigned int Platform::getGamepadTriggerCount(unsigned int gamepadHandle)

+ 75 - 76
gameplay/src/PlatformWin32.cpp

@@ -33,7 +33,6 @@ static HGLRC __hrc = 0;
 static bool __mouseCaptured = false;
 static POINT __mouseCapturePoint = { 0, 0 };
 static bool __cursorVisible = true;
-static unsigned int _gamepadCount = 0;
 
 #ifdef USE_XINPUT
 struct XInputGamepad
@@ -41,13 +40,14 @@ struct XInputGamepad
     static const unsigned int BUTTON_COUNT = 14;
     static const unsigned int JOYSTICK_COUNT = 2;
     static const unsigned int TRIGGER_COUNT = 2;
-    std::string _id;
-    int _handle;
-    bool _isConnected;
-    XINPUT_STATE _xState;
+    std::string id;
+    int handle;
+    bool connected;
+    XINPUT_STATE state;
 };
 
-static XInputGamepad* _xInputGamepads;
+static unsigned int __xinputGamepadsConnected = 0;
+static XInputGamepad* __xinputGamepads = NULL;
 
 static DWORD getXInputGamepadButtonMask(unsigned int buttonHandle)
 {
@@ -86,97 +86,97 @@ static DWORD getXInputGamepadButtonMask(unsigned int buttonHandle)
     }
 }
 
-static bool getXInputState(unsigned long xInputHandle)
+static bool getXInputState(unsigned long gamepadHandle)
 {
-    GP_ASSERT(0 <= xInputHandle && xInputHandle < XUSER_MAX_COUNT);
+    GP_ASSERT(0 <= gamepadHandle && gamepadHandle < XUSER_MAX_COUNT);
 
-    if (XInputGetState((DWORD)xInputHandle, &_xInputGamepads[xInputHandle]._xState) == ERROR_SUCCESS)
-        return (_xInputGamepads[xInputHandle]._isConnected = true);
+    if (XInputGetState((DWORD)gamepadHandle, &__xinputGamepads[gamepadHandle].state) == ERROR_SUCCESS)
+        return (__xinputGamepads[gamepadHandle].connected = true);
     else
-        return (_xInputGamepads[xInputHandle]._isConnected = false);
+        return (__xinputGamepads[gamepadHandle].connected = false);
 }
 
-static bool getXInputButtonState(unsigned long xInputHandle, unsigned long buttonHandle)
+static bool getXInputButtonState(unsigned long gamepadHandle, unsigned long buttonHandle)
 {
-    GP_ASSERT(0 <= xInputHandle && xInputHandle < XUSER_MAX_COUNT);
+    GP_ASSERT(0 <= gamepadHandle && gamepadHandle < XUSER_MAX_COUNT);
     GP_ASSERT(0 <= buttonHandle && buttonHandle < 14);
     
     WORD buttonMask = getXInputGamepadButtonMask(buttonHandle); // Conversion to button mask.
 
-    if ((_xInputGamepads[xInputHandle]._xState.Gamepad.wButtons & buttonMask) == buttonMask)
+    if ((__xinputGamepads[gamepadHandle].state.Gamepad.wButtons & buttonMask) == buttonMask)
         return true;
     else
         return false;
 }
 
-static int sign(int value)
-{
-    if (value < 0)
-        return -1;
-    else if (value > 0)
-        return 1;
-    else
-        return 0;
-}
-
 static float normalizeXInputJoystickAxis(int axisValue, int deadZone)
 {
     int absAxisValue = abs(axisValue);
 
     if (absAxisValue < deadZone)
+    {
         return 0.0f;
+    }
     else
-        return sign(axisValue) * (absAxisValue - deadZone) / (float)(32768 - deadZone);
+    {
+        int value = axisValue;
+        if (value < 0)
+            value = -1;
+        else if (value > 0)
+            value = 1;
+        else
+            value = 0;
+        return value * (absAxisValue - deadZone) / (float)(32768 - deadZone);
+    }
 }
 
-static float getXInputJoystickXAxis(unsigned long xInputHandle, unsigned long joystickHandle)
+static float getXInputJoystickAxisX(unsigned long gamepadHandle, unsigned long joystickHandle)
 {
-    GP_ASSERT(0 <= xInputHandle && xInputHandle < XUSER_MAX_COUNT);
+    GP_ASSERT(0 <= gamepadHandle && gamepadHandle < XUSER_MAX_COUNT);
     GP_ASSERT(0 <= joystickHandle && joystickHandle < 2);
     
     switch(joystickHandle)
     {
     case 0:
-        return normalizeXInputJoystickAxis(_xInputGamepads[xInputHandle]._xState.Gamepad.sThumbLX, XINPUT_GAMEPAD_LEFT_THUMB_DEADZONE);
+        return normalizeXInputJoystickAxis(__xinputGamepads[gamepadHandle].state.Gamepad.sThumbLX, XINPUT_GAMEPAD_LEFT_THUMB_DEADZONE);
     case 1:
-        return normalizeXInputJoystickAxis(_xInputGamepads[xInputHandle]._xState.Gamepad.sThumbRX, XINPUT_GAMEPAD_RIGHT_THUMB_DEADZONE);
+        return normalizeXInputJoystickAxis(__xinputGamepads[gamepadHandle].state.Gamepad.sThumbRX, XINPUT_GAMEPAD_RIGHT_THUMB_DEADZONE);
     default: return 0.0f;
     }
 }
 
-static float getXInputJoystickYAxis(unsigned long xInputHandle, unsigned long joystickHandle)
+static float getXInputJoystickAxisY(unsigned long gamepadHandle, unsigned long joystickHandle)
 {
-    GP_ASSERT(0 <= xInputHandle && xInputHandle < XUSER_MAX_COUNT);
+    GP_ASSERT(0 <= gamepadHandle && gamepadHandle < XUSER_MAX_COUNT);
     GP_ASSERT(0 <= joystickHandle && joystickHandle < 2);
 
     switch(joystickHandle)
     {
     case 0:
-        return normalizeXInputJoystickAxis(_xInputGamepads[xInputHandle]._xState.Gamepad.sThumbLY, XINPUT_GAMEPAD_LEFT_THUMB_DEADZONE);
+        return normalizeXInputJoystickAxis(__xinputGamepads[gamepadHandle].state.Gamepad.sThumbLY, XINPUT_GAMEPAD_LEFT_THUMB_DEADZONE);
     case 1:
-        return normalizeXInputJoystickAxis(_xInputGamepads[xInputHandle]._xState.Gamepad.sThumbRY, XINPUT_GAMEPAD_RIGHT_THUMB_DEADZONE);
+        return normalizeXInputJoystickAxis(__xinputGamepads[gamepadHandle].state.Gamepad.sThumbRY, XINPUT_GAMEPAD_RIGHT_THUMB_DEADZONE);
     default: return 0.0f;
     }
 }
 
-static void getXInputJoystickValue(unsigned long xInputHandle, unsigned long joystickHandle, gameplay::Vector2* value)
+static void getXInputJoystickAxisValues(unsigned long gamepadHandle, unsigned long joystickHandle, gameplay::Vector2* outValue)
 {
-    GP_ASSERT(0 <= xInputHandle && xInputHandle < XUSER_MAX_COUNT);
+    GP_ASSERT(0 <= gamepadHandle && gamepadHandle < XUSER_MAX_COUNT);
     GP_ASSERT(0 <= joystickHandle && joystickHandle < 2);
 
     switch(joystickHandle)
     {
     case 0:
-        value->x = normalizeXInputJoystickAxis(_xInputGamepads[xInputHandle]._xState.Gamepad.sThumbLX, XINPUT_GAMEPAD_LEFT_THUMB_DEADZONE);
-        value->y = normalizeXInputJoystickAxis(_xInputGamepads[xInputHandle]._xState.Gamepad.sThumbLY, XINPUT_GAMEPAD_LEFT_THUMB_DEADZONE);
+        outValue->x = normalizeXInputJoystickAxis(__xinputGamepads[gamepadHandle].state.Gamepad.sThumbLX, XINPUT_GAMEPAD_LEFT_THUMB_DEADZONE);
+        outValue->y = normalizeXInputJoystickAxis(__xinputGamepads[gamepadHandle].state.Gamepad.sThumbLY, XINPUT_GAMEPAD_LEFT_THUMB_DEADZONE);
         break;
     case 1:
-        value->x = normalizeXInputJoystickAxis(_xInputGamepads[xInputHandle]._xState.Gamepad.sThumbRX, XINPUT_GAMEPAD_RIGHT_THUMB_DEADZONE);
-        value->y = normalizeXInputJoystickAxis(_xInputGamepads[xInputHandle]._xState.Gamepad.sThumbRY, XINPUT_GAMEPAD_RIGHT_THUMB_DEADZONE);
+        outValue->x = normalizeXInputJoystickAxis(__xinputGamepads[gamepadHandle].state.Gamepad.sThumbRX, XINPUT_GAMEPAD_RIGHT_THUMB_DEADZONE);
+        outValue->y = normalizeXInputJoystickAxis(__xinputGamepads[gamepadHandle].state.Gamepad.sThumbRY, XINPUT_GAMEPAD_RIGHT_THUMB_DEADZONE);
         break;
     }
 }
-
 #endif
 
 static gameplay::Keyboard::Key getKey(WPARAM win32KeyCode, bool shiftDown)
@@ -622,7 +622,7 @@ Platform::~Platform()
         __hwnd = 0;
     }
 #ifdef USE_XINPUT
-    SAFE_DELETE_ARRAY(_xInputGamepads);
+    SAFE_DELETE_ARRAY(__xinputGamepads);
 #endif
 }
 
@@ -815,26 +815,26 @@ Platform* Platform::create(Game* game, void* attachToWindow)
 
 #ifdef USE_XINPUT
     // Initialize XInputGamepads.
-    _xInputGamepads = new XInputGamepad[XUSER_MAX_COUNT];
+    __xinputGamepads = new XInputGamepad[XUSER_MAX_COUNT];
     for (unsigned int i = 0; i < XUSER_MAX_COUNT; i++)
     {
         switch(i)
         {
         case 0:
-            _xInputGamepads[i]._id = "XINPUT 1";
+            __xinputGamepads[i].id = "XINPUT 1";
             break;
         case 1:
-            _xInputGamepads[i]._id = "XINPUT 2";
+            __xinputGamepads[i].id = "XINPUT 2";
             break;
         case 2:
-            _xInputGamepads[i]._id = "XINPUT 3";
+            __xinputGamepads[i].id = "XINPUT 3";
             break;
         case 3:
-            _xInputGamepads[i]._id = "XINPUT 4";
+            __xinputGamepads[i].id = "XINPUT 4";
             break;
         }
-        _xInputGamepads[i]._isConnected = false;
-        _xInputGamepads[i]._handle = -1;
+        __xinputGamepads[i].connected = false;
+        __xinputGamepads[i].handle = -1;
     }
 #endif
 
@@ -1019,23 +1019,22 @@ void Platform::displayKeyboard(bool display)
     // Do nothing.
 }
 
-unsigned int Platform::getGamepadCount()
+unsigned int Platform::getGamepadsConnected()
 {
-    // Check to see what gamepads are connected.
-    // Check xbox 360 controllers
-    _gamepadCount = 0;
+    // Check to see what xbox360 gamepads are connected.
+    __xinputGamepadsConnected = 0;
 
 #ifdef USE_XINPUT
     for (unsigned int i = 0; i < XUSER_MAX_COUNT; i++)
     {
-        if (isGamepadAttached(i))
-            _gamepadCount++;
+        if (isGamepadConnected(i))
+            __xinputGamepadsConnected++;
     }    
 #endif
-    return _gamepadCount;
+    return __xinputGamepadsConnected;
 }
 
-bool Platform::isGamepadAttached(unsigned int gamepadHandle)
+bool Platform::isGamepadConnected(unsigned int gamepadHandle)
 {
 
 #ifdef USE_XINPUT
@@ -1044,21 +1043,21 @@ bool Platform::isGamepadAttached(unsigned int gamepadHandle)
     Game* game = Game::getInstance();
     GP_ASSERT(game);
 
-    if (_xInputGamepads[gamepadHandle]._handle == -1)
-        _xInputGamepads[gamepadHandle]._handle = game->createGamepad(_xInputGamepads[gamepadHandle]._id.c_str(), gamepadHandle, _xInputGamepads[gamepadHandle].BUTTON_COUNT, 
-            _xInputGamepads[gamepadHandle].JOYSTICK_COUNT, _xInputGamepads[gamepadHandle].TRIGGER_COUNT);
+    if (__xinputGamepads[gamepadHandle].handle == -1)
+        __xinputGamepads[gamepadHandle].handle = game->createGamepad(__xinputGamepads[gamepadHandle].id.c_str(), gamepadHandle, __xinputGamepads[gamepadHandle].BUTTON_COUNT, 
+            __xinputGamepads[gamepadHandle].JOYSTICK_COUNT, __xinputGamepads[gamepadHandle].TRIGGER_COUNT);
 
-    bool isConnected = _xInputGamepads[gamepadHandle]._isConnected;
+    bool isConnected = __xinputGamepads[gamepadHandle].connected;
     if (getXInputState(gamepadHandle))
     {
         if (!isConnected)
         {
-            _xInputGamepads[gamepadHandle]._isConnected = true;
+            __xinputGamepads[gamepadHandle].connected = true;
             
-            Gamepad* gamepad = game->getGamepad(_xInputGamepads[gamepadHandle]._handle);
+            Gamepad* gamepad = game->getGamepad(__xinputGamepads[gamepadHandle].handle);
             GP_ASSERT(gamepad);
             if (game->isInitialized())
-                game->gamepadEvent(Gamepad::ATTACHED_EVENT, game->getGamepad(_xInputGamepads[gamepadHandle]._handle)); 
+                game->gamepadEvent(Gamepad::CONNECTED_EVENT, game->getGamepad(__xinputGamepads[gamepadHandle].handle)); 
         }
         return true;
     }
@@ -1067,12 +1066,12 @@ bool Platform::isGamepadAttached(unsigned int gamepadHandle)
         if (isConnected)
         {
             // if it was connected, but now isn't pass the detached event to gamepadEvent()
-            _xInputGamepads[gamepadHandle]._isConnected = false;
+            __xinputGamepads[gamepadHandle].connected = false;
             
-            Gamepad* gamepad = game->getGamepad(_xInputGamepads[gamepadHandle]._handle);
+            Gamepad* gamepad = game->getGamepad(__xinputGamepads[gamepadHandle].handle);
             GP_ASSERT(gamepad);
             if (game->isInitialized())
-                game->gamepadEvent(Gamepad::DETACHED_EVENT, game->getGamepad(_xInputGamepads[gamepadHandle]._handle));
+                game->gamepadEvent(Gamepad::DISCONNECTED_EVENT, game->getGamepad(__xinputGamepads[gamepadHandle].handle));
         }
         return false;
     }
@@ -1088,7 +1087,7 @@ const char* Platform::getGamepadId(unsigned int gamepadHandle)
     GP_ASSERT(0 <= gamepadHandle);
     GP_ASSERT(gamepadHandle < XUSER_MAX_COUNT);
 
-    return _xInputGamepads[gamepadHandle]._id.c_str();
+    return __xinputGamepads[gamepadHandle].id.c_str();
 #endif
     return NULL;
 }
@@ -1099,7 +1098,7 @@ unsigned int Platform::getGamepadButtonCount(unsigned int gamepadHandle)
 #ifdef USE_XINPUT
     GP_ASSERT(0 <= gamepadHandle);
     GP_ASSERT(gamepadHandle < XUSER_MAX_COUNT);
-    if (!_xInputGamepads[gamepadHandle]._isConnected)
+    if (!__xinputGamepads[gamepadHandle].connected)
         return 0;
 
     return XInputGamepad::BUTTON_COUNT;
@@ -1127,7 +1126,7 @@ unsigned int Platform::getGamepadJoystickCount(unsigned int gamepadHandle)
     GP_ASSERT(0 <= gamepadHandle);
     GP_ASSERT(gamepadHandle < XUSER_MAX_COUNT);
 
-    if (!_xInputGamepads[gamepadHandle]._isConnected)
+    if (!__xinputGamepads[gamepadHandle].connected)
         return 0;
 
     return XInputGamepad::JOYSTICK_COUNT;
@@ -1136,40 +1135,40 @@ unsigned int Platform::getGamepadJoystickCount(unsigned int gamepadHandle)
     return 0;
 }
 
-float Platform::getGamepadJoystickXAxis(unsigned int gamepadHandle, unsigned int joystickIndex)
+float Platform::getGamepadJoystickAxisX(unsigned int gamepadHandle, unsigned int joystickIndex)
 {
     
 #ifdef USE_XINPUT
     GP_ASSERT(0 <= gamepadHandle);
     GP_ASSERT(gamepadHandle < XUSER_MAX_COUNT);
 
-    return getXInputJoystickXAxis(gamepadHandle, joystickIndex);
+    return getXInputJoystickAxisX(gamepadHandle, joystickIndex);
 #endif 
 
     return 0.0f;
 }
 
-float Platform::getGamepadJoystickYAxis(unsigned int gamepadHandle, unsigned int joystickIndex)
+float Platform::getGamepadJoystickAxisY(unsigned int gamepadHandle, unsigned int joystickIndex)
 {
 
 #ifdef USE_XINPUT
     GP_ASSERT(0 <= gamepadHandle);
     GP_ASSERT(gamepadHandle < XUSER_MAX_COUNT);
 
-    return getXInputJoystickYAxis(gamepadHandle, joystickIndex);
+    return getXInputJoystickAxisY(gamepadHandle, joystickIndex);
 #endif
 
     return 0.0f;
 }
 
-void Platform::getGamepadJoystickValue(unsigned int gamepadHandle, unsigned int joystickIndex, Vector2* value)
+void Platform::getGamepadJoystickAxisValues(unsigned int gamepadHandle, unsigned int joystickIndex, Vector2* outValue)
 {
     
 #ifdef USE_XINPUT
     GP_ASSERT(0 <= gamepadHandle);
     GP_ASSERT(gamepadHandle < XUSER_MAX_COUNT);
 
-    getXInputJoystickValue(gamepadHandle, joystickIndex, value);
+    getXInputJoystickAxisValues(gamepadHandle, joystickIndex, outValue);
 #endif
 
 }
@@ -1181,7 +1180,7 @@ bool Platform::isGamepadJoystickActive(unsigned int gamepadHandle, unsigned int
     GP_ASSERT(0 <= gamepadHandle);
     GP_ASSERT(gamepadHandle < XUSER_MAX_COUNT);
 
-    return (getXInputJoystickXAxis(gamepadHandle, joystickIndex) != 0.0f || getXInputJoystickYAxis(gamepadHandle, joystickIndex) != 0.0f);
+    return (getXInputJoystickAxisX(gamepadHandle, joystickIndex) != 0.0f || getXInputJoystickAxisY(gamepadHandle, joystickIndex) != 0.0f);
 #endif 
 
     return false;

+ 5 - 6
gameplay/src/PlatformiOS.mm

@@ -989,12 +989,12 @@ void Platform::sleep(long ms)
     usleep(ms * 1000);
 }
 
-unsigned int Platform::getGamepadCount()
+unsigned int Platform::getGamepadsConnected()
 {
     return 0;
 }
 
-bool Platform::isGamepadAttached(unsigned int gamepadHandle)
+bool Platform::isGamepadConnected(unsigned int gamepadHandle)
 {
     return false;
 }
@@ -1024,19 +1024,18 @@ bool Platform::isGamepadJoystickActive(unsigned int gamepadHandle, unsigned int
     return false;
 }
 
-float Platform::getGamepadJoystickXAxis(unsigned int gamepadHandle, unsigned int joystickIndex)
+float Platform::getGamepadJoystickAxisY(unsigned int gamepadHandle, unsigned int joystickIndex)
 {
     return 0.0f;
 }
 
-float Platform::getGamepadJoystickYAxis(unsigned int gamepadHandle, unsigned int joystickIndex)
+float Platform::getGamepadJoystickAxisY(unsigned int gamepadHandle, unsigned int joystickIndex)
 {
     return 0.0f;
 }
 
-void Platform::getGamepadJoystickValue(unsigned int gamepadHandle, unsigned int joystickIndex, Vector2* value)
+void Platform::getGamepadJoystickAxisValues(unsigned int gamepadHandle, unsigned int joystickIndex, Vector2* outValue)
 {
-
 }
 
 unsigned int Platform::getGamepadTriggerCount(unsigned int gamepadHandle)

+ 38 - 38
gameplay/src/lua/lua_Game.cpp

@@ -30,13 +30,13 @@ void luaRegister_Game()
         {"getAIController", lua_Game_getAIController},
         {"getAccelerometerValues", lua_Game_getAccelerometerValues},
         {"getAnimationController", lua_Game_getAnimationController},
-        {"getAttachedGamepads", lua_Game_getAttachedGamepads},
         {"getAudioController", lua_Game_getAudioController},
         {"getAudioListener", lua_Game_getAudioListener},
         {"getConfig", lua_Game_getConfig},
         {"getFrameRate", lua_Game_getFrameRate},
         {"getGamepad", lua_Game_getGamepad},
         {"getGamepadCount", lua_Game_getGamepadCount},
+        {"getGamepadsConnected", lua_Game_getGamepadsConnected},
         {"getHeight", lua_Game_getHeight},
         {"getPhysicsController", lua_Game_getPhysicsController},
         {"getScriptController", lua_Game_getScriptController},
@@ -499,43 +499,6 @@ int lua_Game_getAnimationController(lua_State* state)
     return 0;
 }
 
-int lua_Game_getAttachedGamepads(lua_State* state)
-{
-    // Get the number of parameters.
-    int paramCount = lua_gettop(state);
-
-    // Attempt to match the parameters to a valid binding.
-    switch (paramCount)
-    {
-        case 1:
-        {
-            if ((lua_type(state, 1) == LUA_TUSERDATA))
-            {
-                Game* instance = getInstance(state);
-                unsigned int result = instance->getAttachedGamepads();
-
-                // Push the return value onto the stack.
-                lua_pushunsigned(state, result);
-
-                return 1;
-            }
-            else
-            {
-                lua_pushstring(state, "lua_Game_getAttachedGamepads - Failed to match the given parameters to a valid function signature.");
-                lua_error(state);
-            }
-            break;
-        }
-        default:
-        {
-            lua_pushstring(state, "Invalid number of parameters (expected 1).");
-            lua_error(state);
-            break;
-        }
-    }
-    return 0;
-}
-
 int lua_Game_getAudioController(lua_State* state)
 {
     // Get the number of parameters.
@@ -798,6 +761,43 @@ int lua_Game_getGamepadCount(lua_State* state)
     return 0;
 }
 
+int lua_Game_getGamepadsConnected(lua_State* state)
+{
+    // Get the number of parameters.
+    int paramCount = lua_gettop(state);
+
+    // Attempt to match the parameters to a valid binding.
+    switch (paramCount)
+    {
+        case 1:
+        {
+            if ((lua_type(state, 1) == LUA_TUSERDATA))
+            {
+                Game* instance = getInstance(state);
+                unsigned int result = instance->getGamepadsConnected();
+
+                // Push the return value onto the stack.
+                lua_pushunsigned(state, result);
+
+                return 1;
+            }
+            else
+            {
+                lua_pushstring(state, "lua_Game_getGamepadsConnected - Failed to match the given parameters to a valid function signature.");
+                lua_error(state);
+            }
+            break;
+        }
+        default:
+        {
+            lua_pushstring(state, "Invalid number of parameters (expected 1).");
+            lua_error(state);
+            break;
+        }
+    }
+    return 0;
+}
+
 int lua_Game_getHeight(lua_State* state)
 {
     // Get the number of parameters.

+ 1 - 1
gameplay/src/lua/lua_Game.h

@@ -14,13 +14,13 @@ int lua_Game_gamepadEvent(lua_State* state);
 int lua_Game_getAIController(lua_State* state);
 int lua_Game_getAccelerometerValues(lua_State* state);
 int lua_Game_getAnimationController(lua_State* state);
-int lua_Game_getAttachedGamepads(lua_State* state);
 int lua_Game_getAudioController(lua_State* state);
 int lua_Game_getAudioListener(lua_State* state);
 int lua_Game_getConfig(lua_State* state);
 int lua_Game_getFrameRate(lua_State* state);
 int lua_Game_getGamepad(lua_State* state);
 int lua_Game_getGamepadCount(lua_State* state);
+int lua_Game_getGamepadsConnected(lua_State* state);
 int lua_Game_getHeight(lua_State* state);
 int lua_Game_getPhysicsController(lua_State* state);
 int lua_Game_getScriptController(lua_State* state);

+ 39 - 39
gameplay/src/lua/lua_Gamepad.cpp

@@ -18,10 +18,10 @@ void luaRegister_Gamepad()
         {"getButtonState", lua_Gamepad_getButtonState},
         {"getForm", lua_Gamepad_getForm},
         {"getId", lua_Gamepad_getId},
+        {"getJoystickAxisValues", lua_Gamepad_getJoystickAxisValues},
+        {"getJoystickAxisX", lua_Gamepad_getJoystickAxisX},
+        {"getJoystickAxisY", lua_Gamepad_getJoystickAxisY},
         {"getJoystickCount", lua_Gamepad_getJoystickCount},
-        {"getJoystickValue", lua_Gamepad_getJoystickValue},
-        {"getJoystickXAxis", lua_Gamepad_getJoystickXAxis},
-        {"getJoystickYAxis", lua_Gamepad_getJoystickYAxis},
         {"isJoystickActive", lua_Gamepad_isJoystickActive},
         {"isVirtual", lua_Gamepad_isVirtual},
         {"update", lua_Gamepad_update},
@@ -235,7 +235,7 @@ int lua_Gamepad_getId(lua_State* state)
     return 0;
 }
 
-int lua_Gamepad_getJoystickCount(lua_State* state)
+int lua_Gamepad_getJoystickAxisValues(lua_State* state)
 {
     // Get the number of parameters.
     int paramCount = lua_gettop(state);
@@ -243,28 +243,33 @@ int lua_Gamepad_getJoystickCount(lua_State* state)
     // Attempt to match the parameters to a valid binding.
     switch (paramCount)
     {
-        case 1:
+        case 3:
         {
-            if ((lua_type(state, 1) == LUA_TUSERDATA))
+            if ((lua_type(state, 1) == LUA_TUSERDATA) &&
+                lua_type(state, 2) == LUA_TNUMBER &&
+                (lua_type(state, 3) == LUA_TUSERDATA || lua_type(state, 3) == LUA_TTABLE || lua_type(state, 3) == LUA_TNIL))
             {
-                Gamepad* instance = getInstance(state);
-                unsigned int result = instance->getJoystickCount();
+                // Get parameter 1 off the stack.
+                unsigned int param1 = (unsigned int)luaL_checkunsigned(state, 2);
 
-                // Push the return value onto the stack.
-                lua_pushunsigned(state, result);
+                // Get parameter 2 off the stack.
+                Vector2* param2 = ScriptUtil::getObjectPointer<Vector2>(3, "Vector2", false);
 
-                return 1;
+                Gamepad* instance = getInstance(state);
+                instance->getJoystickAxisValues(param1, param2);
+                
+                return 0;
             }
             else
             {
-                lua_pushstring(state, "lua_Gamepad_getJoystickCount - Failed to match the given parameters to a valid function signature.");
+                lua_pushstring(state, "lua_Gamepad_getJoystickAxisValues - Failed to match the given parameters to a valid function signature.");
                 lua_error(state);
             }
             break;
         }
         default:
         {
-            lua_pushstring(state, "Invalid number of parameters (expected 1).");
+            lua_pushstring(state, "Invalid number of parameters (expected 3).");
             lua_error(state);
             break;
         }
@@ -272,7 +277,7 @@ int lua_Gamepad_getJoystickCount(lua_State* state)
     return 0;
 }
 
-int lua_Gamepad_getJoystickValue(lua_State* state)
+int lua_Gamepad_getJoystickAxisX(lua_State* state)
 {
     // Get the number of parameters.
     int paramCount = lua_gettop(state);
@@ -280,33 +285,32 @@ int lua_Gamepad_getJoystickValue(lua_State* state)
     // Attempt to match the parameters to a valid binding.
     switch (paramCount)
     {
-        case 3:
+        case 2:
         {
             if ((lua_type(state, 1) == LUA_TUSERDATA) &&
-                lua_type(state, 2) == LUA_TNUMBER &&
-                (lua_type(state, 3) == LUA_TUSERDATA || lua_type(state, 3) == LUA_TTABLE || lua_type(state, 3) == LUA_TNIL))
+                lua_type(state, 2) == LUA_TNUMBER)
             {
                 // Get parameter 1 off the stack.
                 unsigned int param1 = (unsigned int)luaL_checkunsigned(state, 2);
 
-                // Get parameter 2 off the stack.
-                Vector2* param2 = ScriptUtil::getObjectPointer<Vector2>(3, "Vector2", false);
-
                 Gamepad* instance = getInstance(state);
-                instance->getJoystickValue(param1, param2);
-                
-                return 0;
+                float result = instance->getJoystickAxisX(param1);
+
+                // Push the return value onto the stack.
+                lua_pushnumber(state, result);
+
+                return 1;
             }
             else
             {
-                lua_pushstring(state, "lua_Gamepad_getJoystickValue - Failed to match the given parameters to a valid function signature.");
+                lua_pushstring(state, "lua_Gamepad_getJoystickAxisX - Failed to match the given parameters to a valid function signature.");
                 lua_error(state);
             }
             break;
         }
         default:
         {
-            lua_pushstring(state, "Invalid number of parameters (expected 3).");
+            lua_pushstring(state, "Invalid number of parameters (expected 2).");
             lua_error(state);
             break;
         }
@@ -314,7 +318,7 @@ int lua_Gamepad_getJoystickValue(lua_State* state)
     return 0;
 }
 
-int lua_Gamepad_getJoystickXAxis(lua_State* state)
+int lua_Gamepad_getJoystickAxisY(lua_State* state)
 {
     // Get the number of parameters.
     int paramCount = lua_gettop(state);
@@ -331,7 +335,7 @@ int lua_Gamepad_getJoystickXAxis(lua_State* state)
                 unsigned int param1 = (unsigned int)luaL_checkunsigned(state, 2);
 
                 Gamepad* instance = getInstance(state);
-                float result = instance->getJoystickXAxis(param1);
+                float result = instance->getJoystickAxisY(param1);
 
                 // Push the return value onto the stack.
                 lua_pushnumber(state, result);
@@ -340,7 +344,7 @@ int lua_Gamepad_getJoystickXAxis(lua_State* state)
             }
             else
             {
-                lua_pushstring(state, "lua_Gamepad_getJoystickXAxis - Failed to match the given parameters to a valid function signature.");
+                lua_pushstring(state, "lua_Gamepad_getJoystickAxisY - Failed to match the given parameters to a valid function signature.");
                 lua_error(state);
             }
             break;
@@ -355,7 +359,7 @@ int lua_Gamepad_getJoystickXAxis(lua_State* state)
     return 0;
 }
 
-int lua_Gamepad_getJoystickYAxis(lua_State* state)
+int lua_Gamepad_getJoystickCount(lua_State* state)
 {
     // Get the number of parameters.
     int paramCount = lua_gettop(state);
@@ -363,32 +367,28 @@ int lua_Gamepad_getJoystickYAxis(lua_State* state)
     // Attempt to match the parameters to a valid binding.
     switch (paramCount)
     {
-        case 2:
+        case 1:
         {
-            if ((lua_type(state, 1) == LUA_TUSERDATA) &&
-                lua_type(state, 2) == LUA_TNUMBER)
+            if ((lua_type(state, 1) == LUA_TUSERDATA))
             {
-                // Get parameter 1 off the stack.
-                unsigned int param1 = (unsigned int)luaL_checkunsigned(state, 2);
-
                 Gamepad* instance = getInstance(state);
-                float result = instance->getJoystickYAxis(param1);
+                unsigned int result = instance->getJoystickCount();
 
                 // Push the return value onto the stack.
-                lua_pushnumber(state, result);
+                lua_pushunsigned(state, result);
 
                 return 1;
             }
             else
             {
-                lua_pushstring(state, "lua_Gamepad_getJoystickYAxis - Failed to match the given parameters to a valid function signature.");
+                lua_pushstring(state, "lua_Gamepad_getJoystickCount - Failed to match the given parameters to a valid function signature.");
                 lua_error(state);
             }
             break;
         }
         default:
         {
-            lua_pushstring(state, "Invalid number of parameters (expected 2).");
+            lua_pushstring(state, "Invalid number of parameters (expected 1).");
             lua_error(state);
             break;
         }

+ 3 - 3
gameplay/src/lua/lua_Gamepad.h

@@ -10,10 +10,10 @@ int lua_Gamepad_getButtonCount(lua_State* state);
 int lua_Gamepad_getButtonState(lua_State* state);
 int lua_Gamepad_getForm(lua_State* state);
 int lua_Gamepad_getId(lua_State* state);
+int lua_Gamepad_getJoystickAxisValues(lua_State* state);
+int lua_Gamepad_getJoystickAxisX(lua_State* state);
+int lua_Gamepad_getJoystickAxisY(lua_State* state);
 int lua_Gamepad_getJoystickCount(lua_State* state);
-int lua_Gamepad_getJoystickValue(lua_State* state);
-int lua_Gamepad_getJoystickXAxis(lua_State* state);
-int lua_Gamepad_getJoystickYAxis(lua_State* state);
 int lua_Gamepad_isJoystickActive(lua_State* state);
 int lua_Gamepad_isVirtual(lua_State* state);
 int lua_Gamepad_update(lua_State* state);

+ 11 - 11
gameplay/src/lua/lua_GamepadGamepadEvent.cpp

@@ -6,25 +6,25 @@ namespace gameplay
 
 static const char* enumStringEmpty = "";
 
-static const char* luaEnumString_GamepadGamepadEvent_ATTACHED_EVENT = "ATTACHED_EVENT";
-static const char* luaEnumString_GamepadGamepadEvent_DETACHED_EVENT = "DETACHED_EVENT";
+static const char* luaEnumString_GamepadGamepadEvent_CONNECTED_EVENT = "CONNECTED_EVENT";
+static const char* luaEnumString_GamepadGamepadEvent_DISCONNECTED_EVENT = "DISCONNECTED_EVENT";
 
 Gamepad::GamepadEvent lua_enumFromString_GamepadGamepadEvent(const char* s)
 {
-    if (strcmp(s, luaEnumString_GamepadGamepadEvent_ATTACHED_EVENT) == 0)
-        return Gamepad::ATTACHED_EVENT;
-    if (strcmp(s, luaEnumString_GamepadGamepadEvent_DETACHED_EVENT) == 0)
-        return Gamepad::DETACHED_EVENT;
+    if (strcmp(s, luaEnumString_GamepadGamepadEvent_CONNECTED_EVENT) == 0)
+        return Gamepad::CONNECTED_EVENT;
+    if (strcmp(s, luaEnumString_GamepadGamepadEvent_DISCONNECTED_EVENT) == 0)
+        return Gamepad::DISCONNECTED_EVENT;
     GP_ERROR("Invalid enumeration value '%s' for enumeration Gamepad::GamepadEvent.", s);
-    return Gamepad::ATTACHED_EVENT;
+    return Gamepad::CONNECTED_EVENT;
 }
 
 const char* lua_stringFromEnum_GamepadGamepadEvent(Gamepad::GamepadEvent e)
 {
-    if (e == Gamepad::ATTACHED_EVENT)
-        return luaEnumString_GamepadGamepadEvent_ATTACHED_EVENT;
-    if (e == Gamepad::DETACHED_EVENT)
-        return luaEnumString_GamepadGamepadEvent_DETACHED_EVENT;
+    if (e == Gamepad::CONNECTED_EVENT)
+        return luaEnumString_GamepadGamepadEvent_CONNECTED_EVENT;
+    if (e == Gamepad::DISCONNECTED_EVENT)
+        return luaEnumString_GamepadGamepadEvent_DISCONNECTED_EVENT;
     GP_ERROR("Invalid enumeration value '%d' for enumeration Gamepad::GamepadEvent.", e);
     return enumStringEmpty;
 }

+ 2 - 2
gameplay/src/lua/lua_Global.cpp

@@ -352,8 +352,8 @@ void luaRegister_lua_Global()
     {
         std::vector<std::string> scopePath;
         scopePath.push_back("Gamepad");
-        ScriptUtil::registerConstantString("ATTACHED_EVENT", "ATTACHED_EVENT", scopePath);
-        ScriptUtil::registerConstantString("DETACHED_EVENT", "DETACHED_EVENT", scopePath);
+        ScriptUtil::registerConstantString("CONNECTED_EVENT", "CONNECTED_EVENT", scopePath);
+        ScriptUtil::registerConstantString("DISCONNECTED_EVENT", "DISCONNECTED_EVENT", scopePath);
     }
 
     // Register enumeration Image::Format.

+ 70 - 70
gameplay/src/lua/lua_Platform.cpp

@@ -25,17 +25,17 @@ void luaRegister_Platform()
         {"getDisplayWidth", lua_Platform_static_getDisplayWidth},
         {"getGamepadButtonCount", lua_Platform_static_getGamepadButtonCount},
         {"getGamepadButtonState", lua_Platform_static_getGamepadButtonState},
-        {"getGamepadCount", lua_Platform_static_getGamepadCount},
         {"getGamepadId", lua_Platform_static_getGamepadId},
+        {"getGamepadJoystickAxisValues", lua_Platform_static_getGamepadJoystickAxisValues},
+        {"getGamepadJoystickAxisX", lua_Platform_static_getGamepadJoystickAxisX},
+        {"getGamepadJoystickAxisY", lua_Platform_static_getGamepadJoystickAxisY},
         {"getGamepadJoystickCount", lua_Platform_static_getGamepadJoystickCount},
-        {"getGamepadJoystickValue", lua_Platform_static_getGamepadJoystickValue},
-        {"getGamepadJoystickXAxis", lua_Platform_static_getGamepadJoystickXAxis},
-        {"getGamepadJoystickYAxis", lua_Platform_static_getGamepadJoystickYAxis},
         {"getGamepadTriggerCount", lua_Platform_static_getGamepadTriggerCount},
         {"getGamepadTriggerValue", lua_Platform_static_getGamepadTriggerValue},
+        {"getGamepadsConnected", lua_Platform_static_getGamepadsConnected},
         {"hasMouse", lua_Platform_static_hasMouse},
         {"isCursorVisible", lua_Platform_static_isCursorVisible},
-        {"isGamepadAttached", lua_Platform_static_isGamepadAttached},
+        {"isGamepadConnected", lua_Platform_static_isGamepadConnected},
         {"isGamepadJoystickActive", lua_Platform_static_isGamepadJoystickActive},
         {"isMouseCaptured", lua_Platform_static_isMouseCaptured},
         {"isMultiTouch", lua_Platform_static_isMultiTouch},
@@ -384,34 +384,6 @@ int lua_Platform_static_getGamepadButtonState(lua_State* state)
     return 0;
 }
 
-int lua_Platform_static_getGamepadCount(lua_State* state)
-{
-    // Get the number of parameters.
-    int paramCount = lua_gettop(state);
-
-    // Attempt to match the parameters to a valid binding.
-    switch (paramCount)
-    {
-        case 0:
-        {
-            unsigned int result = Platform::getGamepadCount();
-
-            // Push the return value onto the stack.
-            lua_pushunsigned(state, result);
-
-            return 1;
-            break;
-        }
-        default:
-        {
-            lua_pushstring(state, "Invalid number of parameters (expected 0).");
-            lua_error(state);
-            break;
-        }
-    }
-    return 0;
-}
-
 int lua_Platform_static_getGamepadId(lua_State* state)
 {
     // Get the number of parameters.
@@ -451,7 +423,7 @@ int lua_Platform_static_getGamepadId(lua_State* state)
     return 0;
 }
 
-int lua_Platform_static_getGamepadJoystickCount(lua_State* state)
+int lua_Platform_static_getGamepadJoystickAxisValues(lua_State* state)
 {
     // Get the number of parameters.
     int paramCount = lua_gettop(state);
@@ -459,30 +431,35 @@ int lua_Platform_static_getGamepadJoystickCount(lua_State* state)
     // Attempt to match the parameters to a valid binding.
     switch (paramCount)
     {
-        case 1:
+        case 3:
         {
-            if (lua_type(state, 1) == LUA_TNUMBER)
+            if (lua_type(state, 1) == LUA_TNUMBER &&
+                lua_type(state, 2) == LUA_TNUMBER &&
+                (lua_type(state, 3) == LUA_TUSERDATA || lua_type(state, 3) == LUA_TTABLE || lua_type(state, 3) == LUA_TNIL))
             {
                 // Get parameter 1 off the stack.
                 unsigned int param1 = (unsigned int)luaL_checkunsigned(state, 1);
 
-                unsigned int result = Platform::getGamepadJoystickCount(param1);
+                // Get parameter 2 off the stack.
+                unsigned int param2 = (unsigned int)luaL_checkunsigned(state, 2);
 
-                // Push the return value onto the stack.
-                lua_pushunsigned(state, result);
+                // Get parameter 3 off the stack.
+                Vector2* param3 = ScriptUtil::getObjectPointer<Vector2>(3, "Vector2", false);
 
-                return 1;
+                Platform::getGamepadJoystickAxisValues(param1, param2, param3);
+                
+                return 0;
             }
             else
             {
-                lua_pushstring(state, "lua_Platform_static_getGamepadJoystickCount - Failed to match the given parameters to a valid function signature.");
+                lua_pushstring(state, "lua_Platform_static_getGamepadJoystickAxisValues - Failed to match the given parameters to a valid function signature.");
                 lua_error(state);
             }
             break;
         }
         default:
         {
-            lua_pushstring(state, "Invalid number of parameters (expected 1).");
+            lua_pushstring(state, "Invalid number of parameters (expected 3).");
             lua_error(state);
             break;
         }
@@ -490,7 +467,7 @@ int lua_Platform_static_getGamepadJoystickCount(lua_State* state)
     return 0;
 }
 
-int lua_Platform_static_getGamepadJoystickValue(lua_State* state)
+int lua_Platform_static_getGamepadJoystickAxisX(lua_State* state)
 {
     // Get the number of parameters.
     int paramCount = lua_gettop(state);
@@ -498,11 +475,10 @@ int lua_Platform_static_getGamepadJoystickValue(lua_State* state)
     // Attempt to match the parameters to a valid binding.
     switch (paramCount)
     {
-        case 3:
+        case 2:
         {
             if (lua_type(state, 1) == LUA_TNUMBER &&
-                lua_type(state, 2) == LUA_TNUMBER &&
-                (lua_type(state, 3) == LUA_TUSERDATA || lua_type(state, 3) == LUA_TTABLE || lua_type(state, 3) == LUA_TNIL))
+                lua_type(state, 2) == LUA_TNUMBER)
             {
                 // Get parameter 1 off the stack.
                 unsigned int param1 = (unsigned int)luaL_checkunsigned(state, 1);
@@ -510,23 +486,23 @@ int lua_Platform_static_getGamepadJoystickValue(lua_State* state)
                 // Get parameter 2 off the stack.
                 unsigned int param2 = (unsigned int)luaL_checkunsigned(state, 2);
 
-                // Get parameter 3 off the stack.
-                Vector2* param3 = ScriptUtil::getObjectPointer<Vector2>(3, "Vector2", false);
+                float result = Platform::getGamepadJoystickAxisX(param1, param2);
 
-                Platform::getGamepadJoystickValue(param1, param2, param3);
-                
-                return 0;
+                // Push the return value onto the stack.
+                lua_pushnumber(state, result);
+
+                return 1;
             }
             else
             {
-                lua_pushstring(state, "lua_Platform_static_getGamepadJoystickValue - Failed to match the given parameters to a valid function signature.");
+                lua_pushstring(state, "lua_Platform_static_getGamepadJoystickAxisX - Failed to match the given parameters to a valid function signature.");
                 lua_error(state);
             }
             break;
         }
         default:
         {
-            lua_pushstring(state, "Invalid number of parameters (expected 3).");
+            lua_pushstring(state, "Invalid number of parameters (expected 2).");
             lua_error(state);
             break;
         }
@@ -534,7 +510,7 @@ int lua_Platform_static_getGamepadJoystickValue(lua_State* state)
     return 0;
 }
 
-int lua_Platform_static_getGamepadJoystickXAxis(lua_State* state)
+int lua_Platform_static_getGamepadJoystickAxisY(lua_State* state)
 {
     // Get the number of parameters.
     int paramCount = lua_gettop(state);
@@ -553,7 +529,7 @@ int lua_Platform_static_getGamepadJoystickXAxis(lua_State* state)
                 // Get parameter 2 off the stack.
                 unsigned int param2 = (unsigned int)luaL_checkunsigned(state, 2);
 
-                float result = Platform::getGamepadJoystickXAxis(param1, param2);
+                float result = Platform::getGamepadJoystickAxisY(param1, param2);
 
                 // Push the return value onto the stack.
                 lua_pushnumber(state, result);
@@ -562,7 +538,7 @@ int lua_Platform_static_getGamepadJoystickXAxis(lua_State* state)
             }
             else
             {
-                lua_pushstring(state, "lua_Platform_static_getGamepadJoystickXAxis - Failed to match the given parameters to a valid function signature.");
+                lua_pushstring(state, "lua_Platform_static_getGamepadJoystickAxisY - Failed to match the given parameters to a valid function signature.");
                 lua_error(state);
             }
             break;
@@ -577,7 +553,7 @@ int lua_Platform_static_getGamepadJoystickXAxis(lua_State* state)
     return 0;
 }
 
-int lua_Platform_static_getGamepadJoystickYAxis(lua_State* state)
+int lua_Platform_static_getGamepadJoystickCount(lua_State* state)
 {
     // Get the number of parameters.
     int paramCount = lua_gettop(state);
@@ -585,34 +561,30 @@ int lua_Platform_static_getGamepadJoystickYAxis(lua_State* state)
     // Attempt to match the parameters to a valid binding.
     switch (paramCount)
     {
-        case 2:
+        case 1:
         {
-            if (lua_type(state, 1) == LUA_TNUMBER &&
-                lua_type(state, 2) == LUA_TNUMBER)
+            if (lua_type(state, 1) == LUA_TNUMBER)
             {
                 // Get parameter 1 off the stack.
                 unsigned int param1 = (unsigned int)luaL_checkunsigned(state, 1);
 
-                // Get parameter 2 off the stack.
-                unsigned int param2 = (unsigned int)luaL_checkunsigned(state, 2);
-
-                float result = Platform::getGamepadJoystickYAxis(param1, param2);
+                unsigned int result = Platform::getGamepadJoystickCount(param1);
 
                 // Push the return value onto the stack.
-                lua_pushnumber(state, result);
+                lua_pushunsigned(state, result);
 
                 return 1;
             }
             else
             {
-                lua_pushstring(state, "lua_Platform_static_getGamepadJoystickYAxis - Failed to match the given parameters to a valid function signature.");
+                lua_pushstring(state, "lua_Platform_static_getGamepadJoystickCount - Failed to match the given parameters to a valid function signature.");
                 lua_error(state);
             }
             break;
         }
         default:
         {
-            lua_pushstring(state, "Invalid number of parameters (expected 2).");
+            lua_pushstring(state, "Invalid number of parameters (expected 1).");
             lua_error(state);
             break;
         }
@@ -702,6 +674,34 @@ int lua_Platform_static_getGamepadTriggerValue(lua_State* state)
     return 0;
 }
 
+int lua_Platform_static_getGamepadsConnected(lua_State* state)
+{
+    // Get the number of parameters.
+    int paramCount = lua_gettop(state);
+
+    // Attempt to match the parameters to a valid binding.
+    switch (paramCount)
+    {
+        case 0:
+        {
+            unsigned int result = Platform::getGamepadsConnected();
+
+            // Push the return value onto the stack.
+            lua_pushunsigned(state, result);
+
+            return 1;
+            break;
+        }
+        default:
+        {
+            lua_pushstring(state, "Invalid number of parameters (expected 0).");
+            lua_error(state);
+            break;
+        }
+    }
+    return 0;
+}
+
 int lua_Platform_static_hasMouse(lua_State* state)
 {
     // Get the number of parameters.
@@ -758,7 +758,7 @@ int lua_Platform_static_isCursorVisible(lua_State* state)
     return 0;
 }
 
-int lua_Platform_static_isGamepadAttached(lua_State* state)
+int lua_Platform_static_isGamepadConnected(lua_State* state)
 {
     // Get the number of parameters.
     int paramCount = lua_gettop(state);
@@ -773,7 +773,7 @@ int lua_Platform_static_isGamepadAttached(lua_State* state)
                 // Get parameter 1 off the stack.
                 unsigned int param1 = (unsigned int)luaL_checkunsigned(state, 1);
 
-                bool result = Platform::isGamepadAttached(param1);
+                bool result = Platform::isGamepadConnected(param1);
 
                 // Push the return value onto the stack.
                 lua_pushboolean(state, result);
@@ -782,7 +782,7 @@ int lua_Platform_static_isGamepadAttached(lua_State* state)
             }
             else
             {
-                lua_pushstring(state, "lua_Platform_static_isGamepadAttached - Failed to match the given parameters to a valid function signature.");
+                lua_pushstring(state, "lua_Platform_static_isGamepadConnected - Failed to match the given parameters to a valid function signature.");
                 lua_error(state);
             }
             break;

+ 5 - 5
gameplay/src/lua/lua_Platform.h

@@ -14,17 +14,17 @@ int lua_Platform_static_getDisplayHeight(lua_State* state);
 int lua_Platform_static_getDisplayWidth(lua_State* state);
 int lua_Platform_static_getGamepadButtonCount(lua_State* state);
 int lua_Platform_static_getGamepadButtonState(lua_State* state);
-int lua_Platform_static_getGamepadCount(lua_State* state);
 int lua_Platform_static_getGamepadId(lua_State* state);
+int lua_Platform_static_getGamepadJoystickAxisValues(lua_State* state);
+int lua_Platform_static_getGamepadJoystickAxisX(lua_State* state);
+int lua_Platform_static_getGamepadJoystickAxisY(lua_State* state);
 int lua_Platform_static_getGamepadJoystickCount(lua_State* state);
-int lua_Platform_static_getGamepadJoystickValue(lua_State* state);
-int lua_Platform_static_getGamepadJoystickXAxis(lua_State* state);
-int lua_Platform_static_getGamepadJoystickYAxis(lua_State* state);
 int lua_Platform_static_getGamepadTriggerCount(lua_State* state);
 int lua_Platform_static_getGamepadTriggerValue(lua_State* state);
+int lua_Platform_static_getGamepadsConnected(lua_State* state);
 int lua_Platform_static_hasMouse(lua_State* state);
 int lua_Platform_static_isCursorVisible(lua_State* state);
-int lua_Platform_static_isGamepadAttached(lua_State* state);
+int lua_Platform_static_isGamepadConnected(lua_State* state);
 int lua_Platform_static_isGamepadJoystickActive(lua_State* state);
 int lua_Platform_static_isMouseCaptured(lua_State* state);
 int lua_Platform_static_isMultiTouch(lua_State* state);