mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-23 06:09:50 -06:00
Android: add an option to recenter IR after every pointer interaction
This commit is contained in:
@ -98,9 +98,10 @@ public final class EmulationActivity extends AppCompatActivity
|
|||||||
MENU_ACTION_SAVE_SLOT6, MENU_ACTION_LOAD_SLOT1, MENU_ACTION_LOAD_SLOT2,
|
MENU_ACTION_SAVE_SLOT6, MENU_ACTION_LOAD_SLOT1, MENU_ACTION_LOAD_SLOT2,
|
||||||
MENU_ACTION_LOAD_SLOT3, MENU_ACTION_LOAD_SLOT4, MENU_ACTION_LOAD_SLOT5,
|
MENU_ACTION_LOAD_SLOT3, MENU_ACTION_LOAD_SLOT4, MENU_ACTION_LOAD_SLOT5,
|
||||||
MENU_ACTION_LOAD_SLOT6, MENU_ACTION_EXIT, MENU_ACTION_CHANGE_DISC,
|
MENU_ACTION_LOAD_SLOT6, MENU_ACTION_EXIT, MENU_ACTION_CHANGE_DISC,
|
||||||
MENU_ACTION_RESET_OVERLAY, MENU_SET_IR_MODE, MENU_SET_IR_SENSITIVITY,
|
MENU_ACTION_RESET_OVERLAY, MENU_SET_IR_RECENTER, MENU_SET_IR_MODE,
|
||||||
MENU_ACTION_CHOOSE_DOUBLETAP, MENU_ACTION_MOTION_CONTROLS, MENU_ACTION_PAUSE_EMULATION,
|
MENU_SET_IR_SENSITIVITY, MENU_ACTION_CHOOSE_DOUBLETAP, MENU_ACTION_MOTION_CONTROLS,
|
||||||
MENU_ACTION_UNPAUSE_EMULATION, MENU_ACTION_OVERLAY_CONTROLS, MENU_ACTION_SETTINGS})
|
MENU_ACTION_PAUSE_EMULATION, MENU_ACTION_UNPAUSE_EMULATION, MENU_ACTION_OVERLAY_CONTROLS,
|
||||||
|
MENU_ACTION_SETTINGS})
|
||||||
public @interface MenuAction
|
public @interface MenuAction
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@ -132,14 +133,15 @@ public final class EmulationActivity extends AppCompatActivity
|
|||||||
public static final int MENU_ACTION_JOYSTICK_REL_CENTER = 24;
|
public static final int MENU_ACTION_JOYSTICK_REL_CENTER = 24;
|
||||||
public static final int MENU_ACTION_RUMBLE = 25;
|
public static final int MENU_ACTION_RUMBLE = 25;
|
||||||
public static final int MENU_ACTION_RESET_OVERLAY = 26;
|
public static final int MENU_ACTION_RESET_OVERLAY = 26;
|
||||||
public static final int MENU_SET_IR_MODE = 27;
|
public static final int MENU_SET_IR_RECENTER = 27;
|
||||||
public static final int MENU_SET_IR_SENSITIVITY = 28;
|
public static final int MENU_SET_IR_MODE = 28;
|
||||||
public static final int MENU_ACTION_CHOOSE_DOUBLETAP = 29;
|
public static final int MENU_SET_IR_SENSITIVITY = 29;
|
||||||
public static final int MENU_ACTION_MOTION_CONTROLS = 30;
|
public static final int MENU_ACTION_CHOOSE_DOUBLETAP = 30;
|
||||||
public static final int MENU_ACTION_PAUSE_EMULATION = 31;
|
public static final int MENU_ACTION_MOTION_CONTROLS = 31;
|
||||||
public static final int MENU_ACTION_UNPAUSE_EMULATION = 32;
|
public static final int MENU_ACTION_PAUSE_EMULATION = 32;
|
||||||
public static final int MENU_ACTION_OVERLAY_CONTROLS = 33;
|
public static final int MENU_ACTION_UNPAUSE_EMULATION = 33;
|
||||||
public static final int MENU_ACTION_SETTINGS = 34;
|
public static final int MENU_ACTION_OVERLAY_CONTROLS = 34;
|
||||||
|
public static final int MENU_ACTION_SETTINGS = 35;
|
||||||
|
|
||||||
private static final SparseIntArray buttonsActionsMap = new SparseIntArray();
|
private static final SparseIntArray buttonsActionsMap = new SparseIntArray();
|
||||||
|
|
||||||
@ -158,6 +160,8 @@ public final class EmulationActivity extends AppCompatActivity
|
|||||||
buttonsActionsMap.append(R.id.menu_emulation_rumble, EmulationActivity.MENU_ACTION_RUMBLE);
|
buttonsActionsMap.append(R.id.menu_emulation_rumble, EmulationActivity.MENU_ACTION_RUMBLE);
|
||||||
buttonsActionsMap
|
buttonsActionsMap
|
||||||
.append(R.id.menu_emulation_reset_overlay, EmulationActivity.MENU_ACTION_RESET_OVERLAY);
|
.append(R.id.menu_emulation_reset_overlay, EmulationActivity.MENU_ACTION_RESET_OVERLAY);
|
||||||
|
buttonsActionsMap.append(R.id.menu_emulation_ir_recenter,
|
||||||
|
EmulationActivity.MENU_SET_IR_RECENTER);
|
||||||
buttonsActionsMap.append(R.id.menu_emulation_set_ir_mode,
|
buttonsActionsMap.append(R.id.menu_emulation_set_ir_mode,
|
||||||
EmulationActivity.MENU_SET_IR_MODE);
|
EmulationActivity.MENU_SET_IR_MODE);
|
||||||
buttonsActionsMap.append(R.id.menu_emulation_set_ir_sensitivity,
|
buttonsActionsMap.append(R.id.menu_emulation_set_ir_sensitivity,
|
||||||
@ -482,6 +486,11 @@ public final class EmulationActivity extends AppCompatActivity
|
|||||||
.setChecked(BooleanSetting.MAIN_JOYSTICK_REL_CENTER.getBoolean(mSettings));
|
.setChecked(BooleanSetting.MAIN_JOYSTICK_REL_CENTER.getBoolean(mSettings));
|
||||||
menu.findItem(R.id.menu_emulation_rumble)
|
menu.findItem(R.id.menu_emulation_rumble)
|
||||||
.setChecked(BooleanSetting.MAIN_PHONE_RUMBLE.getBoolean(mSettings));
|
.setChecked(BooleanSetting.MAIN_PHONE_RUMBLE.getBoolean(mSettings));
|
||||||
|
if (wii)
|
||||||
|
{
|
||||||
|
menu.findItem(R.id.menu_emulation_ir_recenter)
|
||||||
|
.setChecked(BooleanSetting.MAIN_IR_ALWAYS_RECENTER.getBoolean(mSettings));
|
||||||
|
}
|
||||||
|
|
||||||
popup.setOnMenuItemClickListener(this::onOptionsItemSelected);
|
popup.setOnMenuItemClickListener(this::onOptionsItemSelected);
|
||||||
|
|
||||||
@ -520,6 +529,10 @@ public final class EmulationActivity extends AppCompatActivity
|
|||||||
item.setChecked(!item.isChecked());
|
item.setChecked(!item.isChecked());
|
||||||
toggleRumble(item.isChecked());
|
toggleRumble(item.isChecked());
|
||||||
break;
|
break;
|
||||||
|
case MENU_SET_IR_RECENTER:
|
||||||
|
item.setChecked(!item.isChecked());
|
||||||
|
toggleRecenter(item.isChecked());
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -698,6 +711,12 @@ public final class EmulationActivity extends AppCompatActivity
|
|||||||
Rumble.setPhoneVibrator(state, this);
|
Rumble.setPhoneVibrator(state, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void toggleRecenter(boolean state)
|
||||||
|
{
|
||||||
|
BooleanSetting.MAIN_IR_ALWAYS_RECENTER.setBoolean(mSettings, state);
|
||||||
|
mEmulationFragment.refreshOverlayPointer(mSettings);
|
||||||
|
}
|
||||||
|
|
||||||
private void editControlsPlacement()
|
private void editControlsPlacement()
|
||||||
{
|
{
|
||||||
if (mEmulationFragment.isConfiguringControls())
|
if (mEmulationFragment.isConfiguringControls())
|
||||||
|
@ -71,6 +71,8 @@ public enum BooleanSetting implements AbstractBooleanSetting
|
|||||||
"PhoneRumble", true),
|
"PhoneRumble", true),
|
||||||
MAIN_SHOW_INPUT_OVERLAY(Settings.FILE_DOLPHIN, Settings.SECTION_INI_ANDROID,
|
MAIN_SHOW_INPUT_OVERLAY(Settings.FILE_DOLPHIN, Settings.SECTION_INI_ANDROID,
|
||||||
"ShowInputOverlay", true),
|
"ShowInputOverlay", true),
|
||||||
|
MAIN_IR_ALWAYS_RECENTER(Settings.FILE_DOLPHIN, Settings.SECTION_INI_ANDROID,
|
||||||
|
"IRAlwaysRecenter", false),
|
||||||
|
|
||||||
MAIN_BUTTON_TOGGLE_GC_0(Settings.FILE_DOLPHIN, Settings.SECTION_INI_ANDROID_OVERLAY_BUTTONS,
|
MAIN_BUTTON_TOGGLE_GC_0(Settings.FILE_DOLPHIN, Settings.SECTION_INI_ANDROID_OVERLAY_BUTTONS,
|
||||||
"ButtonToggleGCButtonA", true),
|
"ButtonToggleGCButtonA", true),
|
||||||
|
@ -165,7 +165,8 @@ public final class InputOverlay extends SurfaceView implements OnTouchListener
|
|||||||
}
|
}
|
||||||
|
|
||||||
overlayPointer = new InputOverlayPointer(mSurfacePosition, doubleTapButton,
|
overlayPointer = new InputOverlayPointer(mSurfacePosition, doubleTapButton,
|
||||||
IntSetting.MAIN_IR_MODE.getIntGlobal());
|
IntSetting.MAIN_IR_MODE.getIntGlobal(),
|
||||||
|
BooleanSetting.MAIN_IR_ALWAYS_RECENTER.getBooleanGlobal());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -775,6 +776,7 @@ public final class InputOverlay extends SurfaceView implements OnTouchListener
|
|||||||
if (overlayPointer != null)
|
if (overlayPointer != null)
|
||||||
{
|
{
|
||||||
overlayPointer.setMode(IntSetting.MAIN_IR_MODE.getInt(settings));
|
overlayPointer.setMode(IntSetting.MAIN_IR_MODE.getInt(settings));
|
||||||
|
overlayPointer.setRecenter(BooleanSetting.MAIN_IR_ALWAYS_RECENTER.getBoolean(settings));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33,6 +33,7 @@ public class InputOverlayPointer
|
|||||||
private float mTouchStartY;
|
private float mTouchStartY;
|
||||||
|
|
||||||
private int mMode;
|
private int mMode;
|
||||||
|
private boolean mRecenter;
|
||||||
|
|
||||||
private boolean doubleTap = false;
|
private boolean doubleTap = false;
|
||||||
private int doubleTapButton;
|
private int doubleTapButton;
|
||||||
@ -48,10 +49,11 @@ public class InputOverlayPointer
|
|||||||
DOUBLE_TAP_OPTIONS.add(NativeLibrary.ButtonType.CLASSIC_BUTTON_A);
|
DOUBLE_TAP_OPTIONS.add(NativeLibrary.ButtonType.CLASSIC_BUTTON_A);
|
||||||
}
|
}
|
||||||
|
|
||||||
public InputOverlayPointer(Rect surfacePosition, int button, int mode)
|
public InputOverlayPointer(Rect surfacePosition, int button, int mode, boolean recenter)
|
||||||
{
|
{
|
||||||
doubleTapButton = button;
|
doubleTapButton = button;
|
||||||
mMode = mode;
|
mMode = mode;
|
||||||
|
mRecenter = recenter;
|
||||||
|
|
||||||
mGameCenterX = (surfacePosition.left + surfacePosition.right) / 2.0f;
|
mGameCenterX = (surfacePosition.left + surfacePosition.right) / 2.0f;
|
||||||
mGameCenterY = (surfacePosition.top + surfacePosition.bottom) / 2.0f;
|
mGameCenterY = (surfacePosition.top + surfacePosition.bottom) / 2.0f;
|
||||||
@ -97,6 +99,8 @@ public class InputOverlayPointer
|
|||||||
trackId = -1;
|
trackId = -1;
|
||||||
if (mMode == MODE_DRAG)
|
if (mMode == MODE_DRAG)
|
||||||
updateOldAxes();
|
updateOldAxes();
|
||||||
|
if (mRecenter)
|
||||||
|
reset();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -143,6 +147,11 @@ public class InputOverlayPointer
|
|||||||
oldaxes[1] = axes[1];
|
oldaxes[1] = axes[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void reset()
|
||||||
|
{
|
||||||
|
axes[0] = axes[1] = oldaxes[0] = oldaxes[1] = 0f;
|
||||||
|
}
|
||||||
|
|
||||||
public float[] getAxisValues()
|
public float[] getAxisValues()
|
||||||
{
|
{
|
||||||
float[] iraxes = {0f, 0f, 0f, 0f};
|
float[] iraxes = {0f, 0f, 0f, 0f};
|
||||||
@ -159,4 +168,9 @@ public class InputOverlayPointer
|
|||||||
if (mode == MODE_DRAG)
|
if (mode == MODE_DRAG)
|
||||||
updateOldAxes();
|
updateOldAxes();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setRecenter(boolean recenter)
|
||||||
|
{
|
||||||
|
mRecenter = recenter;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -38,6 +38,10 @@
|
|||||||
android:id="@+id/menu_emulation_ir_group"
|
android:id="@+id/menu_emulation_ir_group"
|
||||||
android:title="@string/emulation_ir_group">
|
android:title="@string/emulation_ir_group">
|
||||||
<menu>
|
<menu>
|
||||||
|
<item
|
||||||
|
android:id="@+id/menu_emulation_ir_recenter"
|
||||||
|
android:checkable="true"
|
||||||
|
android:title="@string/emulation_ir_recenter"/>
|
||||||
<item
|
<item
|
||||||
android:id="@+id/menu_emulation_set_ir_mode"
|
android:id="@+id/menu_emulation_set_ir_mode"
|
||||||
android:title="@string/emulation_ir_mode"/>
|
android:title="@string/emulation_ir_mode"/>
|
||||||
|
@ -517,6 +517,7 @@ It can efficiently compress both junk data and encrypted Wii data.
|
|||||||
<string name="emulation_menu_help">Press Back to access the menu.\nLong press Back to exit emulation.</string>
|
<string name="emulation_menu_help">Press Back to access the menu.\nLong press Back to exit emulation.</string>
|
||||||
<string name="emulation_touch_overlay_reset">Reset Overlay</string>
|
<string name="emulation_touch_overlay_reset">Reset Overlay</string>
|
||||||
<string name="emulation_ir_group">Touch IR Pointer</string>
|
<string name="emulation_ir_group">Touch IR Pointer</string>
|
||||||
|
<string name="emulation_ir_recenter">Always recenter</string>
|
||||||
<string name="emulation_ir_mode">IR Mode</string>
|
<string name="emulation_ir_mode">IR Mode</string>
|
||||||
<string name="emulation_ir_sensitivity">IR Sensitivity</string>
|
<string name="emulation_ir_sensitivity">IR Sensitivity</string>
|
||||||
<string name="emulation_choose_doubletap">Double tap button</string>
|
<string name="emulation_choose_doubletap">Double tap button</string>
|
||||||
|
@ -38,10 +38,10 @@ bool IsSettingSaveable(const Config::Location& config_location)
|
|||||||
// TODO: Kill the current Android controller mappings system
|
// TODO: Kill the current Android controller mappings system
|
||||||
if (config_location.section == "Android")
|
if (config_location.section == "Android")
|
||||||
{
|
{
|
||||||
static constexpr std::array<const char*, 9> android_setting_saveable = {
|
static constexpr std::array<const char*, 10> android_setting_saveable = {
|
||||||
"ControlScale", "ControlOpacity", "EmulationOrientation", "JoystickRelCenter",
|
"ControlScale", "ControlOpacity", "EmulationOrientation", "JoystickRelCenter",
|
||||||
"LastPlatformTab", "MotionControls", "PhoneRumble", "ShowInputOverlay",
|
"LastPlatformTab", "MotionControls", "PhoneRumble", "ShowInputOverlay",
|
||||||
"IRMode"};
|
"IRMode", "IRAlwaysRecenter"};
|
||||||
|
|
||||||
return std::any_of(
|
return std::any_of(
|
||||||
android_setting_saveable.cbegin(), android_setting_saveable.cend(),
|
android_setting_saveable.cbegin(), android_setting_saveable.cend(),
|
||||||
|
Reference in New Issue
Block a user