Removed custom Xperia Play touchpad support, it does not work anyway, and Xperia Play is a failure

This commit is contained in:
pelya
2013-02-02 13:20:42 +02:00
parent 8875a87037
commit d0a5bd4380

View File

@@ -114,7 +114,7 @@ abstract class DifferentTouchInput
return IcsTouchInput.Holder.sInstance;
}
if( android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.GINGERBREAD )
return XperiaPlayTouchpadTouchInput.Holder.sInstance;
return GingerbreadTouchInput.Holder.sInstance;
if (multiTouchAvailable1 && multiTouchAvailable2)
return MultiTouchInput.Holder.sInstance;
else
@@ -295,52 +295,16 @@ abstract class DifferentTouchInput
}
}
}
private static class XperiaPlayTouchpadTouchInput extends MultiTouchInput
private static class GingerbreadTouchInput extends MultiTouchInput
{
private static class Holder
{
private static final XperiaPlayTouchpadTouchInput sInstance = new XperiaPlayTouchpadTouchInput();
private static final GingerbreadTouchInput sInstance = new GingerbreadTouchInput();
}
float xmin = 0.0f;
float xmax = 1.0f;
float ymin = 0.0f;
float ymax = 1.0f;
float minRange = 1.0f;
float xshift = 0.0f;
XperiaPlayTouchpadTouchInput()
GingerbreadTouchInput()
{
super();
int[] devIds = InputDevice.getDeviceIds();
for( int id : devIds )
{
InputDevice device = InputDevice.getDevice(id);
if( device == null )
continue;
System.out.println("libSDL: input device ID " + id + " type " + device.getSources() + " name " + device.getName() );
if( (device.getSources() & InputDevice.SOURCE_TOUCHPAD) != InputDevice.SOURCE_TOUCHPAD )
continue;
System.out.println("libSDL: input device ID " + id + " type " + device.getSources() + " name " + device.getName() + " is a touchpad" );
InputDevice.MotionRange range = device.getMotionRange(MotionEvent.AXIS_X /*, InputDevice.SOURCE_TOUCHPAD*/);
if(range != null)
{
xmin = range.getMin();
xmax = range.getMax() - range.getMin();
System.out.println("libSDL: touch pad X range " + xmin + ":" + xmax );
}
range = device.getMotionRange(MotionEvent.AXIS_Y /*, InputDevice.SOURCE_TOUCHPAD*/);
if(range != null)
{
ymin = range.getMin();
ymax = range.getMax() - range.getMin();
System.out.println("libSDL: touch pad Y range " + ymin + ":" + ymax );
}
// Xperia Play has long wide touchpad with joystick-like embossing on the sides, so we'll leave only a left joystick to function
// I don't know how to use the second joystick, so I'll just ignore it for now
minRange = Math.min( Math.abs(ymax - ymin), Math.abs(xmax - xmin) );
xshift = xmax - minRange;
}
}
public void process(final MotionEvent event)
{
@@ -356,37 +320,10 @@ abstract class DifferentTouchInput
}
public void processGenericEvent(final MotionEvent event)
{
if( event.getSource() != InputDevice.SOURCE_TOUCHPAD )
{
process(event);
return;
}
/*
int x = (int)((event.getX() - xmin) / xmax * 65535.0f);
int y = (int)((event.getY() - ymin) / ymax * 65535.0f);
*/
// Use only right square part of a touch surface - I've heard reports that it breaks functionality, feel free to uncomment and test it.
int x = (int)((event.getX() - xshift) / minRange * 65535.0f);
int y = (int)((event.getY() - ymin) / minRange * 65535.0f);
if( x > 65535 )
x = 65535;
if( x < 0 )
x = 0;
if( y > 65535 )
y = 65535;
if( y < 0 )
y = 0;
int down = 1;
int multitouch = event.getPointerCount() - 1;
if( (event.getAction() & MotionEvent.ACTION_MASK) == MotionEvent.ACTION_UP ||
(event.getAction() & MotionEvent.ACTION_MASK) == MotionEvent.ACTION_CANCEL )
down = 0;
// TODO: we're processing only one touch pointer, touchpad will most probably support multitouch
//System.out.println("libSDL: touch pad event: " + x + ":" + y + " action " + event.getAction() + " down " + down + " multitouch " + multitouch );
DemoGLSurfaceView.nativeTouchpad( x, 65535 - y, down, multitouch ); // Y axis is inverted, as you may have guessed
process(event);
}
}
private static class IcsTouchInput extends XperiaPlayTouchpadTouchInput
private static class IcsTouchInput extends GingerbreadTouchInput
{
private static class Holder
{