Merge pull request #3603 from sigmabeta/android-wiimote

[Android] Add UI support for newly-implemented DolphinBar support
This commit is contained in:
Ryan Houdek 2016-02-09 00:31:33 -05:00
commit b8628433f2
19 changed files with 128 additions and 7 deletions

View File

@ -54,7 +54,13 @@ public final class MainPresenter
mView.launchSettingsActivity(SettingsFile.FILE_NAME_GCPAD);
return true;
case R.id.menu_settings_wiimote:
mView.launchSettingsActivity(SettingsFile.FILE_NAME_WIIMOTE);
return true;
case R.id.menu_refresh:
GameDatabase databaseHelper = DolphinApplication.databaseHelper;
databaseHelper.scanLibrary(databaseHelper.getWritableDatabase());
mView.refresh();
return true;

View File

@ -225,10 +225,6 @@ public final class TvMainActivity extends Activity implements MainView
{
ArrayObjectAdapter rowItems = new ArrayObjectAdapter(new SettingsRowPresenter());
rowItems.add(new TvSettingsItem(R.id.menu_refresh,
R.drawable.ic_refresh_tv,
R.string.grid_menu_refresh));
rowItems.add(new TvSettingsItem(R.id.menu_settings_core,
R.drawable.ic_settings_core_tv,
R.string.grid_menu_core_settings));
@ -241,10 +237,18 @@ public final class TvMainActivity extends Activity implements MainView
R.drawable.ic_settings_gcpad,
R.string.grid_menu_gcpad_settings));
rowItems.add(new TvSettingsItem(R.id.menu_settings_wiimote,
R.drawable.ic_settings_wiimote,
R.string.grid_menu_wiimote_settings));
rowItems.add(new TvSettingsItem(R.id.button_add_directory,
R.drawable.ic_add_tv,
R.string.add_directory_title));
rowItems.add(new TvSettingsItem(R.id.menu_refresh,
R.drawable.ic_refresh_tv,
R.string.grid_menu_refresh));
// Create a header for this row.
HeaderItem header = new HeaderItem(R.string.settings, getString(R.string.settings));

View File

@ -156,6 +156,12 @@ public final class SettingsActivity extends AppCompatActivity implements Setting
mPresenter.onGcPadSettingChanged(key, value);
}
@Override
public void onWiimoteSettingChanged(String section, int value)
{
mPresenter.onWiimoteSettingChanged(section, value);
}
private SettingsFragment getFragment()
{
return (SettingsFragment) getFragmentManager().findFragmentByTag(SettingsFragment.FRAGMENT_TAG);

View File

@ -174,4 +174,18 @@ public final class SettingsActivityPresenter
break;
}
}
public void onWiimoteSettingChanged(String section, int value)
{
switch (value)
{
case 1:
mView.showToastMessage("Configuration coming soon. Settings from old versions will still work.");
break;
case 2:
mView.showToastMessage("Please make sure Continuous Scanning is enabled in Core Settings.");
break;
}
}
}

View File

@ -78,4 +78,14 @@ public interface SettingsActivityView
* @param value New setting for the GCPad.
*/
void onGcPadSettingChanged(String key, int value);
/**
* Called by a containing Fragment to tell the containing Activity that a Wiimote's setting
* was modified.
*
* @param section Identifier for Wiimote that was modified; Wiimotes are identified by their section,
* not their key.
* @param value New setting for the Wiimote.
*/
void onWiimoteSettingChanged(String section, int value);
}

View File

@ -194,6 +194,11 @@ public final class SettingsAdapter extends RecyclerView.Adapter<SettingViewHolde
mView.onGcPadSettingChanged(scSetting.getKey(), value);
}
if (scSetting.getKey().equals(SettingsFile.KEY_WIIMOTE_TYPE))
{
mView.onWiimoteSettingChanged(scSetting.getSetting().getSection(), value);
}
// Get the backing Setting, which may be null (if for example it was missing from the file)
IntSetting setting = scSetting.setSelectedValue(value);
if (setting != null)

View File

@ -157,6 +157,12 @@ public final class SettingsFragment extends Fragment implements SettingsFragment
mActivity.onGcPadSettingChanged(key, value);
}
@Override
public void onWiimoteSettingChanged(String section, int value)
{
mActivity.onWiimoteSettingChanged(section, value);
}
public static final String FRAGMENT_TAG = BuildConfig.APPLICATION_ID + ".fragment.settings";
public static final String ARGUMENT_MENU_TAG = FRAGMENT_TAG + ".menu_tag";

View File

