Explorar el Código

Gamepad can return from getJoystickValues and getTriggerValue if the control doesn't exist, rather than assert that it does. This simplifies some code e.g. in the samples.

ablake hace 12 años
padre
commit
a24737bf58
Se han modificado 1 ficheros con 4 adiciones y 2 borrados
  1. 4 2
      gameplay/src/Gamepad.cpp

+ 4 - 2
gameplay/src/Gamepad.cpp

@@ -328,7 +328,8 @@ unsigned int Gamepad::getJoystickCount() const
 
 void Gamepad::getJoystickValues(unsigned int joystickId, Vector2* outValue) const
 {
-    GP_ASSERT(joystickId < _joystickCount);
+    if (joystickId >= _joystickCount)
+        return;
 
     if (_form)
     {
@@ -356,7 +357,8 @@ unsigned int Gamepad::getTriggerCount() const
 
 float Gamepad::getTriggerValue(unsigned int triggerId) const
 {
-    GP_ASSERT(triggerId < _triggerCount);
+    if (triggerId >= _triggerCount)
+        return 0.0f;
 
     if (_form)
     {