فهرست منبع

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 12 سال پیش
والد
کامیت
a24737bf58
1فایلهای تغییر یافته به همراه4 افزوده شده و 2 حذف شده
  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
 void Gamepad::getJoystickValues(unsigned int joystickId, Vector2* outValue) const
 {
 {
-    GP_ASSERT(joystickId < _joystickCount);
+    if (joystickId >= _joystickCount)
+        return;
 
 
     if (_form)
     if (_form)
     {
     {
@@ -356,7 +357,8 @@ unsigned int Gamepad::getTriggerCount() const
 
 
 float Gamepad::getTriggerValue(unsigned int triggerId) const
 float Gamepad::getTriggerValue(unsigned int triggerId) const
 {
 {
-    GP_ASSERT(triggerId < _triggerCount);
+    if (triggerId >= _triggerCount)
+        return 0.0f;
 
 
     if (_form)
     if (_form)
     {
     {