Left mouse click can be triggered by multitouch too now - this is configurabe

This commit is contained in:
pelya
2010-11-15 18:39:39 +02:00
parent 524a1c1981
commit 4558ec8e91
4 changed files with 40 additions and 10 deletions

View File

@@ -65,6 +65,7 @@ class Globals {
public static final int RIGHT_CLICK_WITH_PRESSURE = 3;
public static int RightClickMethod = RIGHT_CLICK_WITH_MENU_BUTTON;
public static boolean LeftClickUsesPressure = false;
public static boolean LeftClickUsesMultitouch = false;
public static boolean ShowScreenUnderFinger = false;
public static int ClickScreenPressure = 0;
public static int ClickScreenTouchspotSize = 0;

View File

@@ -52,6 +52,7 @@ class Settings
out.writeInt(Globals.RightClickMethod);
out.writeBoolean(Globals.ShowScreenUnderFinger);
out.writeBoolean(Globals.LeftClickUsesPressure);
out.writeBoolean(Globals.LeftClickUsesMultitouch);
out.writeInt(Globals.ClickScreenPressure);
out.writeInt(Globals.ClickScreenTouchspotSize);
@@ -89,6 +90,7 @@ class Settings
Globals.RightClickMethod = settingsFile.readInt();
Globals.ShowScreenUnderFinger = settingsFile.readBoolean();
Globals.LeftClickUsesPressure = settingsFile.readBoolean();
Globals.LeftClickUsesMultitouch = settingsFile.readBoolean();
Globals.ClickScreenPressure = settingsFile.readInt();
Globals.ClickScreenTouchspotSize = settingsFile.readInt();
@@ -493,17 +495,26 @@ class Settings
{
Globals.ShowScreenUnderFinger = false;
Globals.LeftClickUsesPressure = false;
Globals.LeftClickUsesMultitouch = false;
if( ! Globals.AppNeedsTwoButtonMouse )
{
showTouchPressureMeasurementTool(p);
return;
}
CharSequence[] items = { p.getResources().getString(R.string.pointandclick_showcreenunderfinger),
p.getResources().getString(R.string.pointandclick_usepressure) };
CharSequence[] items = { p.getResources().getString(R.string.pointandclick_showcreenunderfinger),
p.getResources().getString(R.string.pointandclick_usepressure),
p.getResources().getString(R.string.pointandclick_multitouch) };
if( Globals.RightClickMethod == Globals.RIGHT_CLICK_WITH_PRESSURE )
{
CharSequence[] items2 = { p.getResources().getString(R.string.pointandclick_showcreenunderfinger) };
CharSequence[] items2 = { p.getResources().getString(R.string.pointandclick_showcreenunderfinger),
p.getResources().getString(R.string.pointandclick_multitouch) };
items = items2;
}
if( Globals.RightClickMethod == Globals.RIGHT_CLICK_WITH_MULTITOUCH )
{
CharSequence[] items2 = { p.getResources().getString(R.string.pointandclick_showcreenunderfinger),
p.getResources().getString(R.string.pointandclick_usepressure) };
items = items2;
}
@@ -516,7 +527,14 @@ class Settings
if( item == 0 )
Globals.ShowScreenUnderFinger = isChecked;
if( item == 1 )
Globals.LeftClickUsesPressure = isChecked;
{
if( Globals.RightClickMethod == Globals.RIGHT_CLICK_WITH_PRESSURE )
Globals.LeftClickUsesMultitouch = isChecked;
else
Globals.LeftClickUsesPressure = isChecked;
}
if( item == 2 )
Globals.LeftClickUsesMultitouch = isChecked;
}
});
builder.setPositiveButton(p.getResources().getString(R.string.ok), new DialogInterface.OnClickListener()
@@ -610,6 +628,7 @@ class Settings
nativeSetMouseUsed( Globals.RightClickMethod,
Globals.ShowScreenUnderFinger ? 1 : 0,
Globals.LeftClickUsesPressure ? 1 : 0,
Globals.LeftClickUsesMultitouch ? 1 : 0,
Globals.ClickScreenPressure,
Globals.ClickScreenTouchspotSize );
if( Globals.AppUsesJoystick && (Globals.UseAccelerometerAsArrowKeys || Globals.UseTouchscreenKeyboard) )
@@ -670,7 +689,7 @@ class Settings
private static native void nativeSetTrackballUsed();
private static native void nativeSetTrackballDampening(int value);
private static native void nativeSetAccelerometerSettings(int sensitivity, int centerPos);
private static native void nativeSetMouseUsed(int RightClickMethod, int ShowScreenUnderFinger, int LeftClickUsesPressure, int MaxForce, int MaxRadius);
private static native void nativeSetMouseUsed(int RightClickMethod, int ShowScreenUnderFinger, int LeftClickUsesPressure, int LeftClickUsesMultitouch, int MaxForce, int MaxRadius);
private static native void nativeSetJoystickUsed();
private static native void nativeSetMultitouchUsed();
private static native void nativeSetTouchscreenKeyboardUsed();

View File

@@ -67,6 +67,7 @@
<string name="pointandclick_question">Advanced point-and-click features</string>
<string name="pointandclick_showcreenunderfinger">Show screen under finger in separate window</string>
<string name="pointandclick_usepressure">Left click triggered by touch force</string>
<string name="pointandclick_multitouch">Left click triggered by touch with second finger</string>
<string name="measurepressure_touchplease">Please slide finger across the screen for two seconds</string>
<string name="measurepressure_response">Pressure %03d radius %03d</string>

View File

@@ -51,6 +51,7 @@ static int rightClickMethod = RIGHT_CLICK_NONE;
int SDL_ANDROID_ShowScreenUnderFinger = 0;
SDL_Rect SDL_ANDROID_ShowScreenUnderFingerRect = {0, 0, 0, 0}, SDL_ANDROID_ShowScreenUnderFingerRectSrc = {0, 0, 0, 0};
static int leftClickUsesPressure = 0;
static int leftClickUsesMultitouch = 0;
static int maxForce = 0;
static int maxRadius = 0;
int SDL_ANDROID_isJoystickUsed = 0;
@@ -193,7 +194,7 @@ JAVA_EXPORT_NAME(DemoGLSurfaceView_nativeMouse) ( JNIEnv* env, jobject thiz, j
}
if( action == MOUSE_DOWN )
{
if( !leftClickUsesPressure )
if( !leftClickUsesPressure && !leftClickUsesMultitouch )
SDL_SendMouseButton( NULL, (action == MOUSE_DOWN) ? SDL_PRESSED : SDL_RELEASED, SDL_BUTTON_LEFT );
else
action == MOUSE_MOVE;
@@ -215,9 +216,16 @@ JAVA_EXPORT_NAME(DemoGLSurfaceView_nativeMouse) ( JNIEnv* env, jobject thiz, j
}
if( pointerId == 1 && rightClickMethod == RIGHT_CLICK_WITH_MULTITOUCH && (action == MOUSE_DOWN || action == MOUSE_UP) )
{
if( SDL_GetMouseState( NULL, NULL ) & SDL_BUTTON(SDL_BUTTON_LEFT) )
SDL_SendMouseButton( NULL, SDL_RELEASED, SDL_BUTTON_LEFT );
SDL_SendMouseButton( NULL, (action == MOUSE_DOWN) ? SDL_PRESSED : SDL_RELEASED, SDL_BUTTON_RIGHT );
if( leftClickUsesMultitouch )
{
SDL_SendMouseButton( NULL, (action == MOUSE_DOWN) ? SDL_PRESSED : SDL_RELEASED, SDL_BUTTON_LEFT );
}
else
{
if( SDL_GetMouseState( NULL, NULL ) & SDL_BUTTON(SDL_BUTTON_LEFT) )
SDL_SendMouseButton( NULL, SDL_RELEASED, SDL_BUTTON_LEFT );
SDL_SendMouseButton( NULL, (action == MOUSE_DOWN) ? SDL_PRESSED : SDL_RELEASED, SDL_BUTTON_RIGHT );
}
}
}
@@ -294,12 +302,13 @@ JAVA_EXPORT_NAME(Settings_nativeSetTrackballUsed) ( JNIEnv* env, jobject thiz)
}
JNIEXPORT void JNICALL
JAVA_EXPORT_NAME(Settings_nativeSetMouseUsed) ( JNIEnv* env, jobject thiz, jint RightClickMethod, jint ShowScreenUnderFinger, jint LeftClickUsesPressure, jint MaxForce, jint MaxRadius)
JAVA_EXPORT_NAME(Settings_nativeSetMouseUsed) ( JNIEnv* env, jobject thiz, jint RightClickMethod, jint ShowScreenUnderFinger, jint LeftClickUsesPressure, jint LeftClickUsesMultitouch, jint MaxForce, jint MaxRadius)
{
isMouseUsed = 1;
rightClickMethod = RightClickMethod;
SDL_ANDROID_ShowScreenUnderFinger = ShowScreenUnderFinger;
leftClickUsesPressure = LeftClickUsesPressure;
leftClickUsesMultitouch = LeftClickUsesMultitouch;
maxForce = MaxForce;
maxRadius = MaxRadius;
}