Merge pull request #7936 from jordan-woyak/numeric-setting-cleanup
InputCommon: Clean up how numeric settings are handled.
This commit is contained in:
commit
e10a472134
|
@ -18,9 +18,9 @@ IR/Right = `Axis 115`
|
||||||
IR/Forward = `Axis 116`
|
IR/Forward = `Axis 116`
|
||||||
IR/Backward = `Axis 117`
|
IR/Backward = `Axis 117`
|
||||||
IR/Hide = `Button 118`
|
IR/Hide = `Button 118`
|
||||||
IR/Height = 50
|
IR/Total Pitch = 15
|
||||||
IR/Width = 50
|
IR/Total Yaw = 15
|
||||||
IR/Center = 50
|
IR/Vertical Offset = 10
|
||||||
Swing/Up = `Axis 120`
|
Swing/Up = `Axis 120`
|
||||||
Swing/Down = `Axis 121`
|
Swing/Down = `Axis 121`
|
||||||
Swing/Left = `Axis 122`
|
Swing/Left = `Axis 122`
|
||||||
|
@ -157,9 +157,9 @@ IR/Right = `Axis 115`
|
||||||
IR/Forward = `Axis 116`
|
IR/Forward = `Axis 116`
|
||||||
IR/Backward = `Axis 117`
|
IR/Backward = `Axis 117`
|
||||||
IR/Hide = `Button 118`
|
IR/Hide = `Button 118`
|
||||||
IR/Height = 50
|
IR/Total Pitch = 15
|
||||||
IR/Width = 50
|
IR/Total Yaw = 15
|
||||||
IR/Center = 50
|
IR/Vertical Offset = 10
|
||||||
Swing/Up = `Axis 120`
|
Swing/Up = `Axis 120`
|
||||||
Swing/Down = `Axis 121`
|
Swing/Down = `Axis 121`
|
||||||
Swing/Left = `Axis 122`
|
Swing/Left = `Axis 122`
|
||||||
|
@ -296,9 +296,9 @@ IR/Right = `Axis 115`
|
||||||
IR/Forward = `Axis 116`
|
IR/Forward = `Axis 116`
|
||||||
IR/Backward = `Axis 117`
|
IR/Backward = `Axis 117`
|
||||||
IR/Hide = `Button 118`
|
IR/Hide = `Button 118`
|
||||||
IR/Height = 50
|
IR/Total Pitch = 15
|
||||||
IR/Width = 50
|
IR/Total Yaw = 15
|
||||||
IR/Center = 50
|
IR/Vertical Offset = 10
|
||||||
Swing/Up = `Axis 120`
|
Swing/Up = `Axis 120`
|
||||||
Swing/Down = `Axis 121`
|
Swing/Down = `Axis 121`
|
||||||
Swing/Left = `Axis 122`
|
Swing/Left = `Axis 122`
|
||||||
|
@ -435,9 +435,9 @@ IR/Right = `Axis 115`
|
||||||
IR/Forward = `Axis 116`
|
IR/Forward = `Axis 116`
|
||||||
IR/Backward = `Axis 117`
|
IR/Backward = `Axis 117`
|
||||||
IR/Hide = `Button 118`
|
IR/Hide = `Button 118`
|
||||||
IR/Height = 50
|
IR/Total Pitch = 15
|
||||||
IR/Width = 50
|
IR/Total Yaw = 15
|
||||||
IR/Center = 50
|
IR/Vertical Offset = 10
|
||||||
Swing/Up = `Axis 120`
|
Swing/Up = `Axis 120`
|
||||||
Swing/Down = `Axis 121`
|
Swing/Down = `Axis 121`
|
||||||
Swing/Left = `Axis 122`
|
Swing/Left = `Axis 122`
|
||||||
|
|
|
@ -18,9 +18,9 @@ IR/Right = `Axis 115`
|
||||||
IR/Forward = `Axis 116`
|
IR/Forward = `Axis 116`
|
||||||
IR/Backward = `Axis 117`
|
IR/Backward = `Axis 117`
|
||||||
IR/Hide = `Button 118`
|
IR/Hide = `Button 118`
|
||||||
IR/Height = 50
|
IR/Total Pitch = 15
|
||||||
IR/Width = 50
|
IR/Total Yaw = 15
|
||||||
IR/Center = 50
|
IR/Vertical Offset = 10
|
||||||
Swing/Up = `Axis 120`
|
Swing/Up = `Axis 120`
|
||||||
Swing/Down = `Axis 121`
|
Swing/Down = `Axis 121`
|
||||||
Swing/Left = `Axis 122`
|
Swing/Left = `Axis 122`
|
||||||
|
|
|
@ -842,26 +842,26 @@ public final class EmulationActivity extends AppCompatActivity
|
||||||
|
|
||||||
private void setIRSensitivity()
|
private void setIRSensitivity()
|
||||||
{
|
{
|
||||||
int irHeight = Integer.valueOf(
|
int ir_pitch = Integer.valueOf(
|
||||||
mPreferences.getString(SettingsFile.KEY_WIIBIND_IR_HEIGHT + mSelectedGameId, "50"));
|
mPreferences.getString(SettingsFile.KEY_WIIBIND_IR_PITCH + mSelectedGameId, "15"));
|
||||||
|
|
||||||
LayoutInflater inflater = LayoutInflater.from(this);
|
LayoutInflater inflater = LayoutInflater.from(this);
|
||||||
View view = inflater.inflate(R.layout.dialog_ir_sensitivity, null);
|
View view = inflater.inflate(R.layout.dialog_ir_sensitivity, null);
|
||||||
|
|
||||||
TextView mTextSliderValueHeight = (TextView) view.findViewById(R.id.text_ir_height);
|
TextView text_slider_value_pitch = (TextView) view.findViewById(R.id.text_ir_pitch);
|
||||||
TextView units = (TextView) view.findViewById(R.id.text_ir_height_units);
|
TextView units = (TextView) view.findViewById(R.id.text_ir_pitch_units);
|
||||||
SeekBar seekbarHeight = view.findViewById(R.id.seekbar_height);
|
SeekBar seekbar_pitch = view.findViewById(R.id.seekbar_pitch);
|
||||||
|
|
||||||
mTextSliderValueHeight.setText(String.valueOf(irHeight));
|
text_slider_value_pitch.setText(String.valueOf(ir_pitch));
|
||||||
units.setText(getString(R.string.height));
|
units.setText(getString(R.string.pitch));
|
||||||
seekbarHeight.setMax(100);
|
seekbar_pitch.setMax(100);
|
||||||
seekbarHeight.setProgress(irHeight);
|
seekbar_pitch.setProgress(ir_pitch);
|
||||||
seekbarHeight.setKeyProgressIncrement(5);
|
seekbar_pitch.setKeyProgressIncrement(5);
|
||||||
seekbarHeight.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener()
|
seekbar_pitch.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener()
|
||||||
{
|
{
|
||||||
@Override public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser)
|
@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)
|
@Override public void onStartTrackingTouch(SeekBar seekBar)
|
||||||
|
@ -875,23 +875,23 @@ public final class EmulationActivity extends AppCompatActivity
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
int irWidth = Integer.valueOf(
|
int ir_yaw = Integer.valueOf(
|
||||||
mPreferences.getString(SettingsFile.KEY_WIIBIND_IR_WIDTH + mSelectedGameId, "50"));
|
mPreferences.getString(SettingsFile.KEY_WIIBIND_IR_YAW + mSelectedGameId, "15"));
|
||||||
|
|
||||||
TextView mTextSliderValueWidth = (TextView) view.findViewById(R.id.text_ir_width);
|
TextView text_slider_value_yaw = (TextView) view.findViewById(R.id.text_ir_yaw);
|
||||||
TextView unitsWidth = (TextView) view.findViewById(R.id.text_ir_width_units);
|
TextView units_yaw = (TextView) view.findViewById(R.id.text_ir_yaw_units);
|
||||||
SeekBar seekbarWidth = view.findViewById(R.id.seekbar_width);
|
SeekBar seekbar_yaw = view.findViewById(R.id.seekbar_width);
|
||||||
|
|
||||||
mTextSliderValueWidth.setText(String.valueOf(irWidth));
|
text_slider_value_yaw.setText(String.valueOf(ir_yaw));
|
||||||
unitsWidth.setText(getString(R.string.width));
|
units_yaw.setText(getString(R.string.yaw));
|
||||||
seekbarWidth.setMax(100);
|
seekbar_yaw.setMax(100);
|
||||||
seekbarWidth.setProgress(irWidth);
|
seekbar_yaw.setProgress(ir_yaw);
|
||||||
seekbarWidth.setKeyProgressIncrement(5);
|
seekbar_yaw.setKeyProgressIncrement(5);
|
||||||
seekbarWidth.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener()
|
seekbar_yaw.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener()
|
||||||
{
|
{
|
||||||
@Override public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser)
|
@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)
|
@Override public void onStartTrackingTouch(SeekBar seekBar)
|
||||||
|
@ -906,23 +906,26 @@ public final class EmulationActivity extends AppCompatActivity
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
int irCenter = Integer.valueOf(
|
int ir_vertical_offset = Integer.valueOf(
|
||||||
mPreferences.getString(SettingsFile.KEY_WIIBIND_IR_CENTER + mSelectedGameId, "50"));
|
mPreferences.getString(SettingsFile.KEY_WIIBIND_IR_VERTICAL_OFFSET + mSelectedGameId,
|
||||||
|
"10"));
|
||||||
|
|
||||||
TextView mTextSliderValueCenter = (TextView) view.findViewById(R.id.text_ir_center);
|
TextView text_slider_value_vertical_offset =
|
||||||
TextView unitsCenter = (TextView) view.findViewById(R.id.text_ir_center_units);
|
(TextView) view.findViewById(R.id.text_ir_vertical_offset);
|
||||||
SeekBar seekbarCenter = view.findViewById(R.id.seekbar_center);
|
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));
|
text_slider_value_vertical_offset.setText(String.valueOf(ir_vertical_offset));
|
||||||
unitsCenter.setText(getString(R.string.center));
|
units_vertical_offset.setText(getString(R.string.vertical_offset));
|
||||||
seekbarCenter.setMax(100);
|
seekbar_vertical_offset.setMax(100);
|
||||||
seekbarCenter.setProgress(irCenter);
|
seekbar_vertical_offset.setProgress(ir_vertical_offset);
|
||||||
seekbarCenter.setKeyProgressIncrement(5);
|
seekbar_vertical_offset.setKeyProgressIncrement(5);
|
||||||
seekbarCenter.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener()
|
seekbar_vertical_offset.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener()
|
||||||
{
|
{
|
||||||
@Override public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser)
|
@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)
|
@Override public void onStartTrackingTouch(SeekBar seekBar)
|
||||||
|
@ -942,21 +945,22 @@ public final class EmulationActivity extends AppCompatActivity
|
||||||
builder.setPositiveButton(R.string.ok, (dialogInterface, i) ->
|
builder.setPositiveButton(R.string.ok, (dialogInterface, i) ->
|
||||||
{
|
{
|
||||||
SettingsFile.saveSingleCustomSetting(mSelectedGameId, Settings.SECTION_CONTROLS,
|
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.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.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();
|
NativeLibrary.ReloadWiimoteConfig();
|
||||||
|
|
||||||
SharedPreferences.Editor editor = mPreferences.edit();
|
SharedPreferences.Editor editor = mPreferences.edit();
|
||||||
editor.putString(SettingsFile.KEY_WIIBIND_IR_HEIGHT + mSelectedGameId,
|
editor.putString(SettingsFile.KEY_WIIBIND_IR_PITCH + mSelectedGameId,
|
||||||
mTextSliderValueHeight.getText().toString());
|
text_slider_value_pitch.getText().toString());
|
||||||
editor.putString(SettingsFile.KEY_WIIBIND_IR_WIDTH + mSelectedGameId,
|
editor.putString(SettingsFile.KEY_WIIBIND_IR_YAW + mSelectedGameId,
|
||||||
mTextSliderValueWidth.getText().toString());
|
text_slider_value_yaw.getText().toString());
|
||||||
editor.putString(SettingsFile.KEY_WIIBIND_IR_CENTER + mSelectedGameId,
|
editor.putString(SettingsFile.KEY_WIIBIND_IR_VERTICAL_OFFSET + mSelectedGameId,
|
||||||
mTextSliderValueCenter.getText().toString());
|
text_slider_value_vertical_offset.getText().toString());
|
||||||
editor.apply();
|
editor.apply();
|
||||||
});
|
});
|
||||||
builder.setNegativeButton(R.string.cancel, (dialogInterface, i) ->
|
builder.setNegativeButton(R.string.cancel, (dialogInterface, i) ->
|
||||||
|
|
|
@ -153,9 +153,9 @@ public final class SettingsFile
|
||||||
public static final String KEY_WIIBIND_IR_FORWARD = "IRForward_";
|
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_BACKWARD = "IRBackward_";
|
||||||
public static final String KEY_WIIBIND_IR_HIDE = "IRHide_";
|
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_PITCH = "IRTotalPitch";
|
||||||
public static final String KEY_WIIBIND_IR_WIDTH = "IRWidth";
|
public static final String KEY_WIIBIND_IR_YAW = "IRTotalYaw";
|
||||||
public static final String KEY_WIIBIND_IR_CENTER = "IRCenter";
|
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_UP = "SwingUp_";
|
||||||
public static final String KEY_WIIBIND_SWING_DOWN = "SwingDown_";
|
public static final String KEY_WIIBIND_SWING_DOWN = "SwingDown_";
|
||||||
public static final String KEY_WIIBIND_SWING_LEFT = "SwingLeft_";
|
public static final String KEY_WIIBIND_SWING_LEFT = "SwingLeft_";
|
||||||
|
|
|
@ -16,13 +16,13 @@
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_alignParentEnd="true"
|
android:layout_alignParentEnd="true"
|
||||||
android:layout_alignParentStart="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_marginBottom="@dimen/spacing_medlarge"
|
||||||
android:layout_marginLeft="@dimen/spacing_large"
|
android:layout_marginLeft="@dimen/spacing_large"
|
||||||
android:layout_marginRight="@dimen/spacing_large"/>
|
android:layout_marginRight="@dimen/spacing_large"/>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/text_ir_width"
|
android:id="@+id/text_ir_yaw"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_alignParentTop="true"
|
android:layout_alignParentTop="true"
|
||||||
|
@ -32,11 +32,11 @@
|
||||||
tools:text="75"/>
|
tools:text="75"/>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/text_ir_width_units"
|
android:id="@+id/text_ir_yaw_units"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_alignTop="@+id/text_ir_width"
|
android:layout_alignTop="@+id/text_ir_yaw"
|
||||||
android:layout_toEndOf="@+id/text_ir_width"
|
android:layout_toEndOf="@+id/text_ir_yaw"
|
||||||
tools:text="%"/>
|
tools:text="%"/>
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
|
||||||
|
@ -46,18 +46,18 @@
|
||||||
android:layout_weight="1">
|
android:layout_weight="1">
|
||||||
|
|
||||||
<SeekBar
|
<SeekBar
|
||||||
android:id="@+id/seekbar_height"
|
android:id="@+id/seekbar_pitch"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_alignParentEnd="true"
|
android:layout_alignParentEnd="true"
|
||||||
android:layout_alignParentStart="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_marginBottom="@dimen/spacing_medlarge"
|
||||||
android:layout_marginLeft="@dimen/spacing_large"
|
android:layout_marginLeft="@dimen/spacing_large"
|
||||||
android:layout_marginRight="@dimen/spacing_large"/>
|
android:layout_marginRight="@dimen/spacing_large"/>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/text_ir_height"
|
android:id="@+id/text_ir_pitch"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_alignParentTop="true"
|
android:layout_alignParentTop="true"
|
||||||
|
@ -67,11 +67,11 @@
|
||||||
tools:text="75"/>
|
tools:text="75"/>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/text_ir_height_units"
|
android:id="@+id/text_ir_pitch_units"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_alignTop="@+id/text_ir_height"
|
android:layout_alignTop="@+id/text_ir_pitch"
|
||||||
android:layout_toEndOf="@+id/text_ir_height"
|
android:layout_toEndOf="@+id/text_ir_pitch"
|
||||||
tools:text="%"/>
|
tools:text="%"/>
|
||||||
|
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
@ -82,18 +82,18 @@
|
||||||
android:layout_weight="1">
|
android:layout_weight="1">
|
||||||
|
|
||||||
<SeekBar
|
<SeekBar
|
||||||
android:id="@+id/seekbar_center"
|
android:id="@+id/seekbar_vertical_offset"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_alignParentEnd="true"
|
android:layout_alignParentEnd="true"
|
||||||
android:layout_alignParentStart="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_marginBottom="@dimen/spacing_medlarge"
|
||||||
android:layout_marginLeft="@dimen/spacing_large"
|
android:layout_marginLeft="@dimen/spacing_large"
|
||||||
android:layout_marginRight="@dimen/spacing_large"/>
|
android:layout_marginRight="@dimen/spacing_large"/>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/text_ir_center"
|
android:id="@+id/text_ir_vertical_offset"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_alignParentTop="true"
|
android:layout_alignParentTop="true"
|
||||||
|
@ -103,11 +103,11 @@
|
||||||
tools:text="75"/>
|
tools:text="75"/>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/text_ir_center_units"
|
android:id="@+id/text_ir_vertical_offset_units"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_alignTop="@+id/text_ir_center"
|
android:layout_alignTop="@+id/text_ir_vertical_offset"
|
||||||
android:layout_toEndOf="@+id/text_ir_center"
|
android:layout_toEndOf="@+id/text_ir_vertical_offset"
|
||||||
tools:text="%"/>
|
tools:text="%"/>
|
||||||
|
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
|
|
@ -330,8 +330,8 @@
|
||||||
<string name="select_dir">Select This Directory</string>
|
<string name="select_dir">Select This Directory</string>
|
||||||
|
|
||||||
<!-- Misc -->
|
<!-- Misc -->
|
||||||
<string name="height">Height</string>
|
<string name="pitch">Total Pitch</string>
|
||||||
<string name="width">Width</string>
|
<string name="yaw">Total Yaw</string>
|
||||||
<string name="center">Center</string>
|
<string name="vertical_offset">Vertical Offset</string>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
@ -10,7 +10,6 @@
|
||||||
#include "InputCommon/ControllerEmu/ControlGroup/Buttons.h"
|
#include "InputCommon/ControllerEmu/ControlGroup/Buttons.h"
|
||||||
#include "InputCommon/ControllerEmu/ControlGroup/ControlGroup.h"
|
#include "InputCommon/ControllerEmu/ControlGroup/ControlGroup.h"
|
||||||
#include "InputCommon/ControllerEmu/ControllerEmu.h"
|
#include "InputCommon/ControllerEmu/ControllerEmu.h"
|
||||||
#include "InputCommon/ControllerEmu/Setting/BooleanSetting.h"
|
|
||||||
#include "InputCommon/KeyboardStatus.h"
|
#include "InputCommon/KeyboardStatus.h"
|
||||||
|
|
||||||
static const u16 keys0_bitmasks[] = {KEYMASK_HOME, KEYMASK_END, KEYMASK_PGUP, KEYMASK_PGDN,
|
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/Buttons.h"
|
||||||
#include "InputCommon/ControllerEmu/ControlGroup/ControlGroup.h"
|
#include "InputCommon/ControllerEmu/ControlGroup/ControlGroup.h"
|
||||||
#include "InputCommon/ControllerEmu/ControlGroup/MixedTriggers.h"
|
#include "InputCommon/ControllerEmu/ControlGroup/MixedTriggers.h"
|
||||||
#include "InputCommon/ControllerEmu/Setting/BooleanSetting.h"
|
|
||||||
#include "InputCommon/ControllerEmu/StickGate.h"
|
#include "InputCommon/ControllerEmu/StickGate.h"
|
||||||
|
|
||||||
#include "InputCommon/GCPadStatus.h"
|
#include "InputCommon/GCPadStatus.h"
|
||||||
|
@ -102,10 +101,10 @@ GCPad::GCPad(const unsigned int index) : m_index(index)
|
||||||
|
|
||||||
// options
|
// options
|
||||||
groups.emplace_back(m_options = new ControllerEmu::ControlGroup(_trans("Options")));
|
groups.emplace_back(m_options = new ControllerEmu::ControlGroup(_trans("Options")));
|
||||||
m_options->boolean_settings.emplace_back(
|
m_options->AddSetting(&m_always_connected_setting,
|
||||||
// i18n: Treat a controller as always being connected regardless of what
|
// i18n: Treat a controller as always being connected regardless of what
|
||||||
// devices the user actually has plugged in
|
// devices the user actually has plugged in
|
||||||
m_always_connected = new ControllerEmu::BooleanSetting(_trans("Always Connected"), false));
|
_trans("Always Connected"), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string GCPad::GetName() const
|
std::string GCPad::GetName() const
|
||||||
|
@ -143,7 +142,7 @@ GCPadStatus GCPad::GetInput() const
|
||||||
const auto lock = GetStateLock();
|
const auto lock = GetStateLock();
|
||||||
GCPadStatus pad = {};
|
GCPadStatus pad = {};
|
||||||
|
|
||||||
if (!(m_always_connected->GetValue() || IsDefaultDeviceConnected()))
|
if (!(m_always_connected_setting.GetValue() || IsDefaultDeviceConnected()))
|
||||||
{
|
{
|
||||||
pad.isConnected = false;
|
pad.isConnected = false;
|
||||||
return pad;
|
return pad;
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
|
|
||||||
#include "InputCommon/ControllerEmu/ControlGroup/ControlGroup.h"
|
#include "InputCommon/ControllerEmu/ControlGroup/ControlGroup.h"
|
||||||
#include "InputCommon/ControllerEmu/ControllerEmu.h"
|
#include "InputCommon/ControllerEmu/ControllerEmu.h"
|
||||||
|
#include "InputCommon/ControllerEmu/Setting/NumericSetting.h"
|
||||||
|
|
||||||
struct GCPadStatus;
|
struct GCPadStatus;
|
||||||
|
|
||||||
|
@ -57,7 +58,8 @@ private:
|
||||||
ControllerEmu::ControlGroup* m_rumble;
|
ControllerEmu::ControlGroup* m_rumble;
|
||||||
ControllerEmu::Buttons* m_mic;
|
ControllerEmu::Buttons* m_mic;
|
||||||
ControllerEmu::ControlGroup* m_options;
|
ControllerEmu::ControlGroup* m_options;
|
||||||
ControllerEmu::BooleanSetting* m_always_connected;
|
|
||||||
|
ControllerEmu::SettingValue<bool> m_always_connected_setting;
|
||||||
|
|
||||||
const unsigned int m_index;
|
const unsigned int m_index;
|
||||||
};
|
};
|
||||||
|
|
|
@ -12,7 +12,6 @@
|
||||||
#include "Common/MathUtil.h"
|
#include "Common/MathUtil.h"
|
||||||
#include "Common/Matrix.h"
|
#include "Common/Matrix.h"
|
||||||
|
|
||||||
#include "Core/Config/SYSCONFSettings.h"
|
|
||||||
#include "Core/HW/WiimoteCommon/WiimoteReport.h"
|
#include "Core/HW/WiimoteCommon/WiimoteReport.h"
|
||||||
|
|
||||||
namespace WiimoteEmu
|
namespace WiimoteEmu
|
||||||
|
@ -84,13 +83,9 @@ void CameraLogic::Update(const Common::Matrix44& transform)
|
||||||
// This seems to be acceptable for a good number of games.
|
// This seems to be acceptable for a good number of games.
|
||||||
constexpr float SENSOR_BAR_LED_SEPARATION = 0.2f;
|
constexpr float SENSOR_BAR_LED_SEPARATION = 0.2f;
|
||||||
|
|
||||||
// Emulate a sensor bar height that matches the config.
|
|
||||||
const bool sensor_bar_on_top = Config::Get(Config::SYSCONF_SENSOR_BAR_POSITION) != 0;
|
|
||||||
const float sensor_bar_height = sensor_bar_on_top ? 0.11 : -0.11;
|
|
||||||
|
|
||||||
const std::array<Vec3, NUM_POINTS> leds{
|
const std::array<Vec3, NUM_POINTS> leds{
|
||||||
Vec3{-SENSOR_BAR_LED_SEPARATION / 2, 0, sensor_bar_height},
|
Vec3{-SENSOR_BAR_LED_SEPARATION / 2, 0, 0},
|
||||||
Vec3{SENSOR_BAR_LED_SEPARATION / 2, 0, sensor_bar_height},
|
Vec3{SENSOR_BAR_LED_SEPARATION / 2, 0, 0},
|
||||||
};
|
};
|
||||||
|
|
||||||
const auto camera_view = Matrix44::Perspective(CAMERA_FOV_Y, CAMERA_ASPECT_RATIO, 0.001f, 1000) *
|
const auto camera_view = Matrix44::Perspective(CAMERA_FOV_Y, CAMERA_ASPECT_RATIO, 0.001f, 1000) *
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
|
||||||
#include "Common/MathUtil.h"
|
#include "Common/MathUtil.h"
|
||||||
|
#include "Core/Config/SYSCONFSettings.h"
|
||||||
#include "Core/Config/WiimoteInputSettings.h"
|
#include "Core/Config/WiimoteInputSettings.h"
|
||||||
#include "Core/HW/Wiimote.h"
|
#include "Core/HW/Wiimote.h"
|
||||||
#include "Core/HW/WiimoteEmu/WiimoteEmu.h"
|
#include "Core/HW/WiimoteEmu/WiimoteEmu.h"
|
||||||
|
@ -186,25 +187,28 @@ WiimoteCommon::DataReportBuilder::AccelData ConvertAccelData(const Common::Vec3&
|
||||||
|
|
||||||
Common::Matrix44 EmulateCursorMovement(ControllerEmu::Cursor* ir_group)
|
Common::Matrix44 EmulateCursorMovement(ControllerEmu::Cursor* ir_group)
|
||||||
{
|
{
|
||||||
const auto cursor = ir_group->GetState(true);
|
|
||||||
|
|
||||||
using Common::Matrix33;
|
using Common::Matrix33;
|
||||||
using Common::Matrix44;
|
using Common::Matrix44;
|
||||||
|
|
||||||
// Values are optimized for default settings in "Super Mario Galaxy 2"
|
|
||||||
// This seems to be acceptable for a good number of games.
|
|
||||||
constexpr float YAW_ANGLE = 0.1472f;
|
|
||||||
constexpr float PITCH_ANGLE = 0.121f;
|
|
||||||
|
|
||||||
// Nintendo recommends a distance of 1-3 meters.
|
// Nintendo recommends a distance of 1-3 meters.
|
||||||
constexpr float NEUTRAL_DISTANCE = 2.f;
|
constexpr float NEUTRAL_DISTANCE = 2.f;
|
||||||
|
|
||||||
constexpr float MOVE_DISTANCE = 1.f;
|
constexpr float MOVE_DISTANCE = 1.f;
|
||||||
|
|
||||||
|
// When the sensor bar position is on bottom, apply the "offset" setting negatively.
|
||||||
|
// This is kinda odd but it does seem to maintain consistent cursor behavior.
|
||||||
|
const bool sensor_bar_on_top = Config::Get(Config::SYSCONF_SENSOR_BAR_POSITION) != 0;
|
||||||
|
|
||||||
|
const float height = ir_group->GetVerticalOffset() * (sensor_bar_on_top ? 1 : -1);
|
||||||
|
|
||||||
|
const float yaw_scale = ir_group->GetTotalYaw() / 2;
|
||||||
|
const float pitch_scale = ir_group->GetTotalPitch() / 2;
|
||||||
|
|
||||||
|
const auto cursor = ir_group->GetState(true);
|
||||||
|
|
||||||
return Matrix44::Translate({0, MOVE_DISTANCE * float(cursor.z), 0}) *
|
return Matrix44::Translate({0, MOVE_DISTANCE * float(cursor.z), 0}) *
|
||||||
Matrix44::FromMatrix33(Matrix33::RotateX(PITCH_ANGLE * cursor.y) *
|
Matrix44::FromMatrix33(Matrix33::RotateX(pitch_scale * cursor.y) *
|
||||||
Matrix33::RotateZ(YAW_ANGLE * cursor.x)) *
|
Matrix33::RotateZ(yaw_scale * cursor.x)) *
|
||||||
Matrix44::Translate({0, -NEUTRAL_DISTANCE, 0});
|
Matrix44::Translate({0, -NEUTRAL_DISTANCE, height});
|
||||||
}
|
}
|
||||||
|
|
||||||
void ApproachAngleWithAccel(RotationalState* state, const Common::Vec3& angle_target,
|
void ApproachAngleWithAccel(RotationalState* state, const Common::Vec3& angle_target,
|
||||||
|
|
|
@ -18,7 +18,6 @@
|
||||||
#include "Core/HW/WiimoteReal/WiimoteReal.h"
|
#include "Core/HW/WiimoteReal/WiimoteReal.h"
|
||||||
#include "InputCommon/ControllerEmu/ControlGroup/Attachments.h"
|
#include "InputCommon/ControllerEmu/ControlGroup/Attachments.h"
|
||||||
#include "InputCommon/ControllerEmu/ControlGroup/ModifySettingsButton.h"
|
#include "InputCommon/ControllerEmu/ControlGroup/ModifySettingsButton.h"
|
||||||
#include "InputCommon/ControllerEmu/Setting/BooleanSetting.h"
|
|
||||||
|
|
||||||
namespace WiimoteEmu
|
namespace WiimoteEmu
|
||||||
{
|
{
|
||||||
|
@ -233,7 +232,7 @@ void Wiimote::HandleRequestStatus(const OutputReportRequestStatus&)
|
||||||
// Max battery level seems to be 0xc8 (decimal 200)
|
// Max battery level seems to be 0xc8 (decimal 200)
|
||||||
constexpr u8 MAX_BATTERY_LEVEL = 0xc8;
|
constexpr u8 MAX_BATTERY_LEVEL = 0xc8;
|
||||||
|
|
||||||
m_status.battery = u8(std::lround(m_battery_setting->GetValue() * MAX_BATTERY_LEVEL));
|
m_status.battery = u8(std::lround(m_battery_setting.GetValue() / 100 * MAX_BATTERY_LEVEL));
|
||||||
|
|
||||||
if (Core::WantsDeterminism())
|
if (Core::WantsDeterminism())
|
||||||
{
|
{
|
||||||
|
@ -394,7 +393,7 @@ void Wiimote::HandleSpeakerData(const WiimoteCommon::OutputReportSpeakerData& rp
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Speaker Pan
|
// Speaker Pan
|
||||||
const auto pan = m_options->numeric_settings[0]->GetValue();
|
const auto pan = m_speaker_pan_setting.GetValue() / 100;
|
||||||
|
|
||||||
m_speaker_logic.SpeakerData(rpt.data, rpt.length, pan);
|
m_speaker_logic.SpeakerData(rpt.data, rpt.length, pan);
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,8 +41,6 @@
|
||||||
#include "InputCommon/ControllerEmu/ControlGroup/Force.h"
|
#include "InputCommon/ControllerEmu/ControlGroup/Force.h"
|
||||||
#include "InputCommon/ControllerEmu/ControlGroup/ModifySettingsButton.h"
|
#include "InputCommon/ControllerEmu/ControlGroup/ModifySettingsButton.h"
|
||||||
#include "InputCommon/ControllerEmu/ControlGroup/Tilt.h"
|
#include "InputCommon/ControllerEmu/ControlGroup/Tilt.h"
|
||||||
#include "InputCommon/ControllerEmu/Setting/BooleanSetting.h"
|
|
||||||
#include "InputCommon/ControllerEmu/Setting/NumericSetting.h"
|
|
||||||
|
|
||||||
namespace WiimoteEmu
|
namespace WiimoteEmu
|
||||||
{
|
{
|
||||||
|
@ -212,26 +210,28 @@ Wiimote::Wiimote(const unsigned int index) : m_index(index)
|
||||||
// options
|
// options
|
||||||
groups.emplace_back(m_options = new ControllerEmu::ControlGroup(_trans("Options")));
|
groups.emplace_back(m_options = new ControllerEmu::ControlGroup(_trans("Options")));
|
||||||
|
|
||||||
// m_options->boolean_settings.emplace_back(
|
m_options->AddSetting(&m_speaker_pan_setting,
|
||||||
// m_motion_plus_setting =
|
{_trans("Speaker Pan"),
|
||||||
// new ControllerEmu::BooleanSetting("Attach MotionPlus", _trans("Attach MotionPlus"),
|
// i18n: The percent symbol.
|
||||||
// true,
|
_trans("%")},
|
||||||
// ControllerEmu::SettingType::NORMAL, false));
|
0, -100, 100);
|
||||||
|
|
||||||
m_options->boolean_settings.emplace_back(
|
m_options->AddSetting(&m_battery_setting,
|
||||||
new ControllerEmu::BooleanSetting("Forward Wiimote", _trans("Forward Wii Remote"), true,
|
{_trans("Battery"),
|
||||||
ControllerEmu::SettingType::NORMAL, true));
|
// i18n: The percent symbol.
|
||||||
m_options->boolean_settings.emplace_back(m_upright_setting = new ControllerEmu::BooleanSetting(
|
_trans("%")},
|
||||||
"Upright Wiimote", _trans("Upright Wii Remote"),
|
95, 0, 100);
|
||||||
false, ControllerEmu::SettingType::NORMAL, true));
|
|
||||||
m_options->boolean_settings.emplace_back(m_sideways_setting = new ControllerEmu::BooleanSetting(
|
|
||||||
"Sideways Wiimote", _trans("Sideways Wii Remote"),
|
|
||||||
false, ControllerEmu::SettingType::NORMAL, true));
|
|
||||||
|
|
||||||
m_options->numeric_settings.emplace_back(
|
// m_options->AddSetting(&m_motion_plus_setting, {_trans("Attach MotionPlus")}, true);
|
||||||
std::make_unique<ControllerEmu::NumericSetting>(_trans("Speaker Pan"), 0, -100, 100));
|
|
||||||
m_options->numeric_settings.emplace_back(
|
// Note: "Upright" and "Sideways" options can be enabled at the same time which produces an
|
||||||
m_battery_setting = new ControllerEmu::NumericSetting(_trans("Battery"), 95.0 / 100, 0, 100));
|
// orientation where the wiimote points towards the left with the buttons towards you.
|
||||||
|
m_options->AddSetting(&m_upright_setting,
|
||||||
|
{"Upright Wiimote", nullptr, nullptr, _trans("Upright Wii Remote")}, false);
|
||||||
|
|
||||||
|
m_options->AddSetting(&m_sideways_setting,
|
||||||
|
{"Sideways Wiimote", nullptr, nullptr, _trans("Sideways Wii Remote")},
|
||||||
|
false);
|
||||||
|
|
||||||
// hotkeys
|
// hotkeys
|
||||||
groups.emplace_back(m_hotkeys = new ControllerEmu::ModifySettingsButton(_trans("Hotkeys")));
|
groups.emplace_back(m_hotkeys = new ControllerEmu::ModifySettingsButton(_trans("Hotkeys")));
|
||||||
|
@ -667,14 +667,14 @@ bool Wiimote::IsSideways() const
|
||||||
{
|
{
|
||||||
const bool sideways_modifier_toggle = m_hotkeys->getSettingsModifier()[0];
|
const bool sideways_modifier_toggle = m_hotkeys->getSettingsModifier()[0];
|
||||||
const bool sideways_modifier_switch = m_hotkeys->getSettingsModifier()[2];
|
const bool sideways_modifier_switch = m_hotkeys->getSettingsModifier()[2];
|
||||||
return m_sideways_setting->GetValue() ^ sideways_modifier_toggle ^ sideways_modifier_switch;
|
return m_sideways_setting.GetValue() ^ sideways_modifier_toggle ^ sideways_modifier_switch;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Wiimote::IsUpright() const
|
bool Wiimote::IsUpright() const
|
||||||
{
|
{
|
||||||
const bool upright_modifier_toggle = m_hotkeys->getSettingsModifier()[1];
|
const bool upright_modifier_toggle = m_hotkeys->getSettingsModifier()[1];
|
||||||
const bool upright_modifier_switch = m_hotkeys->getSettingsModifier()[3];
|
const bool upright_modifier_switch = m_hotkeys->getSettingsModifier()[3];
|
||||||
return m_upright_setting->GetValue() ^ upright_modifier_toggle ^ upright_modifier_switch;
|
return m_upright_setting.GetValue() ^ upright_modifier_toggle ^ upright_modifier_switch;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Wiimote::SetRumble(bool on)
|
void Wiimote::SetRumble(bool on)
|
||||||
|
|
|
@ -23,14 +23,12 @@ class PointerWrap;
|
||||||
namespace ControllerEmu
|
namespace ControllerEmu
|
||||||
{
|
{
|
||||||
class Attachments;
|
class Attachments;
|
||||||
class BooleanSetting;
|
|
||||||
class Buttons;
|
class Buttons;
|
||||||
class ControlGroup;
|
class ControlGroup;
|
||||||
class Cursor;
|
class Cursor;
|
||||||
class Extension;
|
class Extension;
|
||||||
class Force;
|
class Force;
|
||||||
class ModifySettingsButton;
|
class ModifySettingsButton;
|
||||||
class NumericSetting;
|
|
||||||
class Output;
|
class Output;
|
||||||
class Tilt;
|
class Tilt;
|
||||||
} // namespace ControllerEmu
|
} // namespace ControllerEmu
|
||||||
|
@ -235,12 +233,14 @@ private:
|
||||||
ControllerEmu::Output* m_motor;
|
ControllerEmu::Output* m_motor;
|
||||||
ControllerEmu::Attachments* m_attachments;
|
ControllerEmu::Attachments* m_attachments;
|
||||||
ControllerEmu::ControlGroup* m_options;
|
ControllerEmu::ControlGroup* m_options;
|
||||||
ControllerEmu::BooleanSetting* m_sideways_setting;
|
|
||||||
ControllerEmu::BooleanSetting* m_upright_setting;
|
|
||||||
ControllerEmu::NumericSetting* m_battery_setting;
|
|
||||||
// ControllerEmu::BooleanSetting* m_motion_plus_setting;
|
|
||||||
ControllerEmu::ModifySettingsButton* m_hotkeys;
|
ControllerEmu::ModifySettingsButton* m_hotkeys;
|
||||||
|
|
||||||
|
ControllerEmu::SettingValue<bool> m_sideways_setting;
|
||||||
|
ControllerEmu::SettingValue<bool> m_upright_setting;
|
||||||
|
ControllerEmu::SettingValue<double> m_battery_setting;
|
||||||
|
ControllerEmu::SettingValue<double> m_speaker_pan_setting;
|
||||||
|
// ControllerEmu::SettingValue<bool> m_motion_plus_setting;
|
||||||
|
|
||||||
SpeakerLogic m_speaker_logic;
|
SpeakerLogic m_speaker_logic;
|
||||||
MotionPlus m_motion_plus;
|
MotionPlus m_motion_plus;
|
||||||
CameraLogic m_camera_logic;
|
CameraLogic m_camera_logic;
|
||||||
|
|
|
@ -63,12 +63,10 @@ add_executable(dolphin-emu
|
||||||
Config/Mapping/HotkeyTAS.cpp
|
Config/Mapping/HotkeyTAS.cpp
|
||||||
Config/Mapping/HotkeyWii.cpp
|
Config/Mapping/HotkeyWii.cpp
|
||||||
Config/Mapping/IOWindow.cpp
|
Config/Mapping/IOWindow.cpp
|
||||||
Config/Mapping/MappingBool.cpp
|
|
||||||
Config/Mapping/MappingButton.cpp
|
Config/Mapping/MappingButton.cpp
|
||||||
Config/Mapping/MappingCommon.cpp
|
Config/Mapping/MappingCommon.cpp
|
||||||
Config/Mapping/MappingIndicator.cpp
|
Config/Mapping/MappingIndicator.cpp
|
||||||
Config/Mapping/MappingNumeric.cpp
|
Config/Mapping/MappingNumeric.cpp
|
||||||
Config/Mapping/MappingRadio.cpp
|
|
||||||
Config/Mapping/MappingWidget.cpp
|
Config/Mapping/MappingWidget.cpp
|
||||||
Config/Mapping/MappingWindow.cpp
|
Config/Mapping/MappingWindow.cpp
|
||||||
Config/Mapping/WiimoteEmuExtension.cpp
|
Config/Mapping/WiimoteEmuExtension.cpp
|
||||||
|
|
|
@ -10,7 +10,6 @@
|
||||||
#include "Core/HW/GCPad.h"
|
#include "Core/HW/GCPad.h"
|
||||||
#include "Core/HW/GCPadEmu.h"
|
#include "Core/HW/GCPadEmu.h"
|
||||||
|
|
||||||
#include "InputCommon/ControllerEmu/Setting/BooleanSetting.h"
|
|
||||||
#include "InputCommon/ControllerEmu/Setting/NumericSetting.h"
|
#include "InputCommon/ControllerEmu/Setting/NumericSetting.h"
|
||||||
#include "InputCommon/InputConfig.h"
|
#include "InputCommon/InputConfig.h"
|
||||||
|
|
||||||
|
|
|
@ -1,29 +0,0 @@
|
||||||
// Copyright 2017 Dolphin Emulator Project
|
|
||||||
// Licensed under GPLv2+
|
|
||||||
// Refer to the license.txt file included.
|
|
||||||
|
|
||||||
#include "DolphinQt/Config/Mapping/MappingBool.h"
|
|
||||||
|
|
||||||
#include "DolphinQt/Config/Mapping/MappingWidget.h"
|
|
||||||
|
|
||||||
#include "InputCommon/ControllerEmu/ControllerEmu.h"
|
|
||||||
#include "InputCommon/ControllerEmu/Setting/BooleanSetting.h"
|
|
||||||
#include "InputCommon/ControllerInterface/ControllerInterface.h"
|
|
||||||
|
|
||||||
MappingBool::MappingBool(MappingWidget* parent, ControllerEmu::BooleanSetting* setting)
|
|
||||||
: QCheckBox(tr(setting->m_ui_name.c_str())), m_setting(*setting)
|
|
||||||
{
|
|
||||||
connect(this, &QCheckBox::stateChanged, this, [this, parent](int value) {
|
|
||||||
m_setting.SetValue(value);
|
|
||||||
parent->SaveSettings();
|
|
||||||
});
|
|
||||||
|
|
||||||
connect(parent, &MappingWidget::ConfigChanged, this, &MappingBool::ConfigChanged);
|
|
||||||
}
|
|
||||||
|
|
||||||
void MappingBool::ConfigChanged()
|
|
||||||
{
|
|
||||||
const bool old_state = blockSignals(true);
|
|
||||||
setChecked(m_setting.GetValue());
|
|
||||||
blockSignals(old_state);
|
|
||||||
}
|
|
|
@ -1,25 +0,0 @@
|
||||||
// Copyright 2017 Dolphin Emulator Project
|
|
||||||
// Licensed under GPLv2+
|
|
||||||
// Refer to the license.txt file included.
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include <QCheckBox>
|
|
||||||
|
|
||||||
class MappingWidget;
|
|
||||||
|
|
||||||
namespace ControllerEmu
|
|
||||||
{
|
|
||||||
class BooleanSetting;
|
|
||||||
};
|
|
||||||
|
|
||||||
class MappingBool : public QCheckBox
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
MappingBool(MappingWidget* widget, ControllerEmu::BooleanSetting* setting);
|
|
||||||
|
|
||||||
private:
|
|
||||||
void ConfigChanged();
|
|
||||||
|
|
||||||
ControllerEmu::BooleanSetting& m_setting;
|
|
||||||
};
|
|
|
@ -158,7 +158,7 @@ void MappingIndicator::DrawCursor(ControllerEmu::Cursor& cursor)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Deadzone for Z (forward/backward):
|
// Deadzone for Z (forward/backward):
|
||||||
const double deadzone = cursor.numeric_settings[cursor.SETTING_DEADZONE]->GetValue();
|
const double deadzone = cursor.GetDeadzonePercentage();
|
||||||
if (deadzone > 0.0)
|
if (deadzone > 0.0)
|
||||||
{
|
{
|
||||||
p.setPen(DEADZONE_COLOR);
|
p.setPen(DEADZONE_COLOR);
|
||||||
|
@ -181,23 +181,12 @@ void MappingIndicator::DrawCursor(ControllerEmu::Cursor& cursor)
|
||||||
}
|
}
|
||||||
|
|
||||||
// TV screen or whatever you want to call this:
|
// TV screen or whatever you want to call this:
|
||||||
constexpr double tv_scale = 0.75;
|
constexpr double TV_SCALE = 0.75;
|
||||||
constexpr double center_scale = 2.0 / 3.0;
|
|
||||||
|
|
||||||
const double tv_center = (cursor.numeric_settings[cursor.SETTING_CENTER]->GetValue() - 0.5);
|
|
||||||
const double tv_width = cursor.numeric_settings[cursor.SETTING_WIDTH]->GetValue();
|
|
||||||
const double tv_height = cursor.numeric_settings[cursor.SETTING_HEIGHT]->GetValue();
|
|
||||||
|
|
||||||
p.setPen(tv_pen_color);
|
p.setPen(tv_pen_color);
|
||||||
p.setBrush(tv_brush_color);
|
p.setBrush(tv_brush_color);
|
||||||
auto gate_polygon = GetPolygonFromRadiusGetter(
|
p.drawPolygon(GetPolygonFromRadiusGetter(
|
||||||
[&cursor](double ang) { return cursor.GetGateRadiusAtAngle(ang); }, scale);
|
[&cursor](double ang) { return cursor.GetGateRadiusAtAngle(ang); }, scale * TV_SCALE));
|
||||||
for (auto& pt : gate_polygon)
|
|
||||||
{
|
|
||||||
pt = {pt.x() * tv_width, pt.y() * tv_height + tv_center * center_scale * scale};
|
|
||||||
pt *= tv_scale;
|
|
||||||
}
|
|
||||||
p.drawPolygon(gate_polygon);
|
|
||||||
|
|
||||||
// Deadzone.
|
// Deadzone.
|
||||||
p.setPen(DEADZONE_COLOR);
|
p.setPen(DEADZONE_COLOR);
|
||||||
|
@ -221,8 +210,8 @@ void MappingIndicator::DrawCursor(ControllerEmu::Cursor& cursor)
|
||||||
{
|
{
|
||||||
p.setPen(Qt::NoPen);
|
p.setPen(Qt::NoPen);
|
||||||
p.setBrush(ADJ_INPUT_COLOR);
|
p.setBrush(ADJ_INPUT_COLOR);
|
||||||
const QPointF pt(adj_coord.x / 2.0, (adj_coord.y - tv_center) / 2.0 + tv_center * center_scale);
|
p.drawEllipse(QPointF{adj_coord.x, adj_coord.y} * scale * TV_SCALE, INPUT_DOT_RADIUS,
|
||||||
p.drawEllipse(pt * scale * tv_scale, INPUT_DOT_RADIUS, INPUT_DOT_RADIUS);
|
INPUT_DOT_RADIUS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -444,7 +433,7 @@ void MappingIndicator::DrawForce(ControllerEmu::Force& force)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Deadzone for Z (forward/backward):
|
// Deadzone for Z (forward/backward):
|
||||||
const double deadzone = force.numeric_settings[force.SETTING_DEADZONE]->GetValue();
|
const double deadzone = force.GetDeadzonePercentage();
|
||||||
if (deadzone > 0.0)
|
if (deadzone > 0.0)
|
||||||
{
|
{
|
||||||
p.setPen(DEADZONE_COLOR);
|
p.setPen(DEADZONE_COLOR);
|
||||||
|
|
|
@ -16,7 +16,6 @@ class Control;
|
||||||
class ControlGroup;
|
class ControlGroup;
|
||||||
class Cursor;
|
class Cursor;
|
||||||
class Force;
|
class Force;
|
||||||
class NumericSetting;
|
|
||||||
} // namespace ControllerEmu
|
} // namespace ControllerEmu
|
||||||
|
|
||||||
class QPainter;
|
class QPainter;
|
||||||
|
|
|
@ -7,26 +7,56 @@
|
||||||
#include "DolphinQt/Config/Mapping/MappingWidget.h"
|
#include "DolphinQt/Config/Mapping/MappingWidget.h"
|
||||||
|
|
||||||
#include "InputCommon/ControllerEmu/ControllerEmu.h"
|
#include "InputCommon/ControllerEmu/ControllerEmu.h"
|
||||||
#include "InputCommon/ControllerEmu/Setting/NumericSetting.h"
|
|
||||||
#include "InputCommon/ControllerInterface/ControllerInterface.h"
|
#include "InputCommon/ControllerInterface/ControllerInterface.h"
|
||||||
|
|
||||||
MappingNumeric::MappingNumeric(MappingWidget* parent, ControllerEmu::NumericSetting* setting)
|
MappingDouble::MappingDouble(MappingWidget* parent, ControllerEmu::NumericSetting<double>* setting)
|
||||||
: m_setting(*setting)
|
: QDoubleSpinBox(parent), m_setting(*setting)
|
||||||
{
|
{
|
||||||
setRange(setting->m_low, setting->m_high);
|
setRange(m_setting.GetMinValue(), m_setting.GetMaxValue());
|
||||||
|
setDecimals(2);
|
||||||
|
|
||||||
connect(this, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), this,
|
if (const auto ui_suffix = m_setting.GetUISuffix())
|
||||||
[this, parent](int value) {
|
setSuffix(QStringLiteral(" ") + tr(ui_suffix));
|
||||||
m_setting.SetValue(static_cast<double>(value) / 100);
|
|
||||||
|
if (const auto ui_description = m_setting.GetUIDescription())
|
||||||
|
setToolTip(tr(ui_description));
|
||||||
|
|
||||||
|
connect(this, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this,
|
||||||
|
[this, parent](double value) {
|
||||||
|
m_setting.SetValue(value);
|
||||||
parent->SaveSettings();
|
parent->SaveSettings();
|
||||||
});
|
});
|
||||||
|
|
||||||
connect(parent, &MappingWidget::ConfigChanged, this, &MappingNumeric::ConfigChanged);
|
connect(parent, &MappingWidget::ConfigChanged, this, &MappingDouble::ConfigChanged);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MappingNumeric::ConfigChanged()
|
// Overriding QDoubleSpinBox's fixup to set the default value when input is cleared.
|
||||||
|
void MappingDouble::fixup(QString& input) const
|
||||||
|
{
|
||||||
|
input = QString::number(m_setting.GetDefaultValue());
|
||||||
|
}
|
||||||
|
|
||||||
|
void MappingDouble::ConfigChanged()
|
||||||
{
|
{
|
||||||
const bool old_state = blockSignals(true);
|
const bool old_state = blockSignals(true);
|
||||||
setValue(m_setting.GetValue() * 100);
|
setValue(m_setting.GetValue());
|
||||||
|
blockSignals(old_state);
|
||||||
|
}
|
||||||
|
|
||||||
|
MappingBool::MappingBool(MappingWidget* parent, ControllerEmu::NumericSetting<bool>* setting)
|
||||||
|
: QCheckBox(parent), m_setting(*setting)
|
||||||
|
{
|
||||||
|
connect(this, &QCheckBox::stateChanged, this, [this, parent](int value) {
|
||||||
|
m_setting.SetValue(value != 0);
|
||||||
|
parent->SaveSettings();
|
||||||
|
});
|
||||||
|
|
||||||
|
connect(parent, &MappingWidget::ConfigChanged, this, &MappingBool::ConfigChanged);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MappingBool::ConfigChanged()
|
||||||
|
{
|
||||||
|
const bool old_state = blockSignals(true);
|
||||||
|
setChecked(m_setting.GetValue());
|
||||||
blockSignals(old_state);
|
blockSignals(old_state);
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,23 +4,34 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <QSpinBox>
|
#include <QCheckBox>
|
||||||
|
#include <QDoubleSpinBox>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
|
||||||
|
#include "InputCommon/ControllerEmu/Setting/NumericSetting.h"
|
||||||
|
|
||||||
class MappingWidget;
|
class MappingWidget;
|
||||||
|
|
||||||
namespace ControllerEmu
|
class MappingDouble : public QDoubleSpinBox
|
||||||
{
|
|
||||||
class NumericSetting;
|
|
||||||
}
|
|
||||||
|
|
||||||
class MappingNumeric : public QSpinBox
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
MappingNumeric(MappingWidget* widget, ControllerEmu::NumericSetting* ref);
|
MappingDouble(MappingWidget* parent, ControllerEmu::NumericSetting<double>* setting);
|
||||||
|
|
||||||
|
private:
|
||||||
|
void fixup(QString& input) const override;
|
||||||
|
|
||||||
|
void ConfigChanged();
|
||||||
|
|
||||||
|
ControllerEmu::NumericSetting<double>& m_setting;
|
||||||
|
};
|
||||||
|
|
||||||
|
class MappingBool : public QCheckBox
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
MappingBool(MappingWidget* widget, ControllerEmu::NumericSetting<bool>* setting);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void ConfigChanged();
|
void ConfigChanged();
|
||||||
|
|
||||||
ControllerEmu::NumericSetting& m_setting;
|
ControllerEmu::NumericSetting<bool>& m_setting;
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,29 +0,0 @@
|
||||||
// Copyright 2017 Dolphin Emulator Project
|
|
||||||
// Licensed under GPLv2+
|
|
||||||
// Refer to the license.txt file included.
|
|
||||||
|
|
||||||
#include "DolphinQt/Config/Mapping/MappingRadio.h"
|
|
||||||
|
|
||||||
#include "DolphinQt/Config/Mapping/MappingWidget.h"
|
|
||||||
|
|
||||||
#include "InputCommon/ControllerEmu/ControllerEmu.h"
|
|
||||||
#include "InputCommon/ControllerEmu/Setting/BooleanSetting.h"
|
|
||||||
#include "InputCommon/ControllerInterface/ControllerInterface.h"
|
|
||||||
|
|
||||||
MappingRadio::MappingRadio(MappingWidget* parent, ControllerEmu::BooleanSetting* setting)
|
|
||||||
: QRadioButton(tr(setting->m_ui_name.c_str())), m_setting(*setting)
|
|
||||||
{
|
|
||||||
connect(this, &QRadioButton::toggled, this, [this, parent](int value) {
|
|
||||||
m_setting.SetValue(value);
|
|
||||||
parent->SaveSettings();
|
|
||||||
});
|
|
||||||
|
|
||||||
connect(parent, &MappingWidget::ConfigChanged, this, &MappingRadio::ConfigChanged);
|
|
||||||
}
|
|
||||||
|
|
||||||
void MappingRadio::ConfigChanged()
|
|
||||||
{
|
|
||||||
const bool old_state = blockSignals(true);
|
|
||||||
setChecked(m_setting.GetValue());
|
|
||||||
blockSignals(old_state);
|
|
||||||
}
|
|
|
@ -1,25 +0,0 @@
|
||||||
// Copyright 2017 Dolphin Emulator Project
|
|
||||||
// Licensed under GPLv2+
|
|
||||||
// Refer to the license.txt file included.
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include <QRadioButton>
|
|
||||||
|
|
||||||
class MappingWidget;
|
|
||||||
|
|
||||||
namespace ControllerEmu
|
|
||||||
{
|
|
||||||
class BooleanSetting;
|
|
||||||
};
|
|
||||||
|
|
||||||
class MappingRadio : public QRadioButton
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
MappingRadio(MappingWidget* widget, ControllerEmu::BooleanSetting* setting);
|
|
||||||
|
|
||||||
private:
|
|
||||||
void ConfigChanged();
|
|
||||||
|
|
||||||
ControllerEmu::BooleanSetting& m_setting;
|
|
||||||
};
|
|
|
@ -10,11 +10,9 @@
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
|
|
||||||
#include "DolphinQt/Config/Mapping/IOWindow.h"
|
#include "DolphinQt/Config/Mapping/IOWindow.h"
|
||||||
#include "DolphinQt/Config/Mapping/MappingBool.h"
|
|
||||||
#include "DolphinQt/Config/Mapping/MappingButton.h"
|
#include "DolphinQt/Config/Mapping/MappingButton.h"
|
||||||
#include "DolphinQt/Config/Mapping/MappingIndicator.h"
|
#include "DolphinQt/Config/Mapping/MappingIndicator.h"
|
||||||
#include "DolphinQt/Config/Mapping/MappingNumeric.h"
|
#include "DolphinQt/Config/Mapping/MappingNumeric.h"
|
||||||
#include "DolphinQt/Config/Mapping/MappingRadio.h"
|
|
||||||
#include "DolphinQt/Config/Mapping/MappingWindow.h"
|
#include "DolphinQt/Config/Mapping/MappingWindow.h"
|
||||||
#include "DolphinQt/Settings.h"
|
#include "DolphinQt/Settings.h"
|
||||||
|
|
||||||
|
@ -22,7 +20,6 @@
|
||||||
#include "InputCommon/ControllerEmu/Control/Control.h"
|
#include "InputCommon/ControllerEmu/Control/Control.h"
|
||||||
#include "InputCommon/ControllerEmu/ControlGroup/ControlGroup.h"
|
#include "InputCommon/ControllerEmu/ControlGroup/ControlGroup.h"
|
||||||
#include "InputCommon/ControllerEmu/ControllerEmu.h"
|
#include "InputCommon/ControllerEmu/ControllerEmu.h"
|
||||||
#include "InputCommon/ControllerEmu/Setting/BooleanSetting.h"
|
|
||||||
#include "InputCommon/ControllerEmu/Setting/NumericSetting.h"
|
#include "InputCommon/ControllerEmu/Setting/NumericSetting.h"
|
||||||
#include "InputCommon/ControllerEmu/StickGate.h"
|
#include "InputCommon/ControllerEmu/StickGate.h"
|
||||||
|
|
||||||
|
@ -109,30 +106,25 @@ QGroupBox* MappingWidget::CreateGroupBox(const QString& name, ControllerEmu::Con
|
||||||
m_buttons.push_back(button);
|
m_buttons.push_back(button);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto& numeric : group->numeric_settings)
|
for (auto& setting : group->numeric_settings)
|
||||||
{
|
{
|
||||||
auto* spinbox = new MappingNumeric(this, numeric.get());
|
QWidget* setting_widget = nullptr;
|
||||||
form_layout->addRow(tr(numeric->m_name.c_str()), spinbox);
|
|
||||||
|
switch (setting->GetType())
|
||||||
|
{
|
||||||
|
case ControllerEmu::SettingType::Double:
|
||||||
|
setting_widget = new MappingDouble(
|
||||||
|
this, static_cast<ControllerEmu::NumericSetting<double>*>(setting.get()));
|
||||||
|
break;
|
||||||
|
|
||||||
|
case ControllerEmu::SettingType::Bool:
|
||||||
|
setting_widget =
|
||||||
|
new MappingBool(this, static_cast<ControllerEmu::NumericSetting<bool>*>(setting.get()));
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto& boolean : group->boolean_settings)
|
if (setting_widget)
|
||||||
{
|
form_layout->addRow(tr(setting->GetUIName()), setting_widget);
|
||||||
if (!boolean->IsExclusive())
|
|
||||||
continue;
|
|
||||||
|
|
||||||
auto* checkbox = new MappingRadio(this, boolean.get());
|
|
||||||
|
|
||||||
form_layout->addRow(checkbox);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (auto& boolean : group->boolean_settings)
|
|
||||||
{
|
|
||||||
if (boolean->IsExclusive())
|
|
||||||
continue;
|
|
||||||
|
|
||||||
auto* checkbox = new MappingBool(this, boolean.get());
|
|
||||||
|
|
||||||
form_layout->addRow(checkbox);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (need_indicator)
|
if (need_indicator)
|
||||||
|
|
|
@ -13,11 +13,9 @@
|
||||||
class ControlGroupBox;
|
class ControlGroupBox;
|
||||||
class InputConfig;
|
class InputConfig;
|
||||||
class IOWindow;
|
class IOWindow;
|
||||||
class MappingBool;
|
|
||||||
class MappingButton;
|
class MappingButton;
|
||||||
class MappingNumeric;
|
class MappingNumeric;
|
||||||
class MappingWindow;
|
class MappingWindow;
|
||||||
class MappingRadio;
|
|
||||||
class QGroupBox;
|
class QGroupBox;
|
||||||
|
|
||||||
namespace ControllerEmu
|
namespace ControllerEmu
|
||||||
|
|
|
@ -239,7 +239,7 @@ void MappingWindow::OnSaveProfilePressed()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MappingWindow::OnSelectDevice(int index)
|
void MappingWindow::OnSelectDevice(int)
|
||||||
{
|
{
|
||||||
if (IsMappingAllDevices())
|
if (IsMappingAllDevices())
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -16,7 +16,6 @@
|
||||||
#include "DolphinQt/Config/Mapping/WiimoteEmuExtension.h"
|
#include "DolphinQt/Config/Mapping/WiimoteEmuExtension.h"
|
||||||
|
|
||||||
#include "InputCommon/ControllerEmu/ControlGroup/Attachments.h"
|
#include "InputCommon/ControllerEmu/ControlGroup/Attachments.h"
|
||||||
#include "InputCommon/ControllerEmu/Setting/BooleanSetting.h"
|
|
||||||
#include "InputCommon/InputConfig.h"
|
#include "InputCommon/InputConfig.h"
|
||||||
|
|
||||||
WiimoteEmuGeneral::WiimoteEmuGeneral(MappingWindow* window, WiimoteEmuExtension* extension)
|
WiimoteEmuGeneral::WiimoteEmuGeneral(MappingWindow* window, WiimoteEmuExtension* extension)
|
||||||
|
|
|
@ -81,7 +81,6 @@
|
||||||
<QtMoc Include="Config\Mapping\HotkeyTAS.h" />
|
<QtMoc Include="Config\Mapping\HotkeyTAS.h" />
|
||||||
<QtMoc Include="Config\Mapping\HotkeyWii.h" />
|
<QtMoc Include="Config\Mapping\HotkeyWii.h" />
|
||||||
<QtMoc Include="Config\Mapping\IOWindow.h" />
|
<QtMoc Include="Config\Mapping\IOWindow.h" />
|
||||||
<QtMoc Include="Config\Mapping\MappingBool.h" />
|
|
||||||
<QtMoc Include="Config\Mapping\MappingButton.h" />
|
<QtMoc Include="Config\Mapping\MappingButton.h" />
|
||||||
<QtMoc Include="Config\Mapping\MappingIndicator.h" />
|
<QtMoc Include="Config\Mapping\MappingIndicator.h" />
|
||||||
<QtMoc Include="Config\Mapping\MappingNumeric.h" />
|
<QtMoc Include="Config\Mapping\MappingNumeric.h" />
|
||||||
|
@ -239,7 +238,6 @@
|
||||||
<ClCompile Include="$(QtMocOutPrefix)LogWidget.cpp" />
|
<ClCompile Include="$(QtMocOutPrefix)LogWidget.cpp" />
|
||||||
<ClCompile Include="$(QtMocOutPrefix)MD5Dialog.cpp" />
|
<ClCompile Include="$(QtMocOutPrefix)MD5Dialog.cpp" />
|
||||||
<ClCompile Include="$(QtMocOutPrefix)MainWindow.cpp" />
|
<ClCompile Include="$(QtMocOutPrefix)MainWindow.cpp" />
|
||||||
<ClCompile Include="$(QtMocOutPrefix)MappingBool.cpp" />
|
|
||||||
<ClCompile Include="$(QtMocOutPrefix)MappingButton.cpp" />
|
<ClCompile Include="$(QtMocOutPrefix)MappingButton.cpp" />
|
||||||
<ClCompile Include="$(QtMocOutPrefix)MappingIndicator.cpp" />
|
<ClCompile Include="$(QtMocOutPrefix)MappingIndicator.cpp" />
|
||||||
<ClCompile Include="$(QtMocOutPrefix)MappingNumeric.cpp" />
|
<ClCompile Include="$(QtMocOutPrefix)MappingNumeric.cpp" />
|
||||||
|
@ -316,12 +314,10 @@
|
||||||
<ClCompile Include="Config\Mapping\HotkeyTAS.cpp" />
|
<ClCompile Include="Config\Mapping\HotkeyTAS.cpp" />
|
||||||
<ClCompile Include="Config\Mapping\HotkeyWii.cpp" />
|
<ClCompile Include="Config\Mapping\HotkeyWii.cpp" />
|
||||||
<ClCompile Include="Config\Mapping\IOWindow.cpp" />
|
<ClCompile Include="Config\Mapping\IOWindow.cpp" />
|
||||||
<ClCompile Include="Config\Mapping\MappingBool.cpp" />
|
|
||||||
<ClCompile Include="Config\Mapping\MappingButton.cpp" />
|
<ClCompile Include="Config\Mapping\MappingButton.cpp" />
|
||||||
<ClCompile Include="Config\Mapping\MappingCommon.cpp" />
|
<ClCompile Include="Config\Mapping\MappingCommon.cpp" />
|
||||||
<ClCompile Include="Config\Mapping\MappingIndicator.cpp" />
|
<ClCompile Include="Config\Mapping\MappingIndicator.cpp" />
|
||||||
<ClCompile Include="Config\Mapping\MappingNumeric.cpp" />
|
<ClCompile Include="Config\Mapping\MappingNumeric.cpp" />
|
||||||
<ClCompile Include="Config\Mapping\MappingRadio.cpp" />
|
|
||||||
<ClCompile Include="Config\Mapping\MappingWidget.cpp" />
|
<ClCompile Include="Config\Mapping\MappingWidget.cpp" />
|
||||||
<ClCompile Include="Config\Mapping\MappingWindow.cpp" />
|
<ClCompile Include="Config\Mapping\MappingWindow.cpp" />
|
||||||
<ClCompile Include="Config\Mapping\WiimoteEmuExtension.cpp" />
|
<ClCompile Include="Config\Mapping\WiimoteEmuExtension.cpp" />
|
||||||
|
@ -402,7 +398,6 @@
|
||||||
<!--Put standard C/C++ headers here. Headers that are listed in the QtMoc ItemGroup must NOT be listed here.-->
|
<!--Put standard C/C++ headers here. Headers that are listed in the QtMoc ItemGroup must NOT be listed here.-->
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="Config\Mapping\MappingCommon.h" />
|
<ClInclude Include="Config\Mapping\MappingCommon.h" />
|
||||||
<ClInclude Include="Config\Mapping\MappingRadio.h" />
|
|
||||||
<ClInclude Include="Debugger\RegisterColumn.h" />
|
<ClInclude Include="Debugger\RegisterColumn.h" />
|
||||||
<ClInclude Include="QtUtils\ActionHelper.h" />
|
<ClInclude Include="QtUtils\ActionHelper.h" />
|
||||||
<ClInclude Include="QtUtils\ImageConverter.h" />
|
<ClInclude Include="QtUtils\ImageConverter.h" />
|
||||||
|
|
|
@ -17,7 +17,6 @@ add_library(inputcommon
|
||||||
ControllerEmu/ControlGroup/Slider.cpp
|
ControllerEmu/ControlGroup/Slider.cpp
|
||||||
ControllerEmu/ControlGroup/Tilt.cpp
|
ControllerEmu/ControlGroup/Tilt.cpp
|
||||||
ControllerEmu/ControlGroup/Triggers.cpp
|
ControllerEmu/ControlGroup/Triggers.cpp
|
||||||
ControllerEmu/Setting/BooleanSetting.cpp
|
|
||||||
ControllerEmu/Setting/NumericSetting.cpp
|
ControllerEmu/Setting/NumericSetting.cpp
|
||||||
ControllerInterface/ControllerInterface.cpp
|
ControllerInterface/ControllerInterface.cpp
|
||||||
ControllerInterface/Device.cpp
|
ControllerInterface/Device.cpp
|
||||||
|
|
|
@ -11,7 +11,6 @@
|
||||||
#include "InputCommon/ControllerEmu/Control/Control.h"
|
#include "InputCommon/ControllerEmu/Control/Control.h"
|
||||||
#include "InputCommon/ControllerEmu/ControlGroup/Attachments.h"
|
#include "InputCommon/ControllerEmu/ControlGroup/Attachments.h"
|
||||||
#include "InputCommon/ControllerEmu/ControllerEmu.h"
|
#include "InputCommon/ControllerEmu/ControllerEmu.h"
|
||||||
#include "InputCommon/ControllerEmu/Setting/BooleanSetting.h"
|
|
||||||
#include "InputCommon/ControllerEmu/Setting/NumericSetting.h"
|
#include "InputCommon/ControllerEmu/Setting/NumericSetting.h"
|
||||||
|
|
||||||
namespace ControllerEmu
|
namespace ControllerEmu
|
||||||
|
@ -27,30 +26,26 @@ ControlGroup::ControlGroup(const std::string& name_, const std::string& ui_name_
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ControlGroup::AddDeadzoneSetting(SettingValue<double>* value, double maximum_deadzone)
|
||||||
|
{
|
||||||
|
AddSetting(value,
|
||||||
|
{_trans("Dead Zone"),
|
||||||
|
// i18n: The percent symbol.
|
||||||
|
_trans("%"),
|
||||||
|
// i18n: Refers to the dead-zone setting of gamepad inputs.
|
||||||
|
_trans("Input strength to ignore.")},
|
||||||
|
0, 0, maximum_deadzone);
|
||||||
|
}
|
||||||
|
|
||||||
ControlGroup::~ControlGroup() = default;
|
ControlGroup::~ControlGroup() = default;
|
||||||
|
|
||||||
void ControlGroup::LoadConfig(IniFile::Section* sec, const std::string& defdev,
|
void ControlGroup::LoadConfig(IniFile::Section* sec, const std::string& defdev,
|
||||||
const std::string& base)
|
const std::string& base)
|
||||||
{
|
{
|
||||||
std::string group(base + name + "/");
|
const std::string group(base + name + "/");
|
||||||
|
|
||||||
// settings
|
for (auto& setting : numeric_settings)
|
||||||
for (auto& s : numeric_settings)
|
setting->LoadFromIni(*sec, group);
|
||||||
{
|
|
||||||
if (s->m_type == SettingType::VIRTUAL)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
sec->Get(group + s->m_name, &s->m_value, s->m_default_value * 100);
|
|
||||||
s->m_value /= 100;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (auto& s : boolean_settings)
|
|
||||||
{
|
|
||||||
if (s->m_type == SettingType::VIRTUAL)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
sec->Get(group + s->m_name, &s->m_value, s->m_default_value);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (auto& c : controls)
|
for (auto& c : controls)
|
||||||
{
|
{
|
||||||
|
@ -92,23 +87,10 @@ void ControlGroup::LoadConfig(IniFile::Section* sec, const std::string& defdev,
|
||||||
void ControlGroup::SaveConfig(IniFile::Section* sec, const std::string& defdev,
|
void ControlGroup::SaveConfig(IniFile::Section* sec, const std::string& defdev,
|
||||||
const std::string& base)
|
const std::string& base)
|
||||||
{
|
{
|
||||||
std::string group(base + name + "/");
|
const std::string group(base + name + "/");
|
||||||
|
|
||||||
for (auto& s : numeric_settings)
|
for (auto& setting : numeric_settings)
|
||||||
{
|
setting->SaveToIni(*sec, group);
|
||||||
if (s->m_type == SettingType::VIRTUAL)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
sec->Set(group + s->m_name, s->m_value * 100.0, s->m_default_value * 100.0);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (auto& s : boolean_settings)
|
|
||||||
{
|
|
||||||
if (s->m_type == SettingType::VIRTUAL)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
sec->Set(group + s->m_name, s->m_value, s->m_default_value);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (auto& c : controls)
|
for (auto& c : controls)
|
||||||
{
|
{
|
||||||
|
|
|
@ -13,10 +13,17 @@
|
||||||
|
|
||||||
namespace ControllerEmu
|
namespace ControllerEmu
|
||||||
{
|
{
|
||||||
class BooleanSetting;
|
|
||||||
class Control;
|
class Control;
|
||||||
|
|
||||||
|
class NumericSettingBase;
|
||||||
|
struct NumericSettingDetails;
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
class NumericSetting;
|
class NumericSetting;
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
class SettingValue;
|
||||||
|
|
||||||
enum class GroupType
|
enum class GroupType
|
||||||
{
|
{
|
||||||
Other,
|
Other,
|
||||||
|
@ -46,12 +53,22 @@ public:
|
||||||
|
|
||||||
void SetControlExpression(int index, const std::string& expression);
|
void SetControlExpression(int index, const std::string& expression);
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
void AddSetting(SettingValue<T>* value, const NumericSettingDetails& details,
|
||||||
|
std::common_type_t<T> default_value, std::common_type_t<T> min_value = {},
|
||||||
|
std::common_type_t<T> max_value = T(100))
|
||||||
|
{
|
||||||
|
numeric_settings.emplace_back(
|
||||||
|
std::make_unique<NumericSetting<T>>(value, details, default_value, min_value, max_value));
|
||||||
|
}
|
||||||
|
|
||||||
|
void AddDeadzoneSetting(SettingValue<double>* value, double maximum_deadzone);
|
||||||
|
|
||||||
const std::string name;
|
const std::string name;
|
||||||
const std::string ui_name;
|
const std::string ui_name;
|
||||||
const GroupType type;
|
const GroupType type;
|
||||||
|
|
||||||
std::vector<std::unique_ptr<Control>> controls;
|
std::vector<std::unique_ptr<Control>> controls;
|
||||||
std::vector<std::unique_ptr<NumericSetting>> numeric_settings;
|
std::vector<std::unique_ptr<NumericSettingBase>> numeric_settings;
|
||||||
std::vector<std::unique_ptr<BooleanSetting>> boolean_settings;
|
|
||||||
};
|
};
|
||||||
} // namespace ControllerEmu
|
} // namespace ControllerEmu
|
||||||
|
|
|
@ -16,7 +16,6 @@
|
||||||
#include "InputCommon/ControllerEmu/Control/Control.h"
|
#include "InputCommon/ControllerEmu/Control/Control.h"
|
||||||
#include "InputCommon/ControllerEmu/Control/Input.h"
|
#include "InputCommon/ControllerEmu/Control/Input.h"
|
||||||
#include "InputCommon/ControllerEmu/ControllerEmu.h"
|
#include "InputCommon/ControllerEmu/ControllerEmu.h"
|
||||||
#include "InputCommon/ControllerEmu/Setting/BooleanSetting.h"
|
|
||||||
#include "InputCommon/ControllerEmu/Setting/NumericSetting.h"
|
#include "InputCommon/ControllerEmu/Setting/NumericSetting.h"
|
||||||
|
|
||||||
namespace ControllerEmu
|
namespace ControllerEmu
|
||||||
|
@ -32,12 +31,36 @@ Cursor::Cursor(const std::string& name_)
|
||||||
controls.emplace_back(std::make_unique<Input>(Translate, _trans("Hide")));
|
controls.emplace_back(std::make_unique<Input>(Translate, _trans("Hide")));
|
||||||
controls.emplace_back(std::make_unique<Input>(Translate, _trans("Recenter")));
|
controls.emplace_back(std::make_unique<Input>(Translate, _trans("Recenter")));
|
||||||
|
|
||||||
numeric_settings.emplace_back(std::make_unique<NumericSetting>(_trans("Center"), 0.5));
|
// Default values are optimized for "Super Mario Galaxy 2".
|
||||||
numeric_settings.emplace_back(std::make_unique<NumericSetting>(_trans("Width"), 0.5));
|
// This seems to be acceptable for a good number of games.
|
||||||
numeric_settings.emplace_back(std::make_unique<NumericSetting>(_trans("Height"), 0.5));
|
|
||||||
|
|
||||||
boolean_settings.emplace_back(std::make_unique<BooleanSetting>(_trans("Relative Input"), false));
|
AddSetting(&m_vertical_offset_setting,
|
||||||
boolean_settings.emplace_back(std::make_unique<BooleanSetting>(_trans("Auto-Hide"), false));
|
// i18n: Refers to a positional offset applied to an emulated wiimote.
|
||||||
|
{_trans("Vertical Offset"),
|
||||||
|
// i18n: The symbol/abbreviation for centimeters.
|
||||||
|
_trans("cm")},
|
||||||
|
10, -100, 100);
|
||||||
|
|
||||||
|
AddSetting(&m_yaw_setting,
|
||||||
|
// i18n: Refers to an amount of rotational movement about the "yaw" axis.
|
||||||
|
{_trans("Total Yaw"),
|
||||||
|
// i18n: The symbol/abbreviation for degrees (unit of angular measure).
|
||||||
|
_trans("°"),
|
||||||
|
// i18n: Refers to emulated wii remote movements.
|
||||||
|
_trans("Total rotation about the yaw axis.")},
|
||||||
|
15, 0, 180);
|
||||||
|
|
||||||
|
AddSetting(&m_pitch_setting,
|
||||||
|
// i18n: Refers to an amount of rotational movement about the "pitch" axis.
|
||||||
|
{_trans("Total Pitch"),
|
||||||
|
// i18n: The symbol/abbreviation for degrees (unit of angular measure).
|
||||||
|
_trans("°"),
|
||||||
|
// i18n: Refers to emulated wii remote movements.
|
||||||
|
_trans("Total rotation about the pitch axis.")},
|
||||||
|
15, 0, 180);
|
||||||
|
|
||||||
|
AddSetting(&m_relative_setting, {_trans("Relative Input")}, false);
|
||||||
|
AddSetting(&m_autohide_setting, {_trans("Auto-Hide")}, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
Cursor::ReshapeData Cursor::GetReshapableState(bool adjusted)
|
Cursor::ReshapeData Cursor::GetReshapableState(bool adjusted)
|
||||||
|
@ -81,7 +104,7 @@ Cursor::StateData Cursor::GetState(const bool adjusted)
|
||||||
const double max_z_step = STEP_Z_PER_SEC / 1000.0 * ms_since_update;
|
const double max_z_step = STEP_Z_PER_SEC / 1000.0 * ms_since_update;
|
||||||
|
|
||||||
// Apply deadzone to z:
|
// Apply deadzone to z:
|
||||||
const ControlState deadzone = numeric_settings[SETTING_DEADZONE]->GetValue();
|
const ControlState deadzone = GetDeadzonePercentage();
|
||||||
z = std::copysign(std::max(0.0, std::abs(z) - deadzone) / (1.0 - deadzone), z);
|
z = std::copysign(std::max(0.0, std::abs(z) - deadzone) / (1.0 - deadzone), z);
|
||||||
|
|
||||||
// Smooth out z movement:
|
// Smooth out z movement:
|
||||||
|
@ -89,7 +112,7 @@ Cursor::StateData Cursor::GetState(const bool adjusted)
|
||||||
m_state.z += MathUtil::Clamp(z - m_state.z, -max_z_step, max_z_step);
|
m_state.z += MathUtil::Clamp(z - m_state.z, -max_z_step, max_z_step);
|
||||||
|
|
||||||
// Relative input:
|
// Relative input:
|
||||||
if (boolean_settings[0]->GetValue())
|
if (m_relative_setting.GetValue())
|
||||||
{
|
{
|
||||||
// Recenter:
|
// Recenter:
|
||||||
if (controls[7]->control_ref->State() > BUTTON_THRESHOLD)
|
if (controls[7]->control_ref->State() > BUTTON_THRESHOLD)
|
||||||
|
@ -112,12 +135,7 @@ Cursor::StateData Cursor::GetState(const bool adjusted)
|
||||||
|
|
||||||
StateData result = m_state;
|
StateData result = m_state;
|
||||||
|
|
||||||
// Adjust cursor according to settings:
|
const bool autohide = m_autohide_setting.GetValue();
|
||||||
result.x *= (numeric_settings[SETTING_WIDTH]->GetValue() * 2);
|
|
||||||
result.y *= (numeric_settings[SETTING_HEIGHT]->GetValue() * 2);
|
|
||||||
result.y += (numeric_settings[SETTING_CENTER]->GetValue() - 0.5);
|
|
||||||
|
|
||||||
const bool autohide = boolean_settings[1]->GetValue();
|
|
||||||
|
|
||||||
// Auto-hide timer:
|
// Auto-hide timer:
|
||||||
// TODO: should Z movement reset this?
|
// TODO: should Z movement reset this?
|
||||||
|
@ -144,4 +162,19 @@ Cursor::StateData Cursor::GetState(const bool adjusted)
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ControlState Cursor::GetTotalYaw() const
|
||||||
|
{
|
||||||
|
return m_yaw_setting.GetValue() * MathUtil::TAU / 360;
|
||||||
|
}
|
||||||
|
|
||||||
|
ControlState Cursor::GetTotalPitch() const
|
||||||
|
{
|
||||||
|
return m_pitch_setting.GetValue() * MathUtil::TAU / 360;
|
||||||
|
}
|
||||||
|
|
||||||
|
ControlState Cursor::GetVerticalOffset() const
|
||||||
|
{
|
||||||
|
return m_vertical_offset_setting.GetValue() / 100;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace ControllerEmu
|
} // namespace ControllerEmu
|
||||||
|
|
|
@ -22,13 +22,6 @@ public:
|
||||||
ControlState z{};
|
ControlState z{};
|
||||||
};
|
};
|
||||||
|
|
||||||
enum
|
|
||||||
{
|
|
||||||
SETTING_CENTER = ReshapableInput::SETTING_COUNT,
|
|
||||||
SETTING_WIDTH,
|
|
||||||
SETTING_HEIGHT,
|
|
||||||
};
|
|
||||||
|
|
||||||
explicit Cursor(const std::string& name);
|
explicit Cursor(const std::string& name);
|
||||||
|
|
||||||
ReshapeData GetReshapableState(bool adjusted) final override;
|
ReshapeData GetReshapableState(bool adjusted) final override;
|
||||||
|
@ -36,6 +29,15 @@ public:
|
||||||
|
|
||||||
StateData GetState(bool adjusted);
|
StateData GetState(bool adjusted);
|
||||||
|
|
||||||
|
// Yaw movement in radians.
|
||||||
|
ControlState GetTotalYaw() const;
|
||||||
|
|
||||||
|
// Pitch movement in radians.
|
||||||
|
ControlState GetTotalPitch() const;
|
||||||
|
|
||||||
|
// Vertical offset in meters.
|
||||||
|
ControlState GetVerticalOffset() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// This is used to reduce the cursor speed for relative input
|
// This is used to reduce the cursor speed for relative input
|
||||||
// to something that makes sense with the default range.
|
// to something that makes sense with the default range.
|
||||||
|
@ -59,5 +61,12 @@ private:
|
||||||
|
|
||||||
using Clock = std::chrono::steady_clock;
|
using Clock = std::chrono::steady_clock;
|
||||||
Clock::time_point m_last_update;
|
Clock::time_point m_last_update;
|
||||||
|
|
||||||
|
SettingValue<double> m_yaw_setting;
|
||||||
|
SettingValue<double> m_pitch_setting;
|
||||||
|
SettingValue<double> m_vertical_offset_setting;
|
||||||
|
|
||||||
|
SettingValue<bool> m_relative_setting;
|
||||||
|
SettingValue<bool> m_autohide_setting;
|
||||||
};
|
};
|
||||||
} // namespace ControllerEmu
|
} // namespace ControllerEmu
|
||||||
|
|
|
@ -25,15 +25,30 @@ Force::Force(const std::string& name_) : ReshapableInput(name_, name_, GroupType
|
||||||
controls.emplace_back(std::make_unique<Input>(Translate, _trans("Forward")));
|
controls.emplace_back(std::make_unique<Input>(Translate, _trans("Forward")));
|
||||||
controls.emplace_back(std::make_unique<Input>(Translate, _trans("Backward")));
|
controls.emplace_back(std::make_unique<Input>(Translate, _trans("Backward")));
|
||||||
|
|
||||||
// Maximum swing movement (centimeters).
|
AddSetting(&m_distance_setting,
|
||||||
numeric_settings.emplace_back(std::make_unique<NumericSetting>(_trans("Distance"), 0.25, 1, 100));
|
{_trans("Distance"),
|
||||||
|
// i18n: The symbol/abbreviation for centimeters.
|
||||||
|
_trans("cm"),
|
||||||
|
// i18n: Refering to emulated wii remote swing movement.
|
||||||
|
_trans("Distance of travel from neutral position.")},
|
||||||
|
25, 0, 100);
|
||||||
|
|
||||||
// Maximum jerk (m/s^3).
|
AddSetting(&m_jerk_setting,
|
||||||
// i18n: "Jerk" as it relates to physics. The time derivative of acceleration.
|
// i18n: "Jerk" as it relates to physics. The time derivative of acceleration.
|
||||||
numeric_settings.emplace_back(std::make_unique<NumericSetting>(_trans("Jerk"), 5.0, 1, 1000));
|
{_trans("Jerk"),
|
||||||
|
// i18n: The symbol/abbreviation for meters per second to the 3rd power.
|
||||||
|
_trans("m/s³"),
|
||||||
|
// i18n: Refering to emulated wii remote swing movement.
|
||||||
|
_trans("Maximum change in acceleration.")},
|
||||||
|
500, 1, 1000);
|
||||||
|
|
||||||
// Angle of twist applied at the extremities of the swing (degrees).
|
AddSetting(&m_angle_setting,
|
||||||
numeric_settings.emplace_back(std::make_unique<NumericSetting>(_trans("Angle"), 0.45, 0, 180));
|
{_trans("Angle"),
|
||||||
|
// i18n: The symbol/abbreviation for degrees (unit of angular measure).
|
||||||
|
_trans("°"),
|
||||||
|
// i18n: Refering to emulated wii remote swing movement.
|
||||||
|
_trans("Rotation applied at extremities of swing.")},
|
||||||
|
45, 0, 180);
|
||||||
}
|
}
|
||||||
|
|
||||||
Force::ReshapeData Force::GetReshapableState(bool adjusted)
|
Force::ReshapeData Force::GetReshapableState(bool adjusted)
|
||||||
|
@ -56,7 +71,7 @@ Force::StateData Force::GetState(bool adjusted)
|
||||||
if (adjusted)
|
if (adjusted)
|
||||||
{
|
{
|
||||||
// Apply deadzone to z.
|
// Apply deadzone to z.
|
||||||
const ControlState deadzone = numeric_settings[SETTING_DEADZONE]->GetValue();
|
const ControlState deadzone = GetDeadzonePercentage();
|
||||||
z = std::copysign(std::max(0.0, std::abs(z) - deadzone) / (1.0 - deadzone), z);
|
z = std::copysign(std::max(0.0, std::abs(z) - deadzone) / (1.0 - deadzone), z);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -66,22 +81,22 @@ Force::StateData Force::GetState(bool adjusted)
|
||||||
ControlState Force::GetGateRadiusAtAngle(double) const
|
ControlState Force::GetGateRadiusAtAngle(double) const
|
||||||
{
|
{
|
||||||
// Just a circle of the configured distance:
|
// Just a circle of the configured distance:
|
||||||
return numeric_settings[SETTING_DISTANCE]->GetValue();
|
return GetMaxDistance();
|
||||||
}
|
}
|
||||||
|
|
||||||
ControlState Force::GetMaxJerk() const
|
ControlState Force::GetMaxJerk() const
|
||||||
{
|
{
|
||||||
return numeric_settings[SETTING_JERK]->GetValue() * 100;
|
return m_jerk_setting.GetValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
ControlState Force::GetTwistAngle() const
|
ControlState Force::GetTwistAngle() const
|
||||||
{
|
{
|
||||||
return numeric_settings[SETTING_ANGLE]->GetValue() * MathUtil::TAU / 3.60;
|
return m_angle_setting.GetValue() * MathUtil::TAU / 360;
|
||||||
}
|
}
|
||||||
|
|
||||||
ControlState Force::GetMaxDistance() const
|
ControlState Force::GetMaxDistance() const
|
||||||
{
|
{
|
||||||
return numeric_settings[SETTING_DISTANCE]->GetValue();
|
return m_distance_setting.GetValue() / 100;
|
||||||
}
|
}
|
||||||
|
|
||||||
ControlState Force::GetDefaultInputRadiusAtAngle(double) const
|
ControlState Force::GetDefaultInputRadiusAtAngle(double) const
|
||||||
|
|
|
@ -36,11 +36,8 @@ public:
|
||||||
ControlState GetMaxDistance() const;
|
ControlState GetMaxDistance() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
enum
|
SettingValue<double> m_distance_setting;
|
||||||
{
|
SettingValue<double> m_jerk_setting;
|
||||||
SETTING_DISTANCE = ReshapableInput::SETTING_COUNT,
|
SettingValue<double> m_angle_setting;
|
||||||
SETTING_JERK,
|
|
||||||
SETTING_ANGLE,
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
} // namespace ControllerEmu
|
} // namespace ControllerEmu
|
||||||
|
|
|
@ -14,22 +14,28 @@
|
||||||
|
|
||||||
#include "InputCommon/ControlReference/ControlReference.h"
|
#include "InputCommon/ControlReference/ControlReference.h"
|
||||||
#include "InputCommon/ControllerEmu/Control/Control.h"
|
#include "InputCommon/ControllerEmu/Control/Control.h"
|
||||||
#include "InputCommon/ControllerEmu/Setting/NumericSetting.h"
|
|
||||||
|
|
||||||
namespace ControllerEmu
|
namespace ControllerEmu
|
||||||
{
|
{
|
||||||
MixedTriggers::MixedTriggers(const std::string& name_)
|
MixedTriggers::MixedTriggers(const std::string& name_)
|
||||||
: ControlGroup(name_, GroupType::MixedTriggers)
|
: ControlGroup(name_, GroupType::MixedTriggers)
|
||||||
{
|
{
|
||||||
numeric_settings.emplace_back(std::make_unique<NumericSetting>(_trans("Threshold"), 0.9));
|
AddSetting(&m_threshold_setting,
|
||||||
numeric_settings.emplace_back(std::make_unique<NumericSetting>(_trans("Dead Zone"), 0.0, 0, 25));
|
{_trans("Threshold"),
|
||||||
|
// i18n: The percent symbol.
|
||||||
|
_trans("%"),
|
||||||
|
// i18n: Refers to the "threshold" setting for pressure sensitive gamepad inputs.
|
||||||
|
_trans("Input strength required for activation.")},
|
||||||
|
90, 0, 100);
|
||||||
|
|
||||||
|
AddDeadzoneSetting(&m_deadzone_setting, 25);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MixedTriggers::GetState(u16* const digital, const u16* bitmasks, ControlState* analog,
|
void MixedTriggers::GetState(u16* const digital, const u16* bitmasks, ControlState* analog,
|
||||||
bool adjusted) const
|
bool adjusted) const
|
||||||
{
|
{
|
||||||
const ControlState threshold = numeric_settings[SETTING_THRESHOLD]->GetValue();
|
const ControlState threshold = GetThreshold();
|
||||||
ControlState deadzone = numeric_settings[SETTING_DEADZONE]->GetValue();
|
ControlState deadzone = GetDeadzone();
|
||||||
|
|
||||||
// Return raw values. (used in UI)
|
// Return raw values. (used in UI)
|
||||||
if (!adjusted)
|
if (!adjusted)
|
||||||
|
@ -63,12 +69,12 @@ void MixedTriggers::GetState(u16* const digital, const u16* bitmasks, ControlSta
|
||||||
|
|
||||||
ControlState MixedTriggers::GetDeadzone() const
|
ControlState MixedTriggers::GetDeadzone() const
|
||||||
{
|
{
|
||||||
return numeric_settings[SETTING_DEADZONE]->GetValue();
|
return m_deadzone_setting.GetValue() / 100;
|
||||||
}
|
}
|
||||||
|
|
||||||
ControlState MixedTriggers::GetThreshold() const
|
ControlState MixedTriggers::GetThreshold() const
|
||||||
{
|
{
|
||||||
return numeric_settings[SETTING_THRESHOLD]->GetValue();
|
return m_threshold_setting.GetValue() / 100;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace ControllerEmu
|
} // namespace ControllerEmu
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include "InputCommon/ControllerEmu/ControlGroup/ControlGroup.h"
|
#include "InputCommon/ControllerEmu/ControlGroup/ControlGroup.h"
|
||||||
|
#include "InputCommon/ControllerEmu/Setting/NumericSetting.h"
|
||||||
#include "InputCommon/ControllerInterface/Device.h"
|
#include "InputCommon/ControllerInterface/Device.h"
|
||||||
|
|
||||||
namespace ControllerEmu
|
namespace ControllerEmu
|
||||||
|
@ -22,10 +23,7 @@ public:
|
||||||
ControlState GetThreshold() const;
|
ControlState GetThreshold() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
enum
|
SettingValue<double> m_threshold_setting;
|
||||||
{
|
SettingValue<double> m_deadzone_setting;
|
||||||
SETTING_THRESHOLD,
|
|
||||||
SETTING_DEADZONE,
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
} // namespace ControllerEmu
|
} // namespace ControllerEmu
|
||||||
|
|
|
@ -13,7 +13,6 @@
|
||||||
#include "InputCommon/ControlReference/ControlReference.h"
|
#include "InputCommon/ControlReference/ControlReference.h"
|
||||||
#include "InputCommon/ControllerEmu/Control/Control.h"
|
#include "InputCommon/ControllerEmu/Control/Control.h"
|
||||||
#include "InputCommon/ControllerEmu/Control/Input.h"
|
#include "InputCommon/ControllerEmu/Control/Input.h"
|
||||||
#include "InputCommon/ControllerEmu/Setting/BooleanSetting.h"
|
|
||||||
#include "InputCommon/ControllerEmu/Setting/NumericSetting.h"
|
#include "InputCommon/ControllerEmu/Setting/NumericSetting.h"
|
||||||
#include "VideoCommon/OnScreenDisplay.h"
|
#include "VideoCommon/OnScreenDisplay.h"
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,6 @@
|
||||||
#include "InputCommon/ControllerEmu/Control/Control.h"
|
#include "InputCommon/ControllerEmu/Control/Control.h"
|
||||||
#include "InputCommon/ControllerEmu/Control/Input.h"
|
#include "InputCommon/ControllerEmu/Control/Input.h"
|
||||||
#include "InputCommon/ControllerEmu/ControllerEmu.h"
|
#include "InputCommon/ControllerEmu/ControllerEmu.h"
|
||||||
#include "InputCommon/ControllerEmu/Setting/NumericSetting.h"
|
|
||||||
|
|
||||||
namespace ControllerEmu
|
namespace ControllerEmu
|
||||||
{
|
{
|
||||||
|
@ -23,7 +22,7 @@ Slider::Slider(const std::string& name_, const std::string& ui_name_)
|
||||||
controls.emplace_back(std::make_unique<Input>(Translate, _trans("Left")));
|
controls.emplace_back(std::make_unique<Input>(Translate, _trans("Left")));
|
||||||
controls.emplace_back(std::make_unique<Input>(Translate, _trans("Right")));
|
controls.emplace_back(std::make_unique<Input>(Translate, _trans("Right")));
|
||||||
|
|
||||||
numeric_settings.emplace_back(std::make_unique<NumericSetting>(_trans("Dead Zone"), 0, 0, 50));
|
AddDeadzoneSetting(&m_deadzone_setting, 50);
|
||||||
}
|
}
|
||||||
|
|
||||||
Slider::Slider(const std::string& name_) : Slider(name_, name_)
|
Slider::Slider(const std::string& name_) : Slider(name_, name_)
|
||||||
|
@ -32,7 +31,7 @@ Slider::Slider(const std::string& name_) : Slider(name_, name_)
|
||||||
|
|
||||||
Slider::StateData Slider::GetState()
|
Slider::StateData Slider::GetState()
|
||||||
{
|
{
|
||||||
const ControlState deadzone = numeric_settings[0]->GetValue();
|
const ControlState deadzone = m_deadzone_setting.GetValue() / 100;
|
||||||
const ControlState state = controls[1]->control_ref->State() - controls[0]->control_ref->State();
|
const ControlState state = controls[1]->control_ref->State() - controls[0]->control_ref->State();
|
||||||
|
|
||||||
if (fabs(state) > deadzone)
|
if (fabs(state) > deadzone)
|
||||||
|
|
|
@ -5,7 +5,9 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include "InputCommon/ControllerEmu/ControlGroup/ControlGroup.h"
|
#include "InputCommon/ControllerEmu/ControlGroup/ControlGroup.h"
|
||||||
|
#include "InputCommon/ControllerEmu/Setting/NumericSetting.h"
|
||||||
#include "InputCommon/ControllerInterface/Device.h"
|
#include "InputCommon/ControllerInterface/Device.h"
|
||||||
|
|
||||||
namespace ControllerEmu
|
namespace ControllerEmu
|
||||||
|
@ -22,5 +24,8 @@ public:
|
||||||
explicit Slider(const std::string& name_);
|
explicit Slider(const std::string& name_);
|
||||||
|
|
||||||
StateData GetState();
|
StateData GetState();
|
||||||
|
|
||||||
|
private:
|
||||||
|
SettingValue<double> m_deadzone_setting;
|
||||||
};
|
};
|
||||||
} // namespace ControllerEmu
|
} // namespace ControllerEmu
|
||||||
|
|
|
@ -24,7 +24,13 @@ Tilt::Tilt(const std::string& name_) : ReshapableInput(name_, name_, GroupType::
|
||||||
|
|
||||||
controls.emplace_back(std::make_unique<Input>(Translate, _trans("Modifier")));
|
controls.emplace_back(std::make_unique<Input>(Translate, _trans("Modifier")));
|
||||||
|
|
||||||
numeric_settings.emplace_back(std::make_unique<NumericSetting>(_trans("Angle"), 0.9, 0, 180));
|
AddSetting(&m_max_angle_setting,
|
||||||
|
{_trans("Angle"),
|
||||||
|
// i18n: The symbol/abbreviation for degrees (unit of angular measure).
|
||||||
|
_trans("°"),
|
||||||
|
// i18n: Refers to emulated wii remote movement.
|
||||||
|
_trans("Maximum tilt angle.")},
|
||||||
|
90, 0, 180);
|
||||||
}
|
}
|
||||||
|
|
||||||
Tilt::ReshapeData Tilt::GetReshapableState(bool adjusted)
|
Tilt::ReshapeData Tilt::GetReshapableState(bool adjusted)
|
||||||
|
@ -48,7 +54,7 @@ Tilt::StateData Tilt::GetState()
|
||||||
|
|
||||||
ControlState Tilt::GetGateRadiusAtAngle(double ang) const
|
ControlState Tilt::GetGateRadiusAtAngle(double ang) const
|
||||||
{
|
{
|
||||||
const ControlState max_tilt_angle = numeric_settings[SETTING_MAX_ANGLE]->GetValue() / 1.8;
|
const ControlState max_tilt_angle = m_max_angle_setting.GetValue() / 180;
|
||||||
return SquareStickGate(max_tilt_angle).GetRadiusAtAngle(ang);
|
return SquareStickGate(max_tilt_angle).GetRadiusAtAngle(ang);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
#include "InputCommon/ControllerEmu/Setting/NumericSetting.h"
|
||||||
#include "InputCommon/ControllerEmu/StickGate.h"
|
#include "InputCommon/ControllerEmu/StickGate.h"
|
||||||
#include "InputCommon/ControllerInterface/Device.h"
|
#include "InputCommon/ControllerInterface/Device.h"
|
||||||
|
|
||||||
|
@ -28,9 +29,6 @@ public:
|
||||||
StateData GetState();
|
StateData GetState();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
enum
|
SettingValue<double> m_max_angle_setting;
|
||||||
{
|
|
||||||
SETTING_MAX_ANGLE = ReshapableInput::SETTING_COUNT,
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
} // namespace ControllerEmu
|
} // namespace ControllerEmu
|
||||||
|
|
|
@ -18,13 +18,13 @@ namespace ControllerEmu
|
||||||
{
|
{
|
||||||
Triggers::Triggers(const std::string& name_) : ControlGroup(name_, GroupType::Triggers)
|
Triggers::Triggers(const std::string& name_) : ControlGroup(name_, GroupType::Triggers)
|
||||||
{
|
{
|
||||||
numeric_settings.emplace_back(std::make_unique<NumericSetting>(_trans("Dead Zone"), 0, 0, 50));
|
AddDeadzoneSetting(&m_deadzone_setting, 50);
|
||||||
}
|
}
|
||||||
|
|
||||||
Triggers::StateData Triggers::GetState()
|
Triggers::StateData Triggers::GetState()
|
||||||
{
|
{
|
||||||
const size_t trigger_count = controls.size();
|
const size_t trigger_count = controls.size();
|
||||||
const ControlState deadzone = numeric_settings[0]->GetValue();
|
const ControlState deadzone = m_deadzone_setting.GetValue() / 100;
|
||||||
|
|
||||||
StateData result(trigger_count);
|
StateData result(trigger_count);
|
||||||
for (size_t i = 0; i < trigger_count; ++i)
|
for (size_t i = 0; i < trigger_count; ++i)
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "InputCommon/ControllerEmu/ControlGroup/ControlGroup.h"
|
#include "InputCommon/ControllerEmu/ControlGroup/ControlGroup.h"
|
||||||
|
#include "InputCommon/ControllerEmu/Setting/NumericSetting.h"
|
||||||
#include "InputCommon/ControllerInterface/Device.h"
|
#include "InputCommon/ControllerInterface/Device.h"
|
||||||
|
|
||||||
namespace ControllerEmu
|
namespace ControllerEmu
|
||||||
|
@ -26,5 +27,8 @@ public:
|
||||||
explicit Triggers(const std::string& name);
|
explicit Triggers(const std::string& name);
|
||||||
|
|
||||||
StateData GetState();
|
StateData GetState();
|
||||||
|
|
||||||
|
private:
|
||||||
|
SettingValue<double> m_deadzone_setting;
|
||||||
};
|
};
|
||||||
} // namespace ControllerEmu
|
} // namespace ControllerEmu
|
||||||
|
|
|
@ -1,38 +0,0 @@
|
||||||
// Copyright 2017 Dolphin Emulator Project
|
|
||||||
// Licensed under GPLv2+
|
|
||||||
// Refer to the license.txt file included.
|
|
||||||
|
|
||||||
#include "InputCommon/ControllerEmu/Setting/BooleanSetting.h"
|
|
||||||
|
|
||||||
namespace ControllerEmu
|
|
||||||
{
|
|
||||||
BooleanSetting::BooleanSetting(const std::string& setting_name, const std::string& ui_name,
|
|
||||||
const bool default_value, const SettingType setting_type,
|
|
||||||
const bool exclusive)
|
|
||||||
: m_type(setting_type), m_name(setting_name), m_ui_name(ui_name),
|
|
||||||
m_default_value(default_value), m_value(default_value), m_exclusive(exclusive)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
BooleanSetting::BooleanSetting(const std::string& setting_name, const bool default_value,
|
|
||||||
const SettingType setting_type, const bool exclusive)
|
|
||||||
: BooleanSetting(setting_name, setting_name, default_value, setting_type, exclusive)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
bool BooleanSetting::GetValue() const
|
|
||||||
{
|
|
||||||
return m_value;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool BooleanSetting::IsExclusive() const
|
|
||||||
{
|
|
||||||
return m_exclusive;
|
|
||||||
}
|
|
||||||
|
|
||||||
void BooleanSetting::SetValue(bool value)
|
|
||||||
{
|
|
||||||
m_value = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace ControllerEmu
|
|
|
@ -1,38 +0,0 @@
|
||||||
// Copyright 2017 Dolphin Emulator Project
|
|
||||||
// Licensed under GPLv2+
|
|
||||||
// Refer to the license.txt file included.
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
#include "InputCommon/ControllerEmu/Setting/Setting.h"
|
|
||||||
#include "InputCommon/ControllerInterface/Device.h"
|
|
||||||
|
|
||||||
namespace ControllerEmu
|
|
||||||
{
|
|
||||||
class BooleanSetting
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
BooleanSetting(const std::string& setting_name, const std::string& ui_name,
|
|
||||||
const bool default_value, const SettingType setting_type = SettingType::NORMAL,
|
|
||||||
const bool exclusive = false);
|
|
||||||
BooleanSetting(const std::string& setting_name, const bool default_value,
|
|
||||||
const SettingType setting_type = SettingType::NORMAL,
|
|
||||||
const bool exclusive = false);
|
|
||||||
|
|
||||||
bool GetValue() const;
|
|
||||||
void SetValue(bool value);
|
|
||||||
bool IsExclusive() const;
|
|
||||||
|
|
||||||
const SettingType m_type;
|
|
||||||
const std::string m_name;
|
|
||||||
const std::string m_ui_name;
|
|
||||||
const bool m_default_value;
|
|
||||||
bool m_value;
|
|
||||||
|
|
||||||
private:
|
|
||||||
const bool m_exclusive;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace ControllerEmu
|
|
|
@ -6,20 +6,35 @@
|
||||||
|
|
||||||
namespace ControllerEmu
|
namespace ControllerEmu
|
||||||
{
|
{
|
||||||
NumericSetting::NumericSetting(const std::string& setting_name, const ControlState default_value,
|
NumericSettingBase::NumericSettingBase(const NumericSettingDetails& details) : m_details(details)
|
||||||
const u32 low, const u32 high, const SettingType setting_type)
|
|
||||||
: m_type(setting_type), m_name(setting_name), m_default_value(default_value), m_low(low),
|
|
||||||
m_high(high), m_value(default_value)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
ControlState NumericSetting::GetValue() const
|
const char* NumericSettingBase::GetUIName() const
|
||||||
{
|
{
|
||||||
return m_value;
|
return m_details.ui_name;
|
||||||
}
|
}
|
||||||
void NumericSetting::SetValue(ControlState value)
|
|
||||||
|
const char* NumericSettingBase::GetUISuffix() const
|
||||||
{
|
{
|
||||||
m_value = value;
|
return m_details.ui_suffix;
|
||||||
|
}
|
||||||
|
|
||||||
|
const char* NumericSettingBase::GetUIDescription() const
|
||||||
|
{
|
||||||
|
return m_details.ui_description;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <>
|
||||||
|
SettingType NumericSetting<double>::GetType() const
|
||||||
|
{
|
||||||
|
return SettingType::Double;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <>
|
||||||
|
SettingType NumericSetting<bool>::GetType() const
|
||||||
|
{
|
||||||
|
return SettingType::Bool;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace ControllerEmu
|
} // namespace ControllerEmu
|
||||||
|
|
|
@ -4,29 +4,127 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <atomic>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include "Common/CommonTypes.h"
|
#include "Common/CommonTypes.h"
|
||||||
#include "InputCommon/ControllerEmu/Setting/Setting.h"
|
#include "Common/IniFile.h"
|
||||||
#include "InputCommon/ControllerInterface/Device.h"
|
#include "InputCommon/ControllerInterface/Device.h"
|
||||||
|
|
||||||
namespace ControllerEmu
|
namespace ControllerEmu
|
||||||
{
|
{
|
||||||
class NumericSetting
|
enum class SettingType
|
||||||
|
{
|
||||||
|
Double,
|
||||||
|
Bool,
|
||||||
|
};
|
||||||
|
|
||||||
|
struct NumericSettingDetails
|
||||||
|
{
|
||||||
|
NumericSettingDetails(const char* const _ini_name, const char* const _ui_suffix = nullptr,
|
||||||
|
const char* const _ui_description = nullptr,
|
||||||
|
const char* const _ui_name = nullptr)
|
||||||
|
: ini_name(_ini_name), ui_suffix(_ui_suffix), ui_description(_ui_description),
|
||||||
|
ui_name(_ui_name ? _ui_name : _ini_name)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
// The name used in ini files.
|
||||||
|
const char* const ini_name;
|
||||||
|
|
||||||
|
// A string applied to the number in the UI (unit of measure).
|
||||||
|
const char* const ui_suffix;
|
||||||
|
|
||||||
|
// Detailed description of the setting.
|
||||||
|
const char* const ui_description;
|
||||||
|
|
||||||
|
// The name used in the UI (if different from ini file).
|
||||||
|
const char* const ui_name;
|
||||||
|
};
|
||||||
|
|
||||||
|
class NumericSettingBase
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
NumericSetting(const std::string& setting_name, const ControlState default_value,
|
NumericSettingBase(const NumericSettingDetails& details);
|
||||||
const u32 low = 0, const u32 high = 100,
|
|
||||||
const SettingType setting_type = SettingType::NORMAL);
|
|
||||||
|
|
||||||
ControlState GetValue() const;
|
virtual ~NumericSettingBase() = default;
|
||||||
void SetValue(ControlState value);
|
|
||||||
const SettingType m_type;
|
virtual void LoadFromIni(const IniFile::Section& section, const std::string& group_name) = 0;
|
||||||
const std::string m_name;
|
virtual void SaveToIni(IniFile::Section& section, const std::string& group_name) const = 0;
|
||||||
const ControlState m_default_value;
|
|
||||||
const u32 m_low;
|
virtual SettingType GetType() const = 0;
|
||||||
const u32 m_high;
|
|
||||||
ControlState m_value;
|
const char* GetUIName() const;
|
||||||
|
const char* GetUISuffix() const;
|
||||||
|
const char* GetUIDescription() const;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
NumericSettingDetails m_details;
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
class SettingValue;
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
class NumericSetting : public NumericSettingBase
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
using ValueType = T;
|
||||||
|
|
||||||
|
static_assert(std::is_same<ValueType, double>() || std::is_same<ValueType, bool>(),
|
||||||
|
"NumericSetting is only implemented for double and bool.");
|
||||||
|
|
||||||
|
NumericSetting(SettingValue<ValueType>* value, const NumericSettingDetails& details,
|
||||||
|
ValueType default_value, ValueType min_value, ValueType max_value)
|
||||||
|
: NumericSettingBase(details), m_value(*value), m_default_value(default_value),
|
||||||
|
m_min_value(min_value), m_max_value(max_value)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void LoadFromIni(const IniFile::Section& section, const std::string& group_name) override
|
||||||
|
{
|
||||||
|
ValueType value;
|
||||||
|
section.Get(group_name + m_details.ini_name, &value, m_default_value);
|
||||||
|
SetValue(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SaveToIni(IniFile::Section& section, const std::string& group_name) const override
|
||||||
|
{
|
||||||
|
section.Set(group_name + m_details.ini_name, GetValue(), m_default_value);
|
||||||
|
}
|
||||||
|
|
||||||
|
ValueType GetValue() const { return m_value.GetValue(); }
|
||||||
|
void SetValue(ValueType value) { m_value.SetValue(value); }
|
||||||
|
|
||||||
|
ValueType GetDefaultValue() const { return m_default_value; }
|
||||||
|
ValueType GetMinValue() const { return m_min_value; }
|
||||||
|
ValueType GetMaxValue() const { return m_max_value; }
|
||||||
|
|
||||||
|
SettingType GetType() const override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
SettingValue<ValueType>& m_value;
|
||||||
|
|
||||||
|
const ValueType m_default_value;
|
||||||
|
const ValueType m_min_value;
|
||||||
|
const ValueType m_max_value;
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
class SettingValue
|
||||||
|
{
|
||||||
|
using ValueType = T;
|
||||||
|
|
||||||
|
friend class NumericSetting<T>;
|
||||||
|
|
||||||
|
public:
|
||||||
|
ValueType GetValue() const { return m_value; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
void SetValue(ValueType value) { m_value = value; }
|
||||||
|
|
||||||
|
// Values are R/W by both UI and CPU threads.
|
||||||
|
std::atomic<ValueType> m_value;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace ControllerEmu
|
} // namespace ControllerEmu
|
||||||
|
|
|
@ -1,15 +0,0 @@
|
||||||
// Copyright 2017 Dolphin Emulator Project
|
|
||||||
// Licensed under GPLv2+
|
|
||||||
// Refer to the license.txt file included.
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
namespace ControllerEmu
|
|
||||||
{
|
|
||||||
enum class SettingType
|
|
||||||
{
|
|
||||||
NORMAL, // normal settings are saved to configuration files
|
|
||||||
VIRTUAL, // virtual settings are not saved at all
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace ControllerEmu
|
|
|
@ -100,13 +100,13 @@ std::optional<u32> SquareStickGate::GetIdealCalibrationSampleCount() const
|
||||||
ReshapableInput::ReshapableInput(std::string name, std::string ui_name, GroupType type)
|
ReshapableInput::ReshapableInput(std::string name, std::string ui_name, GroupType type)
|
||||||
: ControlGroup(std::move(name), std::move(ui_name), type)
|
: ControlGroup(std::move(name), std::move(ui_name), type)
|
||||||
{
|
{
|
||||||
numeric_settings.emplace_back(std::make_unique<NumericSetting>(_trans("Dead Zone"), 0, 0, 50));
|
AddDeadzoneSetting(&m_deadzone_setting, 50);
|
||||||
}
|
}
|
||||||
|
|
||||||
ControlState ReshapableInput::GetDeadzoneRadiusAtAngle(double angle) const
|
ControlState ReshapableInput::GetDeadzoneRadiusAtAngle(double angle) const
|
||||||
{
|
{
|
||||||
// FYI: deadzone is scaled by input radius which allows the shape to match.
|
// FYI: deadzone is scaled by input radius which allows the shape to match.
|
||||||
return GetInputRadiusAtAngle(angle) * numeric_settings[SETTING_DEADZONE]->GetValue();
|
return GetInputRadiusAtAngle(angle) * GetDeadzonePercentage();
|
||||||
}
|
}
|
||||||
|
|
||||||
ControlState ReshapableInput::GetInputRadiusAtAngle(double angle) const
|
ControlState ReshapableInput::GetInputRadiusAtAngle(double angle) const
|
||||||
|
@ -120,6 +120,11 @@ ControlState ReshapableInput::GetInputRadiusAtAngle(double angle) const
|
||||||
return GetCalibrationDataRadiusAtAngle(m_calibration, angle);
|
return GetCalibrationDataRadiusAtAngle(m_calibration, angle);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ControlState ReshapableInput::GetDeadzonePercentage() const
|
||||||
|
{
|
||||||
|
return m_deadzone_setting.GetValue() / 100;
|
||||||
|
}
|
||||||
|
|
||||||
ControlState ReshapableInput::GetCalibrationDataRadiusAtAngle(const CalibrationData& data,
|
ControlState ReshapableInput::GetCalibrationDataRadiusAtAngle(const CalibrationData& data,
|
||||||
double angle)
|
double angle)
|
||||||
{
|
{
|
||||||
|
@ -267,7 +272,7 @@ ReshapableInput::ReshapeData ReshapableInput::Reshape(ControlState x, ControlSta
|
||||||
}
|
}
|
||||||
|
|
||||||
// Apply deadzone as a percentage of the user-defined calibration shape/size:
|
// Apply deadzone as a percentage of the user-defined calibration shape/size:
|
||||||
const ControlState deadzone = numeric_settings[SETTING_DEADZONE]->GetValue();
|
const ControlState deadzone = GetDeadzonePercentage();
|
||||||
dist = std::max(0.0, dist - deadzone) / (1.0 - deadzone);
|
dist = std::max(0.0, dist - deadzone) / (1.0 - deadzone);
|
||||||
|
|
||||||
// Scale to the gate shape/radius:
|
// Scale to the gate shape/radius:
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
|
|
||||||
#include "InputCommon/ControlReference/ControlReference.h"
|
#include "InputCommon/ControlReference/ControlReference.h"
|
||||||
#include "InputCommon/ControllerEmu/ControlGroup/ControlGroup.h"
|
#include "InputCommon/ControllerEmu/ControlGroup/ControlGroup.h"
|
||||||
|
#include "InputCommon/ControllerEmu/Setting/NumericSetting.h"
|
||||||
|
|
||||||
namespace ControllerEmu
|
namespace ControllerEmu
|
||||||
{
|
{
|
||||||
|
@ -77,16 +78,12 @@ public:
|
||||||
|
|
||||||
using ReshapeData = Common::DVec2;
|
using ReshapeData = Common::DVec2;
|
||||||
|
|
||||||
enum
|
|
||||||
{
|
|
||||||
SETTING_DEADZONE,
|
|
||||||
SETTING_COUNT,
|
|
||||||
};
|
|
||||||
|
|
||||||
// Angle is in radians and should be non-negative
|
// Angle is in radians and should be non-negative
|
||||||
ControlState GetDeadzoneRadiusAtAngle(double angle) const;
|
ControlState GetDeadzoneRadiusAtAngle(double angle) const;
|
||||||
ControlState GetInputRadiusAtAngle(double angle) const;
|
ControlState GetInputRadiusAtAngle(double angle) const;
|
||||||
|
|
||||||
|
ControlState GetDeadzonePercentage() const;
|
||||||
|
|
||||||
virtual ControlState GetGateRadiusAtAngle(double angle) const = 0;
|
virtual ControlState GetGateRadiusAtAngle(double angle) const = 0;
|
||||||
virtual ReshapeData GetReshapableState(bool adjusted) = 0;
|
virtual ReshapeData GetReshapableState(bool adjusted) = 0;
|
||||||
virtual ControlState GetDefaultInputRadiusAtAngle(double ang) const;
|
virtual ControlState GetDefaultInputRadiusAtAngle(double ang) const;
|
||||||
|
@ -108,6 +105,7 @@ private:
|
||||||
void SaveConfig(IniFile::Section*, const std::string&, const std::string&) override;
|
void SaveConfig(IniFile::Section*, const std::string&, const std::string&) override;
|
||||||
|
|
||||||
CalibrationData m_calibration;
|
CalibrationData m_calibration;
|
||||||
|
SettingValue<double> m_deadzone_setting;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace ControllerEmu
|
} // namespace ControllerEmu
|
||||||
|
|
|
@ -52,7 +52,6 @@
|
||||||
<ClCompile Include="ControllerEmu\ControlGroup\Slider.cpp" />
|
<ClCompile Include="ControllerEmu\ControlGroup\Slider.cpp" />
|
||||||
<ClCompile Include="ControllerEmu\ControlGroup\Tilt.cpp" />
|
<ClCompile Include="ControllerEmu\ControlGroup\Tilt.cpp" />
|
||||||
<ClCompile Include="ControllerEmu\ControlGroup\Triggers.cpp" />
|
<ClCompile Include="ControllerEmu\ControlGroup\Triggers.cpp" />
|
||||||
<ClCompile Include="ControllerEmu\Setting\BooleanSetting.cpp" />
|
|
||||||
<ClCompile Include="ControllerEmu\Setting\NumericSetting.cpp" />
|
<ClCompile Include="ControllerEmu\Setting\NumericSetting.cpp" />
|
||||||
<ClCompile Include="ControllerInterface\ControllerInterface.cpp" />
|
<ClCompile Include="ControllerInterface\ControllerInterface.cpp" />
|
||||||
<ClCompile Include="ControllerInterface\Device.cpp" />
|
<ClCompile Include="ControllerInterface\Device.cpp" />
|
||||||
|
@ -92,9 +91,7 @@
|
||||||
<ClInclude Include="ControllerEmu\ControlGroup\Slider.h" />
|
<ClInclude Include="ControllerEmu\ControlGroup\Slider.h" />
|
||||||
<ClInclude Include="ControllerEmu\ControlGroup\Tilt.h" />
|
<ClInclude Include="ControllerEmu\ControlGroup\Tilt.h" />
|
||||||
<ClInclude Include="ControllerEmu\ControlGroup\Triggers.h" />
|
<ClInclude Include="ControllerEmu\ControlGroup\Triggers.h" />
|
||||||
<ClInclude Include="ControllerEmu\Setting\BooleanSetting.h" />
|
|
||||||
<ClInclude Include="ControllerEmu\Setting\NumericSetting.h" />
|
<ClInclude Include="ControllerEmu\Setting\NumericSetting.h" />
|
||||||
<ClInclude Include="ControllerEmu\Setting\Setting.h" />
|
|
||||||
<ClInclude Include="ControllerInterface\ControllerInterface.h" />
|
<ClInclude Include="ControllerInterface\ControllerInterface.h" />
|
||||||
<ClInclude Include="ControllerInterface\Device.h" />
|
<ClInclude Include="ControllerInterface\Device.h" />
|
||||||
<ClInclude Include="ControllerInterface\DInput\DInput.h" />
|
<ClInclude Include="ControllerInterface\DInput\DInput.h" />
|
||||||
|
|
|
@ -77,9 +77,6 @@
|
||||||
<ClCompile Include="ControllerEmu\ControlGroup\Triggers.cpp">
|
<ClCompile Include="ControllerEmu\ControlGroup\Triggers.cpp">
|
||||||
<Filter>ControllerEmu\ControlGroup</Filter>
|
<Filter>ControllerEmu\ControlGroup</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="ControllerEmu\Setting\BooleanSetting.cpp">
|
|
||||||
<Filter>ControllerEmu\Setting</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="ControllerEmu\Setting\NumericSetting.cpp">
|
<ClCompile Include="ControllerEmu\Setting\NumericSetting.cpp">
|
||||||
<Filter>ControllerEmu\Setting</Filter>
|
<Filter>ControllerEmu\Setting</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
@ -170,15 +167,9 @@
|
||||||
<ClInclude Include="ControllerEmu\ControlGroup\Triggers.h">
|
<ClInclude Include="ControllerEmu\ControlGroup\Triggers.h">
|
||||||
<Filter>ControllerEmu\ControlGroup</Filter>
|
<Filter>ControllerEmu\ControlGroup</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="ControllerEmu\Setting\BooleanSetting.h">
|
|
||||||
<Filter>ControllerEmu\Setting</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="ControllerEmu\Setting\NumericSetting.h">
|
<ClInclude Include="ControllerEmu\Setting\NumericSetting.h">
|
||||||
<Filter>ControllerEmu\Setting</Filter>
|
<Filter>ControllerEmu\Setting</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="ControllerEmu\Setting\Setting.h">
|
|
||||||
<Filter>ControllerEmu\Setting</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="ControllerInterface\DInput\DInput.h">
|
<ClInclude Include="ControllerInterface\DInput\DInput.h">
|
||||||
<Filter>ControllerInterface\DInput</Filter>
|
<Filter>ControllerInterface\DInput</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
#include "Core/HW/Wiimote.h"
|
#include "Core/HW/Wiimote.h"
|
||||||
#include "InputCommon/ControllerEmu/ControlGroup/ControlGroup.h"
|
#include "InputCommon/ControllerEmu/ControlGroup/ControlGroup.h"
|
||||||
#include "InputCommon/ControllerEmu/ControllerEmu.h"
|
#include "InputCommon/ControllerEmu/ControllerEmu.h"
|
||||||
|
#include "InputCommon/ControllerEmu/Setting/NumericSetting.h"
|
||||||
#include "InputCommon/ControllerInterface/ControllerInterface.h"
|
#include "InputCommon/ControllerInterface/ControllerInterface.h"
|
||||||
#include "InputCommon/InputConfig.h"
|
#include "InputCommon/InputConfig.h"
|
||||||
#include "InputCommon/InputProfile.h"
|
#include "InputCommon/InputProfile.h"
|
||||||
|
@ -81,13 +82,13 @@ bool InputConfig::LoadConfig(bool isGC)
|
||||||
#if defined(ANDROID)
|
#if defined(ANDROID)
|
||||||
// For use on android touchscreen IR pointer
|
// For use on android touchscreen IR pointer
|
||||||
// Check for IR values
|
// Check for IR values
|
||||||
if (control_section->Exists("IRWidth") && control_section->Exists("IRHeight") &&
|
if (control_section->Exists("IRTotalYaw") && control_section->Exists("IRTotalPitch") &&
|
||||||
control_section->Exists("IRCenter"))
|
control_section->Exists("IRVerticalOffset"))
|
||||||
{
|
{
|
||||||
use_ir_config = true;
|
use_ir_config = true;
|
||||||
control_section->Get("IRWidth", &ir_values[0]);
|
control_section->Get("IRTotalYaw", &ir_values[0]);
|
||||||
control_section->Get("IRHeight", &ir_values[1]);
|
control_section->Get("IRTotalPitch", &ir_values[1]);
|
||||||
control_section->Get("IRCenter", &ir_values[2]);
|
control_section->Get("IRVerticalOffset", &ir_values[2]);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -119,9 +120,9 @@ bool InputConfig::LoadConfig(bool isGC)
|
||||||
// Only set for wii pads
|
// Only set for wii pads
|
||||||
if (!isGC && use_ir_config)
|
if (!isGC && use_ir_config)
|
||||||
{
|
{
|
||||||
config.Set("IR/Width", ir_values[0]);
|
config.Set("IR/Total Yaw", ir_values[0]);
|
||||||
config.Set("IR/Height", ir_values[1]);
|
config.Set("IR/Total Pitch", ir_values[1]);
|
||||||
config.Set("IR/Center", ir_values[2]);
|
config.Set("IR/Vertical Offset", ir_values[2]);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
controller->LoadConfig(&config);
|
controller->LoadConfig(&config);
|
||||||
|
|
Loading…
Reference in New Issue