SDL: option for desktop mouse mode / no touch filtering, added back backspace key handler hack to text input window

This commit is contained in:
Sergii Pylypenko
2017-01-27 22:24:08 +02:00
parent 1b8e4d3414
commit fc3265c289
8 changed files with 30 additions and 11 deletions

View File

@@ -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;

View File

@@ -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;
}

View File

@@ -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;

View File

@@ -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 )
{

View File

@@ -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 )
{

View File

@@ -163,6 +163,7 @@
<string name="display_size_mouse">Mouse emulation mode</string>
<string name="display_size">Display size for mouse emulation</string>
<string name="display_size_desktop">Desktop, no emulation</string>
<string name="display_size_large">Large (tablets)</string>
<string name="display_size_small">Small, magnifying glass</string>
<string name="display_size_small_touchpad">Small, touchpad mode</string>