summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/common/input.h34
-rw-r--r--src/common/settings.h3
-rw-r--r--src/core/hid/emulated_console.cpp6
-rw-r--r--src/yuzu/configuration/config.cpp4
-rw-r--r--src/yuzu/configuration/configure_motion_touch.cpp8
-rw-r--r--src/yuzu/configuration/configure_motion_touch.ui70
-rw-r--r--src/yuzu_cmd/config.cpp3
-rw-r--r--src/yuzu_cmd/default_ini.h17
8 files changed, 46 insertions, 99 deletions
diff --git a/src/common/input.h b/src/common/input.h
index f21872b0a..d997853c6 100644
--- a/src/common/input.h
+++ b/src/common/input.h
@@ -15,6 +15,7 @@
namespace Common::Input {
+// Type of data that is expected to recieve or send
enum class InputType {
None,
Battery,
@@ -30,6 +31,7 @@ enum class InputType {
Ir,
};
+// Internal battery charge level
enum class BatteryLevel : u32 {
None,
Empty,
@@ -41,13 +43,17 @@ enum class BatteryLevel : u32 {
};
enum class PollingMode {
+ // Constant polling of buttons, analogs and motion data
Active,
+ // Only update on button change, digital analogs
Pasive,
- Camera,
- NCF,
+ // Enable near field communication polling
+ NFC,
+ // Enable infrared camera polling
IR,
};
+// Vibration reply from the controller
enum class VibrationError {
None,
NotSupported,
@@ -55,6 +61,7 @@ enum class VibrationError {
Unknown,
};
+// Polling mode reply from the controller
enum class PollingError {
None,
NotSupported,
@@ -67,20 +74,28 @@ enum class VibrationAmplificationType {
Exponential,
};
+// Analog properties for calibration
struct AnalogProperties {
+ // Anything below this value will be detected as zero
float deadzone{};
+ // Anyting above this values will be detected as one
float range{1.0f};
+ // Minimum value to be detected as active
float threshold{0.5f};
+ // Drift correction applied to the raw data
float offset{};
+ // Invert direction of the sensor data
bool inverted{};
};
+// Single analog sensor data
struct AnalogStatus {
float value{};
float raw_value{};
AnalogProperties properties{};
};
+// Button data
struct ButtonStatus {
Common::UUID uuid{};
bool value{};
@@ -89,8 +104,10 @@ struct ButtonStatus {
bool locked{};
};
+// Internal battery data
using BatteryStatus = BatteryLevel;
+// Analog and digital joystick data
struct StickStatus {
Common::UUID uuid{};
AnalogStatus x{};
@@ -101,18 +118,21 @@ struct StickStatus {
bool down{};
};
+// Analog and digital trigger data
struct TriggerStatus {
Common::UUID uuid{};
AnalogStatus analog{};
ButtonStatus pressed{};
};
+// 3D vector representing motion input
struct MotionSensor {
AnalogStatus x{};
AnalogStatus y{};
AnalogStatus z{};
};
+// Motion data used to calculate controller orientation
struct MotionStatus {
// Gyroscope vector measurement in radians/s.
MotionSensor gyro{};
@@ -124,6 +144,7 @@ struct MotionStatus {
bool force_update{};
};
+// Data of a single point on a touch screen
struct TouchStatus {
ButtonStatus pressed{};
AnalogStatus x{};
@@ -131,11 +152,13 @@ struct TouchStatus {
int id{};
};
+// Physical controller color in RGB format
struct BodyColorStatus {
u32 body{};
u32 buttons{};
};
+// HD rumble data
struct VibrationStatus {
f32 low_amplitude{};
f32 low_frequency{};
@@ -144,6 +167,7 @@ struct VibrationStatus {
VibrationAmplificationType type;
};
+// Physical controller LED pattern
struct LedStatus {
bool led_1{};
bool led_2{};
@@ -151,6 +175,7 @@ struct LedStatus {
bool led_4{};
};
+// Callback data consisting of an input type and the equivalent data status
struct CallbackStatus {
InputType type{InputType::None};
ButtonStatus button_status{};
@@ -164,6 +189,7 @@ struct CallbackStatus {
VibrationStatus vibration_status{};
};
+// Triggered once every input change
struct InputCallback {
std::function<void(CallbackStatus)> on_change;
};
@@ -178,15 +204,17 @@ public:
return;
}
- // Force input device to update data regarless of the current state
+ // Force input device to update data regardless of the current state
virtual void ForceUpdate() {
return;
}
+ // Sets the function to be triggered when input changes
void SetCallback(InputCallback callback_) {
callback = std::move(callback_);
}
+ // Triggers the function set in the callback
void TriggerOnChange(CallbackStatus status) {
if (callback.on_change) {
callback.on_change(status);
diff --git a/src/common/settings.h b/src/common/settings.h
index 95225fba7..b52d0d1d0 100644
--- a/src/common/settings.h
+++ b/src/common/settings.h
@@ -559,8 +559,6 @@ struct Values {
Setting<bool> enable_accurate_vibrations{false, "enable_accurate_vibrations"};
Setting<bool> motion_enabled{true, "motion_enabled"};
- BasicSetting<std::string> motion_device{"engine:motion_emu,update_period:100,sensitivity:0.01",
- "motion_device"};
BasicSetting<std::string> udp_input_servers{"127.0.0.1:26760", "udp_input_servers"};
BasicSetting<bool> pause_tas_on_load{true, "pause_tas_on_load"};
@@ -583,7 +581,6 @@ struct Values {
TouchscreenInput touchscreen;
- BasicSetting<bool> use_touch_from_button{false, "use_touch_from_button"};
BasicSetting<std::string> touch_device{"min_x:100,min_y:50,max_x:1800,max_y:850",
"touch_device"};
BasicSetting<int> touch_from_button_map_index{0, "touch_from_button_map"};
diff --git a/src/core/hid/emulated_console.cpp b/src/core/hid/emulated_console.cpp
index dfbaa3f8c..b51c72eae 100644
--- a/src/core/hid/emulated_console.cpp
+++ b/src/core/hid/emulated_console.cpp
@@ -11,7 +11,7 @@ EmulatedConsole::EmulatedConsole() = default;
EmulatedConsole::~EmulatedConsole() = default;
void EmulatedConsole::ReloadFromSettings() {
- // Using first motion device from player 1. No need to assign a special config at the moment
+ // Using first motion device from player 1. No need to assign any unique config at the moment
const auto& player = Settings::values.players.GetValue()[0];
motion_params = Common::ParamPackage(player.motions[0]);
@@ -33,6 +33,7 @@ void EmulatedConsole::SetTouchParams() {
static_cast<u64>(Settings::values.touch_from_button_map_index.GetValue());
const auto& touch_buttons = Settings::values.touch_from_button_maps[button_index].buttons;
+ // Map the rest of the fingers from touch from button configuration
for (const auto& config_entry : touch_buttons) {
Common::ParamPackage params{config_entry};
Common::ParamPackage touch_button_params;
@@ -54,7 +55,9 @@ void EmulatedConsole::SetTouchParams() {
}
void EmulatedConsole::ReloadInput() {
+ // If you load any device here add the equivalent to the UnloadInput() function
SetTouchParams();
+
motion_devices = Common::Input::CreateDevice<Common::Input::InputDevice>(motion_params);
if (motion_devices) {
Common::Input::InputCallback motion_callback{
@@ -62,6 +65,7 @@ void EmulatedConsole::ReloadInput() {
motion_devices->SetCallback(motion_callback);
}
+ // Unique index for identifying touch device source
std::size_t index = 0;
for (auto& touch_device : touch_devices) {
touch_device = Common::Input::CreateDevice<Common::Input::InputDevice>(touch_params[index]);
diff --git a/src/yuzu/configuration/config.cpp b/src/yuzu/configuration/config.cpp
index 7a748d9c8..7669fe474 100644
--- a/src/yuzu/configuration/config.cpp
+++ b/src/yuzu/configuration/config.cpp
@@ -623,9 +623,7 @@ void Config::ReadMotionTouchValues() {
}
qt_config->endArray();
- ReadBasicSetting(Settings::values.motion_device);
ReadBasicSetting(Settings::values.touch_device);
- ReadBasicSetting(Settings::values.use_touch_from_button);
ReadBasicSetting(Settings::values.touch_from_button_map_index);
Settings::values.touch_from_button_map_index = std::clamp(
Settings::values.touch_from_button_map_index.GetValue(), 0, num_touch_from_button_maps - 1);
@@ -1131,9 +1129,7 @@ void Config::SaveTouchscreenValues() {
}
void Config::SaveMotionTouchValues() {
- WriteBasicSetting(Settings::values.motion_device);
WriteBasicSetting(Settings::values.touch_device);
- WriteBasicSetting(Settings::values.use_touch_from_button);
WriteBasicSetting(Settings::values.touch_from_button_map_index);
WriteBasicSetting(Settings::values.udp_input_servers);
diff --git a/src/yuzu/configuration/configure_motion_touch.cpp b/src/yuzu/configuration/configure_motion_touch.cpp
index 9fd1a919f..8539a5c8b 100644
--- a/src/yuzu/configuration/configure_motion_touch.cpp
+++ b/src/yuzu/configuration/configure_motion_touch.cpp
@@ -93,6 +93,7 @@ ConfigureMotionTouch::ConfigureMotionTouch(QWidget* parent,
"using-a-controller-or-android-phone-for-motion-or-touch-input'><span "
"style=\"text-decoration: underline; color:#039be5;\">Learn More</span></a>"));
+ setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
SetConfiguration();
UpdateUiDisplay();
ConnectEvents();
@@ -101,17 +102,14 @@ ConfigureMotionTouch::ConfigureMotionTouch(QWidget* parent,
ConfigureMotionTouch::~ConfigureMotionTouch() = default;
void ConfigureMotionTouch::SetConfiguration() {
- const Common::ParamPackage motion_param(Settings::values.motion_device.GetValue());
const Common::ParamPackage touch_param(Settings::values.touch_device.GetValue());
- ui->touch_from_button_checkbox->setChecked(Settings::values.use_touch_from_button.GetValue());
touch_from_button_maps = Settings::values.touch_from_button_maps;
for (const auto& touch_map : touch_from_button_maps) {
ui->touch_from_button_map->addItem(QString::fromStdString(touch_map.name));
}
ui->touch_from_button_map->setCurrentIndex(
Settings::values.touch_from_button_map_index.GetValue());
- ui->motion_sensitivity->setValue(motion_param.Get("sensitivity", 0.01f));
min_x = touch_param.Get("min_x", 100);
min_y = touch_param.Get("min_y", 50);
@@ -139,9 +137,6 @@ void ConfigureMotionTouch::SetConfiguration() {
void ConfigureMotionTouch::UpdateUiDisplay() {
const QString cemuhook_udp = QStringLiteral("cemuhookudp");
- ui->motion_sensitivity_label->setVisible(true);
- ui->motion_sensitivity->setVisible(true);
-
ui->touch_calibration->setVisible(true);
ui->touch_calibration_config->setVisible(true);
ui->touch_calibration_label->setVisible(true);
@@ -312,7 +307,6 @@ void ConfigureMotionTouch::ApplyConfiguration() {
touch_param.Set("max_y", max_y);
Settings::values.touch_device = touch_param.Serialize();
- Settings::values.use_touch_from_button = ui->touch_from_button_checkbox->isChecked();
Settings::values.touch_from_button_map_index = ui->touch_from_button_map->currentIndex();
Settings::values.touch_from_button_maps = touch_from_button_maps;
Settings::values.udp_input_servers = GetUDPServerString();
diff --git a/src/yuzu/configuration/configure_motion_touch.ui b/src/yuzu/configuration/configure_motion_touch.ui
index 1e35ea946..c75a84ae4 100644
--- a/src/yuzu/configuration/configure_motion_touch.ui
+++ b/src/yuzu/configuration/configure_motion_touch.ui
@@ -2,14 +2,6 @@
<ui version="4.0">
<class>ConfigureMotionTouch</class>
<widget class="QDialog" name="ConfigureMotionTouch">
- <property name="geometry">
- <rect>
- <x>0</x>
- <y>0</y>
- <width>500</width>
- <height>482</height>
- </rect>
- </property>
<property name="windowTitle">
<string>Configure Motion / Touch</string>
</property>
@@ -18,48 +10,6 @@
</property>
<layout class="QVBoxLayout">
<item>
- <widget class="QGroupBox" name="motion_group_box">
- <property name="title">
- <string>Mouse Motion</string>
- </property>
- <layout class="QVBoxLayout">
- <item>
- <layout class="QHBoxLayout">
- <item>
- <widget class="QLabel" name="motion_sensitivity_label">
- <property name="text">
- <string>Sensitivity:</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QDoubleSpinBox" name="motion_sensitivity">
- <property name="alignment">
- <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
- </property>
- <property name="decimals">
- <number>4</number>
- </property>
- <property name="minimum">
- <double>0.010000000000000</double>
- </property>
- <property name="maximum">
- <double>10.000000000000000</double>
- </property>
- <property name="singleStep">
- <double>0.001000000000000</double>
- </property>
- <property name="value">
- <double>0.010000000000000</double>
- </property>
- </widget>
- </item>
- </layout>
- </item>
- </layout>
- </widget>
- </item>
- <item>
<widget class="QGroupBox" name="touch_group_box">
<property name="title">
<string>Touch</string>
@@ -101,19 +51,13 @@
</item>
<item>
<layout class="QHBoxLayout">
- <item>
- <widget class="QCheckBox" name="touch_from_button_checkbox">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Maximum" vsizetype="Fixed">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="text">
- <string>Use button mapping:</string>
- </property>
- </widget>
- </item>
+ <item>
+ <widget class="QLabel" name="touch_from_button_label">
+ <property name="text">
+ <string>Touch from button profile:</string>
+ </property>
+ </widget>
+ </item>
<item>
<widget class="QComboBox" name="touch_from_button_map"/>
</item>
diff --git a/src/yuzu_cmd/config.cpp b/src/yuzu_cmd/config.cpp
index 103a12b12..7ca09a635 100644
--- a/src/yuzu_cmd/config.cpp
+++ b/src/yuzu_cmd/config.cpp
@@ -292,8 +292,6 @@ void Config::ReadValues() {
Settings::values.mouse_buttons[i] = default_param;
}
- ReadSetting("ControlsGeneral", Settings::values.motion_device);
-
ReadSetting("ControlsGeneral", Settings::values.touch_device);
ReadSetting("ControlsGeneral", Settings::values.keyboard_enabled);
@@ -362,7 +360,6 @@ void Config::ReadValues() {
Settings::TouchFromButtonMap{"default", {}});
num_touch_from_button_maps = 1;
}
- ReadSetting("ControlsGeneral", Settings::values.use_touch_from_button);
Settings::values.touch_from_button_map_index = std::clamp(
Settings::values.touch_from_button_map_index.GetValue(), 0, num_touch_from_button_maps - 1);
diff --git a/src/yuzu_cmd/default_ini.h b/src/yuzu_cmd/default_ini.h
index ecdc271a8..6d613bf7a 100644
--- a/src/yuzu_cmd/default_ini.h
+++ b/src/yuzu_cmd/default_ini.h
@@ -84,23 +84,10 @@ enable_accurate_vibrations=
# 0: Disabled, 1 (default): Enabled
motion_enabled =
-# for motion input, the following devices are available:
-# - "motion_emu" (default) for emulating motion input from mouse input. Required parameters:
-# - "update_period": update period in milliseconds (default to 100)
-# - "sensitivity": the coefficient converting mouse movement to tilting angle (default to 0.01)
-# - "cemuhookudp" reads motion input from a udp server that uses cemuhook's udp protocol
-motion_device=
-
-# for touch input, the following devices are available:
-# - "emu_window" (default) for emulating touch input from mouse input to the emulation window. No parameters required
-# - "cemuhookudp" reads touch input from a udp server that uses cemuhook's udp protocol
-# - "min_x", "min_y", "max_x", "max_y": defines the udp device's touch screen coordinate system
+# Defines the udp device's touch screen coordinate system for cemuhookudp devices
+# - "min_x", "min_y", "max_x", "max_y"
touch_device=
-# Whether to enable or disable touch input from button
-# 0 (default): Disabled, 1: Enabled
-use_touch_from_button=
-
# for mapping buttons to touch inputs.
#touch_from_button_map=1
#touch_from_button_maps_0_name=default