From 6f634de0f16f7d8b814dd44522ca81fb9200080b Mon Sep 17 00:00:00 2001 From: pelya Date: Tue, 5 Jun 2012 15:44:26 +0300 Subject: [PATCH] Another fix for XPeria Play touchpad --- project/java/Video.java | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/project/java/Video.java b/project/java/Video.java index 443759703..a965458ce 100644 --- a/project/java/Video.java +++ b/project/java/Video.java @@ -344,20 +344,29 @@ abstract class DifferentTouchInput process(event); return; } + int x = (int)((event.getX() - xmin) / xmax * 65535.0f); + int y = (int)((event.getY() - ymin) / ymax * 65535.0f); + // Use only left 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() - xmin) / 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 oen touch pointer, touchpad will most probably support multitouch + // 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, -y, down, multitouch ); // Y axis is inverted, as you may have guessed + DemoGLSurfaceView.nativeTouchpad( x, 65535-y, down, multitouch ); // Y axis is inverted, as you may have guessed } } }