Implement Gamecube Input setting screen

This commit is contained in:
sigmabeta 2016-01-27 08:58:44 -05:00
parent f1ca95eec7
commit 6115d39a7a
26 changed files with 210 additions and 16 deletions

View File

@ -0,0 +1,6 @@
package org.dolphinemu.dolphinemu.ui.input.gamecube;
public class ControllerFragment
{
}

View File

@ -0,0 +1,6 @@
package org.dolphinemu.dolphinemu.ui.input.gamecube;
public class ControllerFragmentPresenter
{
}

View File

@ -0,0 +1,6 @@
package org.dolphinemu.dolphinemu.ui.input.gamecube;
public interface ControllerFragmentView
{
}

View File

@ -50,6 +50,10 @@ public final class MainPresenter
mView.launchSettingsActivity(SettingsFile.FILE_NAME_GFX);
return true;
case R.id.menu_settings_gcpad:
mView.launchSettingsActivity(SettingsFile.FILE_NAME_GCPAD);
return true;
case R.id.menu_refresh:
mView.refresh();
return true;

View File

@ -237,6 +237,10 @@ public final class TvMainActivity extends Activity implements MainView
R.drawable.ic_settings_graphics_tv,
R.string.grid_menu_video_settings));
rowItems.add(new TvSettingsItem(R.id.menu_settings_gcpad,
R.drawable.ic_settings_gcpad,
R.string.grid_menu_gcpad_settings));
rowItems.add(new TvSettingsItem(R.id.button_add_directory,
R.drawable.ic_add_tv,
R.string.add_directory_title));

View File

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

View File

@ -39,6 +39,21 @@ public final class SettingsActivityPresenter
if (savedInstanceState == null)
{
// TODO DI should be able to get rid of this hack
if (filename.equals(SettingsFile.FILE_NAME_GCPAD))
{
// Psyche! Don't actually load that file (yet).
mFileName = SettingsFile.FILE_NAME_DOLPHIN;
// But do display its fragment, as if we had.
mView.showSettingsFragment(SettingsFile.FILE_NAME_GCPAD, false);
}
else
{
mFileName = filename;
mView.showSettingsFragment(mFileName, false);
}
SettingsFile.readFile(mFileName)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
@ -60,8 +75,6 @@ public final class SettingsActivityPresenter
mView.onSettingsFileNotFound();
}
});
mView.showSettingsFragment(mFileName, false);
}
else
{
@ -147,4 +160,18 @@ public final class SettingsActivityPresenter
{
outState.putBoolean(SHOULD_SAVE, mShouldSave);
}
public void onGcPadSettingChanged(String key, int value)
{
switch (value)
{
case 6:
mView.showToastMessage("Configuration coming soon. Settings from old versions will still work.");
break;
case 12:
mView.showSettingsFragment(key, true);
break;
}
}
}

View File

@ -69,4 +69,13 @@ public interface SettingsActivityView
* unless this has been called, the Activity will not save to disk.
*/
void onSettingChanged();
/**
* Called by a containing Fragment to tell the containing Activity that a GCPad's setting
* was modified.
*
* @param key Identifier for the GCPad that was modified.
* @param value New setting for the GCPad.
*/
void onGcPadSettingChanged(String key, int value);
}

View File

