Skip to content

Commit

Permalink
Remove right thumbstick value capping from XInputController
Browse files Browse the repository at this point in the history
  • Loading branch information
noorus committed Nov 15, 2014
1 parent c5883d2 commit 9f53138
Showing 1 changed file with 2 additions and 10 deletions.
12 changes: 2 additions & 10 deletions src/XInputController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,27 +62,19 @@ namespace Nil {

Real XInputController::filterRightThumbAxis( int val )
{
// There's a problem with the right thumbstick's axes often not reaching
// their maximum. So we adjust the range upward slightly to make up for it.
// It's OK to lose a tiny bit of low-range precision in order to do that.
// However, we'll try to stay as neutral as possible, and leave further
// filtering to the end-user application.

static int adjustedDeadzone = (int)( (double)XINPUT_GAMEPAD_RIGHT_THUMB_DEADZONE * 0.8 );

if ( val < 0 )
{
if ( val > -XINPUT_GAMEPAD_RIGHT_THUMB_DEADZONE )
return NIL_REAL_ZERO;
val += adjustedDeadzone;
val += XINPUT_GAMEPAD_RIGHT_THUMB_DEADZONE;
Real ret = (Real)val / (Real)( 32767 - XINPUT_GAMEPAD_RIGHT_THUMB_DEADZONE );
return ( ret < NIL_REAL_MINUSONE ? NIL_REAL_MINUSONE : ret );
}
else if ( val > 0 )
{
if ( val < XINPUT_GAMEPAD_RIGHT_THUMB_DEADZONE )
return NIL_REAL_ZERO;
val -= adjustedDeadzone;
val -= XINPUT_GAMEPAD_RIGHT_THUMB_DEADZONE;
Real ret = (Real)val / (Real)( 32767 - XINPUT_GAMEPAD_RIGHT_THUMB_DEADZONE );
return ( ret > NIL_REAL_ONE ? NIL_REAL_ONE : ret );
}
Expand Down

0 comments on commit 9f53138

Please sign in to comment.