Skip to content
Permalink
Browse files

Merge pull request #7936 from jordan-woyak/numeric-setting-cleanup

InputCommon: Clean up how numeric settings are handled.
  • Loading branch information...
JMC47 committed Apr 9, 2019
2 parents 0b8ac0a + 5efb717 commit e10a472134fdf557ec35505eb5fb7c74ba9f2af7
Showing with 557 additions and 572 deletions.
  1. +12 −12 Source/Android/app/src/main/assets/WiimoteNew.ini
  2. +4 −4 Source/Android/app/src/main/assets/WiimoteProfile.ini
  3. +49 −45 Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/activities/EmulationActivity.java
  4. +3 −3 Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/utils/SettingsFile.java
  5. +17 −17 Source/Android/app/src/main/res/layout/dialog_ir_sensitivity.xml
  6. +3 −3 Source/Android/app/src/main/res/values/strings.xml
  7. +0 −1 Source/Core/Core/HW/GCKeyboardEmu.cpp
  8. +5 −6 Source/Core/Core/HW/GCPadEmu.cpp
  9. +3 −1 Source/Core/Core/HW/GCPadEmu.h
  10. +2 −7 Source/Core/Core/HW/WiimoteEmu/Camera.cpp
  11. +15 −11 Source/Core/Core/HW/WiimoteEmu/Dynamics.cpp
  12. +2 −3 Source/Core/Core/HW/WiimoteEmu/EmuSubroutines.cpp
  13. +24 −24 Source/Core/Core/HW/WiimoteEmu/WiimoteEmu.cpp
  14. +6 −6 Source/Core/Core/HW/WiimoteEmu/WiimoteEmu.h
  15. +0 −2 Source/Core/DolphinQt/CMakeLists.txt
  16. +0 −1 Source/Core/DolphinQt/Config/Mapping/GCPadEmu.cpp
  17. +0 −29 Source/Core/DolphinQt/Config/Mapping/MappingBool.cpp
  18. +0 −25 Source/Core/DolphinQt/Config/Mapping/MappingBool.h
  19. +7 −18 Source/Core/DolphinQt/Config/Mapping/MappingIndicator.cpp
  20. +0 −1 Source/Core/DolphinQt/Config/Mapping/MappingIndicator.h
  21. +40 −10 Source/Core/DolphinQt/Config/Mapping/MappingNumeric.cpp
  22. +18 −7 Source/Core/DolphinQt/Config/Mapping/MappingNumeric.h
  23. +0 −29 Source/Core/DolphinQt/Config/Mapping/MappingRadio.cpp
  24. +0 −25 Source/Core/DolphinQt/Config/Mapping/MappingRadio.h
  25. +16 −24 Source/Core/DolphinQt/Config/Mapping/MappingWidget.cpp
  26. +0 −2 Source/Core/DolphinQt/Config/Mapping/MappingWidget.h
  27. +1 −1 Source/Core/DolphinQt/Config/Mapping/MappingWindow.cpp
  28. +0 −1 Source/Core/DolphinQt/Config/Mapping/WiimoteEmuGeneral.cpp
  29. +0 −5 Source/Core/DolphinQt/DolphinQt.vcxproj
  30. +0 −1 Source/Core/InputCommon/CMakeLists.txt
  31. +17 −35 Source/Core/InputCommon/ControllerEmu/ControlGroup/ControlGroup.cpp
  32. +20 −3 Source/Core/InputCommon/ControllerEmu/ControlGroup/ControlGroup.h
  33. +48 −15 Source/Core/InputCommon/ControllerEmu/ControlGroup/Cursor.cpp
  34. +16 −7 Source/Core/InputCommon/ControllerEmu/ControlGroup/Cursor.h
  35. +29 −14 Source/Core/InputCommon/ControllerEmu/ControlGroup/Force.cpp
  36. +3 −6 Source/Core/InputCommon/ControllerEmu/ControlGroup/Force.h
  37. +13 −7 Source/Core/InputCommon/ControllerEmu/ControlGroup/MixedTriggers.cpp
  38. +3 −5 Source/Core/InputCommon/ControllerEmu/ControlGroup/MixedTriggers.h
  39. +0 −1 Source/Core/InputCommon/ControllerEmu/ControlGroup/ModifySettingsButton.cpp
  40. +2 −3 Source/Core/InputCommon/ControllerEmu/ControlGroup/Slider.cpp
  41. +5 −0 Source/Core/InputCommon/ControllerEmu/ControlGroup/Slider.h
  42. +8 −2 Source/Core/InputCommon/ControllerEmu/ControlGroup/Tilt.cpp
  43. +2 −4 Source/Core/InputCommon/ControllerEmu/ControlGroup/Tilt.h
  44. +2 −2 Source/Core/InputCommon/ControllerEmu/ControlGroup/Triggers.cpp
  45. +4 −0 Source/Core/InputCommon/ControllerEmu/ControlGroup/Triggers.h
  46. +0 −38 Source/Core/InputCommon/ControllerEmu/Setting/BooleanSetting.cpp
  47. +0 −38 Source/Core/InputCommon/ControllerEmu/Setting/BooleanSetting.h
  48. +23 −8 Source/Core/InputCommon/ControllerEmu/Setting/NumericSetting.cpp
  49. +112 −14 Source/Core/InputCommon/ControllerEmu/Setting/NumericSetting.h
  50. +0 −15 Source/Core/InputCommon/ControllerEmu/Setting/Setting.h
  51. +8 −3 Source/Core/InputCommon/ControllerEmu/StickGate.cpp
  52. +4 −6 Source/Core/InputCommon/ControllerEmu/StickGate.h
  53. +1 −4 Source/Core/InputCommon/InputCommon.vcxproj
  54. +1 −10 Source/Core/InputCommon/InputCommon.vcxproj.filters
  55. +9 −8 Source/Core/InputCommon/InputConfig.cpp