@ -189,6 +189,11 @@ public final class SettingsAdapter extends RecyclerView.Adapter<SettingViewHolde
int value = getValueForSingleChoiceSelection(scSetting, which);
if (scSetting.getKey().startsWith(SettingsFile.KEY_GCPAD_TYPE))
{
mView.onGcPadSettingChanged(scSetting.getKey(), 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

@ -151,6 +151,12 @@ public final class SettingsFragment extends Fragment implements SettingsFragment
mActivity.onSettingChanged();
}
@Override
public void onGcPadSettingChanged(String key, int value)
{
mActivity.onGcPadSettingChanged(key, 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

@ -26,6 +26,8 @@ public final class SettingsFragmentPresenter
private HashMap<String, SettingSection> mSettings;
private ArrayList<SettingsItem> mSettingsList;
private int mGcPadNumber;
public SettingsFragmentPresenter(SettingsFragmentView view)
{
mView = view;
@ -33,7 +35,15 @@ public final class SettingsFragmentPresenter
public void onCreate(String menuTag)
{
mMenuTag = menuTag;
if (menuTag.startsWith(SettingsFile.KEY_GCPAD_TYPE))
{
mMenuTag = SettingsFile.KEY_GCPAD_TYPE;
mGcPadNumber = Integer.valueOf(menuTag.substring(menuTag.length() - 1));
}
else
{
mMenuTag = menuTag;
}
}
public void onViewCreated(HashMap<String, SettingSection> settings)
@ -92,6 +102,10 @@ public final class SettingsFragmentPresenter
addGraphicsSettings(sl);
break;
case SettingsFile.FILE_NAME_GCPAD:
addGcPadSettings(sl);
break;
case SettingsFile.SECTION_GFX_ENHANCEMENTS:
addEnhanceSettings(sl);
break;
@ -100,6 +114,10 @@ public final class SettingsFragmentPresenter
addHackSettings(sl);
break;
case SettingsFile.KEY_GCPAD_TYPE:
addGcAdapterSettings(sl, mGcPadNumber);
break;
default:
mView.showToastMessage("Unimplemented menu.");
return;
@ -139,6 +157,19 @@ public final class SettingsFragmentPresenter
}
private void addGcPadSettings(ArrayList<SettingsItem> sl)
{
if (mSettings != null)
{
for (int i = 0; i < 4; i++)
{
// TODO This controller_0 + i business is quite the hack. It should work, but only if the definitions are kept together and in order.
Setting gcPadSetting = mSettings.get(SettingsFile.SECTION_CORE).getSetting(SettingsFile.KEY_GCPAD_TYPE + i);
sl.add(new SingleChoiceSetting(SettingsFile.KEY_GCPAD_TYPE + i, SettingsFile.SECTION_CORE, R.string.controller_0 + i, 0, R.array.gcpadTypeEntries, R.array.gcpadTypeValues, 0, gcPadSetting));
}
}
}
private void addGraphicsSettings(ArrayList<SettingsItem> sl)
{
Setting showFps = null;
@ -229,6 +260,15 @@ public final class SettingsFragmentPresenter
sl.add(new SingleChoiceSetting(SettingsFile.KEY_ASPECT_RATIO, SettingsFile.SECTION_GFX_HACKS, R.string.aspect_ratio, R.string.aspect_ratio_descrip, R.array.aspectRatioEntries, R.array.aspectRatioValues, 0, aspectRatio));
}
private void addGcAdapterSettings(ArrayList<SettingsItem> sl, int gcPadNumber)
{
Setting rumble = mSettings.get(SettingsFile.SECTION_CORE).getSetting(SettingsFile.KEY_GCADAPTER_RUMBLE + gcPadNumber);
Setting bongos = mSettings.get(SettingsFile.SECTION_CORE).getSetting(SettingsFile.KEY_GCADAPTER_BONGOS + gcPadNumber);
sl.add(new CheckBoxSetting(SettingsFile.KEY_GCADAPTER_RUMBLE + gcPadNumber, SettingsFile.SECTION_CORE, R.string.gc_adapter_rumble, R.string.gc_adapter_rumble_description, false, rumble));
sl.add(new CheckBoxSetting(SettingsFile.KEY_GCADAPTER_BONGOS + gcPadNumber, SettingsFile.SECTION_CORE, R.string.gc_adapter_bongos, R.string.gc_adapter_bongos_description, false, bongos));
}
private int getXfbValue()
{
int xfbValue;

View File

@ -76,4 +76,12 @@ public interface SettingsFragmentView
* Have the fragment tell the containing Activity that a setting was modified.
*/
void onSettingChanged();
/**
* Have the fragment tell the containing Activity that a GCPad's setting was modified.
*
* @param key Identifier for the GCPad that was modified.
* @param value New setting for the GCPad.
*/
void onGcPadSettingChanged(String key, int value);
}

View File

@ -20,9 +20,7 @@ import java.util.Map;
public class Java_GCAdapter {
public static UsbManager manager;
public static Activity our_activity;
static byte[] controller_payload = new byte[37];
static byte HasRead;
static UsbDeviceConnection usb_con;
static UsbInterface usb_intf;

View File

@ -70,8 +70,13 @@ public final class SettingsFile
public static final String KEY_TEXCACHE_ACCURACY = "SafeTextureCacheColorSamples";
public static final String KEY_XFB = "UseXFB";
public static final String KEY_XFB_REAL = "UseRealXFB";
public static final String KEY_FAST_DEPTH= "FastDepthCalc";
public static final String KEY_ASPECT_RATIO= "AspectRatio";
public static final String KEY_FAST_DEPTH = "FastDepthCalc";
public static final String KEY_ASPECT_RATIO = "AspectRatio";
public static final String KEY_GCPAD_TYPE = "SIDevice";
public static final String KEY_GCADAPTER_RUMBLE = "AdapterRumble";
public static final String KEY_GCADAPTER_BONGOS = "SimulateKonga";
// Internal only, not actually found in settings file.
public static final String KEY_XFB_METHOD = "XFBMethod";

Binary file not shown.

After

Width:  |  Height:  |  Size: 267 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 157 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 250 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 364 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 506 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 506 B

View File

@ -0,0 +1,36 @@
<?xml version="1.0" encoding="utf-8"?>
<org.dolphinemu.dolphinemu.ui.settings.SettingsFrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginEnd="@dimen/activity_horizontal_margin"
android:layout_marginStart="@dimen/activity_horizontal_margin"
android:background="@android:color/white"
android:elevation="@dimen/elevation_high"
android:orientation="vertical">
<include
android:id="@+id/list_item_controller_one"
layout="@layout/list_item_setting"
/>
<include
android:id="@+id/list_item_controller_two"
layout="@layout/list_item_setting"
/>
<include
android:id="@+id/list_item_controller_two"
layout="@layout/list_item_setting"
/>
<include
android:id="@+id/list_item_controller_two"
layout="@layout/list_item_setting"
/>
</LinearLayout>
</org.dolphinemu.dolphinemu.ui.settings.SettingsFrameLayout>

View File

@ -1,11 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item
android:id="@+id/menu_refresh"
android:title="@string/grid_menu_refresh"
android:icon="@drawable/ic_refresh"
app:showAsAction="ifRoom"/>
<item
android:id="@+id/menu_settings_core"
android:title="@string/grid_menu_core_settings"
@ -16,5 +11,15 @@
android:title="@string/grid_menu_video_settings"
android:icon="@drawable/ic_settings_graphics"
app:showAsAction="ifRoom"/>
<item
android:id="@+id/menu_settings_gcpad"
android:title="@string/grid_menu_gcpad_settings"
android:icon="@drawable/ic_settings_gcpad"
app:showAsAction="ifRoom"/>
<item
android:id="@+id/menu_refresh"
android:title="@string/grid_menu_refresh"
android:icon="@drawable/ic_refresh"
app:showAsAction="ifRoom"/>
</menu>

View File

@ -147,4 +147,16 @@
<item>Taiwan</item>
<item>Unknown</item>
</string-array>
<string-array name="gcpadTypeEntries">
<item>Disabled</item>
<item>Emulated</item>
<item>Gamecube Adapter</item>
</string-array>
<integer-array name="gcpadTypeValues">
<item>0</item>
<item>6</item>
<item>12</item>
</integer-array>
</resources>

View File

@ -78,10 +78,14 @@
<string name="controller_bindings">Controller Bindings</string>
<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! -->
<string name="controller_0">GameCube Controller 1</string>
<string name="controller_1">GameCube Controller 2</string>
<string name="controller_2">GameCube Controller 3</string>
<string name="controller_3">GameCube Controller 4</string>
<!-- END WARNING -->
<string name="enable_controller">Enable controller</string>
<string name="controller_buttons">Buttons</string>
<string name="controller_dpad">Directional Keys</string>
@ -317,8 +321,9 @@
<!-- Game Grid Screen-->
<string name="grid_menu_core_settings">Settings</string>
<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_refresh">Refresh Library</string>
<!-- Add Directory Screen-->
@ -340,7 +345,13 @@
<string name="emulation_toggle_input">Toggle Touch Controls</string>
<string name="emulation_quicksave">Quick Save</string>
<string name="emulation_quickload">Quick Load</string>
<!-- GC Adapter Menu-->
<string name="gc_adapter_rumble">Enable Vibration</string>
<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>
<!-- Package Names-->
<string name="application_id">org.dolphinemu.dolphinemu</string>
</resources>

View File

@ -5,7 +5,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.0.0-alpha7'
classpath 'com.android.tools.build:gradle:2.0.0-alpha8'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files

View File

@ -10,7 +10,7 @@
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
# Default value: -Xmx10248m -XX:MaxPermSize=256m
# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit