|
|
@@ -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
|