@ -106,6 +106,10 @@ public final class SettingsFragmentPresenter
addGcPadSettings(sl);
break;
case SettingsFile.FILE_NAME_WIIMOTE:
addWiimoteSettings(sl);
break;
case SettingsFile.SECTION_GFX_ENHANCEMENTS:
addEnhanceSettings(sl);
break;
@ -133,6 +137,8 @@ public final class SettingsFragmentPresenter
Setting dualCore = null;
Setting overclockEnable = null;
Setting overclock = null;
Setting continuousScan = null;
Setting wiimoteSpeaker = null;
if (mSettings != null)
{
@ -140,6 +146,8 @@ public final class SettingsFragmentPresenter
dualCore = mSettings.get(SettingsFile.SECTION_CORE).getSetting(SettingsFile.KEY_DUAL_CORE);
overclockEnable = mSettings.get(SettingsFile.SECTION_CORE).getSetting(SettingsFile.KEY_OVERCLOCK_ENABLE);
overclock = mSettings.get(SettingsFile.SECTION_CORE).getSetting(SettingsFile.KEY_OVERCLOCK_PERCENT);
continuousScan = mSettings.get(SettingsFile.SECTION_CORE).getSetting(SettingsFile.KEY_WIIMOTE_SCAN);
wiimoteSpeaker = mSettings.get(SettingsFile.SECTION_CORE).getSetting(SettingsFile.KEY_WIIMOTE_SPEAKER);
}
else
{
@ -154,7 +162,8 @@ public final class SettingsFragmentPresenter
sl.add(new CheckBoxSetting(SettingsFile.KEY_DUAL_CORE, SettingsFile.SECTION_CORE, R.string.dual_core, R.string.dual_core_descrip, true, dualCore));
sl.add(new CheckBoxSetting(SettingsFile.KEY_OVERCLOCK_ENABLE, SettingsFile.SECTION_CORE, R.string.overclock_enable, R.string.overclock_enable_description, false, overclockEnable));
sl.add(new SliderSetting(SettingsFile.KEY_OVERCLOCK_PERCENT, SettingsFile.SECTION_CORE, R.string.overclock_title, 0, 400, "%", 100, overclock));
sl.add(new CheckBoxSetting(SettingsFile.KEY_WIIMOTE_SCAN, SettingsFile.SECTION_CORE, R.string.wiimote_scanning, R.string.wiimote_scanning_description, true, continuousScan));
sl.add(new CheckBoxSetting(SettingsFile.KEY_WIIMOTE_SPEAKER, SettingsFile.SECTION_CORE, R.string.wiimote_speaker, R.string.wiimote_speaker_description, true, wiimoteSpeaker));
}
private void addGcPadSettings(ArrayList<SettingsItem> sl)
@ -170,6 +179,19 @@ public final class SettingsFragmentPresenter
}
}
private void addWiimoteSettings(ArrayList<SettingsItem> sl)
{
if (mSettings != null)
{
for (int i = 1; i <= 4; i++)
{
// TODO This wiimote_0 + i business is quite the hack. It should work, but only if the definitions are kept together and in order.
Setting wiimoteSetting = mSettings.get(SettingsFile.SECTION_WIIMOTE + i).getSetting(SettingsFile.KEY_WIIMOTE_TYPE);
sl.add(new SingleChoiceSetting(SettingsFile.KEY_WIIMOTE_TYPE, SettingsFile.SECTION_WIIMOTE + i, R.string.wiimote_0 + i - 1, 0, R.array.wiimoteTypeEntries, R.array.wiimoteTypeValues, 0, wiimoteSetting));
}
}
}
private void addGraphicsSettings(ArrayList<SettingsItem> sl)
{
Setting showFps = null;

View File

@ -84,4 +84,13 @@ public interface SettingsFragmentView
* @param value New setting for the GCPad.
*/
void onGcPadSettingChanged(String key, int value);
/**
* Have the fragment tell the containing Activity that a Wiimote's setting was modified.
*
* @param section Identifier for Wiimote that was modified; Wiimotes are identified by their section,
* not their key.
* @param value New setting for the Wiimote.
*/
void onWiimoteSettingChanged(String section, int value);
}

View File

@ -41,6 +41,8 @@ public final class SettingsFile
public static final String SECTION_STEREOSCOPY = "Stereoscopy";
public static final String SECTION_WIIMOTE = "Wiimote";
public static final String KEY_CPU_CORE = "CPUCore";
public static final String KEY_DUAL_CORE = "CPUThread";
public static final String KEY_OVERCLOCK_ENABLE = "OverclockEnable";
@ -78,6 +80,11 @@ public final class SettingsFile
public static final String KEY_GCADAPTER_RUMBLE = "AdapterRumble";
public static final String KEY_GCADAPTER_BONGOS = "SimulateKonga";
public static final String KEY_WIIMOTE_TYPE = "Source";
public static final String KEY_WIIMOTE_SCAN = "WiimoteContinuousScanning";
public static final String KEY_WIIMOTE_SPEAKER = "WiimoteEnableSpeaker";
// Internal only, not actually found in settings file.
public static final String KEY_XFB_METHOD = "XFBMethod";

