Android: add reset touch overlay
This commit is contained in:
parent
ab46f0cb82
commit
f05d85dfe4
|
@ -94,7 +94,8 @@ public final class EmulationActivity extends AppCompatActivity
|
|||
MENU_ACTION_SAVE_SLOT3, MENU_ACTION_SAVE_SLOT4, MENU_ACTION_SAVE_SLOT5,
|
||||
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_SLOT6, MENU_ACTION_EXIT, MENU_ACTION_CHANGE_DISC})
|
||||
MENU_ACTION_LOAD_SLOT6, MENU_ACTION_EXIT, MENU_ACTION_CHANGE_DISC,
|
||||
MENU_ACTION_RESET_OVERLAY})
|
||||
public @interface MenuAction
|
||||
{
|
||||
}
|
||||
|
@ -125,6 +126,7 @@ public final class EmulationActivity extends AppCompatActivity
|
|||
public static final int MENU_ACTION_CHANGE_DISC = 23;
|
||||
public static final int MENU_ACTION_JOYSTICK_REL_CENTER = 24;
|
||||
public static final int MENU_ACTION_RUMBLE = 25;
|
||||
public static final int MENU_ACTION_RESET_OVERLAY = 26;
|
||||
|
||||
|
||||
private static SparseIntArray buttonsActionsMap = new SparseIntArray();
|
||||
|
@ -165,6 +167,8 @@ public final class EmulationActivity extends AppCompatActivity
|
|||
buttonsActionsMap.append(R.id.menu_emulation_joystick_rel_center,
|
||||
EmulationActivity.MENU_ACTION_JOYSTICK_REL_CENTER);
|
||||
buttonsActionsMap.append(R.id.menu_emulation_rumble, EmulationActivity.MENU_ACTION_RUMBLE);
|
||||
buttonsActionsMap
|
||||
.append(R.id.menu_emulation_reset_overlay, EmulationActivity.MENU_ACTION_RESET_OVERLAY);
|
||||
}
|
||||
|
||||
public static void launch(FragmentActivity activity, GameFile gameFile, int position,
|
||||
|
@ -525,6 +529,11 @@ public final class EmulationActivity extends AppCompatActivity
|
|||
editControlsPlacement();
|
||||
break;
|
||||
|
||||
// Reset overlay placement
|
||||
case MENU_ACTION_RESET_OVERLAY:
|
||||
resetOverlay();
|
||||
break;
|
||||
|
||||
// Enable/Disable specific buttons or the entire input overlay.
|
||||
case MENU_ACTION_TOGGLE_CONTROLS:
|
||||
toggleControls();
|
||||
|
@ -833,6 +842,21 @@ public final class EmulationActivity extends AppCompatActivity
|
|||
|
||||
}
|
||||
|
||||
private void resetOverlay()
|
||||
{
|
||||
new AlertDialog.Builder(this)
|
||||
.setTitle(getString(R.string.emulation_touch_overlay_reset))
|
||||
.setPositiveButton(R.string.yes, (dialogInterface, i) ->
|
||||
{
|
||||
mEmulationFragment.resetInputOverlay();
|
||||
})
|
||||
.setNegativeButton(R.string.cancel, (dialogInterface, i) ->
|
||||
{
|
||||
})
|
||||
.create()
|
||||
.show();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean dispatchGenericMotionEvent(MotionEvent event)
|
||||
{
|
||||
|
|
|
@ -218,6 +218,11 @@ public final class EmulationFragment extends Fragment implements SurfaceHolder.C
|
|||
mInputOverlay.refreshControls();
|
||||
}
|
||||
|
||||
public void resetInputOverlay()
|
||||
{
|
||||
mInputOverlay.resetButtonPlacement();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void surfaceCreated(SurfaceHolder holder)
|
||||
{
|
||||
|
|
|
@ -638,6 +638,36 @@ public final class InputOverlay extends SurfaceView implements OnTouchListener
|
|||
invalidate();
|
||||
}
|
||||
|
||||
public void resetButtonPlacement()
|
||||
{
|
||||
boolean isLandscape =
|
||||
getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE;
|
||||
|
||||
// Values for these come from R.array.controllersEntries
|
||||
if (EmulationActivity.isGameCubeGame() || mPreferences.getInt("wiiController", 3) == 0)
|
||||
{
|
||||
if (isLandscape)
|
||||
gcDefaultOverlay();
|
||||
else
|
||||
gcPortraitDefaultOverlay();
|
||||
}
|
||||
else if (mPreferences.getInt("wiiController", 3) == 4)
|
||||
{
|
||||
if (isLandscape)
|
||||
wiiClassicDefaultOverlay();
|
||||
else
|
||||
wiiClassicPortraitDefaultOverlay();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (isLandscape)
|
||||
wiiDefaultOverlay();
|
||||
else
|
||||
wiiPortraitDefaultOverlay();
|
||||
}
|
||||
refreshControls();
|
||||
}
|
||||
|
||||
private void saveControlPosition(int sharedPrefsId, int x, int y, String orientation)
|
||||
{
|
||||
final SharedPreferences sPrefs = PreferenceManager.getDefaultSharedPreferences(getContext());
|
||||
|
|
|
@ -102,6 +102,10 @@
|
|||
android:id="@+id/menu_emulation_rumble"
|
||||
android:checkable="true"
|
||||
android:title="@string/emulation_control_rumble"/>
|
||||
|
||||
<item
|
||||
android:id="@+id/menu_emulation_reset_overlay"
|
||||
android:title="@string/emulation_touch_overlay_reset"/>
|
||||
</menu>
|
||||
</item>
|
||||
|
||||
|
|
|
@ -108,6 +108,9 @@
|
|||
android:id="@+id/menu_emulation_choose_controller"
|
||||
android:title="@string/emulation_choose_controller"/>
|
||||
|
||||
<item
|
||||
android:id="@+id/menu_emulation_reset_overlay"
|
||||
android:title="@string/emulation_touch_overlay_reset"/>
|
||||
</menu>
|
||||
</item>
|
||||
|
||||
|
|
|
@ -275,6 +275,7 @@
|
|||
<string name="emulation_choose_controller">Choose Controller</string>
|
||||
<string name="emulation_controller_changed">You may have to reload the game after changing extensions.</string>
|
||||
<string name="emulation_touch_button_help">To change the button layout, open the menu -> Configure Controls -> Edit Layout</string>
|
||||
<string name="emulation_touch_overlay_reset">Reset Overlay</string>
|
||||
|
||||
<!-- GC Adapter Menu-->
|
||||
<string name="gc_adapter_rumble">Enable Vibration</string>
|
||||
|
|
Loading…
Reference in New Issue