Browse Source

Removed confusing ButtonMapping enum values and HID impl details

seanpaultaylor 11 years ago
parent
commit
b6f9b8bd4d

+ 18 - 49
gameplay/src/Gamepad.cpp

@@ -12,15 +12,13 @@ namespace gameplay
 static std::vector<Gamepad*> __gamepads;
 
 Gamepad::Gamepad(const char* formPath)
-    : _handle((GamepadHandle)INT_MAX), _buttonCount(0), _joystickCount(0), _triggerCount(0), _vendorId(0), _productId(0),
-      _form(NULL), _buttons(0)
+    : _handle((GamepadHandle)INT_MAX), _buttonCount(0), _joystickCount(0), _triggerCount(0), _form(NULL), _buttons(0)
 {
     GP_ASSERT(formPath);
     _form = Form::create(formPath);
     GP_ASSERT(_form);
     _form->setConsumeInputEvents(false);
-    _vendorString = "None";
-    _productString = "Virtual";
+    _name = "Virtual";
 
     for (int i = 0; i < 2; ++i)
     {
@@ -36,19 +34,13 @@ Gamepad::Gamepad(const char* formPath)
     bindGamepadControls(_form);
 }
 
-Gamepad::Gamepad(GamepadHandle handle, unsigned int buttonCount, unsigned int joystickCount, unsigned int triggerCount,
-                 unsigned int vendorId, unsigned int productId, const char* vendorString, const char* productString)
+Gamepad::Gamepad(GamepadHandle handle, unsigned int buttonCount, unsigned int joystickCount, unsigned int triggerCount, const char* name)
     : _handle(handle), _buttonCount(buttonCount), _joystickCount(joystickCount), _triggerCount(triggerCount),
-      _vendorId(vendorId), _productId(productId), _form(NULL), _buttons(0)
+      _form(NULL), _buttons(0)
 {
-    if (vendorString)
-    {
-        _vendorString = vendorString;
-    }
-    
-    if (productString)
+    if (name)
     {
-        _productString = productString;
+        _name = name;
     }
 
     for (int i = 0; i < 2; ++i)
@@ -65,11 +57,9 @@ Gamepad::~Gamepad()
     }
 }
 
-Gamepad* Gamepad::add(GamepadHandle handle, unsigned int buttonCount, unsigned int joystickCount, unsigned int triggerCount,
-                      unsigned int vendorId, unsigned int productId, 
-                      const char* vendorString, const char* productString)
+Gamepad* Gamepad::add(GamepadHandle handle, unsigned int buttonCount, unsigned int joystickCount, unsigned int triggerCount, const char* name)
 {
-    Gamepad* gamepad = new Gamepad(handle, buttonCount, joystickCount, triggerCount, vendorId, productId, vendorString, productString);
+    Gamepad* gamepad = new Gamepad(handle, buttonCount, joystickCount, triggerCount, name);
 
     __gamepads.push_back(gamepad);
     Game::getInstance()->gamepadEvent(CONNECTED_EVENT, gamepad);
@@ -211,22 +201,10 @@ Gamepad::ButtonMapping Gamepad::getButtonMappingFromString(const char* string)
         return BUTTON_A;
     else if (strcmp(string, "B") == 0 || strcmp(string, "BUTTON_B") == 0)
         return BUTTON_B;
-    else if (strcmp(string, "C") == 0 || strcmp(string, "BUTTON_C") == 0)
-        return BUTTON_C;
     else if (strcmp(string, "X") == 0 || strcmp(string, "BUTTON_X") == 0)
         return BUTTON_X;
     else if (strcmp(string, "Y") == 0 || strcmp(string, "BUTTON_Y") == 0)
         return BUTTON_Y;
-    else if (strcmp(string, "Z") == 0 || strcmp(string, "BUTTON_Z") == 0)
-        return BUTTON_Z;
-    else if (strcmp(string, "MENU1") == 0 || strcmp(string, "BUTTON_MENU1") == 0)
-        return BUTTON_MENU1;
-    else if (strcmp(string, "MENU2") == 0 || strcmp(string, "BUTTON_MENU2") == 0)
-        return BUTTON_MENU2;
-    else if (strcmp(string, "MENU3") == 0 || strcmp(string, "BUTTON_MENU3") == 0)
-        return BUTTON_MENU3;
-    else if (strcmp(string, "MENU4") == 0 || strcmp(string, "BUTTON_MENU4") == 0)
-        return BUTTON_MENU4;
     else if (strcmp(string, "L1") == 0 || strcmp(string, "BUTTON_L1") == 0)
         return BUTTON_L1;
     else if (strcmp(string, "L2") == 0 || strcmp(string, "BUTTON_L2") == 0)
@@ -247,29 +225,20 @@ Gamepad::ButtonMapping Gamepad::getButtonMappingFromString(const char* string)
         return BUTTON_LEFT;
     else if (strcmp(string, "RIGHT") == 0 || strcmp(string, "BUTTON_RIGHT") == 0)
         return BUTTON_RIGHT;
+    else if (strcmp(string, "MENU1") == 0 || strcmp(string, "BUTTON_MENU1") == 0)
+        return BUTTON_MENU1;
+    else if (strcmp(string, "MENU2") == 0 || strcmp(string, "BUTTON_MENU2") == 0)
+        return BUTTON_MENU2;
+    else if (strcmp(string, "MENU3") == 0 || strcmp(string, "BUTTON_MENU3") == 0)
+        return BUTTON_MENU3;
 
-    GP_WARN("Unknown GamepadButton string.");
+    GP_WARN("Unknown string for ButtonMapping.");
     return BUTTON_A;
 }
 