@@ -18,9 +18,9 @@ IR/Right = `Axis 115`
IR/Forward = `Axis 116`
IR/Backward = `Axis 117`
IR/Hide = `Button 118`
IR/Height = 50
IR/Width = 50
IR/Center = 50
IR/Total Pitch = 15
IR/Total Yaw = 15
IR/Vertical Offset = 10
Swing/Up = `Axis 120`
Swing/Down = `Axis 121`
Swing/Left = `Axis 122`
@@ -157,9 +157,9 @@ IR/Right = `Axis 115`
IR/Forward = `Axis 116`
IR/Backward = `Axis 117`
IR/Hide = `Button 118`
IR/Height = 50
IR/Width = 50
IR/Center = 50
IR/Total Pitch = 15
IR/Total Yaw = 15
IR/Vertical Offset = 10
Swing/Up = `Axis 120`
Swing/Down = `Axis 121`
Swing/Left = `Axis 122`
@@ -296,9 +296,9 @@ IR/Right = `Axis 115`
IR/Forward = `Axis 116`
IR/Backward = `Axis 117`
IR/Hide = `Button 118`
IR/Height = 50
IR/Width = 50
IR/Center = 50
IR/Total Pitch = 15
IR/Total Yaw = 15
IR/Vertical Offset = 10
Swing/Up = `Axis 120`
Swing/Down = `Axis 121`
Swing/Left = `Axis 122`
@@ -435,9 +435,9 @@ IR/Right = `Axis 115`
IR/Forward = `Axis 116`
IR/Backward = `Axis 117`
IR/Hide = `Button 118`
IR/Height = 50
IR/Width = 50
IR/Center = 50
IR/Total Pitch = 15
IR/Total Yaw = 15
IR/Vertical Offset = 10
Swing/Up = `Axis 120`
Swing/Down = `Axis 121`
Swing/Left = `Axis 122`
@@ -18,9 +18,9 @@ IR/Right = `Axis 115`
IR/Forward = `Axis 116`
IR/Backward = `Axis 117`
IR/Hide = `Button 118`
IR/Height = 50
IR/Width = 50
IR/Center = 50
IR/Total Pitch = 15
IR/Total Yaw = 15
IR/Vertical Offset = 10
Swing/Up = `Axis 120`
Swing/Down = `Axis 121`
Swing/Left = `Axis 122`
@@ -135,4 +135,4 @@ Turntable/Stick/Radius = 100,000000
Turntable/Effect/Dial = `Axis 621`
Turntable/Crossfade/Left = `Axis 623`
Turntable/Crossfade/Right = `Axis 624`
Rumble/Motor = `Rumble 700`
Rumble/Motor = `Rumble 700`
@@ -842,26 +842,26 @@ private void chooseController()

private void setIRSensitivity()
{
int irHeight = Integer.valueOf(
mPreferences.getString(SettingsFile.KEY_WIIBIND_IR_HEIGHT + mSelectedGameId, "50"));
int ir_pitch = Integer.valueOf(
mPreferences.getString(SettingsFile.KEY_WIIBIND_IR_PITCH + mSelectedGameId, "15"));

LayoutInflater inflater = LayoutInflater.from(this);
View view = inflater.inflate(R.layout.dialog_ir_sensitivity, null);

TextView mTextSliderValueHeight = (TextView) view.findViewById(R.id.text_ir_height);
TextView units = (TextView) view.findViewById(R.id.text_ir_height_units);
SeekBar seekbarHeight = view.findViewById(R.id.seekbar_height);
TextView text_slider_value_pitch = (TextView) view.findViewById(R.id.text_ir_pitch);
TextView units = (TextView) view.findViewById(R.id.text_ir_pitch_units);
SeekBar seekbar_pitch = view.findViewById(R.id.seekbar_pitch);

mTextSliderValueHeight.setText(String.valueOf(irHeight));
units.setText(getString(R.string.height));
seekbarHeight.setMax(100);
seekbarHeight.setProgress(irHeight);
seekbarHeight.setKeyProgressIncrement(5);
seekbarHeight.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener()
text_slider_value_pitch.setText(String.valueOf(ir_pitch));
units.setText(getString(R.string.pitch));
seekbar_pitch.setMax(100);
seekbar_pitch.setProgress(ir_pitch);
seekbar_pitch.setKeyProgressIncrement(5);
seekbar_pitch.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener()
{
@Override public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser)
{
mTextSliderValueHeight.setText(String.valueOf(progress));
text_slider_value_pitch.setText(String.valueOf(progress));
}

@Override public void onStartTrackingTouch(SeekBar seekBar)
@@ -875,23 +875,23 @@ private void setIRSensitivity()
}
});

int irWidth = Integer.valueOf(
mPreferences.getString(SettingsFile.KEY_WIIBIND_IR_WIDTH + mSelectedGameId, "50"));
int ir_yaw = Integer.valueOf(
mPreferences.getString(SettingsFile.KEY_WIIBIND_IR_YAW + mSelectedGameId, "15"));

TextView mTextSliderValueWidth = (TextView) view.findViewById(R.id.text_ir_width);
TextView unitsWidth = (TextView) view.findViewById(R.id.text_ir_width_units);
SeekBar seekbarWidth = view.findViewById(R.id.seekbar_width);
TextView text_slider_value_yaw = (TextView) view.findViewById(R.id.text_ir_yaw);
TextView units_yaw = (TextView) view.findViewById(R.id.text_ir_yaw_units);
SeekBar seekbar_yaw = view.findViewById(R.id.seekbar_width);

mTextSliderValueWidth.setText(String.valueOf(irWidth));
unitsWidth.setText(getString(R.string.width));
seekbarWidth.setMax(100);
seekbarWidth.setProgress(irWidth);
seekbarWidth.setKeyProgressIncrement(5);
seekbarWidth.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener()
text_slider_value_yaw.setText(String.valueOf(ir_yaw));
units_yaw.setText(getString(R.string.yaw));
seekbar_yaw.setMax(100);
seekbar_yaw.setProgress(ir_yaw);
seekbar_yaw.setKeyProgressIncrement(5);
seekbar_yaw.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener()
{
@Override public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser)
{
mTextSliderValueWidth.setText(String.valueOf(progress));
text_slider_value_yaw.setText(String.valueOf(progress));
}

@Override public void onStartTrackingTouch(SeekBar seekBar)
@@ -906,23 +906,26 @@ private void setIRSensitivity()
});


int irCenter = Integer.valueOf(
mPreferences.getString(SettingsFile.KEY_WIIBIND_IR_CENTER + mSelectedGameId, "50"));
int ir_vertical_offset = Integer.valueOf(
mPreferences.getString(SettingsFile.KEY_WIIBIND_IR_VERTICAL_OFFSET + mSelectedGameId,
"10"));

TextView mTextSliderValueCenter = (TextView) view.findViewById(R.id.text_ir_center);
TextView unitsCenter = (TextView) view.findViewById(R.id.text_ir_center_units);
SeekBar seekbarCenter = view.findViewById(R.id.seekbar_center);
TextView text_slider_value_vertical_offset =
(TextView) view.findViewById(R.id.text_ir_vertical_offset);
TextView units_vertical_offset =
(TextView) view.findViewById(R.id.text_ir_vertical_offset_units);
SeekBar seekbar_vertical_offset = view.findViewById(R.id.seekbar_vertical_offset);

