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

Android: Add a button for accessing controller mappings #11605

Merged
merged 3 commits into from Mar 2, 2023
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -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
Expand Down
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
}
Expand Up @@ -4,6 +4,8 @@

import android.os.Bundle;

import androidx.annotation.NonNull;

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

/**
Expand Down Expand Up @@ -59,40 +61,22 @@ public interface SettingsActivityView
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
Expand Down
Expand Up @@ -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
Expand All @@ -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();
Expand All @@ -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();
Expand Down
Expand Up @@ -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()
Expand Down
Expand Up @@ -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;
Expand Down Expand Up @@ -72,35 +73,20 @@ public interface SettingsFragmentView
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);
}