diff --git a/android/app/src/main/java/com/github/stenzek/duckstation/TouchscreenControllerButtonView.java b/android/app/src/main/java/com/github/stenzek/duckstation/TouchscreenControllerButtonView.java index 373e8a8ae..e48f9afeb 100644 --- a/android/app/src/main/java/com/github/stenzek/duckstation/TouchscreenControllerButtonView.java +++ b/android/app/src/main/java/com/github/stenzek/duckstation/TouchscreenControllerButtonView.java @@ -12,12 +12,19 @@ import android.view.View; * TODO: document your custom view class. */ public final class TouchscreenControllerButtonView extends View { + public enum Hotkey + { + NONE, + FAST_FORWARD + } + private Drawable mUnpressedDrawable; private Drawable mPressedDrawable; private boolean mPressed = false; private boolean mHapticFeedback = false; private int mControllerIndex = -1; private int mButtonCode = -1; + private Hotkey mHotkey = Hotkey.NONE; private String mConfigName; public TouchscreenControllerButtonView(Context context) { @@ -95,6 +102,10 @@ public final class TouchscreenControllerButtonView extends View { mButtonCode = code; } + public void setHotkey(Hotkey hotkey) { + mHotkey = hotkey; + } + public void setConfigName(String name) { mConfigName = name; } @@ -110,6 +121,17 @@ public final class TouchscreenControllerButtonView extends View { private void updateControllerState() { if (mButtonCode >= 0) AndroidHostInterface.getInstance().setControllerButtonState(mControllerIndex, mButtonCode, mPressed); + + switch (mHotkey) + { + case FAST_FORWARD: + AndroidHostInterface.getInstance().setFastForwardEnabled(mPressed); + break; + + case NONE: + default: + break; + } } public Drawable getPressedDrawable() { diff --git a/android/app/src/main/java/com/github/stenzek/duckstation/TouchscreenControllerView.java b/android/app/src/main/java/com/github/stenzek/duckstation/TouchscreenControllerView.java index 6ac5a724f..7c0b3e23a 100644 --- a/android/app/src/main/java/com/github/stenzek/duckstation/TouchscreenControllerView.java +++ b/android/app/src/main/java/com/github/stenzek/duckstation/TouchscreenControllerView.java @@ -204,6 +204,9 @@ public class TouchscreenControllerView extends FrameLayout { linkAxisToButtons(mMainView, R.id.controller_axis_left, "LeftAxis", ""); linkAxis(mMainView, R.id.controller_axis_right, "RightAxis", "Right"); + + linkHotkeyButton(mMainView, R.id.controller_button_fast_forward, TouchscreenControllerButtonView.Hotkey.FAST_FORWARD); + reloadButtonTranslation(); requestLayout(); } @@ -262,6 +265,15 @@ public class TouchscreenControllerView extends FrameLayout { return true; } + private void linkHotkeyButton(View view, int id, TouchscreenControllerButtonView.Hotkey hotkey) { + TouchscreenControllerButtonView buttonView = (TouchscreenControllerButtonView) view.findViewById(id); + if (buttonView == null) + return; + + buttonView.setHotkey(hotkey); + mButtonViews.add(buttonView); + } + private int dpToPixels(float dp) { return Math.round(TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dp, getResources().getDisplayMetrics())); } diff --git a/android/app/src/main/res/drawable/ic_controller_fast_forward.xml b/android/app/src/main/res/drawable/ic_controller_fast_forward.xml new file mode 100644 index 000000000..37e89e29b --- /dev/null +++ b/android/app/src/main/res/drawable/ic_controller_fast_forward.xml @@ -0,0 +1,17 @@ + + + + diff --git a/android/app/src/main/res/drawable/ic_controller_fast_forward_pressed.xml b/android/app/src/main/res/drawable/ic_controller_fast_forward_pressed.xml new file mode 100644 index 000000000..2a505aad8 --- /dev/null +++ b/android/app/src/main/res/drawable/ic_controller_fast_forward_pressed.xml @@ -0,0 +1,17 @@ + + + + diff --git a/android/app/src/main/res/layout/layout_touchscreen_controller_analog_stick.xml b/android/app/src/main/res/layout/layout_touchscreen_controller_analog_stick.xml index 3129a0f18..f1482c2e0 100644 --- a/android/app/src/main/res/layout/layout_touchscreen_controller_analog_stick.xml +++ b/android/app/src/main/res/layout/layout_touchscreen_controller_analog_stick.xml @@ -55,7 +55,7 @@ android:id="@+id/controller_button_start" android:layout_width="40dp" android:layout_height="25dp" - android:layout_marginStart="80dp" + android:layout_marginStart="70dp" android:layout_marginBottom="8dp" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent" @@ -68,7 +68,7 @@ android:id="@+id/controller_button_select" android:layout_width="40dp" android:layout_height="25dp" - android:layout_marginEnd="50dp" + android:layout_marginEnd="70dp" android:layout_marginBottom="8dp" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent" @@ -133,4 +133,16 @@ android:paddingRight="20dp" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintStart_toStartOf="parent" /> + + \ No newline at end of file diff --git a/android/app/src/main/res/layout/layout_touchscreen_controller_analog_sticks.xml b/android/app/src/main/res/layout/layout_touchscreen_controller_analog_sticks.xml index 891d4316f..9b53250f6 100644 --- a/android/app/src/main/res/layout/layout_touchscreen_controller_analog_sticks.xml +++ b/android/app/src/main/res/layout/layout_touchscreen_controller_analog_sticks.xml @@ -55,7 +55,7 @@ android:id="@+id/controller_button_start" android:layout_width="40dp" android:layout_height="25dp" - android:layout_marginStart="80dp" + android:layout_marginStart="70dp" android:layout_marginBottom="8dp" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent" @@ -68,7 +68,7 @@ android:id="@+id/controller_button_select" android:layout_width="40dp" android:layout_height="25dp" - android:layout_marginEnd="50dp" + android:layout_marginEnd="70dp" android:layout_marginBottom="8dp" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent" @@ -198,4 +198,16 @@ app:layout_constraintStart_toStartOf="parent" app:pressedDrawable="@drawable/ic_controller_up_button_pressed" app:unpressedDrawable="@drawable/ic_controller_up_button" /> + + \ No newline at end of file diff --git a/android/app/src/main/res/layout/layout_touchscreen_controller_digital.xml b/android/app/src/main/res/layout/layout_touchscreen_controller_digital.xml index dd1991f54..9970e1bf8 100644 --- a/android/app/src/main/res/layout/layout_touchscreen_controller_digital.xml +++ b/android/app/src/main/res/layout/layout_touchscreen_controller_digital.xml @@ -107,7 +107,7 @@ android:id="@+id/controller_button_start" android:layout_width="40dp" android:layout_height="25dp" - android:layout_marginStart="80dp" + android:layout_marginStart="70dp" android:layout_marginBottom="8dp" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent" @@ -120,7 +120,7 @@ android:id="@+id/controller_button_select" android:layout_width="40dp" android:layout_height="25dp" - android:layout_marginEnd="50dp" + android:layout_marginEnd="70dp" android:layout_marginBottom="8dp" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent" @@ -172,4 +172,16 @@ app:layout_constraintEnd_toEndOf="parent" app:pressedDrawable="@drawable/ic_controller_circle_button_pressed" app:unpressedDrawable="@drawable/ic_controller_circle_button" /> + + \ No newline at end of file