Jelajahi Sumber

Polishing the BlackBerry platform's gamepad support by correcting joystick normalization and
adding known devices.
Adding a GamepadTest to the test app.

Adam Blake 13 tahun lalu
induk
melakukan
ee817295d5
2 mengubah file dengan 25 tambahan dan 11 penghapusan
  1. 3 1
      gameplay/src/Gamepad.cpp
  2. 22 10
      gameplay/src/PlatformBlackBerry.cpp

+ 3 - 1
gameplay/src/Gamepad.cpp

@@ -26,13 +26,15 @@ unsigned int Gamepad::getIndexFromMapping(Gamepad::ButtonMapping mapping)
 }
 
 Gamepad::Gamepad(const char* formPath)
-    : _id(""), _handle(0), _buttonCount(0), _joystickCount(0), _triggerCount(0), _form(NULL)
+    : _id(""), _handle(0), _vendorId(0), _productId(0), _buttonCount(0), _joystickCount(0), _triggerCount(0), _form(NULL)
 {
     GP_ASSERT(formPath);
     _form = Form::create(formPath);
     GP_ASSERT(_form);
     _form->setConsumeInputEvents(false);
     _id = _form->getId();
+    _vendorString = "GamePlay";
+    _productString = "Virtual Gamepad";
     bindGamepadControls(_form);
 }
 

+ 22 - 10
gameplay/src/PlatformBlackBerry.cpp

@@ -494,24 +494,32 @@ void gesture_callback(gesture_base_t* gesture, mtouch_event_t* event, void* para
 #ifdef __BB10__
 
 static const int __VIDs[] = {
-    0x1038
+    0x1038,
+    0x057e,
+    0x25b6
 };
 
 static const int __PIDs[] = {
-    0x1412
+    0x1412,
+    0x0306,
+    0x0001
 };
 
 static const char* __vendorStrings[] =
 {
-    "SteelSeries"
+    "SteelSeries",
+    "Nintendo",
+    "Fructel"
 };
 
 static const char* __productStrings[] =
 {
-    "FREE"
+    "FREE",
+    "Wii Remote",
+    "Gametel"
 };
 
-static const unsigned int __knownGamepads = 1;
+static const unsigned int __knownGamepads = 3;
 
 void loadGamepad(GamepadHandle handle, int* buttonCount, int* joystickCount, int* productId, int* vendorId, char* id, char* productString, char* vendorString)
 {
@@ -563,8 +571,6 @@ void loadGamepad(GamepadHandle handle, int* buttonCount, int* joystickCount, int
             }
         }
     }
-
-    fprintf(stderr, "Vendor: %s, Product: %s", vendorString, productString);
 }
 
 void Platform::pollGamepadState(Gamepad* gamepad)
@@ -591,9 +597,15 @@ void Platform::pollGamepadState(Gamepad* gamepad)
         // the SteelSeries FREE, and the iControlPad.
         // Both return values between -128 and +127, with the y axis starting from
         // the top at -128.
-        // 1 / 128 == 0.0078125
-        float x = (float)analog[0] * 0.0078125f;
-        float y = -(float)analog[1] * 0.0078125f;
+        // 1 / 128 == 0.0078125f
+        // 1 / 127 == 0.0078740157480315f
+        //float x = (float)analog[0] * 0.0078125f;
+        //float y = -(float)analog[1] * 0.0078125f;
+        float x = (float)analog[0];
+        float y = -(float)analog[1];
+        x *= (x < 0) ? 0.0078125f : 0.0078740157480315f;
+        y *= (y > 0) ? 0.0078125f : 0.0078740157480315f;
+
         gamepad->_joysticks[i].set(x, y);        
     }