Binary file not shown.

After

Width:  |  Height:  |  Size: 470 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 308 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 552 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 830 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

@ -16,6 +16,11 @@
android:title="@string/grid_menu_gcpad_settings"
android:icon="@drawable/ic_settings_gcpad"
app:showAsAction="ifRoom"/>
<item
android:id="@+id/menu_settings_wiimote"
android:title="@string/grid_menu_wiimote_settings"
android:icon="@drawable/ic_settings_wiimote"
app:showAsAction="ifRoom"/>
<item
android:id="@+id/menu_refresh"
android:title="@string/grid_menu_refresh"

View File

@ -159,4 +159,15 @@
<item>12</item>
</integer-array>
<string-array name="wiimoteTypeEntries">
<item>Disabled</item>
<item>Emulated</item>
<item>Real Wiimote (DolphinBar required)</item>
</string-array>
<integer-array name="wiimoteTypeValues">
<item>0</item>
<item>1</item>
<item>2</item>
</integer-array>
</resources>

View File

@ -79,7 +79,8 @@
<string name="controller_gc">GameCube Controllers</string>
<string name="controller_wii">Wii Controllers (Wiimotes)</string>
<!-- WARNING Do not move these controller entries AT ALL COSTS! -->
<!-- WARNING Do not move these controller entries AT ALL COSTS! They are indexed with ints, and an assumption
is made that they are placed together so that we can access them sequentially in a loop. -->
<string name="controller_0">GameCube Controller 1</string>
<string name="controller_1">GameCube Controller 2</string>
<string name="controller_2">GameCube Controller 3</string>
@ -95,10 +96,15 @@
<string name="modifier_range">Modifier Range</string>
<string name="analog_radius">Analog Radius (High value = High sensitivity)</string>
<string name="analog_threshold">Analog Threshold (Low value = High sensitivity)</string>
<!-- WARNING Do not move these controller entries AT ALL COSTS! They are indexed with ints, and an assumption
is made that they are placed together so that we can access them sequentially in a loop. -->
<string name="wiimote_0">Wiimote 1</string>
<string name="wiimote_1">Wiimote 2</string>
<string name="wiimote_2">Wiimote 3</string>
<string name="wiimote_3">Wiimote 4</string>
<!-- END WARNING -->
<string name="enable_wiimote">Enable Wiimote</string>
<string name="wiimote_ir">IR Motion Controls</string>
<string name="wiimote_swing">Swing Navigation</string>
@ -245,6 +251,11 @@
<string name="overclock_enable_description">Higher values can make variable-framerate games run at a higher framerate, requiring a powerful device. Lower values make games run at a lower framerate, increasing emulation speed, but reducing the emulated console\'s performance.</string>
<string name="overclock_title">Emulated CPU Clock Speed</string>
<string name="overclock_warning">WARNING: Changing this from the default (100%) WILL break games and cause glitches. Please do not report bugs that occur with a non-default clock.</string>
<string name="wiimote_scanning">Wiimote Continuous Scanning</string>
<string name="wiimote_scanning_description">Leave this on if you are using a DolphinBar for real Wiimote support.</string>
<string name="wiimote_speaker">Wiimote Speaker</string>
<string name="wiimote_speaker_description">Enable sound output through the speaker on a real Wiimote (DolphinBar required).</string>
<!-- Video Preference Fragment -->
<string name="video_settings">Video</string>
@ -324,6 +335,7 @@
<string name="grid_menu_core_settings">CPU Settings</string>
<string name="grid_menu_video_settings">Video Settings</string>
<string name="grid_menu_gcpad_settings">GameCube Input</string>
<string name="grid_menu_wiimote_settings">Wii Input</string>
<string name="grid_menu_refresh">Refresh Library</string>
<!-- Add Directory Screen-->
@ -354,6 +366,10 @@
<string name="gc_adapter_bongos">Bongo Controller</string>
<string name="gc_adapter_bongos_description">Enable this if you are using bongos on this port.</string>
<!-- Wiimote Input Menu-->
<string name="header_wiimote_general">General</string>
<string name="header_controllers">Controllers</string>
<!-- Package Names-->
<string name="application_id">org.dolphinemu.dolphinemu</string>
</resources>