ANDROID: Add Control tab for mouse pointer speed
and joystick deadzone. By supporting kFeatureKbdMouseSpeed and kFeatureJoystickDeadzone and registering default values Both of these config settings (kbdmouse_speed, joystick_deadzone) factor in virtual mouse movement. Helps handle virtual mouse pointer speed when controlled with DPAD or is too fast for the user
This commit is contained in:
parent
969f41ab93
commit
077460788d
3 changed files with 30 additions and 14 deletions
|
@ -470,6 +470,10 @@ void OSystem_Android::initBackend() {
|
||||||
ConfMan.registerDefault("aspect_ratio", true);
|
ConfMan.registerDefault("aspect_ratio", true);
|
||||||
ConfMan.registerDefault("filtering", false);
|
ConfMan.registerDefault("filtering", false);
|
||||||
ConfMan.registerDefault("autosave_period", 0);
|
ConfMan.registerDefault("autosave_period", 0);
|
||||||
|
// slow down a bit virtual mouse speed (typical default seems to be "3") - eg. when controlling the virtual mouse cursor with DPAD keys
|
||||||
|
// Also see declaration of support for feature kFeatureKbdMouseSpeed bellow
|
||||||
|
ConfMan.registerDefault("kbdmouse_speed", 2);
|
||||||
|
ConfMan.registerDefault("joystick_deadzone", 3);
|
||||||
|
|
||||||
// explicitly set this, since fullscreen cannot be changed from GUI
|
// explicitly set this, since fullscreen cannot be changed from GUI
|
||||||
// and for Android it should be persisted (and ConfMan.hasKey("fullscreen") check should return true for it)
|
// and for Android it should be persisted (and ConfMan.hasKey("fullscreen") check should return true for it)
|
||||||
|
@ -623,7 +627,9 @@ bool OSystem_Android::hasFeature(Feature f) {
|
||||||
return false;
|
return false;
|
||||||
if (f == kFeatureVirtualKeyboard ||
|
if (f == kFeatureVirtualKeyboard ||
|
||||||
f == kFeatureOpenUrl ||
|
f == kFeatureOpenUrl ||
|
||||||
f == kFeatureClipboardSupport) {
|
f == kFeatureClipboardSupport ||
|
||||||
|
f == kFeatureKbdMouseSpeed ||
|
||||||
|
f == kFeatureJoystickDeadzone) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
/* Even if we are using the 2D graphics manager,
|
/* Even if we are using the 2D graphics manager,
|
||||||
|
|
|
@ -1154,6 +1154,7 @@ void OSystem_Android::pushEvent(int type, int arg1, int arg2, int arg3,
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case JE_MOUSE_WHEEL_UP:
|
case JE_MOUSE_WHEEL_UP:
|
||||||
|
// Rolling wheel upwards
|
||||||
e.type = Common::EVENT_WHEELUP;
|
e.type = Common::EVENT_WHEELUP;
|
||||||
e.mouse.x = arg1;
|
e.mouse.x = arg1;
|
||||||
e.mouse.y = arg2;
|
e.mouse.y = arg2;
|
||||||
|
@ -1164,6 +1165,7 @@ void OSystem_Android::pushEvent(int type, int arg1, int arg2, int arg3,
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case JE_MOUSE_WHEEL_DOWN:
|
case JE_MOUSE_WHEEL_DOWN:
|
||||||
|
// Rolling wheel downwards
|
||||||
e.type = Common::EVENT_WHEELDOWN;
|
e.type = Common::EVENT_WHEELDOWN;
|
||||||
e.mouse.x = arg1;
|
e.mouse.x = arg1;
|
||||||
e.mouse.y = arg2;
|
e.mouse.y = arg2;
|
||||||
|
|
|
@ -68,31 +68,36 @@ public class ScummVMEventsModern extends ScummVMEventsBase {
|
||||||
private float repeatingX = 0.0f;
|
private float repeatingX = 0.0f;
|
||||||
private float repeatingY = 0.0f;
|
private float repeatingY = 0.0f;
|
||||||
|
|
||||||
private static float getCenteredAxis(MotionEvent event, InputDevice device, int axis, int historyPos) {
|
private static float getCenteredAxis(MotionEvent event, InputDevice device, int axisId, int historyPos) {
|
||||||
final InputDevice.MotionRange range = device.getMotionRange(axis, event.getSource());
|
final InputDevice.MotionRange range = device.getMotionRange(axisId, event.getSource());
|
||||||
final int actionPointerIndex = event.getActionIndex();
|
final int actionPointerIndex = event.getActionIndex();
|
||||||
|
|
||||||
// A joystick at rest does not always report an absolute position of
|
// A joystick at rest does not always report an absolute position of
|
||||||
// (0,0). Use the getFlat() method to determine the range of values
|
// (0,0). Use the getFlat() method to determine the range of values
|
||||||
// bounding the joystick axis center.
|
// bounding the joystick axis center.
|
||||||
if (range != null) {
|
if (range != null) {
|
||||||
final float flat = range.getFlat();
|
final float axisFlat = range.getFlat();
|
||||||
|
final float axisMin = range.getMin();
|
||||||
|
// final float axisMax = range.getMax();
|
||||||
|
final float axisRange = range.getRange();
|
||||||
|
// final float axisRes = range.getResolution();
|
||||||
|
// final float axisFuzz = range.getFuzz();
|
||||||
|
|
||||||
// if (axis == MotionEvent.AXIS_X
|
// if (axisId == MotionEvent.AXIS_X
|
||||||
// || axis == MotionEvent.AXIS_HAT_X
|
// || axisId == MotionEvent.AXIS_HAT_X
|
||||||
// || axis == MotionEvent.AXIS_Z) {
|
// || axisId == MotionEvent.AXIS_Z) {
|
||||||
// Log.d(ScummVM.LOG_TAG, "Flat X= " + flat);
|
// Log.d(ScummVM.LOG_TAG, "Flat X= " + axisFlat);
|
||||||
// } else {
|
// } else {
|
||||||
// Log.d(ScummVM.LOG_TAG, "Flat Y= " + flat);
|
// Log.d(ScummVM.LOG_TAG, "Flat Y= " + axisFlat);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
float axisVal = (historyPos < 0) ? event.getAxisValue( range.getAxis(), actionPointerIndex) : event.getHistoricalAxisValue( range.getAxis(), actionPointerIndex, historyPos);
|
float axisVal = (historyPos < 0) ? event.getAxisValue( axisId, actionPointerIndex) : event.getHistoricalAxisValue( axisId, actionPointerIndex, historyPos);
|
||||||
// Normalize
|
// Normalize
|
||||||
final float value = (axisVal - range.getMin() ) / range.getRange() * 2.0f - 1.0f;
|
final float value = (axisVal - axisMin ) / axisRange * 2.0f - 1.0f;
|
||||||
|
|
||||||
// Ignore axis values that are within the 'flat' region of the
|
// Ignore axis values that are within the 'flat' region of the
|
||||||
// joystick axis center.
|
// joystick axis center.
|
||||||
if (Math.abs(value) > flat) {
|
if (Math.abs(value) > axisFlat) {
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -205,11 +210,14 @@ public class ScummVMEventsModern extends ScummVMEventsBase {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else if ((event.getSource() & InputDevice.SOURCE_CLASS_POINTER) != 0) {
|
} else if ((event.getSource() & InputDevice.SOURCE_CLASS_POINTER) != 0) {
|
||||||
// TODO Check if we need to handle other cases of InputDevice SOURCE_CLASS_POINTER for GenericMotionEvent, that are not ACTION_SCROLL
|
|
||||||
//Log.d(ScummVM.LOG_TAG, "MOUSE PHYSICAL POINTER - onGenericMotionEvent(m) ");
|
//Log.d(ScummVM.LOG_TAG, "MOUSE PHYSICAL POINTER - onGenericMotionEvent(m) ");
|
||||||
//
|
//
|
||||||
// Check that the event might be a mouse scroll wheel
|
// Check that the event might be a mouse scroll wheel (ACTION_SCROLL)
|
||||||
// Code inspired from https://stackoverflow.com/a/33086042
|
// Code inspired from https://stackoverflow.com/a/33086042
|
||||||
|
//
|
||||||
|
// NOTE Other GenericMotionEvent are also triggered for InputDevice of SOURCE_CLASS_POINTER (eg. physical mouse).
|
||||||
|
// These seem to be for button down/up events, which are handled along with pushing a JE_MOVE event
|
||||||
|
// in MouseHelper's onMouseEvent() called from ScummVMEventsBase onTouch().
|
||||||
switch (event.getActionMasked()) {
|
switch (event.getActionMasked()) {
|
||||||
case MotionEvent.ACTION_SCROLL:
|
case MotionEvent.ACTION_SCROLL:
|
||||||
//Log.d(ScummVM.LOG_TAG, "MOUSE PHYSICAL POINTER - ACTION SCROLL");
|
//Log.d(ScummVM.LOG_TAG, "MOUSE PHYSICAL POINTER - ACTION SCROLL");
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue