Merge pull request #9152 from Ebola16/SP1

Android: Convert SharedPreferences to INI Settings (simple cases)
This commit is contained in:
Léo Lam 2020-10-21 16:48:18 +02:00 committed by GitHub
commit f265c412b4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 229 additions and 160 deletions

View File

@ -114,7 +114,7 @@ public final class NativeLibrary
public static final int NUNCHUK_SWING_UP = 208;
public static final int NUNCHUK_SWING_DOWN = 209;
public static final int NUNCHUK_SWING_LEFT = 210;
public static final int NUNCHUK_SWING_RIGHT = 221;
public static final int NUNCHUK_SWING_RIGHT = 211;
public static final int NUNCHUK_SWING_FORWARD = 212;
public static final int NUNCHUK_SWING_BACKWARD = 213;
public static final int NUNCHUK_TILT = 214;

View File

@ -33,6 +33,8 @@ import androidx.fragment.app.FragmentManager;
import org.dolphinemu.dolphinemu.NativeLibrary;
import org.dolphinemu.dolphinemu.R;
import org.dolphinemu.dolphinemu.features.settings.model.BooleanSetting;
import org.dolphinemu.dolphinemu.features.settings.model.IntSetting;
import org.dolphinemu.dolphinemu.features.settings.model.Settings;
import org.dolphinemu.dolphinemu.features.settings.ui.MenuTag;
import org.dolphinemu.dolphinemu.features.settings.ui.SettingsActivity;
@ -149,7 +151,7 @@ public final class EmulationActivity extends AppCompatActivity
public static final int MENU_ACTION_SETTINGS_CORE = 34;
public static final int MENU_ACTION_SETTINGS_GRAPHICS = 35;
private static SparseIntArray buttonsActionsMap = new SparseIntArray();
private static final SparseIntArray buttonsActionsMap = new SparseIntArray();
static
{
@ -248,7 +250,6 @@ public final class EmulationActivity extends AppCompatActivity
{
SharedPreferences.Editor editor = PreferenceManager.getDefaultSharedPreferences(context).edit();
editor.remove("wiiController");
editor.remove("motionControlsEnabled");
editor.apply();
}
@ -324,6 +325,7 @@ public final class EmulationActivity extends AppCompatActivity
{
if (!isChangingConfigurations())
{
mSettings.saveSettings(null, null);
mEmulationFragment.saveTemporaryState();
}
outState.putStringArray(EXTRA_SELECTED_GAMES, mPaths);
@ -359,7 +361,7 @@ public final class EmulationActivity extends AppCompatActivity
{
super.onResume();
if (!sIsGameCubeGame && mPreferences.getInt("motionControlsEnabled", 0) != 2)
if (!sIsGameCubeGame && IntSetting.MAIN_MOTION_CONTROLS.getInt(mSettings) != 2)
mMotionListener.enable();
}
@ -481,9 +483,9 @@ public final class EmulationActivity extends AppCompatActivity
// Populate the checkbox value for joystick center on touch
menu.findItem(R.id.menu_emulation_joystick_rel_center)
.setChecked(mPreferences.getBoolean("joystickRelCenter", true));
.setChecked(BooleanSetting.MAIN_JOYSTICK_REL_CENTER.getBoolean(mSettings));
menu.findItem(R.id.menu_emulation_rumble)
.setChecked(mPreferences.getBoolean("phoneRumble", true));
.setChecked(BooleanSetting.MAIN_PHONE_RUMBLE.getBoolean(mSettings));
popup.setOnMenuItemClickListener(this::onOptionsItemSelected);
@ -693,16 +695,12 @@ public final class EmulationActivity extends AppCompatActivity
private void toggleJoystickRelCenter(boolean state)
{
final SharedPreferences.Editor editor = mPreferences.edit();
editor.putBoolean("joystickRelCenter", state);
editor.commit();
BooleanSetting.MAIN_JOYSTICK_REL_CENTER.setBoolean(mSettings, state);
}
private void toggleRumble(boolean state)
{
final SharedPreferences.Editor editor = mPreferences.edit();
editor.putBoolean("phoneRumble", state);
editor.apply();
BooleanSetting.MAIN_PHONE_RUMBLE.setBoolean(mSettings, state);
Rumble.setPhoneVibrator(state, this);
}
@ -748,71 +746,74 @@ public final class EmulationActivity extends AppCompatActivity
private void toggleControls()
{
final SharedPreferences.Editor editor = mPreferences.edit();
boolean[] enabledButtons = new boolean[14];
AlertDialog.Builder builder = new AlertDialog.Builder(this, R.style.DolphinDialogBase);
builder.setTitle(R.string.emulation_toggle_controls);
if (sIsGameCubeGame || mPreferences.getInt("wiiController", 3) == 0)
{
for (int i = 0; i < enabledButtons.length; i++)
boolean[] gcEnabledButtons = new boolean[11];
String gcSettingBase = "MAIN_BUTTON_TOGGLE_GC_";
for (int i = 0; i < gcEnabledButtons.length; i++)
{
enabledButtons[i] = mPreferences.getBoolean("buttonToggleGc" + i, true);
gcEnabledButtons[i] = BooleanSetting.valueOf(gcSettingBase + i).getBoolean(mSettings);
}
builder.setMultiChoiceItems(R.array.gcpadButtons, enabledButtons,
(dialog, indexSelected, isChecked) -> editor
.putBoolean("buttonToggleGc" + indexSelected, isChecked));
builder.setMultiChoiceItems(R.array.gcpadButtons, gcEnabledButtons,
(dialog, indexSelected, isChecked) -> BooleanSetting
.valueOf(gcSettingBase + indexSelected).setBoolean(mSettings, isChecked));
}
else if (mPreferences.getInt("wiiController", 3) == 4)
{
for (int i = 0; i < enabledButtons.length; i++)
boolean[] wiiClassicEnabledButtons = new boolean[14];
String classicSettingBase = "MAIN_BUTTON_TOGGLE_CLASSIC_";
for (int i = 0; i < wiiClassicEnabledButtons.length; i++)
{
enabledButtons[i] = mPreferences.getBoolean("buttonToggleClassic" + i, true);
wiiClassicEnabledButtons[i] =
BooleanSetting.valueOf(classicSettingBase + i).getBoolean(mSettings);
}
builder.setMultiChoiceItems(R.array.classicButtons, enabledButtons,
(dialog, indexSelected, isChecked) -> editor
.putBoolean("buttonToggleClassic" + indexSelected, isChecked));
builder.setMultiChoiceItems(R.array.classicButtons, wiiClassicEnabledButtons,
(dialog, indexSelected, isChecked) -> BooleanSetting
.valueOf(classicSettingBase + indexSelected)
.setBoolean(mSettings, isChecked));
}
else
{
for (int i = 0; i < enabledButtons.length; i++)
boolean[] wiiEnabledButtons = new boolean[11];
String wiiSettingBase = "MAIN_BUTTON_TOGGLE_WII_";
for (int i = 0; i < wiiEnabledButtons.length; i++)
{
enabledButtons[i] = mPreferences.getBoolean("buttonToggleWii" + i, true);
wiiEnabledButtons[i] = BooleanSetting.valueOf(wiiSettingBase + i).getBoolean(mSettings);
}
if (mPreferences.getInt("wiiController", 3) == 3)
{
builder.setMultiChoiceItems(R.array.nunchukButtons, enabledButtons,
(dialog, indexSelected, isChecked) -> editor
.putBoolean("buttonToggleWii" + indexSelected, isChecked));
builder.setMultiChoiceItems(R.array.nunchukButtons, wiiEnabledButtons,
(dialog, indexSelected, isChecked) -> BooleanSetting
.valueOf(wiiSettingBase + indexSelected).setBoolean(mSettings, isChecked));
}
else
{
builder.setMultiChoiceItems(R.array.wiimoteButtons, enabledButtons,
(dialog, indexSelected, isChecked) -> editor
.putBoolean("buttonToggleWii" + indexSelected, isChecked));
builder.setMultiChoiceItems(R.array.wiimoteButtons, wiiEnabledButtons,
(dialog, indexSelected, isChecked) -> BooleanSetting
.valueOf(wiiSettingBase + indexSelected).setBoolean(mSettings, isChecked));
}
}
builder.setNeutralButton(R.string.emulation_toggle_all,
(dialogInterface, i) -> mEmulationFragment.toggleInputOverlayVisibility());
(dialogInterface, i) -> mEmulationFragment.toggleInputOverlayVisibility(mSettings));
builder.setPositiveButton(R.string.ok, (dialogInterface, i) ->
{
editor.apply();
mEmulationFragment.refreshInputOverlay();
});
mEmulationFragment.refreshInputOverlay());
builder.show();
}
public void chooseDoubleTapButton()
{
final SharedPreferences.Editor editor = mPreferences.edit();
AlertDialog.Builder builder = new AlertDialog.Builder(this, R.style.DolphinDialogBase);
int currentController =
mPreferences.getInt("wiiController", InputOverlay.OVERLAY_WIIMOTE_NUNCHUK);
int currentValue = mPreferences.getInt("doubleTapButton",
InputOverlayPointer.DOUBLE_TAP_OPTIONS.get(InputOverlayPointer.DOUBLE_TAP_A));
int currentValue = IntSetting.MAIN_DOUBLE_TAP_BUTTON.getInt(mSettings);
int buttonList = currentController == InputOverlay.OVERLAY_WIIMOTE_CLASSIC ?
R.array.doubleTapWithClassic : R.array.doubleTap;
@ -823,14 +824,12 @@ public final class EmulationActivity extends AppCompatActivity
currentValue = InputOverlay.OVERLAY_WIIMOTE;
}
builder.setSingleChoiceItems(buttonList, currentValue, (DialogInterface dialog, int which) ->
editor.putInt("doubleTapButton", InputOverlayPointer.DOUBLE_TAP_OPTIONS.get(which)));
builder.setSingleChoiceItems(buttonList, currentValue,
(DialogInterface dialog, int which) -> IntSetting.MAIN_DOUBLE_TAP_BUTTON
.setInt(mSettings, InputOverlayPointer.DOUBLE_TAP_OPTIONS.get(which)));
builder.setPositiveButton(R.string.ok, (dialogInterface, i) ->
{
editor.commit();
mEmulationFragment.initInputPointer();
});
mEmulationFragment.initInputPointer());
builder.show();
}
@ -845,7 +844,7 @@ public final class EmulationActivity extends AppCompatActivity
final TextView units = view.findViewById(R.id.text_units);
seekbar.setMax(150);
seekbar.setProgress(mPreferences.getInt("controlScale", 50));
seekbar.setProgress(IntSetting.MAIN_CONTROL_SCALE.getInt(mSettings));
seekbar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener()
{
public void onStartTrackingTouch(SeekBar seekBar)
@ -872,10 +871,12 @@ public final class EmulationActivity extends AppCompatActivity
builder.setView(view);
builder.setPositiveButton(R.string.ok, (dialogInterface, i) ->
{
SharedPreferences.Editor editor = mPreferences.edit();
editor.putInt("controlScale", seekbar.getProgress());
editor.apply();
IntSetting.MAIN_CONTROL_SCALE.setInt(mSettings, seekbar.getProgress());
mEmulationFragment.refreshInputOverlay();
});
builder.setNeutralButton(R.string.default_values, (dialogInterface, i) ->
{
IntSetting.MAIN_CONTROL_SCALE.delete(mSettings);
mEmulationFragment.refreshInputOverlay();
});
@ -913,14 +914,13 @@ public final class EmulationActivity extends AppCompatActivity
private void showMotionControlsOptions()
{
final SharedPreferences.Editor editor = mPreferences.edit();
AlertDialog.Builder builder = new AlertDialog.Builder(this, R.style.DolphinDialogBase);
builder.setTitle(R.string.emulation_motion_controls);
builder.setSingleChoiceItems(R.array.motionControlsEntries,
mPreferences.getInt("motionControlsEnabled", 1),
IntSetting.MAIN_MOTION_CONTROLS.getInt(mSettings),
(dialog, indexSelected) ->
{
editor.putInt("motionControlsEnabled", indexSelected);
IntSetting.MAIN_MOTION_CONTROLS.setInt(mSettings, indexSelected);
if (indexSelected != 2)
mMotionListener.enable();
@ -934,7 +934,7 @@ public final class EmulationActivity extends AppCompatActivity
NativeLibrary.ReloadWiimoteConfig();
});
builder.setPositiveButton(R.string.ok, (dialogInterface, i) -> editor.apply());
builder.setPositiveButton(R.string.ok, (dialogInterface, i) -> dialogInterface.dismiss());
builder.show();
}
@ -971,8 +971,11 @@ public final class EmulationActivity extends AppCompatActivity
private void setIRSensitivity()
{
int ir_pitch = Integer.parseInt(
mPreferences.getString(SettingsFile.KEY_WIIBIND_IR_PITCH + mSelectedGameId, "15"));
// IR settings always get saved per-game since WiimoteNew.ini is wiped upon reinstall.
File file = SettingsFile.getCustomGameSettingsFile(mSelectedGameId);
IniFile ini = new IniFile(file);
int ir_pitch = ini.getInt(Settings.SECTION_CONTROLS, SettingsFile.KEY_WIIBIND_IR_PITCH, 15);
LayoutInflater inflater = LayoutInflater.from(this);
View view = inflater.inflate(R.layout.dialog_ir_sensitivity, null);
@ -1004,8 +1007,7 @@ public final class EmulationActivity extends AppCompatActivity
}
});
int ir_yaw = Integer.parseInt(
mPreferences.getString(SettingsFile.KEY_WIIBIND_IR_YAW + mSelectedGameId, "15"));
int ir_yaw = ini.getInt(Settings.SECTION_CONTROLS, SettingsFile.KEY_WIIBIND_IR_YAW, 15);
TextView text_slider_value_yaw = view.findViewById(R.id.text_ir_yaw);
TextView units_yaw = view.findViewById(R.id.text_ir_yaw_units);
@ -1035,9 +1037,8 @@ public final class EmulationActivity extends AppCompatActivity
});
int ir_vertical_offset = Integer.parseInt(
mPreferences.getString(SettingsFile.KEY_WIIBIND_IR_VERTICAL_OFFSET + mSelectedGameId,
"10"));
int ir_vertical_offset =
ini.getInt(Settings.SECTION_CONTROLS, SettingsFile.KEY_WIIBIND_IR_VERTICAL_OFFSET, 10);
TextView text_slider_value_vertical_offset = view.findViewById(R.id.text_ir_vertical_offset);
TextView units_vertical_offset = view.findViewById(R.id.text_ir_vertical_offset_units);
@ -1071,8 +1072,6 @@ public final class EmulationActivity extends AppCompatActivity
builder.setView(view);
builder.setPositiveButton(R.string.ok, (dialogInterface, i) ->
{
File file = SettingsFile.getCustomGameSettingsFile(mSelectedGameId);
IniFile ini = new IniFile(file);
ini.setString(Settings.SECTION_CONTROLS, SettingsFile.KEY_WIIBIND_IR_PITCH,
text_slider_value_pitch.getText().toString());
ini.setString(Settings.SECTION_CONTROLS, SettingsFile.KEY_WIIBIND_IR_YAW,
@ -1082,20 +1081,20 @@ public final class EmulationActivity extends AppCompatActivity
ini.save(file);
NativeLibrary.ReloadWiimoteConfig();
SharedPreferences.Editor editor = mPreferences.edit();
editor.putString(SettingsFile.KEY_WIIBIND_IR_PITCH + mSelectedGameId,
text_slider_value_pitch.getText().toString());
editor.putString(SettingsFile.KEY_WIIBIND_IR_YAW + mSelectedGameId,
text_slider_value_yaw.getText().toString());
editor.putString(SettingsFile.KEY_WIIBIND_IR_VERTICAL_OFFSET + mSelectedGameId,
text_slider_value_vertical_offset.getText().toString());
editor.apply();
});
builder.setNegativeButton(R.string.cancel, (dialogInterface, i) ->
{
// Do nothing
});
builder.setNeutralButton(R.string.default_values, (dialogInterface, i) ->
{
ini.deleteKey(Settings.SECTION_CONTROLS, SettingsFile.KEY_WIIBIND_IR_PITCH);
ini.deleteKey(Settings.SECTION_CONTROLS, SettingsFile.KEY_WIIBIND_IR_YAW);
ini.deleteKey(Settings.SECTION_CONTROLS, SettingsFile.KEY_WIIBIND_IR_VERTICAL_OFFSET);
ini.save(file);
NativeLibrary.ReloadWiimoteConfig();
});
builder.show();
}

View File

@ -41,6 +41,86 @@ public enum BooleanSetting implements AbstractBooleanSetting
MAIN_USE_GAME_COVERS(Settings.FILE_DOLPHIN, Settings.SECTION_INI_GENERAL,
"UseGameCovers", true),
MAIN_JOYSTICK_REL_CENTER(Settings.FILE_DOLPHIN, Settings.SECTION_INI_ANDROID,
"JoystickRelCenter", true),
MAIN_PHONE_RUMBLE(Settings.FILE_DOLPHIN, Settings.SECTION_INI_ANDROID,
"PhoneRumble", true),
MAIN_SHOW_INPUT_OVERLAY(Settings.FILE_DOLPHIN, Settings.SECTION_INI_ANDROID,
"ShowInputOverlay", true),
MAIN_BUTTON_TOGGLE_GC_0(Settings.FILE_DOLPHIN, Settings.SECTION_INI_ANDROID_OVERLAY_BUTTONS,
"ButtonToggleGCButtonA", true),
MAIN_BUTTON_TOGGLE_GC_1(Settings.FILE_DOLPHIN, Settings.SECTION_INI_ANDROID_OVERLAY_BUTTONS,
"ButtonToggleGCButtonB", true),
MAIN_BUTTON_TOGGLE_GC_2(Settings.FILE_DOLPHIN, Settings.SECTION_INI_ANDROID_OVERLAY_BUTTONS,
"ButtonToggleGCButtonX", true),
MAIN_BUTTON_TOGGLE_GC_3(Settings.FILE_DOLPHIN, Settings.SECTION_INI_ANDROID_OVERLAY_BUTTONS,
"ButtonToggleGCButtonY", true),
MAIN_BUTTON_TOGGLE_GC_4(Settings.FILE_DOLPHIN, Settings.SECTION_INI_ANDROID_OVERLAY_BUTTONS,
"ButtonToggleGCButtonZ", true),
MAIN_BUTTON_TOGGLE_GC_5(Settings.FILE_DOLPHIN, Settings.SECTION_INI_ANDROID_OVERLAY_BUTTONS,
"ButtonToggleGCButtonStart", true),
MAIN_BUTTON_TOGGLE_GC_6(Settings.FILE_DOLPHIN, Settings.SECTION_INI_ANDROID_OVERLAY_BUTTONS,
"ButtonToggleGCTriggerL", true),
MAIN_BUTTON_TOGGLE_GC_7(Settings.FILE_DOLPHIN, Settings.SECTION_INI_ANDROID_OVERLAY_BUTTONS,
"ButtonToggleGCTriggerR", true),
MAIN_BUTTON_TOGGLE_GC_8(Settings.FILE_DOLPHIN, Settings.SECTION_INI_ANDROID_OVERLAY_BUTTONS,
"ButtonToggleGCDPad", true),
MAIN_BUTTON_TOGGLE_GC_9(Settings.FILE_DOLPHIN, Settings.SECTION_INI_ANDROID_OVERLAY_BUTTONS,
"ButtonToggleGCStickMain", true),
MAIN_BUTTON_TOGGLE_GC_10(Settings.FILE_DOLPHIN, Settings.SECTION_INI_ANDROID_OVERLAY_BUTTONS,
"ButtonToggleGCStickC", true),
MAIN_BUTTON_TOGGLE_CLASSIC_0(Settings.FILE_DOLPHIN, Settings.SECTION_INI_ANDROID_OVERLAY_BUTTONS,
"ButtonToggleClassicButtonA", true),
MAIN_BUTTON_TOGGLE_CLASSIC_1(Settings.FILE_DOLPHIN, Settings.SECTION_INI_ANDROID_OVERLAY_BUTTONS,
"ButtonToggleClassicButtonB", true),
MAIN_BUTTON_TOGGLE_CLASSIC_2(Settings.FILE_DOLPHIN, Settings.SECTION_INI_ANDROID_OVERLAY_BUTTONS,
"ButtonToggleClassicButtonX", true),
MAIN_BUTTON_TOGGLE_CLASSIC_3(Settings.FILE_DOLPHIN, Settings.SECTION_INI_ANDROID_OVERLAY_BUTTONS,
"ButtonToggleClassicButtonY", true),
MAIN_BUTTON_TOGGLE_CLASSIC_4(Settings.FILE_DOLPHIN, Settings.SECTION_INI_ANDROID_OVERLAY_BUTTONS,
"ButtonToggleClassicButtonPlus", true),
MAIN_BUTTON_TOGGLE_CLASSIC_5(Settings.FILE_DOLPHIN, Settings.SECTION_INI_ANDROID_OVERLAY_BUTTONS,
"ButtonToggleClassicButtonMinus", true),
MAIN_BUTTON_TOGGLE_CLASSIC_6(Settings.FILE_DOLPHIN, Settings.SECTION_INI_ANDROID_OVERLAY_BUTTONS,
"ButtonToggleClassicButtonHome", true),
MAIN_BUTTON_TOGGLE_CLASSIC_7(Settings.FILE_DOLPHIN, Settings.SECTION_INI_ANDROID_OVERLAY_BUTTONS,
"ButtonToggleClassicTriggerL", true),
MAIN_BUTTON_TOGGLE_CLASSIC_8(Settings.FILE_DOLPHIN, Settings.SECTION_INI_ANDROID_OVERLAY_BUTTONS,
"ButtonToggleClassicTriggerR", true),
MAIN_BUTTON_TOGGLE_CLASSIC_9(Settings.FILE_DOLPHIN, Settings.SECTION_INI_ANDROID_OVERLAY_BUTTONS,
"ButtonToggleClassicButtonZL", true),
MAIN_BUTTON_TOGGLE_CLASSIC_10(Settings.FILE_DOLPHIN, Settings.SECTION_INI_ANDROID_OVERLAY_BUTTONS,
"ButtonToggleClassicButtonZR", true),
MAIN_BUTTON_TOGGLE_CLASSIC_11(Settings.FILE_DOLPHIN, Settings.SECTION_INI_ANDROID_OVERLAY_BUTTONS,
"ButtonToggleClassicDPad", true),
MAIN_BUTTON_TOGGLE_CLASSIC_12(Settings.FILE_DOLPHIN, Settings.SECTION_INI_ANDROID_OVERLAY_BUTTONS,
"ButtonToggleClassicStickLeft", true),
MAIN_BUTTON_TOGGLE_CLASSIC_13(Settings.FILE_DOLPHIN, Settings.SECTION_INI_ANDROID_OVERLAY_BUTTONS,
"ButtonToggleClassicStickRight", true),
MAIN_BUTTON_TOGGLE_WII_0(Settings.FILE_DOLPHIN, Settings.SECTION_INI_ANDROID_OVERLAY_BUTTONS,
"ButtonToggleWiimoteButtonA", true),
MAIN_BUTTON_TOGGLE_WII_1(Settings.FILE_DOLPHIN, Settings.SECTION_INI_ANDROID_OVERLAY_BUTTONS,
"ButtonToggleWiimoteButtonB", true),
MAIN_BUTTON_TOGGLE_WII_2(Settings.FILE_DOLPHIN, Settings.SECTION_INI_ANDROID_OVERLAY_BUTTONS,
"ButtonToggleWiimoteButton1", true),
MAIN_BUTTON_TOGGLE_WII_3(Settings.FILE_DOLPHIN, Settings.SECTION_INI_ANDROID_OVERLAY_BUTTONS,
"ButtonToggleWiimoteButton2", true),
MAIN_BUTTON_TOGGLE_WII_4(Settings.FILE_DOLPHIN, Settings.SECTION_INI_ANDROID_OVERLAY_BUTTONS,
"ButtonToggleWiimoteButtonPlus", true),
MAIN_BUTTON_TOGGLE_WII_5(Settings.FILE_DOLPHIN, Settings.SECTION_INI_ANDROID_OVERLAY_BUTTONS,
"ButtonToggleWiimoteButtonMinus", true),
MAIN_BUTTON_TOGGLE_WII_6(Settings.FILE_DOLPHIN, Settings.SECTION_INI_ANDROID_OVERLAY_BUTTONS,
"ButtonToggleWiimoteButtonHome", true),
MAIN_BUTTON_TOGGLE_WII_7(Settings.FILE_DOLPHIN, Settings.SECTION_INI_ANDROID_OVERLAY_BUTTONS,
"ButtonToggleWiimoteDPad", true),
MAIN_BUTTON_TOGGLE_WII_8(Settings.FILE_DOLPHIN, Settings.SECTION_INI_ANDROID_OVERLAY_BUTTONS,
"ButtonToggleNunchukC", true),
MAIN_BUTTON_TOGGLE_WII_9(Settings.FILE_DOLPHIN, Settings.SECTION_INI_ANDROID_OVERLAY_BUTTONS,
"ButtonToggleNunchukZ", true),
MAIN_BUTTON_TOGGLE_WII_10(Settings.FILE_DOLPHIN, Settings.SECTION_INI_ANDROID_OVERLAY_BUTTONS,
"ButtonToggleNunchukStick", true),
SYSCONF_SCREENSAVER(Settings.FILE_SYSCONF, "IPL", "SSV", false),
SYSCONF_WIDESCREEN(Settings.FILE_SYSCONF, "IPL", "AR", true),
SYSCONF_PAL60(Settings.FILE_SYSCONF, "IPL", "E60", true),

View File

@ -1,6 +1,7 @@
package org.dolphinemu.dolphinemu.features.settings.model;
import org.dolphinemu.dolphinemu.NativeLibrary;
import org.dolphinemu.dolphinemu.overlay.InputOverlayPointer;
import java.util.Arrays;
import java.util.HashSet;
@ -18,7 +19,13 @@ public enum IntSetting implements AbstractIntSetting
MAIN_AUDIO_VOLUME(Settings.FILE_DOLPHIN, Settings.SECTION_INI_DSP, "Volume", 100),
MAIN_CONTROL_SCALE(Settings.FILE_DOLPHIN, Settings.SECTION_INI_ANDROID, "ControlScale", 50),
MAIN_LAST_PLATFORM_TAB(Settings.FILE_DOLPHIN, Settings.SECTION_INI_ANDROID, "LastPlatformTab", 0),
MAIN_MOTION_CONTROLS(Settings.FILE_DOLPHIN, Settings.SECTION_INI_ANDROID, "MotionControls", 1),
MAIN_DOUBLE_TAP_BUTTON(Settings.FILE_DOLPHIN, Settings.SECTION_INI_ANDROID_OVERLAY_BUTTONS,
"DoubleTapButton",
InputOverlayPointer.DOUBLE_TAP_OPTIONS.get(InputOverlayPointer.DOUBLE_TAP_A)),
SYSCONF_LANGUAGE(Settings.FILE_SYSCONF, "IPL", "LNG", 0x01),
SYSCONF_SOUND_MODE(Settings.FILE_SYSCONF, "IPL", "SND", 0x01),

View File

@ -24,6 +24,7 @@ public class Settings implements Closeable
public static final String FILE_WIIMOTE = "WiimoteNew";
public static final String SECTION_INI_ANDROID = "Android";
public static final String SECTION_INI_ANDROID_OVERLAY_BUTTONS = "AndroidOverlayButtons";
public static final String SECTION_INI_GENERAL = "General";
public static final String SECTION_INI_CORE = "Core";
public static final String SECTION_INI_INTERFACE = "Interface";

View File

@ -1,9 +1,7 @@
package org.dolphinemu.dolphinemu.fragments;
import android.content.Context;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.view.LayoutInflater;
import android.view.Surface;
import android.view.SurfaceHolder;
@ -18,6 +16,8 @@ import androidx.fragment.app.Fragment;
import org.dolphinemu.dolphinemu.NativeLibrary;
import org.dolphinemu.dolphinemu.R;
import org.dolphinemu.dolphinemu.activities.EmulationActivity;
import org.dolphinemu.dolphinemu.features.settings.model.BooleanSetting;
import org.dolphinemu.dolphinemu.features.settings.model.Settings;
import org.dolphinemu.dolphinemu.overlay.InputOverlay;
import org.dolphinemu.dolphinemu.utils.Log;
@ -27,8 +27,6 @@ public final class EmulationFragment extends Fragment implements SurfaceHolder.C
{
private static final String KEY_GAMEPATHS = "gamepaths";
private SharedPreferences mPreferences;
private InputOverlay mInputOverlay;
private EmulationState mEmulationState;
@ -72,8 +70,6 @@ public final class EmulationFragment extends Fragment implements SurfaceHolder.C
// So this fragment doesn't restart on configuration changes; i.e. rotation.
setRetainInstance(true);
mPreferences = PreferenceManager.getDefaultSharedPreferences(getActivity());
String[] gamePaths = getArguments().getStringArray(KEY_GAMEPATHS);
mEmulationState = new EmulationState(gamePaths, getTemporaryStateFilePath());
}
@ -124,20 +120,10 @@ public final class EmulationFragment extends Fragment implements SurfaceHolder.C
super.onDetach();
}
public void toggleInputOverlayVisibility()
public void toggleInputOverlayVisibility(Settings settings)
{
SharedPreferences.Editor editor = mPreferences.edit();
// If the overlay is currently set to INVISIBLE
if (!mPreferences.getBoolean("showInputOverlay", false))
{
editor.putBoolean("showInputOverlay", true);
}
else
{
editor.putBoolean("showInputOverlay", false);
}
editor.commit();
BooleanSetting.MAIN_SHOW_INPUT_OVERLAY
.setBoolean(settings, !BooleanSetting.MAIN_SHOW_INPUT_OVERLAY.getBoolean(settings));
mInputOverlay.refreshControls();
}

View File

@ -31,6 +31,8 @@ import org.dolphinemu.dolphinemu.NativeLibrary.ButtonState;
import org.dolphinemu.dolphinemu.NativeLibrary.ButtonType;
import org.dolphinemu.dolphinemu.R;
import org.dolphinemu.dolphinemu.activities.EmulationActivity;
import org.dolphinemu.dolphinemu.features.settings.model.BooleanSetting;
import org.dolphinemu.dolphinemu.features.settings.model.IntSetting;
import org.dolphinemu.dolphinemu.features.settings.model.Settings;
import org.dolphinemu.dolphinemu.features.settings.utils.SettingsFile;
import org.dolphinemu.dolphinemu.utils.IniFile;
@ -67,7 +69,7 @@ public final class InputOverlay extends SurfaceView implements OnTouchListener
private InputOverlayDrawableDpad mDpadBeingConfigured;
private InputOverlayDrawableJoystick mJoystickBeingConfigured;
private SharedPreferences mPreferences;
private final SharedPreferences mPreferences;
// Buttons that have special positions in Wiimote only
private static final ArrayList<Integer> WIIMOTE_H_BUTTONS = new ArrayList<>();
@ -152,8 +154,7 @@ public final class InputOverlay extends SurfaceView implements OnTouchListener
if (!EmulationActivity.isGameCubeGame())
{
int doubleTapButton = mPreferences.getInt("doubleTapButton",
InputOverlayPointer.DOUBLE_TAP_OPTIONS.get(InputOverlayPointer.DOUBLE_TAP_A));
int doubleTapButton = IntSetting.MAIN_DOUBLE_TAP_BUTTON.getIntGlobal();
if (mPreferences.getInt("wiiController", OVERLAY_WIIMOTE_NUNCHUK) !=
InputOverlay.OVERLAY_WIIMOTE_CLASSIC &&
@ -493,47 +494,47 @@ public final class InputOverlay extends SurfaceView implements OnTouchListener
private void addGameCubeOverlayControls(String orientation)
{
if (mPreferences.getBoolean("buttonToggleGc0", true))
if (BooleanSetting.MAIN_BUTTON_TOGGLE_GC_0.getBooleanGlobal())
{
overlayButtons.add(initializeOverlayButton(getContext(), R.drawable.gcpad_a,
R.drawable.gcpad_a_pressed, ButtonType.BUTTON_A, orientation));
}
if (mPreferences.getBoolean("buttonToggleGc1", true))
if (BooleanSetting.MAIN_BUTTON_TOGGLE_GC_1.getBooleanGlobal())
{
overlayButtons.add(initializeOverlayButton(getContext(), R.drawable.gcpad_b,
R.drawable.gcpad_b_pressed, ButtonType.BUTTON_B, orientation));
}
if (mPreferences.getBoolean("buttonToggleGc2", true))
if (BooleanSetting.MAIN_BUTTON_TOGGLE_GC_2.getBooleanGlobal())
{
overlayButtons.add(initializeOverlayButton(getContext(), R.drawable.gcpad_x,
R.drawable.gcpad_x_pressed, ButtonType.BUTTON_X, orientation));
}
if (mPreferences.getBoolean("buttonToggleGc3", true))
if (BooleanSetting.MAIN_BUTTON_TOGGLE_GC_3.getBooleanGlobal())
{
overlayButtons.add(initializeOverlayButton(getContext(), R.drawable.gcpad_y,
R.drawable.gcpad_y_pressed, ButtonType.BUTTON_Y, orientation));
}
if (mPreferences.getBoolean("buttonToggleGc4", true))
if (BooleanSetting.MAIN_BUTTON_TOGGLE_GC_4.getBooleanGlobal())
{
overlayButtons.add(initializeOverlayButton(getContext(), R.drawable.gcpad_z,
R.drawable.gcpad_z_pressed, ButtonType.BUTTON_Z, orientation));
}
if (mPreferences.getBoolean("buttonToggleGc5", true))
if (BooleanSetting.MAIN_BUTTON_TOGGLE_GC_5.getBooleanGlobal())
{
overlayButtons.add(initializeOverlayButton(getContext(), R.drawable.gcpad_start,
R.drawable.gcpad_start_pressed, ButtonType.BUTTON_START, orientation));
}
if (mPreferences.getBoolean("buttonToggleGc6", true))
if (BooleanSetting.MAIN_BUTTON_TOGGLE_GC_6.getBooleanGlobal())
{
overlayButtons.add(initializeOverlayButton(getContext(), R.drawable.gcpad_l,
R.drawable.gcpad_l_pressed, ButtonType.TRIGGER_L, orientation));
}
if (mPreferences.getBoolean("buttonToggleGc7", true))
if (BooleanSetting.MAIN_BUTTON_TOGGLE_GC_7.getBooleanGlobal())
{
overlayButtons.add(initializeOverlayButton(getContext(), R.drawable.gcpad_r,
R.drawable.gcpad_r_pressed, ButtonType.TRIGGER_R, orientation));
}
if (mPreferences.getBoolean("buttonToggleGc8", true))
if (BooleanSetting.MAIN_BUTTON_TOGGLE_GC_8.getBooleanGlobal())
{
overlayDpads.add(initializeOverlayDpad(getContext(), R.drawable.gcwii_dpad,
R.drawable.gcwii_dpad_pressed_one_direction,
@ -541,13 +542,13 @@ public final class InputOverlay extends SurfaceView implements OnTouchListener
ButtonType.BUTTON_UP, ButtonType.BUTTON_DOWN,
ButtonType.BUTTON_LEFT, ButtonType.BUTTON_RIGHT, orientation));
}
if (mPreferences.getBoolean("buttonToggleGc9", true))
if (BooleanSetting.MAIN_BUTTON_TOGGLE_GC_9.getBooleanGlobal())
{
overlayJoysticks.add(initializeOverlayJoystick(getContext(), R.drawable.gcwii_joystick_range,
R.drawable.gcwii_joystick, R.drawable.gcwii_joystick_pressed, ButtonType.STICK_MAIN,
orientation));
}
if (mPreferences.getBoolean("buttonToggleGc10", true))
if (BooleanSetting.MAIN_BUTTON_TOGGLE_GC_10.getBooleanGlobal())
{
overlayJoysticks.add(initializeOverlayJoystick(getContext(), R.drawable.gcwii_joystick_range,
R.drawable.gcpad_c, R.drawable.gcpad_c_pressed, ButtonType.STICK_C, orientation));
@ -556,42 +557,42 @@ public final class InputOverlay extends SurfaceView implements OnTouchListener
private void addWiimoteOverlayControls(String orientation)
{
if (mPreferences.getBoolean("buttonToggleWii0", true))
if (BooleanSetting.MAIN_BUTTON_TOGGLE_WII_0.getBooleanGlobal())
{
overlayButtons.add(initializeOverlayButton(getContext(), R.drawable.wiimote_a,
R.drawable.wiimote_a_pressed, ButtonType.WIIMOTE_BUTTON_A, orientation));
}
if (mPreferences.getBoolean("buttonToggleWii1", true))
if (BooleanSetting.MAIN_BUTTON_TOGGLE_WII_1.getBooleanGlobal())
{
overlayButtons.add(initializeOverlayButton(getContext(), R.drawable.wiimote_b,
R.drawable.wiimote_b_pressed, ButtonType.WIIMOTE_BUTTON_B, orientation));
}
if (mPreferences.getBoolean("buttonToggleWii2", true))
if (BooleanSetting.MAIN_BUTTON_TOGGLE_WII_2.getBooleanGlobal())
{
overlayButtons.add(initializeOverlayButton(getContext(), R.drawable.wiimote_one,
R.drawable.wiimote_one_pressed, ButtonType.WIIMOTE_BUTTON_1, orientation));
}
if (mPreferences.getBoolean("buttonToggleWii3", true))
if (BooleanSetting.MAIN_BUTTON_TOGGLE_WII_3.getBooleanGlobal())
{
overlayButtons.add(initializeOverlayButton(getContext(), R.drawable.wiimote_two,
R.drawable.wiimote_two_pressed, ButtonType.WIIMOTE_BUTTON_2, orientation));
}
if (mPreferences.getBoolean("buttonToggleWii4", true))
if (BooleanSetting.MAIN_BUTTON_TOGGLE_WII_4.getBooleanGlobal())
{
overlayButtons.add(initializeOverlayButton(getContext(), R.drawable.wiimote_plus,
R.drawable.wiimote_plus_pressed, ButtonType.WIIMOTE_BUTTON_PLUS, orientation));
}
if (mPreferences.getBoolean("buttonToggleWii5", true))
if (BooleanSetting.MAIN_BUTTON_TOGGLE_WII_5.getBooleanGlobal())
{
overlayButtons.add(initializeOverlayButton(getContext(), R.drawable.wiimote_minus,
R.drawable.wiimote_minus_pressed, ButtonType.WIIMOTE_BUTTON_MINUS, orientation));
}
if (mPreferences.getBoolean("buttonToggleWii6", true))
if (BooleanSetting.MAIN_BUTTON_TOGGLE_WII_6.getBooleanGlobal())
{
overlayButtons.add(initializeOverlayButton(getContext(), R.drawable.wiimote_home,
R.drawable.wiimote_home_pressed, ButtonType.WIIMOTE_BUTTON_HOME, orientation));
}
if (mPreferences.getBoolean("buttonToggleWii7", true))
if (BooleanSetting.MAIN_BUTTON_TOGGLE_WII_7.getBooleanGlobal())
{
overlayDpads.add(initializeOverlayDpad(getContext(), R.drawable.gcwii_dpad,
R.drawable.gcwii_dpad_pressed_one_direction,
@ -603,17 +604,17 @@ public final class InputOverlay extends SurfaceView implements OnTouchListener
private void addNunchukOverlayControls(String orientation)
{
if (mPreferences.getBoolean("buttonToggleWii8", true))
if (BooleanSetting.MAIN_BUTTON_TOGGLE_WII_8.getBooleanGlobal())
{
overlayButtons.add(initializeOverlayButton(getContext(), R.drawable.nunchuk_c,
R.drawable.nunchuk_c_pressed, ButtonType.NUNCHUK_BUTTON_C, orientation));
}
if (mPreferences.getBoolean("buttonToggleWii9", true))
if (BooleanSetting.MAIN_BUTTON_TOGGLE_WII_9.getBooleanGlobal())
{
overlayButtons.add(initializeOverlayButton(getContext(), R.drawable.nunchuk_z,
R.drawable.nunchuk_z_pressed, ButtonType.NUNCHUK_BUTTON_Z, orientation));
}
if (mPreferences.getBoolean("buttonToggleWii10", true))
if (BooleanSetting.MAIN_BUTTON_TOGGLE_WII_10.getBooleanGlobal())
{
overlayJoysticks.add(initializeOverlayJoystick(getContext(), R.drawable.gcwii_joystick_range,
R.drawable.gcwii_joystick, R.drawable.gcwii_joystick_pressed,
@ -623,62 +624,62 @@ public final class InputOverlay extends SurfaceView implements OnTouchListener
private void addClassicOverlayControls(String orientation)
{
if (mPreferences.getBoolean("buttonToggleClassic0", true))
if (BooleanSetting.MAIN_BUTTON_TOGGLE_CLASSIC_0.getBooleanGlobal())
{
overlayButtons.add(initializeOverlayButton(getContext(), R.drawable.classic_a,
R.drawable.classic_a_pressed, ButtonType.CLASSIC_BUTTON_A, orientation));
}
if (mPreferences.getBoolean("buttonToggleClassic1", true))
if (BooleanSetting.MAIN_BUTTON_TOGGLE_CLASSIC_1.getBooleanGlobal())
{
overlayButtons.add(initializeOverlayButton(getContext(), R.drawable.classic_b,
R.drawable.classic_b_pressed, ButtonType.CLASSIC_BUTTON_B, orientation));
}
if (mPreferences.getBoolean("buttonToggleClassic2", true))
if (BooleanSetting.MAIN_BUTTON_TOGGLE_CLASSIC_2.getBooleanGlobal())
{
overlayButtons.add(initializeOverlayButton(getContext(), R.drawable.classic_x,
R.drawable.classic_x_pressed, ButtonType.CLASSIC_BUTTON_X, orientation));
}
if (mPreferences.getBoolean("buttonToggleClassic3", true))
if (BooleanSetting.MAIN_BUTTON_TOGGLE_CLASSIC_3.getBooleanGlobal())
{
overlayButtons.add(initializeOverlayButton(getContext(), R.drawable.classic_y,
R.drawable.classic_y_pressed, ButtonType.CLASSIC_BUTTON_Y, orientation));
}
if (mPreferences.getBoolean("buttonToggleClassic4", true))
if (BooleanSetting.MAIN_BUTTON_TOGGLE_CLASSIC_4.getBooleanGlobal())
{
overlayButtons.add(initializeOverlayButton(getContext(), R.drawable.wiimote_plus,
R.drawable.wiimote_plus_pressed, ButtonType.CLASSIC_BUTTON_PLUS, orientation));
}
if (mPreferences.getBoolean("buttonToggleClassic5", true))
if (BooleanSetting.MAIN_BUTTON_TOGGLE_CLASSIC_5.getBooleanGlobal())
{
overlayButtons.add(initializeOverlayButton(getContext(), R.drawable.wiimote_minus,
R.drawable.wiimote_minus_pressed, ButtonType.CLASSIC_BUTTON_MINUS, orientation));
}
if (mPreferences.getBoolean("buttonToggleClassic6", true))
if (BooleanSetting.MAIN_BUTTON_TOGGLE_CLASSIC_6.getBooleanGlobal())
{
overlayButtons.add(initializeOverlayButton(getContext(), R.drawable.wiimote_home,
R.drawable.wiimote_home_pressed, ButtonType.CLASSIC_BUTTON_HOME, orientation));
}
if (mPreferences.getBoolean("buttonToggleClassic7", true))
if (BooleanSetting.MAIN_BUTTON_TOGGLE_CLASSIC_7.getBooleanGlobal())
{
overlayButtons.add(initializeOverlayButton(getContext(), R.drawable.classic_l,
R.drawable.classic_l_pressed, ButtonType.CLASSIC_TRIGGER_L, orientation));
}
if (mPreferences.getBoolean("buttonToggleClassic8", true))
if (BooleanSetting.MAIN_BUTTON_TOGGLE_CLASSIC_8.getBooleanGlobal())
{
overlayButtons.add(initializeOverlayButton(getContext(), R.drawable.classic_r,
R.drawable.classic_r_pressed, ButtonType.CLASSIC_TRIGGER_R, orientation));
}
if (mPreferences.getBoolean("buttonToggleClassic9", true))
if (BooleanSetting.MAIN_BUTTON_TOGGLE_CLASSIC_9.getBooleanGlobal())
{
overlayButtons.add(initializeOverlayButton(getContext(), R.drawable.classic_zl,
R.drawable.classic_zl_pressed, ButtonType.CLASSIC_BUTTON_ZL, orientation));
}
if (mPreferences.getBoolean("buttonToggleClassic10", true))
if (BooleanSetting.MAIN_BUTTON_TOGGLE_CLASSIC_10.getBooleanGlobal())
{
overlayButtons.add(initializeOverlayButton(getContext(), R.drawable.classic_zr,
R.drawable.classic_zr_pressed, ButtonType.CLASSIC_BUTTON_ZR, orientation));
}
if (mPreferences.getBoolean("buttonToggleClassic11", true))
if (BooleanSetting.MAIN_BUTTON_TOGGLE_CLASSIC_11.getBooleanGlobal())
{
overlayDpads.add(initializeOverlayDpad(getContext(), R.drawable.gcwii_dpad,
R.drawable.gcwii_dpad_pressed_one_direction,
@ -686,13 +687,13 @@ public final class InputOverlay extends SurfaceView implements OnTouchListener
ButtonType.CLASSIC_DPAD_UP, ButtonType.CLASSIC_DPAD_DOWN,
ButtonType.CLASSIC_DPAD_LEFT, ButtonType.CLASSIC_DPAD_RIGHT, orientation));
}
if (mPreferences.getBoolean("buttonToggleClassic12", true))
if (BooleanSetting.MAIN_BUTTON_TOGGLE_CLASSIC_12.getBooleanGlobal())
{
overlayJoysticks.add(initializeOverlayJoystick(getContext(), R.drawable.gcwii_joystick_range,
R.drawable.gcwii_joystick, R.drawable.gcwii_joystick_pressed,
ButtonType.CLASSIC_STICK_LEFT, orientation));
}
if (mPreferences.getBoolean("buttonToggleClassic13", true))
if (BooleanSetting.MAIN_BUTTON_TOGGLE_CLASSIC_13.getBooleanGlobal())
{
overlayJoysticks.add(initializeOverlayJoystick(getContext(), R.drawable.gcwii_joystick_range,
R.drawable.gcwii_joystick, R.drawable.gcwii_joystick_pressed,
@ -711,7 +712,7 @@ public final class InputOverlay extends SurfaceView implements OnTouchListener
getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT ?
"-Portrait" : "";
if (mPreferences.getBoolean("showInputOverlay", true))
if (BooleanSetting.MAIN_SHOW_INPUT_OVERLAY.getBooleanGlobal())
{
// Add all the enabled overlay items back to the HashSet.
if (EmulationActivity.isGameCubeGame())
@ -928,7 +929,7 @@ public final class InputOverlay extends SurfaceView implements OnTouchListener
break;
}
scale *= (sPrefs.getInt("controlScale", 50) + 50);
scale *= (IntSetting.MAIN_CONTROL_SCALE.getIntGlobal() + 50);
scale /= 100;
// Initialize the InputOverlayDrawableButton.
@ -1006,7 +1007,7 @@ public final class InputOverlay extends SurfaceView implements OnTouchListener
break;
}
scale *= (sPrefs.getInt("controlScale", 50) + 50);
scale *= (IntSetting.MAIN_CONTROL_SCALE.getIntGlobal() + 50);
scale /= 100;
// Initialize the InputOverlayDrawableDpad.
@ -1063,7 +1064,7 @@ public final class InputOverlay extends SurfaceView implements OnTouchListener
// Decide scale based on user preference
float scale = 0.275f;
scale *= (sPrefs.getInt("controlScale", 50) + 50);
scale *= (IntSetting.MAIN_CONTROL_SCALE.getIntGlobal() + 50);
scale /= 100;
// Initialize the InputOverlayDrawableJoystick.
@ -1096,10 +1097,9 @@ public final class InputOverlay extends SurfaceView implements OnTouchListener
Rect innerRect = new Rect(0, 0, (int) (outerSize / innerScale), (int) (outerSize / innerScale));
// Send the drawableId to the joystick so it can be referenced when saving control position.
final InputOverlayDrawableJoystick overlayDrawable
= new InputOverlayDrawableJoystick(res, bitmapOuter,
bitmapInnerDefault, bitmapInnerPressed,
outerRect, innerRect, joystick, sPrefs);
final InputOverlayDrawableJoystick overlayDrawable =
new InputOverlayDrawableJoystick(res, bitmapOuter, bitmapInnerDefault,
bitmapInnerPressed, outerRect, innerRect, joystick);
// Need to set the image's position
overlayDrawable.setPosition(drawableX, drawableY);
@ -1236,7 +1236,6 @@ public final class InputOverlay extends SurfaceView implements OnTouchListener
sPrefsEditor.commit();
}
private void gcPortraitDefaultOverlay()
{
SharedPreferences.Editor sPrefsEditor = mPreferences.edit();

View File

@ -6,7 +6,6 @@
package org.dolphinemu.dolphinemu.overlay;
import android.content.SharedPreferences;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.Canvas;
@ -15,6 +14,7 @@ import android.graphics.drawable.BitmapDrawable;
import android.view.MotionEvent;
import org.dolphinemu.dolphinemu.NativeLibrary;
import org.dolphinemu.dolphinemu.features.settings.model.BooleanSetting;
/**
* Custom {@link BitmapDrawable} that is capable
@ -22,22 +22,20 @@ import org.dolphinemu.dolphinemu.NativeLibrary;
*/
public final class InputOverlayDrawableJoystick
{
private SharedPreferences mPreferences;
private final int[] axisIDs = {0, 0, 0, 0};
private final float[] axises = {0f, 0f};
private int trackId = -1;
private int mJoystickType;
private final int mJoystickType;
private int mControlPositionX, mControlPositionY;
private int mPreviousTouchX, mPreviousTouchY;
private int mWidth;
private int mHeight;
private final int mWidth;
private final int mHeight;
private Rect mVirtBounds;
private Rect mOrigBounds;
private BitmapDrawable mOuterBitmap;
private BitmapDrawable mDefaultStateInnerBitmap;
private BitmapDrawable mPressedStateInnerBitmap;
private BitmapDrawable mBoundsBoxBitmap;
private final BitmapDrawable mOuterBitmap;
private final BitmapDrawable mDefaultStateInnerBitmap;
private final BitmapDrawable mPressedStateInnerBitmap;
private final BitmapDrawable mBoundsBoxBitmap;
private boolean mPressedState = false;
/**
@ -51,9 +49,8 @@ public final class InputOverlayDrawableJoystick
* @param rectInner {@link Rect} which represents the inner joystick bounds.
* @param joystick Identifier for which joystick this is.
*/
public InputOverlayDrawableJoystick(Resources res, Bitmap bitmapOuter,
Bitmap bitmapInnerDefault, Bitmap bitmapInnerPressed,
Rect rectOuter, Rect rectInner, int joystick, SharedPreferences prefsHandle)
public InputOverlayDrawableJoystick(Resources res, Bitmap bitmapOuter, Bitmap bitmapInnerDefault,
Bitmap bitmapInnerPressed, Rect rectOuter, Rect rectInner, int joystick)
{
axisIDs[0] = joystick + 1;
axisIDs[1] = joystick + 2;
@ -61,7 +58,6 @@ public final class InputOverlayDrawableJoystick
axisIDs[3] = joystick + 4;
mJoystickType = joystick;
mPreferences = prefsHandle;
mOuterBitmap = new BitmapDrawable(res, bitmapOuter);
mDefaultStateInnerBitmap = new BitmapDrawable(res, bitmapInnerDefault);
mPressedStateInnerBitmap = new BitmapDrawable(res, bitmapInnerPressed);
@ -98,7 +94,7 @@ public final class InputOverlayDrawableJoystick
public boolean TrackEvent(MotionEvent event)
{
boolean reCenter = mPreferences.getBoolean("joystickRelCenter", true);
boolean reCenter = BooleanSetting.MAIN_JOYSTICK_REL_CENTER.getBooleanGlobal();
int pointerIndex = event.getActionIndex();
boolean pressed = false;

View File

@ -4,12 +4,12 @@ import android.content.Context;
import android.os.Build;
import android.os.VibrationEffect;
import android.os.Vibrator;
import android.preference.PreferenceManager;
import android.util.SparseArray;
import android.view.InputDevice;
import org.dolphinemu.dolphinemu.activities.EmulationActivity;
import org.dolphinemu.dolphinemu.features.settings.model.AdHocStringSetting;
import org.dolphinemu.dolphinemu.features.settings.model.BooleanSetting;
import org.dolphinemu.dolphinemu.features.settings.model.Settings;
import org.dolphinemu.dolphinemu.features.settings.utils.SettingsFile;
@ -22,7 +22,7 @@ public class Rumble
{
clear();
if (PreferenceManager.getDefaultSharedPreferences(activity).getBoolean("phoneRumble", true))
if (BooleanSetting.MAIN_PHONE_RUMBLE.getBooleanGlobal())
{
setPhoneVibrator(true, activity);
}

View File

@ -435,6 +435,7 @@ It can efficiently compress both junk data and encrypted Wii data.
<string name="pitch">Total Pitch</string>
<string name="yaw">Total Yaw</string>
<string name="vertical_offset">Vertical Offset</string>
<string name="default_values">Default Values</string>
<string name="slider_setting_value">%1$d%2$s</string>
<string name="disc_number">Disc %1$d</string>
<string name="disabled_gc_overlay_notice">GameCube Controller 1 is set to \"None\"</string>

View File

@ -25,8 +25,8 @@ bool IsSettingSaveable(const Config::Location& config_location)
if (config_location.system == Config::System::Main)
{
for (const std::string& section :
{"NetPlay", "General", "Display", "Network", "Analytics", "Android"})
for (const std::string& section : {"NetPlay", "General", "Display", "Network", "Analytics",
"AndroidOverlayButtons", "Android"})
{
if (config_location.section == section)
return true;