-const unsigned int Gamepad::getVendorId() const
-{
-    return _vendorId;
-}
-
-const unsigned int Gamepad::getProductId() const
-{
-    return _productId;
-}
-
-const char* Gamepad::getVendorString() const
-{
-    return _vendorString.c_str();
-}
-
-const char* Gamepad::getProductString() const
+const char* Gamepad::getName() const
 {
-    return _productString.c_str();
+    return _name.c_str();
 }
 
 void Gamepad::update(float elapsedTime)
@@ -365,7 +334,7 @@ float Gamepad::getTriggerValue(unsigned int triggerId) const
 
     if (_form)
     {
-        // Triggers are currently not available for virtual gamepads.
+        // Triggers are not part of the virtual gamepad defintion
         return 0.0f;
     }
     else

+ 15 - 49
gameplay/src/Gamepad.h

@@ -42,14 +42,8 @@ public:
     {        
         BUTTON_A,
         BUTTON_B,
-        BUTTON_C,
         BUTTON_X,
         BUTTON_Y,
-        BUTTON_Z,
-        BUTTON_MENU1,
-        BUTTON_MENU2,
-        BUTTON_MENU3,
-        BUTTON_MENU4,
         BUTTON_L1,
         BUTTON_L2,
         BUTTON_L3,
@@ -59,7 +53,10 @@ public:
         BUTTON_UP,
         BUTTON_DOWN,
         BUTTON_LEFT,
-        BUTTON_RIGHT
+        BUTTON_RIGHT,
+        BUTTON_MENU1,
+        BUTTON_MENU2,
+        BUTTON_MENU3
     };
 
     /**
@@ -110,33 +107,12 @@ public:
      */
     float getTriggerValue(unsigned int triggerId) const;
 
-   /**
-     * Get this gamepad's vendor ID.
-     *
-     * @return This gamepad's vendor ID.
-     */
-    const unsigned int getVendorId() const;
-
-    /**
-     * Get this gamepad's product ID.
-     *
-     * @return This gamepad's product ID.
-     */
-    const unsigned int getProductId() const;
-
-    /**
-     * Get this gamepad's vendor name.
-     *
-     * @return This gamepad's vendor name.
-     */
-    const char* getVendorString() const;
-
     /**
-     * Get this gamepad's product name.
+     * Get this gamepad's device/product name.
      *
-     * @return This gamepad's product name.
+     * @return This gamepad's device/product name.
      */
-    const char* getProductString() const;
+    const char* getName() const;
 
     /**
      * Returns whether the gamepad is currently represented with a UI form or not.
@@ -184,14 +160,9 @@ private:
      * @param buttonCount the number of buttons on the gamepad. 
      * @param joystickCount the number of joysticks on the gamepad.
      * @param triggerCount the number of triggers on the gamepad.
-     * @param vendorId The vendor id
-     * @param productId The product id
-     * @param vendorString The vendor string/name.
-     * @param productString The product string/name.
+     * @param name The product/device name.
      */
-    Gamepad(GamepadHandle handle, unsigned int buttonCount, unsigned int joystickCount, unsigned int triggerCount,
-            unsigned int vendorId, unsigned int productId, 
-            const char* vendorString, const char* productString);
+    Gamepad(GamepadHandle handle, unsigned int buttonCount, unsigned int joystickCount, unsigned int triggerCount, const char* name);
 
     /**
      * Copy constructor.
@@ -205,9 +176,7 @@ private:
 
     static void updateInternal(float elapsedTime);
 
-    static Gamepad* add(GamepadHandle handle, unsigned int buttonCount, unsigned int joystickCount, unsigned int triggerCount,
-                        unsigned int vendorId, unsigned int productId, 
-                        const char* vendorString, const char* productString);
+    static Gamepad* add(GamepadHandle handle, unsigned int buttonCount, unsigned int joystickCount, unsigned int triggerCount, const char* name);
 
     static Gamepad* add(const char* formPath);
 
@@ -231,14 +200,11 @@ private:
     
     void bindGamepadControls(Container* container);
 
-    GamepadHandle _handle;        // The handle of the Gamepad.
-    unsigned int _buttonCount;    // Number of buttons.
-    unsigned int _joystickCount;  // Number of joysticks.
-    unsigned int _triggerCount;   // Number of triggers.
-    unsigned int _vendorId;
-    unsigned int _productId;
-    std::string _vendorString;
-    std::string _productString;
+    GamepadHandle _handle;
+    unsigned int _buttonCount;
+    unsigned int _joystickCount;
+    unsigned int _triggerCount;
+    std::string _name;
     Form* _form;
     JoystickControl* _uiJoysticks[2];
     Button* _uiButtons[20];

+ 2 - 3
gameplay/src/Platform.cpp

@@ -91,10 +91,9 @@ void Platform::resizeEventInternal(unsigned int width, unsigned int height)
     Form::resizeEventInternal(width, height);
 }
 
-void Platform::gamepadEventConnectedInternal(GamepadHandle handle,  unsigned int buttonCount, unsigned int joystickCount, unsigned int triggerCount,
-                                             unsigned int vendorId, unsigned int productId, const char* vendorString, const char* productString)
+void Platform::gamepadEventConnectedInternal(GamepadHandle handle,  unsigned int buttonCount, unsigned int joystickCount, unsigned int triggerCount, const char* name)
 {
-    Gamepad::add(handle, buttonCount, joystickCount, triggerCount, vendorId, productId, vendorString, productString);
+    Gamepad::add(handle, buttonCount, joystickCount, triggerCount, name);
 }
 
 void Platform::gamepadEventDisconnectedInternal(GamepadHandle handle)

+ 1 - 3
gameplay/src/Platform.h

@@ -370,9 +370,7 @@ public:
      *
      * @script{ignore}
      */
