Skip to content

Commit

Permalink
Merge pull request #3603 from sigmabeta/android-wiimote
Browse files Browse the repository at this point in the history
[Android] Add UI support for newly-implemented DolphinBar support
  • Loading branch information
Sonicadvance1 committed Feb 9, 2016
2 parents 32dcb4c + c2d03e6 commit b862843
Show file tree
Hide file tree
Showing 19 changed files with 128 additions and 7 deletions.
Expand Up @@ -54,7 +54,13 @@ public boolean handleOptionSelection(int itemId)
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;

Expand Down
Expand Up @@ -225,10 +225,6 @@ private ListRow buildSettingsRow()
{
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));
Expand All @@ -241,10 +237,18 @@ private ListRow buildSettingsRow()
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));

Expand Down
Expand Up @@ -156,6 +156,12 @@ public void onGcPadSettingChanged(String key, int value)
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);
Expand Down
Expand Up @@ -174,4 +174,18 @@ public void onGcPadSettingChanged(String key, int value)
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;
}
}
}
Expand Up @@ -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);
}
Expand Up @@ -194,6 +194,11 @@ public void onClick(DialogInterface dialog, int which)
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)
Expand Down
Expand Up @@ -157,6 +157,12 @@ public void onGcPadSettingChanged(String key, int value)
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";
Expand Down
Expand Up @@ -106,6 +106,10 @@ private void loadSettingsList()
addGcPadSettings(sl);
break;

case SettingsFile.FILE_NAME_WIIMOTE:
addWiimoteSettings(sl);
break;

case SettingsFile.SECTION_GFX_ENHANCEMENTS:
addEnhanceSettings(sl);
break;
Expand Down Expand Up @@ -133,13 +137,17 @@ private void addCoreSettings(ArrayList<SettingsItem> sl)
Setting dualCore = null;
Setting overclockEnable = null;
Setting overclock = null;
Setting continuousScan = null;
Setting wiimoteSpeaker = null;

if (mSettings != null)
{
cpuCore = mSettings.get(SettingsFile.SECTION_CORE).getSetting(SettingsFile.KEY_CPU_CORE);
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
{
Expand All @@ -154,7 +162,8 @@ private void addCoreSettings(ArrayList<SettingsItem> sl)
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)
Expand All @@ -170,6 +179,19 @@ private void addGcPadSettings(ArrayList<SettingsItem> sl)
}
}

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;
Expand Down
Expand Up @@ -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);
}
Expand Up @@ -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";
Expand Down Expand Up @@ -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";

Expand Down
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions Source/Android/app/src/main/res/menu/menu_game_grid.xml
Expand Up @@ -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"
Expand Down
11 changes: 11 additions & 0 deletions Source/Android/app/src/main/res/values/arrays.xml
Expand Up @@ -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>
20 changes: 18 additions & 2 deletions Source/Android/app/src/main/res/values/strings.xml
Expand Up @@ -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>
Expand All @@ -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>
Expand Down Expand Up @@ -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>
Expand Down Expand Up @@ -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-->
Expand Down Expand Up @@ -353,7 +365,11 @@
<string name="gc_adapter_rumble_description">Enable the vibration function for this GameCube controller.</string>
<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>

0 comments on commit b862843

Please sign in to comment.