Skip to content
Permalink
Browse files
Merge pull request #8739 from Ebola16/GCOVERLAY
Android: Separate GameCube overlay refresh logic
  • Loading branch information
JosJuice committed Jun 21, 2020
2 parents 9982251 + ea3c3fd commit 08c93ad
Show file tree
Hide file tree
Showing 7 changed files with 63 additions and 18 deletions.
@@ -814,7 +814,7 @@ public void chooseDoubleTapButton()
AlertDialog.Builder builder = new AlertDialog.Builder(this, R.style.DolphinDialogBase);

int currentController =
mPreferences.getInt("wiiController", InputOverlay.OVERLAY_WIIMOTE_NUNCHUCK);
mPreferences.getInt("wiiController", InputOverlay.OVERLAY_WIIMOTE_NUNCHUK);

int currentValue = mPreferences.getInt("doubleTapButton",
InputOverlayPointer.DOUBLE_TAP_OPTIONS.get(InputOverlayPointer.DOUBLE_TAP_A));
@@ -119,6 +119,7 @@
public static final String KEY_DEBUG_JITREGISTERCACHEOFF = "JitRegisterCacheOff";

public static final String KEY_GCPAD_TYPE = "SIDevice";
public static final String KEY_GCPAD_PLAYER_1 = "SIDevice0";
public static final String KEY_GCPAD_G_TYPE = "PadType";

public static final String KEY_GCBIND_A = "InputA_";
@@ -24,12 +24,15 @@
import android.view.SurfaceView;
import android.view.View;
import android.view.View.OnTouchListener;
import android.widget.Toast;

import org.dolphinemu.dolphinemu.NativeLibrary;
import org.dolphinemu.dolphinemu.NativeLibrary.ButtonState;
import org.dolphinemu.dolphinemu.NativeLibrary.ButtonType;
import org.dolphinemu.dolphinemu.R;
import org.dolphinemu.dolphinemu.activities.EmulationActivity;
import org.dolphinemu.dolphinemu.features.settings.model.Settings;
import org.dolphinemu.dolphinemu.features.settings.utils.SettingsFile;

import java.util.ArrayList;
import java.util.HashSet;
@@ -44,14 +47,20 @@ public final class InputOverlay extends SurfaceView implements OnTouchListener
public static final int OVERLAY_GAMECUBE = 0;
public static final int OVERLAY_WIIMOTE = 1;
public static final int OVERLAY_WIIMOTE_SIDEWAYS = 2;
public static final int OVERLAY_WIIMOTE_NUNCHUCK = 3;
public static final int OVERLAY_WIIMOTE_NUNCHUK = 3;
public static final int OVERLAY_WIIMOTE_CLASSIC = 4;
public static final int OVERLAY_NONE = 5;

private static final String DISABLED_GAMECUBE_CONTROLLER = "0";
private static final String EMULATED_GAMECUBE_CONTROLLER = "6";
private static final String GAMECUBE_ADAPTER = "12";

private final Set<InputOverlayDrawableButton> overlayButtons = new HashSet<>();
private final Set<InputOverlayDrawableDpad> overlayDpads = new HashSet<>();
private final Set<InputOverlayDrawableJoystick> overlayJoysticks = new HashSet<>();
private InputOverlayPointer overlayPointer;

private boolean mIsFirstRun = true;
private boolean mIsInEditMode = false;
private InputOverlayDrawableButton mButtonBeingConfigured;
private InputOverlayDrawableDpad mDpadBeingConfigured;
@@ -135,7 +144,7 @@ public void initTouchPointer()
int doubleTapButton = mPreferences.getInt("doubleTapButton",
InputOverlayPointer.DOUBLE_TAP_OPTIONS.get(InputOverlayPointer.DOUBLE_TAP_A));

