Configurable speed and accel to move mouse with joystick
This commit is contained in:
@@ -63,6 +63,7 @@ class Globals {
|
||||
public static final int LEFT_CLICK_NEAR_CURSOR = 1;
|
||||
public static final int LEFT_CLICK_WITH_MULTITOUCH = 2;
|
||||
public static final int LEFT_CLICK_WITH_PRESSURE = 3;
|
||||
public static final int LEFT_CLICK_WITH_DPAD = 4;
|
||||
public static int LeftClickMethod = LEFT_CLICK_NORMAL;
|
||||
public static final int RIGHT_CLICK_NONE = 0;
|
||||
public static final int RIGHT_CLICK_WITH_MULTITOUCH = 1;
|
||||
@@ -70,6 +71,8 @@ class Globals {
|
||||
public static final int RIGHT_CLICK_WITH_MENU_BUTTON = 3;
|
||||
public static int RightClickMethod = RIGHT_CLICK_NONE;
|
||||
public static boolean MoveMouseWithJoystick = false;
|
||||
public static int MoveMouseWithJoystickSpeed = 0;
|
||||
public static int MoveMouseWithJoystickAccel = 0;
|
||||
public static boolean ClickMouseWithDpad = false;
|
||||
public static boolean ShowScreenUnderFinger = false;
|
||||
public static boolean KeepAspectRatio = false;
|
||||
|
||||
@@ -57,6 +57,8 @@ class Settings
|
||||
out.writeInt(Globals.ClickScreenPressure);
|
||||
out.writeInt(Globals.ClickScreenTouchspotSize);
|
||||
out.writeBoolean(Globals.KeepAspectRatio);
|
||||
out.writeInt(Globals.MoveMouseWithJoystickSpeed);
|
||||
out.writeInt(Globals.MoveMouseWithJoystickAccel);
|
||||
|
||||
out.close();
|
||||
settingsLoaded = true;
|
||||
@@ -97,6 +99,8 @@ class Settings
|
||||
Globals.ClickScreenPressure = settingsFile.readInt();
|
||||
Globals.ClickScreenTouchspotSize = settingsFile.readInt();
|
||||
Globals.KeepAspectRatio = settingsFile.readBoolean();
|
||||
Globals.MoveMouseWithJoystickSpeed = settingsFile.readInt();
|
||||
Globals.MoveMouseWithJoystickAccel = settingsFile.readInt();
|
||||
|
||||
settingsLoaded = true;
|
||||
|
||||
@@ -167,6 +171,9 @@ class Settings
|
||||
|
||||
if( Globals.AppUsesMouse )
|
||||
items.add(p.getResources().getString(R.string.leftclick_question));
|
||||
|
||||
if( Globals.MoveMouseWithJoystick )
|
||||
items.add(p.getResources().getString(R.string.pointandclick_joystickmouse));
|
||||
|
||||
items.add(p.getResources().getString(R.string.audiobuf_question));
|
||||
|
||||
@@ -180,48 +187,65 @@ class Settings
|
||||
{
|
||||
MainMenuLastSelected = item;
|
||||
dialog.dismiss();
|
||||
int selected = 0;
|
||||
|
||||
if( item == 0 )
|
||||
if( item == selected )
|
||||
showDownloadConfig(p);
|
||||
selected++;
|
||||
|
||||
if( Globals.DataDownloadUrl.split("\\^").length <= 1 )
|
||||
item += 1;
|
||||
else
|
||||
if( item == 1 )
|
||||
if( item == selected )
|
||||
showOptionalDownloadConfig(p);
|
||||
selected++;
|
||||
|
||||
if( item == 2 )
|
||||
showAdditionalInputConfig(p);
|
||||
selected++;
|
||||
|
||||
if( ! Globals.AppNeedsArrowKeys && ! Globals.MoveMouseWithJoystick )
|
||||
item += 1;
|
||||
else
|
||||
if( item == 3 )
|
||||
if( item == selected )
|
||||
showKeyboardConfig(p);
|
||||
selected++;
|
||||
|
||||
if( ! Globals.UseAccelerometerAsArrowKeys || Globals.AppHandlesJoystickSensitivity )
|
||||
item += 1;
|
||||
else
|
||||
if( item == 4 )
|
||||
if( item == selected )
|
||||
showAccelerometerConfig(p);
|
||||
|
||||
selected++;
|
||||
|
||||
if( ! Globals.UseTouchscreenKeyboard )
|
||||
item += 1;
|
||||
else
|
||||
if( item == 5 )
|
||||
if( item == selected )
|
||||
showScreenKeyboardConfig(p);
|
||||
selected++;
|
||||
|
||||
if( ! Globals.AppUsesMouse )
|
||||
item += 1;
|
||||
else
|
||||
if( item == 6 )
|
||||
if( item == selected )
|
||||
showLeftClickConfig(p);
|
||||
|
||||
if( item == 7 )
|
||||
showAudioConfig(p);
|
||||
selected++;
|
||||
|
||||
if( item == 8 )
|
||||
if( ! Globals.MoveMouseWithJoystick )
|
||||
item += 1;
|
||||
else
|
||||
if( item == selected )
|
||||
showJoystickMouseConfig(p);
|
||||
selected++;
|
||||
|
||||
if( item == selected )
|
||||
showAudioConfig(p);
|
||||
selected++;
|
||||
|
||||
if( item == selected )
|
||||
showTouchPressureMeasurementTool(p);
|
||||
selected++;
|
||||
}
|
||||
});
|
||||
AlertDialog alert = builder.create();
|
||||
@@ -315,7 +339,7 @@ class Settings
|
||||
p.getResources().getString(R.string.pointandclick_keepaspectratio),
|
||||
p.getResources().getString(R.string.pointandclick_showcreenunderfinger),
|
||||
p.getResources().getString(R.string.pointandclick_joystickmouse),
|
||||
p.getResources().getString(R.string.leftclick_dpadcenter) };
|
||||
p.getResources().getString(R.string.click_with_dpadcenter) };
|
||||
|
||||
boolean defaults[] = {
|
||||
Globals.UseTouchscreenKeyboard,
|
||||
@@ -538,7 +562,8 @@ class Settings
|
||||
final CharSequence[] items = { p.getResources().getString(R.string.leftclick_normal),
|
||||
p.getResources().getString(R.string.leftclick_near_cursor),
|
||||
p.getResources().getString(R.string.leftclick_multitouch),
|
||||
p.getResources().getString(R.string.leftclick_pressure) };
|
||||
p.getResources().getString(R.string.leftclick_pressure),
|
||||
p.getResources().getString(R.string.leftclick_dpadcenter) };
|
||||
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(p);
|
||||
builder.setTitle(R.string.leftclick_question);
|
||||
@@ -648,6 +673,67 @@ class Settings
|
||||
alert.show();
|
||||
}
|
||||
|
||||
static void showJoystickMouseConfig(final MainActivity p)
|
||||
{
|
||||
if( ! Globals.MoveMouseWithJoystick )
|
||||
{
|
||||
Globals.MoveMouseWithJoystickSpeed = 0;
|
||||
showJoystickMouseAccelConfig(p);
|
||||
return;
|
||||
}
|
||||
|
||||
final CharSequence[] items = { p.getResources().getString(R.string.accel_slow),
|
||||
p.getResources().getString(R.string.accel_medium),
|
||||
p.getResources().getString(R.string.accel_fast) };
|
||||
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(p);
|
||||
builder.setTitle(R.string.pointandclick_joystickmousespeed);
|
||||
builder.setSingleChoiceItems(items, Globals.MoveMouseWithJoystickSpeed, new DialogInterface.OnClickListener()
|
||||
{
|
||||
public void onClick(DialogInterface dialog, int item)
|
||||
{
|
||||
Globals.MoveMouseWithJoystickSpeed = item;
|
||||
|
||||
dialog.dismiss();
|
||||
showJoystickMouseAccelConfig(p);
|
||||
}
|
||||
});
|
||||
AlertDialog alert = builder.create();
|
||||
alert.setOwnerActivity(p);
|
||||
alert.show();
|
||||
}
|
||||
|
||||
static void showJoystickMouseAccelConfig(final MainActivity p)
|
||||
{
|
||||
if( ! Globals.MoveMouseWithJoystick )
|
||||
{
|
||||
Globals.MoveMouseWithJoystickAccel = 0;
|
||||
showConfigMainMenu(p);
|
||||
return;
|
||||
}
|
||||
|
||||
final CharSequence[] items = { p.getResources().getString(R.string.none),
|
||||
p.getResources().getString(R.string.accel_slow),
|
||||
p.getResources().getString(R.string.accel_medium),
|
||||
p.getResources().getString(R.string.accel_fast) };
|
||||
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(p);
|
||||
builder.setTitle(R.string.pointandclick_joystickmousespeed);
|
||||
builder.setSingleChoiceItems(items, Globals.MoveMouseWithJoystickAccel, new DialogInterface.OnClickListener()
|
||||
{
|
||||
public void onClick(DialogInterface dialog, int item)
|
||||
{
|
||||
Globals.MoveMouseWithJoystickAccel = item;
|
||||
|
||||
dialog.dismiss();
|
||||
showConfigMainMenu(p);
|
||||
}
|
||||
});
|
||||
AlertDialog alert = builder.create();
|
||||
alert.setOwnerActivity(p);
|
||||
alert.show();
|
||||
}
|
||||
|
||||
static void showTouchPressureMeasurementTool(final MainActivity p)
|
||||
{
|
||||
if( Globals.RightClickMethod == Globals.RIGHT_CLICK_WITH_PRESSURE || Globals.LeftClickMethod == Globals.LEFT_CLICK_WITH_PRESSURE )
|
||||
@@ -727,7 +813,9 @@ class Settings
|
||||
Globals.MoveMouseWithJoystick ? 1 : 0,
|
||||
Globals.ClickMouseWithDpad ? 1 : 0,
|
||||
Globals.ClickScreenPressure,
|
||||
Globals.ClickScreenTouchspotSize );
|
||||
Globals.ClickScreenTouchspotSize,
|
||||
Globals.MoveMouseWithJoystickSpeed,
|
||||
Globals.MoveMouseWithJoystickAccel );
|
||||
if( Globals.AppUsesJoystick && (Globals.UseAccelerometerAsArrowKeys || Globals.UseTouchscreenKeyboard) )
|
||||
nativeSetJoystickUsed();
|
||||
if( Globals.AppUsesMultitouch )
|
||||
@@ -787,7 +875,9 @@ 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 LeftClickMethod, int MoveMouseWithJoystick, int ClickMouseWithDpad, int MaxForce, int MaxRadius);
|
||||
private static native void nativeSetMouseUsed(int RightClickMethod, int ShowScreenUnderFinger, int LeftClickMethod,
|
||||
int MoveMouseWithJoystick, int ClickMouseWithDpad, int MaxForce, int MaxRadius,
|
||||
int MoveMouseWithJoystickSpeed, int MoveMouseWithJoystickAccel);
|
||||
private static native void nativeSetJoystickUsed();
|
||||
private static native void nativeSetMultitouchUsed();
|
||||
private static native void nativeSetTouchscreenKeyboardUsed();
|
||||
|
||||
@@ -75,4 +75,8 @@
|
||||
<string name="leftclick_dpadcenter">Trackball klicken Select-Taste</string>
|
||||
<string name="pointandclick_joystickmouse">Bewegen Sie die Maus mit Joystick oder Trackball</string>
|
||||
<string name="measurepressure_response">Pressure %03d Radius %03d</string>
|
||||
<string name="click_with_dpadcenter">Linker Mausklick mit Trackball / Joystick Zentrum</string>
|
||||
<string name="pointandclick_joystickmousespeed">Bewegen Sie die Maus mit Joystick-Geschwindigkeit</string>
|
||||
<string name="pointandclick_joystickmouseaccel">Bewegen Sie die Maus mit Joystick-Beschleunigung</string>
|
||||
<string name="none">Keine</string>
|
||||
</resources>
|
||||
|
||||
@@ -75,4 +75,8 @@
|
||||
<string name="leftclick_dpadcenter">Trackball Valitse / Select-näppäintä</string>
|
||||
<string name="pointandclick_joystickmouse">Siirrä hiiren ohjaimella tai trackball</string>
|
||||
<string name="measurepressure_response">Paine %03d säde %03d</string>
|
||||
<string name="click_with_dpadcenter">Vasen hiiren klikkaus trackball-ohjaimella keskusta</string>
|
||||
<string name="pointandclick_joystickmousespeed">Siirrä hiiri ohjainta nopeasti</string>
|
||||
<string name="pointandclick_joystickmouseaccel">Siirrä hiiri ohjainta kiihtyvyys</string>
|
||||
<string name="none">Ei</string>
|
||||
</resources>
|
||||
|
||||
@@ -78,4 +78,8 @@
|
||||
<string name="leftclick_dpadcenter">Trackball cliquez / touche de sélection</string>
|
||||
<string name="pointandclick_joystickmouse">Déplacez la souris ou un trackball avec joystick</string>
|
||||
<string name="measurepressure_response">pression %03d rayon %03d</string>
|
||||
<string name="click_with_dpadcenter">cliquez gauche de la souris avec trackball centre du joystick /</string>
|
||||
<string name="pointandclick_joystickmousespeed">Déplacez la souris avec la vitesse joystick</string>
|
||||
<string name="pointandclick_joystickmouseaccel">Déplacez la souris avec une accélération joystick</string>
|
||||
<string name="none">Aucun</string>
|
||||
</resources>
|
||||
|
||||
@@ -68,4 +68,8 @@
|
||||
<string name="leftclick_pressure">Нажатие с силой</string>
|
||||
<string name="leftclick_dpadcenter">Нажатие на трекбол / центр джойстика</string>
|
||||
<string name="pointandclick_joystickmouse">Перемещение мыши при помощи джойстика или трекбола</string>
|
||||
<string name="click_with_dpadcenter">Левый клик мыши при помощи трекбола / центра джойстика</string>
|
||||
<string name="pointandclick_joystickmousespeed">Перемещение мыши джойстиком - скорость</string>
|
||||
<string name="pointandclick_joystickmouseaccel">Перемещение мыши джойстиком - ускорение</string>
|
||||
<string name="none">Нет</string>
|
||||
</resources>
|
||||
|
||||
@@ -68,4 +68,8 @@
|
||||
<string name="leftclick_pressure">>Натиск на екран з силою</string>
|
||||
<string name="leftclick_dpadcenter">Натиск на трекбол / центр джойстику</string>
|
||||
<string name="pointandclick_joystickmouse">Переміщення миші за допомогою джойстика або трекбола</string>
|
||||
<string name="click_with_dpadcenter">Лівий клік миші за допомогою трекбола / центра джойстика</string>
|
||||
<string name="pointandclick_joystickmousespeed">Переміщення миші джойстиком - швидкiсть</string>
|
||||
<string name="pointandclick_joystickmouseaccel">Переміщення миші джойстиком - прискорення</string>
|
||||
<string name="none">Немає</string>
|
||||
</resources>
|
||||
|
||||
@@ -71,11 +71,15 @@
|
||||
<string name="leftclick_multitouch">Touch screen with second finger</string>
|
||||
<string name="leftclick_pressure">Touch screen with force</string>
|
||||
<string name="leftclick_dpadcenter">Trackball click / joystick center</string>
|
||||
<string name="click_with_dpadcenter">Left mouse click with trackball / joystick center</string>
|
||||
|
||||
<string name="pointandclick_question">Advanced features</string>
|
||||
<string name="pointandclick_keepaspectratio">Keep 4:3 screen aspect ratio</string>
|
||||
<string name="pointandclick_showcreenunderfinger">Show screen under finger in separate window</string>
|
||||
<string name="pointandclick_joystickmouse">Move mouse with joystick or trackball</string>
|
||||
<string name="pointandclick_joystickmousespeed">Move mouse with joystick speed</string>
|
||||
<string name="pointandclick_joystickmouseaccel">Move mouse with joystick acceleration</string>
|
||||
<string name="none">None</string>
|
||||
|
||||
<string name="measurepressure_touchplease">Please slide finger across the screen for two seconds</string>
|
||||
<string name="measurepressure_response">Pressure %03d radius %03d</string>
|
||||
|
||||
@@ -21,13 +21,13 @@ RedefinedKeys="LCTRL m t h e"
|
||||
AppTouchscreenKeyboardKeysAmount=0
|
||||
AppTouchscreenKeyboardKeysAmountAutoFire=0
|
||||
MultiABI=n
|
||||
AppVersionCode=209704
|
||||
AppVersionName="2097.04"
|
||||
AppVersionCode=211205
|
||||
AppVersionName="2112.05"
|
||||
CompiledLibraries="sdl_net sdl_mixer sdl_image sdl_ttf png intl"
|
||||
CustomBuildScript=n
|
||||
AppCflags='-finline-functions -O2 -DWITH_ZLIB -DWITH_MIXER -DWITH_XML -DWITH_IMAGE -DWITH_TTF -DBUILD_RELEASE'
|
||||
AppCflags='-finline-functions -O2 -DWITH_ZLIB -DWITH_MIXER -DWITH_XML -DWITH_IMAGE -DWITH_TTF'
|
||||
AppLdflags=''
|
||||
AppSubdirsBuild='fheroes2/src/engine/* fheroes2/src/fheroes2/* fheroes2/src/xmlccwrap/* fheroes2-ai'
|
||||
AppUseCrystaXToolchain=n
|
||||
AppCmdline='fheroes2'
|
||||
AppCmdline='fheroes2 -d 500'
|
||||
ReadmeText='^You may press "Home" now - the data will be downloaded in background'
|
||||
|
||||
@@ -1 +1 @@
|
||||
teeworlds
|
||||
fheroes2
|
||||
@@ -57,16 +57,19 @@ static int isTrackballUsed = 0;
|
||||
static int isMouseUsed = 0;
|
||||
|
||||
enum { RIGHT_CLICK_NONE = 0, RIGHT_CLICK_WITH_MULTITOUCH = 1, RIGHT_CLICK_WITH_PRESSURE = 2, RIGHT_CLICK_WITH_MENU_BUTTON = 3 };
|
||||
enum { LEFT_CLICK_NORMAL = 0, LEFT_CLICK_NEAR_CURSOR = 1, LEFT_CLICK_WITH_MULTITOUCH = 2, LEFT_CLICK_WITH_PRESSURE = 3 };
|
||||
enum { LEFT_CLICK_NORMAL = 0, LEFT_CLICK_NEAR_CURSOR = 1, LEFT_CLICK_WITH_MULTITOUCH = 2, LEFT_CLICK_WITH_PRESSURE = 3, LEFT_CLICK_WITH_DPAD = 4 };
|
||||
static int leftClickMethod = LEFT_CLICK_NORMAL;
|
||||
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 moveMouseWithArrowKeys = 0;
|
||||
static int clickMouseWithDpadCenter = 0;
|
||||
static int moveMouseWithKbSpeed = 0;
|
||||
static int moveMouseWithKbAccel = 0;
|
||||
static int moveMouseWithKbX = -1, moveMouseWithKbY = -1;
|
||||
static int moveMouseWithKbXspeed = 0, moveMouseWithKbYspeed = 0;
|
||||
static int moveMouseWithKbUpdateSpeedX = 0, moveMouseWithKbUpdateSpeedY = 0;
|
||||
static int moveMouseWithKbSpeedX = 0, moveMouseWithKbSpeedY = 0;
|
||||
static int moveMouseWithKbAccelX = 0, moveMouseWithKbAccelY = 0;
|
||||
static int moveMouseWithKbAccelUpdateNeeded = 0;
|
||||
static int maxForce = 0;
|
||||
static int maxRadius = 0;
|
||||
int SDL_ANDROID_isJoystickUsed = 0;
|
||||
@@ -248,8 +251,8 @@ JAVA_EXPORT_NAME(DemoGLSurfaceView_nativeMouse) ( JNIEnv* env, jobject thiz, j
|
||||
}
|
||||
moveMouseWithKbX = -1;
|
||||
moveMouseWithKbY = -1;
|
||||
moveMouseWithKbXspeed = 0;
|
||||
moveMouseWithKbYspeed = 0;
|
||||
moveMouseWithKbSpeedX = 0;
|
||||
moveMouseWithKbSpeedY = 0;
|
||||
}
|
||||
if( action == MOUSE_DOWN )
|
||||
{
|
||||
@@ -279,24 +282,24 @@ JAVA_EXPORT_NAME(DemoGLSurfaceView_nativeMouse) ( JNIEnv* env, jobject thiz, j
|
||||
if( moveMouseWithKbX >= 0 )
|
||||
{
|
||||
if( abs(moveMouseWithKbX - x) > SDL_ANDROID_sFakeWindowWidth / 10 )
|
||||
moveMouseWithKbXspeed += moveMouseWithKbX > x ? -1 : 1;
|
||||
moveMouseWithKbSpeedX += moveMouseWithKbX > x ? -1 : 1;
|
||||
else
|
||||
moveMouseWithKbXspeed = moveMouseWithKbXspeed * 2 / 3;
|
||||
moveMouseWithKbSpeedX = moveMouseWithKbSpeedX * 2 / 3;
|
||||
if( abs(moveMouseWithKbY - y) > SDL_ANDROID_sFakeWindowHeight / 10 )
|
||||
moveMouseWithKbYspeed += moveMouseWithKbY > y ? -1 : 1;
|
||||
moveMouseWithKbSpeedY += moveMouseWithKbY > y ? -1 : 1;
|
||||
else
|
||||
moveMouseWithKbYspeed = moveMouseWithKbYspeed * 2 / 3;
|
||||
moveMouseWithKbSpeedY = moveMouseWithKbSpeedY * 2 / 3;
|
||||
|
||||
moveMouseWithKbX += moveMouseWithKbXspeed;
|
||||
moveMouseWithKbY += moveMouseWithKbYspeed;
|
||||
moveMouseWithKbX += moveMouseWithKbSpeedX;
|
||||
moveMouseWithKbY += moveMouseWithKbSpeedY;
|
||||
|
||||
if( abs(moveMouseWithKbX - x) > SDL_ANDROID_sFakeWindowWidth / 5 ||
|
||||
abs(moveMouseWithKbY - y) > SDL_ANDROID_sFakeWindowHeight / 5 )
|
||||
{
|
||||
moveMouseWithKbX = -1;
|
||||
moveMouseWithKbY = -1;
|
||||
moveMouseWithKbXspeed = 0;
|
||||
moveMouseWithKbYspeed = 0;
|
||||
moveMouseWithKbSpeedX = 0;
|
||||
moveMouseWithKbSpeedY = 0;
|
||||
SDL_ANDROID_MainThreadPushMouseMotion(x, y);
|
||||
}
|
||||
else
|
||||
@@ -364,7 +367,7 @@ JAVA_EXPORT_NAME(DemoGLSurfaceView_nativeKey) ( JNIEnv* env, jobject thiz, jint
|
||||
SDL_ANDROID_MainThreadPushMouseButton( action ? SDL_PRESSED : SDL_RELEASED, SDL_BUTTON_RIGHT );
|
||||
return;
|
||||
}
|
||||
if( key == KEYCODE_DPAD_CENTER && clickMouseWithDpadCenter )
|
||||
if( key == KEYCODE_DPAD_CENTER && ( clickMouseWithDpadCenter || leftClickMethod == LEFT_CLICK_WITH_DPAD ) )
|
||||
{
|
||||
SDL_ANDROID_MainThreadPushMouseButton( action ? SDL_PRESSED : SDL_RELEASED, SDL_BUTTON_LEFT );
|
||||
return;
|
||||
@@ -424,7 +427,8 @@ JNIEXPORT void JNICALL
|
||||
JAVA_EXPORT_NAME(Settings_nativeSetMouseUsed) ( JNIEnv* env, jobject thiz,
|
||||
jint RightClickMethod, jint ShowScreenUnderFinger, jint LeftClickMethod,
|
||||
jint MoveMouseWithJoystick, jint ClickMouseWithDpad,
|
||||
jint MaxForce, jint MaxRadius)
|
||||
jint MaxForce, jint MaxRadius,
|
||||
jint MoveMouseWithJoystickSpeed, jint MoveMouseWithJoystickAccel)
|
||||
{
|
||||
isMouseUsed = 1;
|
||||
rightClickMethod = RightClickMethod;
|
||||
@@ -434,6 +438,8 @@ JAVA_EXPORT_NAME(Settings_nativeSetMouseUsed) ( JNIEnv* env, jobject thiz,
|
||||
leftClickMethod = LeftClickMethod;
|
||||
maxForce = MaxForce;
|
||||
maxRadius = MaxRadius;
|
||||
moveMouseWithKbSpeed = MoveMouseWithJoystickSpeed + 1;
|
||||
moveMouseWithKbAccel = MoveMouseWithJoystickAccel;
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
@@ -976,50 +982,56 @@ extern void SDL_ANDROID_MainThreadPushKeyboardKey(int pressed, SDL_scancode key)
|
||||
{
|
||||
if( key == SDL_KEY(LEFT) )
|
||||
{
|
||||
if( moveMouseWithKbXspeed > 0 )
|
||||
moveMouseWithKbXspeed = 0;
|
||||
moveMouseWithKbXspeed --;
|
||||
moveMouseWithKbUpdateSpeedX = -1;
|
||||
if( moveMouseWithKbSpeedX > 0 )
|
||||
moveMouseWithKbSpeedX = 0;
|
||||
moveMouseWithKbSpeedX -= moveMouseWithKbSpeed;
|
||||
moveMouseWithKbAccelX = -moveMouseWithKbAccel;
|
||||
moveMouseWithKbAccelUpdateNeeded |= 1;
|
||||
}
|
||||
else if( key == SDL_KEY(RIGHT) )
|
||||
{
|
||||
if( moveMouseWithKbXspeed < 0 )
|
||||
moveMouseWithKbXspeed = 0;
|
||||
moveMouseWithKbXspeed ++;
|
||||
moveMouseWithKbUpdateSpeedX = 1;
|
||||
if( moveMouseWithKbSpeedX < 0 )
|
||||
moveMouseWithKbSpeedX = 0;
|
||||
moveMouseWithKbSpeedX += moveMouseWithKbSpeed;
|
||||
moveMouseWithKbAccelX = moveMouseWithKbAccel;
|
||||
moveMouseWithKbAccelUpdateNeeded |= 1;
|
||||
}
|
||||
|
||||
if( key == SDL_KEY(UP) )
|
||||
{
|
||||
if( moveMouseWithKbYspeed > 0 )
|
||||
moveMouseWithKbYspeed = 0;
|
||||
moveMouseWithKbYspeed --;
|
||||
moveMouseWithKbUpdateSpeedY = -1;
|
||||
if( moveMouseWithKbSpeedY > 0 )
|
||||
moveMouseWithKbSpeedY = 0;
|
||||
moveMouseWithKbSpeedY -= moveMouseWithKbSpeed;
|
||||
moveMouseWithKbAccelY = -moveMouseWithKbAccel;
|
||||
moveMouseWithKbAccelUpdateNeeded |= 2;
|
||||
}
|
||||
else if( key == SDL_KEY(DOWN) )
|
||||
{
|
||||
if( moveMouseWithKbYspeed < 0 )
|
||||
moveMouseWithKbYspeed = 0;
|
||||
moveMouseWithKbYspeed ++;
|
||||
moveMouseWithKbUpdateSpeedY = 1;
|
||||
if( moveMouseWithKbSpeedY < 0 )
|
||||
moveMouseWithKbSpeedY = 0;
|
||||
moveMouseWithKbSpeedY += moveMouseWithKbSpeed;
|
||||
moveMouseWithKbAccelY = moveMouseWithKbAccel;
|
||||
moveMouseWithKbAccelUpdateNeeded |= 2;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if( key == SDL_KEY(LEFT) || key == SDL_KEY(RIGHT) )
|
||||
{
|
||||
moveMouseWithKbXspeed = 0;
|
||||
moveMouseWithKbUpdateSpeedX = 0;
|
||||
moveMouseWithKbSpeedX = 0;
|
||||
moveMouseWithKbAccelX = 0;
|
||||
moveMouseWithKbAccelUpdateNeeded &= ~1;
|
||||
}
|
||||
if( key == SDL_KEY(UP) || key == SDL_KEY(DOWN) )
|
||||
{
|
||||
moveMouseWithKbYspeed = 0;
|
||||
moveMouseWithKbUpdateSpeedY = 0;
|
||||
moveMouseWithKbSpeedY = 0;
|
||||
moveMouseWithKbAccelY = 0;
|
||||
moveMouseWithKbAccelUpdateNeeded &= ~2;
|
||||
}
|
||||
}
|
||||
|
||||
moveMouseWithKbX += moveMouseWithKbXspeed;
|
||||
moveMouseWithKbY += moveMouseWithKbYspeed;
|
||||
moveMouseWithKbX += moveMouseWithKbSpeedX;
|
||||
moveMouseWithKbY += moveMouseWithKbSpeedY;
|
||||
|
||||
SDL_mutexV(BufferedEventsMutex);
|
||||
|
||||
@@ -1172,7 +1184,7 @@ Uint32 lastMoveMouseWithKeyboardUpdate = 0;
|
||||
|
||||
void SDL_ANDROID_processMoveMouseWithKeyboard()
|
||||
{
|
||||
if( moveMouseWithKbUpdateSpeedX == 0 && moveMouseWithKbUpdateSpeedY == 0 )
|
||||
if( ! moveMouseWithKbAccelUpdateNeeded )
|
||||
return;
|
||||
|
||||
Uint32 ticks = SDL_GetTicks();
|
||||
@@ -1182,11 +1194,11 @@ void SDL_ANDROID_processMoveMouseWithKeyboard()
|
||||
|
||||
lastMoveMouseWithKeyboardUpdate = ticks;
|
||||
|
||||
moveMouseWithKbXspeed += moveMouseWithKbUpdateSpeedX;
|
||||
moveMouseWithKbYspeed += moveMouseWithKbUpdateSpeedY;
|
||||
moveMouseWithKbSpeedX += moveMouseWithKbAccelX;
|
||||
moveMouseWithKbSpeedY += moveMouseWithKbAccelY;
|
||||
|
||||
moveMouseWithKbX += moveMouseWithKbXspeed;
|
||||
moveMouseWithKbY += moveMouseWithKbYspeed;
|
||||
moveMouseWithKbX += moveMouseWithKbSpeedX;
|
||||
moveMouseWithKbY += moveMouseWithKbSpeedY;
|
||||
SDL_ANDROID_MainThreadPushMouseMotion(moveMouseWithKbX, moveMouseWithKbY);
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user