Skip to content

Commit

Permalink
Fixed bug 5307 - Crash when joysticks hats number is odd (Thanks Sock…
Browse files Browse the repository at this point in the history
…monsters!)
  • Loading branch information
1bsyl committed Oct 7, 2020
1 parent bffbc7e commit b7b8ef5
Showing 1 changed file with 4 additions and 4 deletions.
Expand Up @@ -263,10 +263,10 @@ public boolean handleMotionEvent(MotionEvent event) {
float value = ( event.getAxisValue( range.getAxis(), actionPointerIndex) - range.getMin() ) / range.getRange() * 2.0f - 1.0f;
SDLControllerManager.onNativeJoy(joystick.device_id, i, value );
}
for (int i = 0; i < joystick.hats.size(); i+=2) {
int hatX = Math.round(event.getAxisValue( joystick.hats.get(i).getAxis(), actionPointerIndex ) );
int hatY = Math.round(event.getAxisValue( joystick.hats.get(i+1).getAxis(), actionPointerIndex ) );
SDLControllerManager.onNativeHat(joystick.device_id, i/2, hatX, hatY );
for (int i = 0; i < joystick.hats.size()/2; i++) {
int hatX = Math.round(event.getAxisValue( joystick.hats.get(2 * i).getAxis(), actionPointerIndex ));
int hatY = Math.round(event.getAxisValue( joystick.hats.get(2 * i + 1).getAxis(), actionPointerIndex ));
SDLControllerManager.onNativeHat(joystick.device_id, i, hatX, hatY);
}
}
break;
Expand Down

0 comments on commit b7b8ef5

Please sign in to comment.