if (mPreferences.getInt("wiiController", OVERLAY_WIIMOTE_NUNCHUCK) !=
if (mPreferences.getInt("wiiController", OVERLAY_WIIMOTE_NUNCHUK) !=
InputOverlay.OVERLAY_WIIMOTE_CLASSIC &&
doubleTapButton == InputOverlayPointer.DOUBLE_TAP_CLASSIC_A)
{
@@ -692,24 +701,56 @@ public void refreshControls()
if (mPreferences.getBoolean("showInputOverlay", true))
{
// Add all the enabled overlay items back to the HashSet.
if (EmulationActivity.isGameCubeGame() || mPreferences.getInt("wiiController", 3) == 0)
{
addGameCubeOverlayControls(orientation);
}
else if (mPreferences.getInt("wiiController", 3) == 4)
if (EmulationActivity.isGameCubeGame())
{
addClassicOverlayControls(orientation);
switch (NativeLibrary
.GetConfig(SettingsFile.FILE_NAME_DOLPHIN + ".ini", Settings.SECTION_INI_CORE,
SettingsFile.KEY_GCPAD_PLAYER_1, EMULATED_GAMECUBE_CONTROLLER))
{
case DISABLED_GAMECUBE_CONTROLLER:
if (mIsFirstRun)
{
Toast.makeText(getContext(), R.string.disabled_gc_overlay_notice, Toast.LENGTH_SHORT)
.show();
}
break;

case EMULATED_GAMECUBE_CONTROLLER:
addGameCubeOverlayControls(orientation);
break;

case GAMECUBE_ADAPTER:
break;
}
}
else
{
addWiimoteOverlayControls(orientation);
if (mPreferences.getInt("wiiController", 3) == 3)
switch (mPreferences.getInt("wiiController", 3))
{
addNunchukOverlayControls(orientation);
case OVERLAY_GAMECUBE:
addGameCubeOverlayControls(orientation);
break;

case OVERLAY_WIIMOTE:
case OVERLAY_WIIMOTE_SIDEWAYS:
addWiimoteOverlayControls(orientation);
break;

case OVERLAY_WIIMOTE_NUNCHUK:
addWiimoteOverlayControls(orientation);
addNunchukOverlayControls(orientation);
break;

case OVERLAY_WIIMOTE_CLASSIC:
addClassicOverlayControls(orientation);
break;

case OVERLAY_NONE:
break;
}
}
}

mIsFirstRun = false;
invalidate();
}

@@ -82,9 +82,9 @@
</item>

<item
android:id="@+id/menu_emulation_configure_controls"
android:id="@+id/menu_emulation_overlay_controls"
app:showAsAction="never"
android:title="@string/emulation_configure_controls">
android:title="@string/emulation_overlay_controls">
<menu>
<item
android:id="@+id/menu_emulation_edit_layout"
@@ -82,9 +82,9 @@
</item>

<item
android:id="@+id/menu_emulation_configure_controls"
android:id="@+id/menu_emulation_overlay_controls"
app:showAsAction="never"
android:title="@string/emulation_configure_controls">
android:title="@string/emulation_overlay_controls">
<menu>
<item
android:id="@+id/menu_emulation_edit_layout"
@@ -277,13 +277,15 @@
<item>Horizontal Wii Remote</item>
<item>Wii Remote + Nunchuk</item>
<item>Classic Controller</item>
<item>None</item>
</string-array>
<string-array name="controllersValues">
<item>None</item>
<item>None</item>
<item>None</item>
<item>Nunchuk</item>
<item>Classic</item>
<item>None</item>
</string-array>

<string-array name="gcpadButtons">
@@ -332,7 +332,7 @@
<string name="emulation_quicksave">Quick Save</string>
<string name="emulation_quickload">Quick Load</string>
<string name="emulation_refresh_wiimotes">Refresh Wii Remotes</string>
<string name="emulation_configure_controls">Configure Controls</string>
<string name="emulation_overlay_controls">Overlay Controls</string>
<string name="emulation_edit_layout">Edit Layout</string>
<string name="emulation_done">Done</string>
<string name="emulation_toggle_controls">Toggle Controls</string>
@@ -378,5 +378,6 @@
<string name="yaw">Total Yaw</string>
<string name="vertical_offset">Vertical Offset</string>
<string name="disc_number">Disc %1$d</string>
<string name="disabled_gc_overlay_notice">GameCube Controller 1 is set to \"None\"</string>

</resources>

0 comments on commit 08c93ad

Please sign in to comment.