From fc3265c2896658641ccfea873f43987c55d17194 Mon Sep 17 00:00:00 2001 From: Sergii Pylypenko Date: Fri, 27 Jan 2017 22:24:08 +0200 Subject: [PATCH] SDL: option for desktop mouse mode / no touch filtering, added back backspace key handler hack to text input window --- project/java/Globals.java | 1 + project/java/MainActivity.java | 6 ++---- project/java/Settings.java | 2 ++ project/java/SettingsMenuMouse.java | 19 ++++++++++++++++++- project/java/Video.java | 8 ++++---- project/java/translations/values/strings.xml | 1 + project/jni/application/ninslash/src | 2 +- project/jni/application/openttd/src | 2 +- 8 files changed, 30 insertions(+), 11 deletions(-) diff --git a/project/java/Globals.java b/project/java/Globals.java index 2d8ca7d5b..b632eebc3 100644 --- a/project/java/Globals.java +++ b/project/java/Globals.java @@ -112,6 +112,7 @@ class Globals public static int MoveMouseWithGyroscopeSpeed = 2; public static boolean ClickMouseWithDpad = false; public static boolean RelativeMouseMovement = ForceRelativeMouseMode; // Laptop touchpad mode + public static boolean ForceHardwareMouse = false; public static int RelativeMouseMovementSpeed = 2; public static int RelativeMouseMovementAccel = 0; public static int ShowScreenUnderFinger = Mouse.ZOOM_NONE; diff --git a/project/java/MainActivity.java b/project/java/MainActivity.java index 8fd8caacc..eb13182c7 100644 --- a/project/java/MainActivity.java +++ b/project/java/MainActivity.java @@ -820,7 +820,6 @@ public class MainActivity extends Activity _parent.hideScreenKeyboard(); return true; } - /* if (keyCode == KeyEvent.KEYCODE_DEL || keyCode == KeyEvent.KEYCODE_CLEAR) { // EditText deletes two characters at a time, here's a hacky fix @@ -830,12 +829,12 @@ public class MainActivity extends Activity int start = t.getSelectionStart(); //get cursor starting position int end = t.getSelectionEnd(); //get cursor ending position if ( start < 0 ) - return true; + return false; if ( end < 0 || end == start ) { start --; if ( start < 0 ) - return true; + return false; end = start + 1; } t.setText(t.getText().toString().substring(0, start) + t.getText().toString().substring(end)); @@ -843,7 +842,6 @@ public class MainActivity extends Activity return true; } } - */ //Log.i("SDL", "Key " + keyCode + " flags " + event.getFlags() + " action " + event.getAction()); return false; } diff --git a/project/java/Settings.java b/project/java/Settings.java index da85b52b9..1ba99c6c8 100644 --- a/project/java/Settings.java +++ b/project/java/Settings.java @@ -186,6 +186,7 @@ public class Settings out.writeBoolean(Globals.ImmersiveMode); out.writeBoolean(Globals.AutoDetectOrientation); out.writeBoolean(Globals.TvBorders); + out.writeBoolean(Globals.ForceHardwareMouse); out.close(); settingsLoaded = true; @@ -379,6 +380,7 @@ public class Settings Globals.ImmersiveMode = settingsFile.readBoolean(); Globals.AutoDetectOrientation = settingsFile.readBoolean(); Globals.TvBorders = settingsFile.readBoolean(); + Globals.ForceHardwareMouse = settingsFile.readBoolean(); settingsLoaded = true; diff --git a/project/java/SettingsMenuMouse.java b/project/java/SettingsMenuMouse.java index e1f5feeb1..cf5160070 100644 --- a/project/java/SettingsMenuMouse.java +++ b/project/java/SettingsMenuMouse.java @@ -124,21 +124,25 @@ class SettingsMenuMouse extends SettingsMenu p.getResources().getString(R.string.display_size_small), p.getResources().getString(R.string.display_size_small_touchpad), p.getResources().getString(R.string.display_size_large), + p.getResources().getString(R.string.display_size_desktop), }; int _size_small = 0; int _size_small_touchpad = 1; int _size_large = 2; - int _more_options = 3; + int _size_desktop = 3; + int _more_options = 4; if( ! Globals.SwVideoMode ) { CharSequence[] items2 = { p.getResources().getString(R.string.display_size_small_touchpad), p.getResources().getString(R.string.display_size_large), + p.getResources().getString(R.string.display_size_desktop), }; items = items2; _size_small_touchpad = 0; _size_large = 1; + _size_desktop = 2; _size_small = 1000; } if( firstStart ) @@ -147,6 +151,7 @@ class SettingsMenuMouse extends SettingsMenu p.getResources().getString(R.string.display_size_small), p.getResources().getString(R.string.display_size_small_touchpad), p.getResources().getString(R.string.display_size_large), + p.getResources().getString(R.string.display_size_desktop), p.getResources().getString(R.string.show_more_options), }; items = items2; @@ -155,6 +160,7 @@ class SettingsMenuMouse extends SettingsMenu CharSequence[] items3 = { p.getResources().getString(R.string.display_size_small_touchpad), p.getResources().getString(R.string.display_size_large), + p.getResources().getString(R.string.display_size_desktop), p.getResources().getString(R.string.show_more_options), }; items = items3; @@ -165,6 +171,7 @@ class SettingsMenuMouse extends SettingsMenu final int size_small = _size_small; final int size_small_touchpad = _size_small_touchpad; final int size_large = _size_large; + final int size_desktop = _size_desktop; final int more_options = _more_options; AlertDialog.Builder builder = new AlertDialog.Builder(p); @@ -174,23 +181,33 @@ class SettingsMenuMouse extends SettingsMenu public void onClick(DialogInterface dialog, int item) { dialog.dismiss(); + if( item == size_desktop ) + { + Globals.LeftClickMethod = Mouse.LEFT_CLICK_NORMAL; + Globals.RelativeMouseMovement = false; + Globals.ShowScreenUnderFinger = Mouse.ZOOM_NONE; + Globals.ForceHardwareMouse = true; + } if( item == size_large ) { Globals.LeftClickMethod = Mouse.LEFT_CLICK_NORMAL; Globals.RelativeMouseMovement = false; Globals.ShowScreenUnderFinger = Mouse.ZOOM_NONE; + Globals.ForceHardwareMouse = false; } if( item == size_small ) { Globals.LeftClickMethod = Mouse.LEFT_CLICK_NEAR_CURSOR; Globals.RelativeMouseMovement = false; Globals.ShowScreenUnderFinger = Mouse.ZOOM_MAGNIFIER; + Globals.ForceHardwareMouse = false; } if( item == size_small_touchpad ) { Globals.LeftClickMethod = Mouse.LEFT_CLICK_WITH_TAP_OR_TIMEOUT; Globals.RelativeMouseMovement = true; Globals.ShowScreenUnderFinger = Mouse.ZOOM_NONE; + Globals.ForceHardwareMouse = false; } if( item == more_options ) { diff --git a/project/java/Video.java b/project/java/Video.java index 3454ad472..cb0eb8761 100644 --- a/project/java/Video.java +++ b/project/java/Video.java @@ -106,8 +106,8 @@ abstract class DifferentTouchInput public abstract void process(final MotionEvent event); public abstract void processGenericEvent(final MotionEvent event); - public static int ExternalMouseDetected = 0; - + public static int ExternalMouseDetected = Mouse.MOUSE_HW_INPUT_FINGER; + public static DifferentTouchInput touchInput = getInstance(); public static DifferentTouchInput getInstance() @@ -315,8 +315,8 @@ abstract class DifferentTouchInput } public void process(final MotionEvent event) { - int hwMouseEvent = ((event.getSource() & InputDevice.SOURCE_STYLUS) == InputDevice.SOURCE_STYLUS) ? Mouse.MOUSE_HW_INPUT_STYLUS : - ((event.getSource() & InputDevice.SOURCE_MOUSE) == InputDevice.SOURCE_MOUSE) ? Mouse.MOUSE_HW_INPUT_MOUSE : + int hwMouseEvent = ((event.getSource() & InputDevice.SOURCE_MOUSE) == InputDevice.SOURCE_MOUSE || Globals.ForceHardwareMouse) ? Mouse.MOUSE_HW_INPUT_MOUSE : + ((event.getSource() & InputDevice.SOURCE_STYLUS) == InputDevice.SOURCE_STYLUS) ? Mouse.MOUSE_HW_INPUT_STYLUS : Mouse.MOUSE_HW_INPUT_FINGER; if( ExternalMouseDetected != hwMouseEvent ) { diff --git a/project/java/translations/values/strings.xml b/project/java/translations/values/strings.xml index 834ce24d7..74ca529f0 100644 --- a/project/java/translations/values/strings.xml +++ b/project/java/translations/values/strings.xml @@ -163,6 +163,7 @@ Mouse emulation mode Display size for mouse emulation + Desktop, no emulation Large (tablets) Small, magnifying glass Small, touchpad mode diff --git a/project/jni/application/ninslash/src b/project/jni/application/ninslash/src index 721417db3..9b2cee79d 160000 --- a/project/jni/application/ninslash/src +++ b/project/jni/application/ninslash/src @@ -1 +1 @@ -Subproject commit 721417db327fc76628adcf673b068a7a75810d49 +Subproject commit 9b2cee79d1e00fb3a19953c43b2e8a1e55538d63 diff --git a/project/jni/application/openttd/src b/project/jni/application/openttd/src index f03484e84..b394d53be 160000 --- a/project/jni/application/openttd/src +++ b/project/jni/application/openttd/src @@ -1 +1 @@ -Subproject commit f03484e84ba64a806d59da435d68398bda32caf9 +Subproject commit b394d53be82ec280e9c0909ce42779e6625c107c