mTextSliderValueCenter.setText(String.valueOf(irCenter));
unitsCenter.setText(getString(R.string.center));
seekbarCenter.setMax(100);
seekbarCenter.setProgress(irCenter);
seekbarCenter.setKeyProgressIncrement(5);
seekbarCenter.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener()
text_slider_value_vertical_offset.setText(String.valueOf(ir_vertical_offset));
units_vertical_offset.setText(getString(R.string.vertical_offset));
seekbar_vertical_offset.setMax(100);
seekbar_vertical_offset.setProgress(ir_vertical_offset);
seekbar_vertical_offset.setKeyProgressIncrement(5);
seekbar_vertical_offset.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener()
{
@Override public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser)
{
mTextSliderValueCenter.setText(String.valueOf(progress));
text_slider_value_vertical_offset.setText(String.valueOf(progress));
}

@Override public void onStartTrackingTouch(SeekBar seekBar)
@@ -942,21 +945,22 @@ private void setIRSensitivity()
builder.setPositiveButton(R.string.ok, (dialogInterface, i) ->
{
SettingsFile.saveSingleCustomSetting(mSelectedGameId, Settings.SECTION_CONTROLS,
SettingsFile.KEY_WIIBIND_IR_HEIGHT, mTextSliderValueHeight.getText().toString());
SettingsFile.KEY_WIIBIND_IR_PITCH, text_slider_value_pitch.getText().toString());
SettingsFile.saveSingleCustomSetting(mSelectedGameId, Settings.SECTION_CONTROLS,
SettingsFile.KEY_WIIBIND_IR_WIDTH, mTextSliderValueWidth.getText().toString());
SettingsFile.KEY_WIIBIND_IR_YAW, text_slider_value_yaw.getText().toString());
SettingsFile.saveSingleCustomSetting(mSelectedGameId, Settings.SECTION_CONTROLS,
SettingsFile.KEY_WIIBIND_IR_CENTER, mTextSliderValueCenter.getText().toString());
SettingsFile.KEY_WIIBIND_IR_VERTICAL_OFFSET,
text_slider_value_vertical_offset.getText().toString());

NativeLibrary.ReloadWiimoteConfig();

SharedPreferences.Editor editor = mPreferences.edit();
editor.putString(SettingsFile.KEY_WIIBIND_IR_HEIGHT + mSelectedGameId,
mTextSliderValueHeight.getText().toString());
editor.putString(SettingsFile.KEY_WIIBIND_IR_WIDTH + mSelectedGameId,
mTextSliderValueWidth.getText().toString());
editor.putString(SettingsFile.KEY_WIIBIND_IR_CENTER + mSelectedGameId,
mTextSliderValueCenter.getText().toString());
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) ->
@@ -153,9 +153,9 @@
public static final String KEY_WIIBIND_IR_FORWARD = "IRForward_";
public static final String KEY_WIIBIND_IR_BACKWARD = "IRBackward_";
public static final String KEY_WIIBIND_IR_HIDE = "IRHide_";
public static final String KEY_WIIBIND_IR_HEIGHT = "IRHeight";
public static final String KEY_WIIBIND_IR_WIDTH = "IRWidth";
public static final String KEY_WIIBIND_IR_CENTER = "IRCenter";
public static final String KEY_WIIBIND_IR_PITCH = "IRTotalPitch";
public static final String KEY_WIIBIND_IR_YAW = "IRTotalYaw";
public static final String KEY_WIIBIND_IR_VERTICAL_OFFSET = "IRVerticalOffset";
public static final String KEY_WIIBIND_SWING_UP = "SwingUp_";
public static final String KEY_WIIBIND_SWING_DOWN = "SwingDown_";
public static final String KEY_WIIBIND_SWING_LEFT = "SwingLeft_";
@@ -16,13 +16,13 @@
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentStart="true"
android:layout_below="@+id/text_ir_width"
android:layout_below="@+id/text_ir_yaw"
android:layout_marginBottom="@dimen/spacing_medlarge"
android:layout_marginLeft="@dimen/spacing_large"
android:layout_marginRight="@dimen/spacing_large"/>

<TextView
android:id="@+id/text_ir_width"
android:id="@+id/text_ir_yaw"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
@@ -32,11 +32,11 @@
tools:text="75"/>

<TextView
android:id="@+id/text_ir_width_units"
android:id="@+id/text_ir_yaw_units"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="@+id/text_ir_width"
android:layout_toEndOf="@+id/text_ir_width"
android:layout_alignTop="@+id/text_ir_yaw"
android:layout_toEndOf="@+id/text_ir_yaw"
tools:text="%"/>
</RelativeLayout>

@@ -46,18 +46,18 @@
android:layout_weight="1">

