Skip to content
Permalink
Browse files
Merge pull request #11605 from JosJuice/android-mappings-button
Android: Add a button for accessing controller mappings
  • Loading branch information
lioncash committed Mar 2, 2023
2 parents cbbc518 + 96deb2d commit 6fcec80
Show file tree
Hide file tree
Showing 10 changed files with 205 additions and 148 deletions.
@@ -305,27 +305,15 @@ public void onSettingChanged()
}

@Override
public void onSerialPort1SettingChanged(MenuTag menuTag, int value)
public void onMenuTagAction(@NonNull MenuTag menuTag, int value)
{
mPresenter.onSerialPort1SettingChanged(menuTag, value);
mPresenter.onMenuTagAction(menuTag, value);
}

@Override
public void onGcPadSettingChanged(MenuTag key, int value)
public boolean hasMenuTagActionForValue(@NonNull MenuTag menuTag, int value)
{
mPresenter.onGcPadSettingChanged(key, value);
}

@Override
public void onWiimoteSettingChanged(MenuTag section, int value)
{
mPresenter.onWiimoteSettingChanged(section, value);
}

@Override
public void onExtensionSettingChanged(MenuTag menuTag, int value)
{
mPresenter.onExtensionSettingChanged(menuTag, value);
return mPresenter.hasMenuTagActionForValue(menuTag, value);
}

@Override
@@ -5,6 +5,7 @@
import android.os.Bundle;
import android.text.TextUtils;

import androidx.annotation.NonNull;
import androidx.core.app.ComponentActivity;

import org.dolphinemu.dolphinemu.R;
@@ -128,47 +129,69 @@ public boolean shouldSave()
return mShouldSave;
}

public void onSerialPort1SettingChanged(MenuTag key, int value)
public void onMenuTagAction(@NonNull MenuTag menuTag, int value)
{
if (value != 0 && value != 255) // Not disabled or dummy
if (menuTag.isSerialPort1Menu())
{
Bundle bundle = new Bundle();
bundle.putInt(SettingsFragmentPresenter.ARG_SERIALPORT1_TYPE, value);
mView.showSettingsFragment(key, bundle, true, mGameId);
if (value != 0 && value != 255) // Not disabled or dummy
{
Bundle bundle = new Bundle();
bundle.putInt(SettingsFragmentPresenter.ARG_SERIALPORT1_TYPE, value);
mView.showSettingsFragment(menuTag, bundle, true, mGameId);
}
}
}

public void onGcPadSettingChanged(MenuTag key, int value)
{
if (value != 0) // Not disabled
if (menuTag.isGCPadMenu())
{
Bundle bundle = new Bundle();
bundle.putInt(SettingsFragmentPresenter.ARG_CONTROLLER_TYPE, value);
mView.showSettingsFragment(key, bundle, true, mGameId);
if (value != 0) // Not disabled
{
Bundle bundle = new Bundle();
bundle.putInt(SettingsFragmentPresenter.ARG_CONTROLLER_TYPE, value);
mView.showSettingsFragment(menuTag, bundle, true, mGameId);
}
}
}

public void onWiimoteSettingChanged(MenuTag menuTag, int value)
{
switch (value)
if (menuTag.isWiimoteMenu())
{
case 1:
if (value == 1) // Emulated Wii Remote
{
mView.showSettingsFragment(menuTag, null, true, mGameId);
break;
}
}

case 2:
mView.showToastMessage(mActivity.getString(R.string.make_sure_continuous_scan_enabled));
break;
if (menuTag.isWiimoteExtensionMenu())
{
if (value != 0) // Not disabled
{
Bundle bundle = new Bundle();
bundle.putInt(SettingsFragmentPresenter.ARG_CONTROLLER_TYPE, value);
mView.showSettingsFragment(menuTag, bundle, true, mGameId);
}
}
}

public void onExtensionSettingChanged(MenuTag menuTag, int value)
public boolean hasMenuTagActionForValue(@NonNull MenuTag menuTag, int value)
{
if (value != 0) // None
if (menuTag.isSerialPort1Menu())
{
return (value != 0 && value != 255); // Not disabled or dummy
}

if (menuTag.isGCPadMenu())
{
return (value != 0); // Not disabled
}

if (menuTag.isWiimoteMenu())
{
return (value == 1); // Emulated Wii Remote
}

if (menuTag.isWiimoteExtensionMenu())
{
Bundle bundle = new Bundle();
bundle.putInt(SettingsFragmentPresenter.ARG_CONTROLLER_TYPE, value);
mView.showSettingsFragment(menuTag, bundle, true, mGameId);
return (value != 0); // Not disabled
}

return false;
}
}
@@ -4,6 +4,8 @@

import android.os.Bundle;

import androidx.annotation.NonNull;

import org.dolphinemu.dolphinemu.features.settings.model.Settings;

/**
@@ -59,40 +61,22 @@
void onSettingChanged();

/**
* Called by a containing Fragment to tell the containing Activity that the Serial Port 1 setting
* was modified.
*
* @param menuTag Identifier for the SerialPort that was modified.
* @param value New setting for the SerialPort.
*/
void onSerialPort1SettingChanged(MenuTag menuTag, int value);

/**
* Called by a containing Fragment to tell the containing Activity that a GCPad's setting
* was modified.
*
* @param menuTag Identifier for the GCPad that was modified.
* @param value New setting for the GCPad.
*/
void onGcPadSettingChanged(MenuTag menuTag, int value);

