Android: Add quick load/save touchscreen buttons

This commit is contained in:
Connor McLaughlin 2021-06-07 18:36:07 +10:00
parent 20afc1c4a1
commit 81da9be2d1
8 changed files with 127 additions and 2 deletions

View File

@ -19,6 +19,8 @@ public final class TouchscreenControllerButtonView extends View {
FAST_FORWARD,
ANALOG_TOGGLE,
OPEN_PAUSE_MENU,
QUICK_LOAD,
QUICK_SAVE
}
private Drawable mUnpressedDrawable;
@ -149,9 +151,10 @@ public final class TouchscreenControllerButtonView extends View {
switch (mHotkey)
{
case FAST_FORWARD:
case FAST_FORWARD: {
hi.setFastForwardEnabled(mPressed);
break;
}
break;
case ANALOG_TOGGLE: {
if (!mPressed)
@ -165,6 +168,18 @@ public final class TouchscreenControllerButtonView extends View {
}
break;
case QUICK_LOAD: {
if (!mPressed)
hi.loadState(false, 0);
}
break;
case QUICK_SAVE: {
if (!mPressed)
hi.saveState(false, 0);
}
break;
case NONE:
default:
break;

View File

@ -328,6 +328,10 @@ public class TouchscreenControllerView extends FrameLayout {
TouchscreenControllerButtonView.Hotkey.ANALOG_TOGGLE, false);
linkHotkeyButton(mMainView, R.id.controller_button_pause, "OpenPauseMenu",
TouchscreenControllerButtonView.Hotkey.OPEN_PAUSE_MENU, true);
linkHotkeyButton(mMainView, R.id.controller_button_quick_load, "QuickLoad",
TouchscreenControllerButtonView.Hotkey.QUICK_LOAD, false);
linkHotkeyButton(mMainView, R.id.controller_button_quick_save, "QuickSave",
TouchscreenControllerButtonView.Hotkey.QUICK_SAVE, false);
reloadButtonSettings();
updateOpacity();

View File

@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="#4d4d4d"
android:pathData="M14,12c0,-1.1 -0.9,-2 -2,-2s-2,0.9 -2,2 0.9,2 2,2 2,-0.9 2,-2zM12,3c-4.97,0 -9,4.03 -9,9L0,12l4,4 4,-4L5,12c0,-3.87 3.13,-7 7,-7s7,3.13 7,7 -3.13,7 -7,7c-1.51,0 -2.91,-0.49 -4.06,-1.3l-1.42,1.44C8.04,20.3 9.94,21 12,21c4.97,0 9,-4.03 9,-9s-4.03,-9 -9,-9z"/>
</vector>

View File

@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="#4d4d4d"
android:pathData="M17,3L5,3c-1.11,0 -2,0.9 -2,2v14c0,1.1 0.89,2 2,2h14c1.1,0 2,-0.9 2,-2L21,7l-4,-4zM12,19c-1.66,0 -3,-1.34 -3,-3s1.34,-3 3,-3 3,1.34 3,3 -1.34,3 -3,3zM15,9L5,9L5,5h10v4z"/>
</vector>

View File

@ -179,6 +179,28 @@
app:pressedDrawable="@drawable/ic_controller_pause_button"
app:unpressedDrawable="@drawable/ic_controller_pause_button" />
<com.github.stenzek.duckstation.TouchscreenControllerButtonView
android:id="@+id/controller_button_quick_load"
android:layout_width="35dp"
android:layout_height="35dp"
android:layout_marginTop="20dp"
android:layout_marginLeft="20dp"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:pressedDrawable="@drawable/ic_controller_quick_load_button"
app:unpressedDrawable="@drawable/ic_controller_quick_load_button" />
<com.github.stenzek.duckstation.TouchscreenControllerButtonView
android:id="@+id/controller_button_quick_save"
android:layout_width="35dp"
android:layout_height="35dp"
android:layout_marginTop="20dp"
android:layout_marginLeft="75dp"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:pressedDrawable="@drawable/ic_controller_quick_save_button"
app:unpressedDrawable="@drawable/ic_controller_quick_save_button" />
<com.github.stenzek.duckstation.TouchscreenControllerButtonView
android:id="@+id/controller_button_autofire_1"
android:layout_width="35dp"

View File

@ -201,6 +201,28 @@
app:pressedDrawable="@drawable/ic_controller_pause_button"
app:unpressedDrawable="@drawable/ic_controller_pause_button" />
<com.github.stenzek.duckstation.TouchscreenControllerButtonView
android:id="@+id/controller_button_quick_load"
android:layout_width="35dp"
android:layout_height="35dp"
android:layout_marginTop="20dp"
android:layout_marginLeft="20dp"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:pressedDrawable="@drawable/ic_controller_quick_load_button"
app:unpressedDrawable="@drawable/ic_controller_quick_load_button" />
<com.github.stenzek.duckstation.TouchscreenControllerButtonView
android:id="@+id/controller_button_quick_save"
android:layout_width="35dp"
android:layout_height="35dp"
android:layout_marginTop="20dp"
android:layout_marginLeft="75dp"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:pressedDrawable="@drawable/ic_controller_quick_save_button"
app:unpressedDrawable="@drawable/ic_controller_quick_save_button" />
<com.github.stenzek.duckstation.TouchscreenControllerButtonView
android:id="@+id/controller_button_autofire_1"
android:layout_width="35dp"

View File

@ -163,6 +163,28 @@
app:pressedDrawable="@drawable/ic_controller_pause_button"
app:unpressedDrawable="@drawable/ic_controller_pause_button" />
<com.github.stenzek.duckstation.TouchscreenControllerButtonView
android:id="@+id/controller_button_quick_load"
android:layout_width="35dp"
android:layout_height="35dp"
android:layout_marginTop="20dp"
android:layout_marginLeft="20dp"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:pressedDrawable="@drawable/ic_controller_quick_load_button"
app:unpressedDrawable="@drawable/ic_controller_quick_load_button" />
<com.github.stenzek.duckstation.TouchscreenControllerButtonView
android:id="@+id/controller_button_quick_save"
android:layout_width="35dp"
android:layout_height="35dp"
android:layout_marginTop="20dp"
android:layout_marginLeft="75dp"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:pressedDrawable="@drawable/ic_controller_quick_save_button"
app:unpressedDrawable="@drawable/ic_controller_quick_save_button" />
<com.github.stenzek.duckstation.TouchscreenControllerButtonView
android:id="@+id/controller_button_autofire_1"
android:layout_width="35dp"

View File

@ -62,6 +62,28 @@
app:pressedDrawable="@drawable/ic_controller_pause_button"
app:unpressedDrawable="@drawable/ic_controller_pause_button" />
<com.github.stenzek.duckstation.TouchscreenControllerButtonView
android:id="@+id/controller_button_quick_load"
android:layout_width="35dp"
android:layout_height="35dp"
android:layout_marginTop="20dp"
android:layout_marginLeft="20dp"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:pressedDrawable="@drawable/ic_controller_quick_load_button"
app:unpressedDrawable="@drawable/ic_controller_quick_load_button" />
<com.github.stenzek.duckstation.TouchscreenControllerButtonView
android:id="@+id/controller_button_quick_save"
android:layout_width="35dp"
android:layout_height="35dp"
android:layout_marginTop="20dp"
android:layout_marginLeft="75dp"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:pressedDrawable="@drawable/ic_controller_quick_save_button"
app:unpressedDrawable="@drawable/ic_controller_quick_save_button" />
<com.github.stenzek.duckstation.TouchscreenControllerButtonView
android:id="@+id/controller_button_autofire_1"
android:layout_width="35dp"