<SeekBar
android:id="@+id/seekbar_height"
android:id="@+id/seekbar_pitch"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentStart="true"
android:layout_below="@+id/text_ir_height"
android:layout_below="@+id/text_ir_pitch"
android:layout_marginBottom="@dimen/spacing_medlarge"
android:layout_marginLeft="@dimen/spacing_large"
android:layout_marginRight="@dimen/spacing_large"/>

<TextView
android:id="@+id/text_ir_height"
android:id="@+id/text_ir_pitch"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
@@ -67,11 +67,11 @@
tools:text="75"/>

<TextView
android:id="@+id/text_ir_height_units"
android:id="@+id/text_ir_pitch_units"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="@+id/text_ir_height"
android:layout_toEndOf="@+id/text_ir_height"
android:layout_alignTop="@+id/text_ir_pitch"
android:layout_toEndOf="@+id/text_ir_pitch"
tools:text="%"/>

</RelativeLayout>
@@ -82,18 +82,18 @@
android:layout_weight="1">

<SeekBar
android:id="@+id/seekbar_center"
android:id="@+id/seekbar_vertical_offset"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentStart="true"
android:layout_below="@+id/text_ir_center"
android:layout_below="@+id/text_ir_vertical_offset"
android:layout_marginBottom="@dimen/spacing_medlarge"
android:layout_marginLeft="@dimen/spacing_large"
android:layout_marginRight="@dimen/spacing_large"/>

<TextView
android:id="@+id/text_ir_center"
android:id="@+id/text_ir_vertical_offset"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
@@ -103,11 +103,11 @@
tools:text="75"/>

<TextView
android:id="@+id/text_ir_center_units"
android:id="@+id/text_ir_vertical_offset_units"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="@+id/text_ir_center"
android:layout_toEndOf="@+id/text_ir_center"
android:layout_alignTop="@+id/text_ir_vertical_offset"
android:layout_toEndOf="@+id/text_ir_vertical_offset"
tools:text="%"/>

</RelativeLayout>
@@ -330,8 +330,8 @@
<string name="select_dir">Select This Directory</string>

<!-- Misc -->
<string name="height">Height</string>
<string name="width">Width</string>
<string name="center">Center</string>
<string name="pitch">Total Pitch</string>
<string name="yaw">Total Yaw</string>
<string name="vertical_offset">Vertical Offset</string>

</resources>
@@ -10,7 +10,6 @@
#include "InputCommon/ControllerEmu/ControlGroup/Buttons.h"
#include "InputCommon/ControllerEmu/ControlGroup/ControlGroup.h"
#include "InputCommon/ControllerEmu/ControllerEmu.h"
#include "InputCommon/ControllerEmu/Setting/BooleanSetting.h"
#include "InputCommon/KeyboardStatus.h"

static const u16 keys0_bitmasks[] = {KEYMASK_HOME, KEYMASK_END, KEYMASK_PGUP, KEYMASK_PGDN,
@@ -15,7 +15,6 @@
#include "InputCommon/ControllerEmu/ControlGroup/Buttons.h"
#include "InputCommon/ControllerEmu/ControlGroup/ControlGroup.h"
#include "InputCommon/ControllerEmu/ControlGroup/MixedTriggers.h"
#include "InputCommon/ControllerEmu/Setting/BooleanSetting.h"
#include "InputCommon/ControllerEmu/StickGate.h"

#include "InputCommon/GCPadStatus.h"
@@ -102,10 +101,10 @@ GCPad::GCPad(const unsigned int index) : m_index(index)

// options
groups.emplace_back(m_options = new ControllerEmu::ControlGroup(_trans("Options")));
m_options->boolean_settings.emplace_back(
// i18n: Treat a controller as always being connected regardless of what
// devices the user actually has plugged in
m_always_connected = new ControllerEmu::BooleanSetting(_trans("Always Connected"), false));
m_options->AddSetting(&m_always_connected_setting,
// i18n: Treat a controller as always being connected regardless of what
// devices the user actually has plugged in
_trans("Always Connected"), false);
}

std::string GCPad::GetName() const
@@ -143,7 +142,7 @@ GCPadStatus GCPad::GetInput() const
const auto lock = GetStateLock();
GCPadStatus pad = {};

if (!(m_always_connected->GetValue() || IsDefaultDeviceConnected()))
if (!(m_always_connected_setting.GetValue() || IsDefaultDeviceConnected()))
{
pad.isConnected = false;
return pad;

0 comments on commit e10a472

Please sign in to comment.
You can’t perform that action at this time.