Skip to content

Commit

Permalink
front: Nyko PlayPad controller mostly supported.
Browse files Browse the repository at this point in the history
Still difficult to map the left analog nub, since it sends both
AXIS_X and AXIS_HAT_X (and Y) at the same time.  But all other axes and
buttons are easily mapped now.

This should fix issues with other composite controllers, such as the
OUYA controller, which combine mouse emulation and joysticks on one
device.
  • Loading branch information
littleguy77 committed Jan 21, 2013
1 parent 110a237 commit 3ecabf8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,10 @@ public class GenericMotionListener implements View.OnGenericMotionListener
@Override
public boolean onGenericMotion( View v, MotionEvent event )
{
// Ignore motion events from non-joysticks (mice are a problem)
if( event.getSource() != InputDevice.SOURCE_JOYSTICK )
return false;

InputDevice device = event.getDevice();

// Read all the requested axes
Expand All @@ -105,7 +109,8 @@ public boolean onGenericMotion( View v, MotionEvent event )
float strength = event.getAxisValue( axisCode );
if( NORMALIZE && device != null )
{
MotionRange motionRange = device.getMotionRange( axisCode );
MotionRange motionRange = device.getMotionRange( axisCode,
InputDevice.SOURCE_JOYSTICK );
if( motionRange != null )
strength = 2f * ( strength - motionRange.getMin() ) / motionRange.getRange() - 1f;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,11 @@ public class LazyProvider extends AbstractProvider implements AbstractProvider.O
BIAS_CANDIDATES.add( AbstractProvider.axisToInputCode( MotionEvent.AXIS_Z, false ) );
BIAS_CANDIDATES.add( AbstractProvider.axisToInputCode( MotionEvent.AXIS_RZ, false ) );

// Wired PS3 controller triggers
// Other axes that are often analog triggers
BIAS_CANDIDATES.add( AbstractProvider.axisToInputCode( MotionEvent.AXIS_LTRIGGER, false ) );
BIAS_CANDIDATES.add( AbstractProvider.axisToInputCode( MotionEvent.AXIS_RTRIGGER, false ) );
BIAS_CANDIDATES.add( AbstractProvider.axisToInputCode( MotionEvent.AXIS_BRAKE, false ) );
BIAS_CANDIDATES.add( AbstractProvider.axisToInputCode( MotionEvent.AXIS_GAS, false ) );
}

/**
Expand Down

0 comments on commit 3ecabf8

Please sign in to comment.