Support for touch event history, for more accurate drawing.

This commit is contained in:
pelya
2013-11-05 10:48:51 +02:00
parent 7f6347c844
commit 06e6778145
6 changed files with 45 additions and 4 deletions

View File

@@ -848,6 +848,9 @@ echo >> AndroidAppSettings.cfg
echo "# Show SDL mouse cursor, for applications that do not draw cursor at all (y) or (n)" >> AndroidAppSettings.cfg
echo ShowMouseCursor=$ShowMouseCursor >> AndroidAppSettings.cfg
echo >> AndroidAppSettings.cfg
echo "# Generate more touch events, by default SDL generates one event per one video frame, this is useful for drawing apps (y) or (n)" >> AndroidAppSettings.cfg
echo GenerateSubframeTouchEvents=$GenerateSubframeTouchEvents >> AndroidAppSettings.cfg
echo >> AndroidAppSettings.cfg
echo "# Force relative (laptop) mouse movement mode, useful when both on-screen keyboard and mouse are needed (y) or (n)" >> AndroidAppSettings.cfg
echo ForceRelativeMouseMode=$ForceRelativeMouseMode >> AndroidAppSettings.cfg
echo >> AndroidAppSettings.cfg
@@ -1122,6 +1125,12 @@ else
ShowMouseCursor=false
fi
if [ "$GenerateSubframeTouchEvents" = "y" ] ; then
GenerateSubframeTouchEvents=true
else
GenerateSubframeTouchEvents=false
fi
if [ "$AppNeedsArrowKeys" = "y" ] ; then
AppNeedsArrowKeys=true
else
@@ -1329,6 +1338,7 @@ $SEDI "s/public static boolean AppUsesMouse = .*;/public static boolean AppUsesM
$SEDI "s/public static boolean AppNeedsTwoButtonMouse = .*;/public static boolean AppNeedsTwoButtonMouse = $AppNeedsTwoButtonMouse;/" project/src/Globals.java
$SEDI "s/public static boolean ForceRelativeMouseMode = .*;/public static boolean ForceRelativeMouseMode = $ForceRelativeMouseMode;/" project/src/Globals.java
$SEDI "s/public static boolean ShowMouseCursor = .*;/public static boolean ShowMouseCursor = $ShowMouseCursor;/" project/src/Globals.java
$SEDI "s/public static boolean GenerateSubframeTouchEvents = .*;/public static boolean GenerateSubframeTouchEvents = $GenerateSubframeTouchEvents;/" project/src/Globals.java
$SEDI "s/public static boolean AppNeedsArrowKeys = .*;/public static boolean AppNeedsArrowKeys = $AppNeedsArrowKeys;/" project/src/Globals.java
$SEDI "s/public static boolean AppNeedsTextInput = .*;/public static boolean AppNeedsTextInput = $AppNeedsTextInput;/" project/src/Globals.java
$SEDI "s/public static boolean AppUsesJoystick = .*;/public static boolean AppUsesJoystick = $AppUsesJoystick;/" project/src/Globals.java

View File

@@ -52,6 +52,7 @@ class Globals
public static boolean AppNeedsTwoButtonMouse = false;
public static boolean ForceRelativeMouseMode = false; // If both on-screen keyboard and mouse are needed, this will only set the default setting, user may override it later
public static boolean ShowMouseCursor = false;
public static boolean GenerateSubframeTouchEvents = false;
public static boolean AppNeedsArrowKeys = true;
public static boolean AppNeedsTextInput = true;
public static boolean AppUsesJoystick = false;

View File

@@ -112,6 +112,8 @@ abstract class DifferentTouchInput
Log.i("SDL", "Device model: " + android.os.Build.MODEL);
if( android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.ICE_CREAM_SANDWICH )
{
if ( Globals.GenerateSubframeTouchEvents )
return IcsTouchInputWithHistory.Holder.sInstance;
if( DetectCrappyDragonRiseDatexGamepad() )
return CrappyDragonRiseDatexGamepadInputWhichNeedsItsOwnHandlerBecauseImTooCheapAndStupidToBuyProperGamepad.Holder.sInstance;
return IcsTouchInput.Holder.sInstance;
@@ -377,6 +379,32 @@ abstract class DifferentTouchInput
super.processGenericEvent(event);
}
}
private static class IcsTouchInputWithHistory extends IcsTouchInput
{
private static class Holder
{
private static final IcsTouchInputWithHistory sInstance = new IcsTouchInputWithHistory();
}
public void process(final MotionEvent event)
{
int ptr = 0; // Process only one touch event, because that's typically a pen/mouse
for( ptr = 0; ptr < TOUCH_EVENTS_MAX; ptr++ )
{
if( touchEvents[ptr].down )
break;
}
if( ptr >= TOUCH_EVENTS_MAX )
ptr = 0;
//Log.i("SDL", "Got motion event, getHistorySize " + (int)(event.getHistorySize()) + " ptr " + ptr);
for( int i = 0; i < event.getHistorySize(); i++ )
{
DemoGLSurfaceView.nativeMotionEvent( (int)event.getHistoricalX(i), (int)event.getHistoricalY(i),
Mouse.SDL_FINGER_MOVE, ptr, (int)( event.getHistoricalPressure(i) * 1024.0f ), (int)( event.getHistoricalSize(i) * 1024.0f ) );
}
super.process(event); // Push mouse coordinate first
}
}
private static class CrappyDragonRiseDatexGamepadInputWhichNeedsItsOwnHandlerBecauseImTooCheapAndStupidToBuyProperGamepad extends IcsTouchInput
{
private static class Holder

View File

@@ -6,10 +6,10 @@ AppSettingVersion=19
LibSdlVersion=1.2
# Specify application name (e.x. My Application)
AppName="XSDL X server"
AppName="XServer XSDL"
# Specify reversed site name of application (e.x. com.mysite.myapp)
AppFullName=X.org.server
AppFullName=x.org.server
# Specify screen orientation: (v)ertical/(p)ortrait or (h)orizontal/(l)andscape
ScreenOrientation=h
@@ -84,6 +84,8 @@ AppNeedsTwoButtonMouse=y
# Show SDL mouse cursor, for applications that do not draw cursor at all (y) or (n)
ShowMouseCursor=n
GenerateSubframeTouchEvents=y
# Force relative (laptop) mouse movement mode, useful when both on-screen keyboard and mouse are needed (y) or (n)
ForceRelativeMouseMode=n

View File

@@ -17,4 +17,4 @@ x11proto-xext-dev x11proto-xf86bigfont-dev \
x11proto-xf86dga-dev x11proto-xf86dri-dev \
x11proto-xf86vidmode-dev x11proto-xinerama-dev \
libxmuu-dev libxt-dev libsm-dev libice-dev \
libxrender-dev libxrandr-dev
libxrender-dev libxrandr-dev curl