Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add Guide menu to on-screen virtual controller #1265

Merged
merged 5 commits into from
Jul 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,10 @@ private static AnalogStick createRightStick(
private static final int START_BACK_WIDTH = 12;
private static final int START_BACK_HEIGHT = 7;

// Make the Guide Menu be in the center of START and BACK menu
private static final int GUIDE_X = START_X-BACK_X;
private static final int GUIDE_Y = START_BACK_Y;

public static void createDefaultLayout(final VirtualController controller, final Context context) {

DisplayMetrics screen = context.getResources().getDisplayMetrics();
Expand Down Expand Up @@ -333,6 +337,16 @@ public static void createDefaultLayout(final VirtualController controller, final
);
}

if(config.showGuideButton){
controller.addElement(createDigitalButton(VirtualControllerElement.EID_GDB,
ControllerPacket.SPECIAL_BUTTON_FLAG, 0, 1, "GUIDE", -1, controller, context),
screenScale(GUIDE_X, height)+ rightDisplacement,
screenScale(GUIDE_Y, height),
screenScale(START_BACK_WIDTH, height),
screenScale(START_BACK_HEIGHT, height)
);
}

controller.setOpacity(config.oscOpacity);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public abstract class VirtualControllerElement extends View {
public static final int EID_RS = 13;
public static final int EID_LSB = 14;
public static final int EID_RSB = 15;
public static final int EID_GDB = 16;

protected VirtualController virtualController;
protected final int elementId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public enum FormatOption {
private static final String VIDEO_FORMAT_PREF_STRING = "video_format";
private static final String ONSCREEN_CONTROLLER_PREF_STRING = "checkbox_show_onscreen_controls";
private static final String ONLY_L3_R3_PREF_STRING = "checkbox_only_show_L3R3";
private static final String SHOW_GUIDE_BUTTON_PREF_STRING = "checkbox_show_guide_button";
private static final String LEGACY_DISABLE_FRAME_DROP_PREF_STRING = "checkbox_disable_frame_drop";
private static final String ENABLE_HDR_PREF_STRING = "checkbox_enable_hdr";
private static final String ENABLE_PIP_PREF_STRING = "checkbox_enable_pip";
Expand Down Expand Up @@ -75,6 +76,7 @@ public enum FormatOption {

private static final boolean ONSCREEN_CONTROLLER_DEFAULT = false;
private static final boolean ONLY_L3_R3_DEFAULT = false;
private static final boolean SHOW_GUIDE_BUTTON_DEFAULT = true;
private static final boolean DEFAULT_ENABLE_HDR = false;
private static final boolean DEFAULT_ENABLE_PIP = false;
private static final boolean DEFAULT_ENABLE_PERF_OVERLAY = false;
Expand Down Expand Up @@ -120,6 +122,7 @@ public enum FormatOption {
public boolean smallIconMode, multiController, usbDriver, flipFaceButtons;
public boolean onscreenController;
public boolean onlyL3R3;
public boolean showGuideButton;
public boolean enableHdr;
public boolean enablePip;
public boolean enablePerfOverlay;
Expand Down Expand Up @@ -548,6 +551,7 @@ else if (audioConfig.equals("51")) {
config.usbDriver = prefs.getBoolean(USB_DRIVER_PREF_SRING, DEFAULT_USB_DRIVER);
config.onscreenController = prefs.getBoolean(ONSCREEN_CONTROLLER_PREF_STRING, ONSCREEN_CONTROLLER_DEFAULT);
config.onlyL3R3 = prefs.getBoolean(ONLY_L3_R3_PREF_STRING, ONLY_L3_R3_DEFAULT);
config.showGuideButton = prefs.getBoolean(SHOW_GUIDE_BUTTON_PREF_STRING, SHOW_GUIDE_BUTTON_DEFAULT);
config.enableHdr = prefs.getBoolean(ENABLE_HDR_PREF_STRING, DEFAULT_ENABLE_HDR) && !isShieldAtvFirmwareWithBrokenHdr();
config.enablePip = prefs.getBoolean(ENABLE_PIP_PREF_STRING, DEFAULT_ENABLE_PIP);
config.enablePerfOverlay = prefs.getBoolean(ENABLE_PERF_OVERLAY_STRING, DEFAULT_ENABLE_PERF_OVERLAY);
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,8 @@
<string name="summary_checkbox_vibrate_osc">Vibrates your device to emulate rumble for the on-screen controls</string>
<string name="title_only_l3r3">Only show L3 and R3</string>
<string name="summary_only_l3r3">Hide all virtual buttons except L3 and R3</string>
<string name="title_show_guide_button">Show Guide Button</string>
<string name="summary_show_guide_button">Show the guide button on screen</string>
<string name="title_reset_osc">Clear saved on-screen controls layout</string>
<string name="summary_reset_osc">Resets all on-screen controls to their default size and position</string>
<string name="dialog_title_reset_osc">Reset Layout</string>
Expand Down
8 changes: 8 additions & 0 deletions app/src/main/res/xml/preferences.xml
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,14 @@
android:key="checkbox_only_show_L3R3"
android:summary="@string/summary_only_l3r3"
android:title="@string/title_only_l3r3" />
<CheckBoxPreference
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:defaultValue="true"
android:dependency="checkbox_show_onscreen_controls"
android:key="checkbox_show_guide_button"
android:summary="@string/summary_show_guide_button"
android:title="@string/title_show_guide_button" />
<com.limelight.preferences.SeekBarPreference
android:key="seekbar_osc_opacity"
android:dependency="checkbox_show_onscreen_controls"
Expand Down