-    static void gamepadEventConnectedInternal(GamepadHandle handle, unsigned int buttonCount, unsigned int joystickCount, unsigned int triggerCount,
-                                              unsigned int vendorId, unsigned int productId,
-                                              const char* vendorString, const char* productString);
+    static void gamepadEventConnectedInternal(GamepadHandle handle, unsigned int buttonCount, unsigned int joystickCount, unsigned int triggerCount, const char* name);
 
     /**
      * Internal method used only from static code in various platform implementation.

+ 11 - 19
gameplay/src/PlatformAndroid.cpp

@@ -710,15 +710,11 @@ Gamepad::ButtonMapping getGamepadButtonMapping(jint keycode)
         return Gamepad::BUTTON_X;
     case AKEYCODE_BUTTON_Y:
         return Gamepad::BUTTON_Y;
-    case AKEYCODE_BUTTON_Z:
-        return Gamepad::BUTTON_Z;
     case AKEYCODE_BUTTON_A:
     case AKEYCODE_DPAD_CENTER:
         return Gamepad::BUTTON_A;
     case AKEYCODE_BUTTON_B:
         return Gamepad::BUTTON_B;
-    case AKEYCODE_BUTTON_C:
-        return Gamepad::BUTTON_C;
     case AKEYCODE_BUTTON_L1:
         return Gamepad::BUTTON_L1;
     case AKEYCODE_BUTTON_L2:
@@ -731,13 +727,6 @@ Gamepad::ButtonMapping getGamepadButtonMapping(jint keycode)
         return Gamepad::BUTTON_R2;
     case AKEYCODE_BUTTON_THUMBR:
         return Gamepad::BUTTON_R3;
-    case AKEYCODE_BUTTON_SELECT:
-    case AKEYCODE_BACK:
-        return Gamepad::BUTTON_MENU1;
-    case AKEYCODE_BUTTON_START:
-        return Gamepad::BUTTON_MENU2;
-    case AKEYCODE_BUTTON_MODE:
-        return Gamepad::BUTTON_MENU3;
     case AKEYCODE_DPAD_UP:
         return Gamepad::BUTTON_UP;
     case AKEYCODE_DPAD_DOWN:
@@ -746,10 +735,15 @@ Gamepad::ButtonMapping getGamepadButtonMapping(jint keycode)
         return Gamepad::BUTTON_LEFT;
     case AKEYCODE_DPAD_RIGHT:
         return Gamepad::BUTTON_RIGHT;
+    case AKEYCODE_BUTTON_SELECT:
+        return Gamepad::BUTTON_MENU1;
+    case AKEYCODE_BUTTON_START:
+        return Gamepad::BUTTON_MENU2;
+    case AKEYCODE_BUTTON_MODE:
+        return Gamepad::BUTTON_MENU3;
     default:
-        break;
+        return Gamepad::BUTTON_A;
     }
-    return Gamepad::BUTTON_MENU4;
 }
 
 static float clampFuzz(float value, float fuzz)
@@ -1770,15 +1764,13 @@ std::string Platform::displayFileDialog(size_t mode, const char* title, const ch
 extern "C"
 {
 
-JNIEXPORT void JNICALL Java_org_gameplay3d_GameNativeActivity_gamepadEventConnectedImpl(JNIEnv* env, jclass clazz, jint deviceId, jint buttonCount, jint joystickCount, jint triggerCount, jint vendorId, jint productId, jstring vendorIdStr, jstring productIdStr)
+JNIEXPORT void JNICALL Java_org_gameplay3d_GameNativeActivity_gamepadEventConnectedImpl(JNIEnv* env, jclass clazz, jint deviceId, jint buttonCount, jint joystickCount, jint triggerCount, jstring deviceName)
 {
-    const char* vendorString = env->GetStringUTFChars(vendorIdStr, JNI_FALSE);
-    const char* productString = env->GetStringUTFChars(productIdStr, JNI_FALSE);
+    const char* name = env->GetStringUTFChars(deviceName, JNI_FALSE);
     
-	gameplay::Platform::gamepadEventConnectedInternal(deviceId, buttonCount, joystickCount, triggerCount, vendorId, productId, vendorString, productString);
+	gameplay::Platform::gamepadEventConnectedInternal(deviceId, buttonCount, joystickCount, triggerCount, name);
     
-    env->ReleaseStringUTFChars(vendorIdStr, vendorString);
-    env->ReleaseStringUTFChars(productIdStr, productString);
+    env->ReleaseStringUTFChars(deviceName, name);
 }
 
 JNIEXPORT void JNICALL Java_org_gameplay3d_GameNativeActivity_gamepadEventDisconnectedImpl(JNIEnv* env, jclass clazz, jint deviceId)

+ 5 - 5
gameplay/src/PlatformLinux.cpp

@@ -1012,7 +1012,8 @@ void handleConnectedGamepad(dev_t devId, const char* devPath, const char* sysFSI
     unsigned int vendorId =readIntegerGamepadIdPropery(sysFSIdPath,"vendor");
     unsigned int productId =readIntegerGamepadIdPropery(sysFSIdPath,"product");
 
-    if (isBlackListed(vendorId,productId)) return;
+    if (isBlackListed(vendorId, productId))
+        return;
 
     GamepadHandle handle = ::open(devPath,O_RDONLY | O_NONBLOCK);
     if(handle < 0)
@@ -1029,18 +1030,17 @@ void handleConnectedGamepad(dev_t devId, const char* devPath, const char* sysFSI
     ioctl (handle, JSIOCGAXES, &axesNum);
     ioctl (handle, JSIOCGBUTTONS, &btnsNum);
 
-    const GamepadInfoEntry& gpInfo = getGamepadMappedInfo(vendorId,productId,(unsigned int)axesNum,(unsigned int)btnsNum);
+    const GamepadInfoEntry& gpInfo = getGamepadMappedInfo(vendorId, productId, (unsigned int)axesNum, (unsigned int)btnsNum);
     unsigned int numJS = gpInfo.numberOfJS;
     unsigned int numTR = gpInfo.numberOfTriggers;
 
-    // Ignore accelerometer devices that register themselves as joysticks. Ensure they have at least 2 buttons.s
+    // Ignore accelerometer devices that register themselves as joysticks. Ensure they have at least 2 buttons.
     if (btnsNum < 2)
         return;
 
-    Platform::gamepadEventConnectedInternal(handle,btnsNum,numJS,numTR,vendorId,productId,"",name);
+    Platform::gamepadEventConnectedInternal(handle, btnsNum, numJS, numTR, name);
     ConnectedGamepadDevInfo info = {devId,handle,gpInfo}; 
     __connectedGamepads.push_back(info);
-    
 }
 
 static float normalizeJoystickAxis(int axisValue, int deadZone, bool zeroToOne)

+ 6 - 21
gameplay/src/PlatformMacOSX.mm

@@ -332,7 +332,6 @@ double getMachTimeInMilliseconds()
 
 - (NSString*)identifierName;
 - (NSString*)productName;
-- (NSString*)manufacturerName;
 - (NSString*)serialNumber;
 - (int)versionNumber;
 - (int)vendorID;
@@ -544,7 +543,6 @@ double getMachTimeInMilliseconds()
 {
     NSString* idName = NULL;
     if(idName == NULL) idName = [self productName];
-    if(idName == NULL) idName = [self manufacturerName];
     if(idName == NULL) idName = [self serialNumber];
     if(idName == NULL) idName = [NSString stringWithFormat:@"%d-%d", [self vendorID], [self productID]];
     return idName;
@@ -560,16 +558,6 @@ double getMachTimeInMilliseconds()
     return (NSString*)productName;
 }
 
-- (NSString*)manufacturerName
-{
-    CFStringRef manufacturerName = (CFStringRef)IOHIDDeviceGetProperty([self rawDevice], CFSTR(kIOHIDManufacturerKey));
-    if(manufacturerName == NULL || CFGetTypeID(manufacturerName) != CFStringGetTypeID())
-    {
-        return NULL;
-    }
-    return (NSString*)manufacturerName;
-}
-
 - (NSString*)serialNumber
 {
     CFStringRef serialNumber = (CFStringRef)IOHIDDeviceGetProperty([self rawDevice], CFSTR(kIOHIDSerialNumberKey));
@@ -784,9 +772,6 @@ double getMachTimeInMilliseconds()
                                                     [gamepad numberOfButtons],
                                                     [gamepad numberOfSticks],
                                                     [gamepad numberOfTriggerButtons],
-                                                    [gamepad vendorID],
-                                                    [gamepad productID],
-                                                    [[gamepad manufacturerName] cStringUsingEncoding:NSASCIIStringEncoding],
                                                     [[gamepad productName] cStringUsingEncoding:NSASCIIStringEncoding]);
 
             [__activeGamepads setObject:locationID forKey:locationID];
@@ -2054,20 +2039,20 @@ void Platform::pollGamepadState(Gamepad* gamepad)
         
         const int* mapping = NULL;
         float axisDeadZone = 0.0f;
-        if (gamepad->_vendorId == SONY_USB_VENDOR_ID &&
-            gamepad->_productId == SONY_USB_PS3_PRODUCT_ID)
+        if ([gp vendorID] == SONY_USB_VENDOR_ID &&
+            [gp productID] == SONY_USB_PS3_PRODUCT_ID)
         {
             mapping = PS3Mapping;
             axisDeadZone = 0.07f;
         }
-        else if (gamepad->_vendorId == MICROSOFT_VENDOR_ID &&
-                 gamepad->_productId == MICROSOFT_XBOX360_PRODUCT_ID)
+        else if ([gp vendorID] == MICROSOFT_VENDOR_ID &&
+                 [gp productID] == MICROSOFT_XBOX360_PRODUCT_ID)
         {
             mapping = XBox360Mapping;
             axisDeadZone = 0.2f;
         }
-        else if (gamepad->_vendorId == STEELSERIES_VENDOR_ID &&
-                 gamepad->_productId == STEELSERIES_FREE_PRODUCT_ID)
+        else if ([gp vendorID] == STEELSERIES_VENDOR_ID &&
+                 [gp productID] == STEELSERIES_FREE_PRODUCT_ID)
         {
             mapping = SteelSeriesFreeMapping;
             axisDeadZone = 0.005f;

+ 2 - 2
gameplay/src/PlatformWindows.cpp

@@ -951,7 +951,7 @@ Platform* Platform::create(Game* game)
             if (!__connectedXInput[i])
             {
                 // Gamepad is connected.
-                Platform::gamepadEventConnectedInternal(i, XINPUT_BUTTON_COUNT, XINPUT_JOYSTICK_COUNT, XINPUT_TRIGGER_COUNT, 0, 0, "Microsoft", "XBox360 Controller");
+                Platform::gamepadEventConnectedInternal(i, XINPUT_BUTTON_COUNT, XINPUT_JOYSTICK_COUNT, XINPUT_TRIGGER_COUNT, "Microsoft X-Box 360 pad");
                 __connectedXInput[i] = true;
             }
         }
@@ -1008,7 +1008,7 @@ int Platform::enterMessagePump()
                 if (XInputGetState(i, &__xInputState) == NO_ERROR && !__connectedXInput[i])
                 {
                     // Gamepad was just connected.
-                    Platform::gamepadEventConnectedInternal(i, XINPUT_BUTTON_COUNT, XINPUT_JOYSTICK_COUNT, XINPUT_TRIGGER_COUNT, 0, 0, "Microsoft", "XBox360 Controller");
+                    Platform::gamepadEventConnectedInternal(i, XINPUT_BUTTON_COUNT, XINPUT_JOYSTICK_COUNT, XINPUT_TRIGGER_COUNT, "Microsoft X-Box 360 pad");
                     __connectedXInput[i] = true;
                 }
                 else if (XInputGetState(i, &__xInputState) != NO_ERROR && __connectedXInput[i])

+ 4 - 112
gameplay/src/lua/lua_Gamepad.cpp

@@ -22,12 +22,9 @@ void luaRegister_Gamepad()
         {"getForm", lua_Gamepad_getForm},
         {"getJoystickCount", lua_Gamepad_getJoystickCount},
         {"getJoystickValues", lua_Gamepad_getJoystickValues},
-        {"getProductId", lua_Gamepad_getProductId},
-        {"getProductString", lua_Gamepad_getProductString},
+        {"getName", lua_Gamepad_getName},
         {"getTriggerCount", lua_Gamepad_getTriggerCount},
         {"getTriggerValue", lua_Gamepad_getTriggerValue},
-        {"getVendorId", lua_Gamepad_getVendorId},
-        {"getVendorString", lua_Gamepad_getVendorString},
         {"isButtonDown", lua_Gamepad_isButtonDown},
         {"isVirtual", lua_Gamepad_isVirtual},
         {"update", lua_Gamepad_update},
@@ -238,7 +235,7 @@ int lua_Gamepad_getJoystickValues(lua_State* state)
     return 0;
 }
 
-int lua_Gamepad_getProductId(lua_State* state)
+int lua_Gamepad_getName(lua_State* state)
 {
     // Get the number of parameters.
     int paramCount = lua_gettop(state);
@@ -251,42 +248,7 @@ int lua_Gamepad_getProductId(lua_State* state)
             if ((lua_type(state, 1) == LUA_TUSERDATA))
             {
                 Gamepad* instance = getInstance(state);
-                unsigned int result = instance->getProductId();
-
-                // Push the return value onto the stack.
-                lua_pushunsigned(state, result);
-
-                return 1;
-            }
-
-            lua_pushstring(state, "lua_Gamepad_getProductId - 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_Gamepad_getProductString(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))
-            {
-                Gamepad* instance = getInstance(state);
-                const char* result = instance->getProductString();
+                const char* result = instance->getName();
 
                 // Push the return value onto the stack.
                 lua_pushstring(state, result);
@@ -294,7 +256,7 @@ int lua_Gamepad_getProductString(lua_State* state)
                 return 1;
             }
 
-            lua_pushstring(state, "lua_Gamepad_getProductString - Failed to match the given parameters to a valid function signature.");
+            lua_pushstring(state, "lua_Gamepad_getName - Failed to match the given parameters to a valid function signature.");
             lua_error(state);
             break;
         }
@@ -382,76 +344,6 @@ int lua_Gamepad_getTriggerValue(lua_State* state)
     return 0;
 }
 
-int lua_Gamepad_getVendorId(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))
-            {
-                Gamepad* instance = getInstance(state);
-                unsigned int result = instance->getVendorId();
-
-                // Push the return value onto the stack.
-                lua_pushunsigned(state, result);
-
-                return 1;
-            }
-
-            lua_pushstring(state, "lua_Gamepad_getVendorId - 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_Gamepad_getVendorString(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))
-            {
-                Gamepad* instance = getInstance(state);
-                const char* result = instance->getVendorString();
-
-                // Push the return value onto the stack.
-                lua_pushstring(state, result);
-
-                return 1;
-            }
-
-            lua_pushstring(state, "lua_Gamepad_getVendorString - 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_Gamepad_isButtonDown(lua_State* state)
 {
     // Get the number of parameters.

+ 1 - 4
gameplay/src/lua/lua_Gamepad.h

@@ -10,12 +10,9 @@ int lua_Gamepad_getButtonCount(lua_State* state);
 int lua_Gamepad_getForm(lua_State* state);
 int lua_Gamepad_getJoystickCount(lua_State* state);
 int lua_Gamepad_getJoystickValues(lua_State* state);
-int lua_Gamepad_getProductId(lua_State* state);
-int lua_Gamepad_getProductString(lua_State* state);
+int lua_Gamepad_getName(lua_State* state);
 int lua_Gamepad_getTriggerCount(lua_State* state);
 int lua_Gamepad_getTriggerValue(lua_State* state);
-int lua_Gamepad_getVendorId(lua_State* state);
-int lua_Gamepad_getVendorString(lua_State* state);
 int lua_Gamepad_isButtonDown(lua_State* state);
 int lua_Gamepad_isVirtual(lua_State* state);
 int lua_Gamepad_update(lua_State* state);

+ 15 - 30
gameplay/src/lua/lua_GamepadButtonMapping.cpp

@@ -8,14 +8,8 @@ static const char* enumStringEmpty = "";
 
 static const char* luaEnumString_GamepadButtonMapping_BUTTON_A = "BUTTON_A";
 static const char* luaEnumString_GamepadButtonMapping_BUTTON_B = "BUTTON_B";
-static const char* luaEnumString_GamepadButtonMapping_BUTTON_C = "BUTTON_C";
 static const char* luaEnumString_GamepadButtonMapping_BUTTON_X = "BUTTON_X";
 static const char* luaEnumString_GamepadButtonMapping_BUTTON_Y = "BUTTON_Y";
-static const char* luaEnumString_GamepadButtonMapping_BUTTON_Z = "BUTTON_Z";
-static const char* luaEnumString_GamepadButtonMapping_BUTTON_MENU1 = "BUTTON_MENU1";
-static const char* luaEnumString_GamepadButtonMapping_BUTTON_MENU2 = "BUTTON_MENU2";
-static const char* luaEnumString_GamepadButtonMapping_BUTTON_MENU3 = "BUTTON_MENU3";
-static const char* luaEnumString_GamepadButtonMapping_BUTTON_MENU4 = "BUTTON_MENU4";
 static const char* luaEnumString_GamepadButtonMapping_BUTTON_L1 = "BUTTON_L1";
 static const char* luaEnumString_GamepadButtonMapping_BUTTON_L2 = "BUTTON_L2";
 static const char* luaEnumString_GamepadButtonMapping_BUTTON_L3 = "BUTTON_L3";
@@ -26,6 +20,9 @@ static const char* luaEnumString_GamepadButtonMapping_BUTTON_UP = "BUTTON_UP";
 static const char* luaEnumString_GamepadButtonMapping_BUTTON_DOWN = "BUTTON_DOWN";
 static const char* luaEnumString_GamepadButtonMapping_BUTTON_LEFT = "BUTTON_LEFT";
 static const char* luaEnumString_GamepadButtonMapping_BUTTON_RIGHT = "BUTTON_RIGHT";
+static const char* luaEnumString_GamepadButtonMapping_BUTTON_MENU1 = "BUTTON_MENU1";
+static const char* luaEnumString_GamepadButtonMapping_BUTTON_MENU2 = "BUTTON_MENU2";
+static const char* luaEnumString_GamepadButtonMapping_BUTTON_MENU3 = "BUTTON_MENU3";
 
 Gamepad::ButtonMapping lua_enumFromString_GamepadButtonMapping(const char* s)
 {
@@ -33,22 +30,10 @@ Gamepad::ButtonMapping lua_enumFromString_GamepadButtonMapping(const char* s)
         return Gamepad::BUTTON_A;
     if (strcmp(s, luaEnumString_GamepadButtonMapping_BUTTON_B) == 0)
         return Gamepad::BUTTON_B;
-    if (strcmp(s, luaEnumString_GamepadButtonMapping_BUTTON_C) == 0)
-        return Gamepad::BUTTON_C;
     if (strcmp(s, luaEnumString_GamepadButtonMapping_BUTTON_X) == 0)
         return Gamepad::BUTTON_X;
     if (strcmp(s, luaEnumString_GamepadButtonMapping_BUTTON_Y) == 0)
         return Gamepad::BUTTON_Y;
-    if (strcmp(s, luaEnumString_GamepadButtonMapping_BUTTON_Z) == 0)
-        return Gamepad::BUTTON_Z;
-    if (strcmp(s, luaEnumString_GamepadButtonMapping_BUTTON_MENU1) == 0)
-        return Gamepad::BUTTON_MENU1;
-    if (strcmp(s, luaEnumString_GamepadButtonMapping_BUTTON_MENU2) == 0)
-        return Gamepad::BUTTON_MENU2;
-    if (strcmp(s, luaEnumString_GamepadButtonMapping_BUTTON_MENU3) == 0)
-        return Gamepad::BUTTON_MENU3;
-    if (strcmp(s, luaEnumString_GamepadButtonMapping_BUTTON_MENU4) == 0)
-        return Gamepad::BUTTON_MENU4;
     if (strcmp(s, luaEnumString_GamepadButtonMapping_BUTTON_L1) == 0)
         return Gamepad::BUTTON_L1;
     if (strcmp(s, luaEnumString_GamepadButtonMapping_BUTTON_L2) == 0)
@@ -69,6 +54,12 @@ Gamepad::ButtonMapping lua_enumFromString_GamepadButtonMapping(const char* s)
         return Gamepad::BUTTON_LEFT;
     if (strcmp(s, luaEnumString_GamepadButtonMapping_BUTTON_RIGHT) == 0)
         return Gamepad::BUTTON_RIGHT;
+    if (strcmp(s, luaEnumString_GamepadButtonMapping_BUTTON_MENU1) == 0)
+        return Gamepad::BUTTON_MENU1;
+    if (strcmp(s, luaEnumString_GamepadButtonMapping_BUTTON_MENU2) == 0)
+        return Gamepad::BUTTON_MENU2;
+    if (strcmp(s, luaEnumString_GamepadButtonMapping_BUTTON_MENU3) == 0)
+        return Gamepad::BUTTON_MENU3;
     return Gamepad::BUTTON_A;
 }
 
@@ -78,22 +69,10 @@ const char* lua_stringFromEnum_GamepadButtonMapping(Gamepad::ButtonMapping e)
         return luaEnumString_GamepadButtonMapping_BUTTON_A;
     if (e == Gamepad::BUTTON_B)
         return luaEnumString_GamepadButtonMapping_BUTTON_B;
-    if (e == Gamepad::BUTTON_C)
-        return luaEnumString_GamepadButtonMapping_BUTTON_C;
     if (e == Gamepad::BUTTON_X)
         return luaEnumString_GamepadButtonMapping_BUTTON_X;
     if (e == Gamepad::BUTTON_Y)
         return luaEnumString_GamepadButtonMapping_BUTTON_Y;
-    if (e == Gamepad::BUTTON_Z)
-        return luaEnumString_GamepadButtonMapping_BUTTON_Z;
-    if (e == Gamepad::BUTTON_MENU1)
-        return luaEnumString_GamepadButtonMapping_BUTTON_MENU1;
-    if (e == Gamepad::BUTTON_MENU2)
-        return luaEnumString_GamepadButtonMapping_BUTTON_MENU2;
-    if (e == Gamepad::BUTTON_MENU3)
-        return luaEnumString_GamepadButtonMapping_BUTTON_MENU3;
-    if (e == Gamepad::BUTTON_MENU4)
-        return luaEnumString_GamepadButtonMapping_BUTTON_MENU4;
     if (e == Gamepad::BUTTON_L1)
         return luaEnumString_GamepadButtonMapping_BUTTON_L1;
     if (e == Gamepad::BUTTON_L2)
@@ -114,6 +93,12 @@ const char* lua_stringFromEnum_GamepadButtonMapping(Gamepad::ButtonMapping e)
         return luaEnumString_GamepadButtonMapping_BUTTON_LEFT;
     if (e == Gamepad::BUTTON_RIGHT)
         return luaEnumString_GamepadButtonMapping_BUTTON_RIGHT;
+    if (e == Gamepad::BUTTON_MENU1)
+        return luaEnumString_GamepadButtonMapping_BUTTON_MENU1;
+    if (e == Gamepad::BUTTON_MENU2)
+        return luaEnumString_GamepadButtonMapping_BUTTON_MENU2;
+    if (e == Gamepad::BUTTON_MENU3)
+        return luaEnumString_GamepadButtonMapping_BUTTON_MENU3;
     return enumStringEmpty;
 }
 

+ 3 - 8
gameplay/src/org/gameplay3d/GameNativeActivity.java

@@ -91,18 +91,13 @@ public class GameNativeActivity extends NativeActivity
     }
     
     private void onGamepadConnected(int deviceId, String deviceName) {
-        int buttonCount = 20;
+        int buttonCount = 17;
         int joystickCount = 2;
         int triggerCount = 2;
-        int vendorId = 0;
-        int productId = 0;
-        String vendorName = "";
-        String productName = deviceName;
         
         Log.v(TAG, "Gamepad connected:id=" + deviceId + ", name=" + deviceName);
         
-        gamepadEventConnectedImpl(deviceId, buttonCount, joystickCount, triggerCount, 
-                                  productId, vendorId, vendorName, productName);
+        gamepadEventConnectedImpl(deviceId, buttonCount, joystickCount, triggerCount, deviceName);
     }
     
     private InputDevice getGamepadDevice(int deviceId) {
@@ -124,7 +119,7 @@ public class GameNativeActivity extends NativeActivity
     
     
     // JNI calls to PlatformAndroid.cpp
-    private static native void gamepadEventConnectedImpl(int deviceId, int buttonCount, int joystickCount, int triggerCount, int vendorId, int productId, String vendorString, String productString);
+    private static native void gamepadEventConnectedImpl(int deviceId, int buttonCount, int joystickCount, int triggerCount, String deviceName);
     private static native void gamepadEventDisconnectedImpl(int deviceId);
     
     private InputManager _inputManager;

+ 12 - 18
samples/browser/src/GamepadSample.cpp

@@ -30,13 +30,13 @@ void GamepadSample::finalize()
 void GamepadSample::updateGamepad(float elapsedTime, Gamepad* gamepad, unsigned int player)
 {
     char s[128];
-    sprintf(s, "Player: %d - %s\nButtons: ",player, gamepad->getProductString());
+    sprintf(s, "Player: %d - %s\nButtons: ", player, gamepad->getName());
     _status += s;
-    for (int j = 0; j < 20; ++j)
+    for (int i = 0; i < 20; ++i)
     {
-        if (gamepad->isButtonDown((Gamepad::ButtonMapping)j))
+        if (gamepad->isButtonDown((Gamepad::ButtonMapping)i))
         {
-            sprintf(s, "%s ", getStringFromButtonMapping((Gamepad::ButtonMapping)j));
+            sprintf(s, "%s ", getStringFromButtonMapping((Gamepad::ButtonMapping)i));
             _status += s;
         }
     }
@@ -48,9 +48,9 @@ void GamepadSample::updateGamepad(float elapsedTime, Gamepad* gamepad, unsigned
         sprintf(s, "Joystick %d: (%f, %f)\n", j, joystick.x, joystick.y);
         _status += s;
     }
-    for (unsigned int j = 0; j < gamepad->getTriggerCount(); ++j)
+    for (unsigned int k = 0; k < gamepad->getTriggerCount(); ++k)
     {
-        sprintf(s, "Trigger %d: %f\n", j, gamepad->getTriggerValue(j));
+        sprintf(s, "Trigger %d: %f\n", k, gamepad->getTriggerValue(k));
         _status += s;
     }
     _status += "\n";
@@ -100,22 +100,10 @@ const char* GamepadSample::getStringFromButtonMapping(Gamepad::ButtonMapping map
             return "A";
         case Gamepad::BUTTON_B:
             return "B";
-        case Gamepad::BUTTON_C:
-            return "C";
         case Gamepad::BUTTON_X:
             return "X";
         case Gamepad::BUTTON_Y:
             return "Y";
-        case Gamepad::BUTTON_Z:
-            return "Z";
-        case Gamepad::BUTTON_MENU1:
-            return "MENU1";
-        case Gamepad::BUTTON_MENU2:
-            return "MENU2";
-        case Gamepad::BUTTON_MENU3:
-            return "MENU3";
-        case Gamepad::BUTTON_MENU4:
-            return "MENU4";
         case Gamepad::BUTTON_L1:
             return "L1";
         case Gamepad::BUTTON_L2:
@@ -136,6 +124,12 @@ const char* GamepadSample::getStringFromButtonMapping(Gamepad::ButtonMapping map
             return "LEFT";
         case Gamepad::BUTTON_RIGHT:
             return "RIGHT";
+        case Gamepad::BUTTON_MENU1:
+            return "MENU1";
+        case Gamepad::BUTTON_MENU2:
+            return "MENU2";
+        case Gamepad::BUTTON_MENU3:
+            return "MENU3";
         default:
             return "";
     }