/**
* Called by a containing Fragment to tell the containing Activity that a Wiimote's setting
* was modified.
* Called by a containing Fragment to tell the containing Activity that the user wants to open the
* MenuTag associated with a setting.
*
* @param menuTag Identifier for Wiimote that was modified.
* @param value New setting for the Wiimote.
* @param menuTag The MenuTag of the setting.
* @param value The current value of the setting.
*/
void onWiimoteSettingChanged(MenuTag menuTag, int value);
void onMenuTagAction(@NonNull MenuTag menuTag, int value);

/**
* Called by a containing Fragment to tell the containing Activity that an extension setting
* was modified.
* Returns whether anything will happen when the user wants to open the MenuTag associated with a
* setting, given the current value of the setting.
*
* @param menuTag Identifier for the extension that was modified.
* @param value New setting for the extension.
* @param menuTag The MenuTag of the setting.
* @param value The current value of the setting.
*/
void onExtensionSettingChanged(MenuTag menuTag, int value);
boolean hasMenuTagActionForValue(@NonNull MenuTag menuTag, int value);

/**
* Show loading dialog while loading the settings
@@ -467,30 +467,14 @@ public static void clearLog()
}
}

private void handleMenuTag(MenuTag menuTag, int value)
public void onMenuTagAction(@NonNull MenuTag menuTag, int value)
{
if (menuTag != null)
{
if (menuTag.isSerialPort1Menu())
{
mView.onSerialPort1SettingChanged(menuTag, value);
}

if (menuTag.isGCPadMenu())
{
mView.onGcPadSettingChanged(menuTag, value);
}

if (menuTag.isWiimoteMenu())
{
mView.onWiimoteSettingChanged(menuTag, value);
}
mView.onMenuTagAction(menuTag, value);
}

if (menuTag.isWiimoteExtensionMenu())
{
mView.onExtensionSettingChanged(menuTag, value);
}
}
public boolean hasMenuTagActionForValue(@NonNull MenuTag menuTag, int value)
{
return mView.hasMenuTagActionForValue(menuTag, value);
}

@Override
@@ -504,8 +488,6 @@ public void onClick(DialogInterface dialog, int which)
if (scSetting.getSelectedValue(getSettings()) != value)
mView.onSettingChanged();

handleMenuTag(scSetting.getMenuTag(), value);

scSetting.setSelectedValue(getSettings(), value);

closeDialog();
@@ -530,8 +512,6 @@ else if (mClickedItem instanceof StringSingleChoiceSetting)
if (!scSetting.getSelectedValue(getSettings()).equals(value))
mView.onSettingChanged();

handleMenuTag(scSetting.getMenuTag(), which);

scSetting.setSelectedValue(getSettings(), value);

closeDialog();
@@ -226,27 +226,14 @@ public void onSettingChanged()
}

@Override
public void onSerialPort1SettingChanged(MenuTag menuTag, int value)
public void onMenuTagAction(@NonNull MenuTag menuTag, int value)
{
mActivity.onSerialPort1SettingChanged(menuTag, value);
mActivity.onMenuTagAction(menuTag, value);
}

@Override
public void onGcPadSettingChanged(MenuTag menuTag, int value)
{
mActivity.onGcPadSettingChanged(menuTag, value);
}

@Override
public void onWiimoteSettingChanged(MenuTag menuTag, int value)
{
mActivity.onWiimoteSettingChanged(menuTag, value);
}

@Override
public void onExtensionSettingChanged(MenuTag menuTag, int value)
public boolean hasMenuTagActionForValue(@NonNull MenuTag menuTag, int value)
{
mActivity.onExtensionSettingChanged(menuTag, value);
return mActivity.hasMenuTagActionForValue(menuTag, value);
}

private void setInsets()
@@ -2,6 +2,7 @@

package org.dolphinemu.dolphinemu.features.settings.ui;

import androidx.annotation.NonNull;
import androidx.fragment.app.FragmentActivity;

import org.dolphinemu.dolphinemu.features.settings.model.Settings;
@@ -72,35 +73,20 @@
void onSettingChanged();

/**
* Called by a containing Fragment to tell the containing Activity that the Serial Port 1 setting
* was modified.
* Have the fragment tell the containing Activity that the user wants to open the MenuTag
* associated with a setting.
*
* @param menuTag Identifier for the SerialPort that was modified.
* @param value New setting for the SerialPort.
* @param menuTag The MenuTag of the setting.
* @param value The current value of the setting.
*/
void onSerialPort1SettingChanged(MenuTag menuTag, int value);
void onMenuTagAction(@NonNull MenuTag menuTag, int value);

/**
* Have the fragment tell the containing Activity that a GCPad's setting was modified.
* Returns whether anything will happen when the user wants to open the MenuTag associated with a
* setting, given the current value of the setting.
*
* @param menuTag Identifier for the GCPad that was modified.
* @param value New setting for the GCPad.
* @param menuTag The MenuTag of the setting.
* @param value The current value of the setting.
*/
void onGcPadSettingChanged(MenuTag menuTag, int value);

/**
* Have the fragment tell the containing Activity that a Wiimote's setting was modified.
*
* @param menuTag Identifier for Wiimote that was modified.
* @param value New setting for the Wiimote.
*/
void onWiimoteSettingChanged(MenuTag menuTag, int value);

/**
* Have the fragment tell the containing Activity that an extension setting was modified.
*
* @param menuTag Identifier for the extension that was modified.
* @param value New setting for the extension.
*/
void onExtensionSettingChanged(MenuTag menuTag, int value);
boolean hasMenuTagActionForValue(@NonNull MenuTag menuTag, int value);
}

0 comments on commit 6fcec80

Please sign in to comment.