mirror of
https://github.com/starr-dusT/yuzu-mainline
synced 2024-03-05 21:12:25 -08:00
core: hid: Migrate ring from emulated devices to emulated controller
This commit is contained in:
parent
18c9f8eeed
commit
a4074001fe
@ -139,6 +139,7 @@ void EmulatedController::LoadDevices() {
|
||||
|
||||
camera_params = Common::ParamPackage{"engine:camera,camera:1"};
|
||||
nfc_params = Common::ParamPackage{"engine:virtual_amiibo,nfc:1"};
|
||||
ring_params = Common::ParamPackage{"engine:joycon,axis_x:100,axis_y:101"};
|
||||
|
||||
output_params[LeftIndex] = left_joycon;
|
||||
output_params[RightIndex] = right_joycon;
|
||||
@ -160,6 +161,7 @@ void EmulatedController::LoadDevices() {
|
||||
std::ranges::transform(battery_params, battery_devices.begin(),
|
||||
Common::Input::CreateInputDevice);
|
||||
camera_devices = Common::Input::CreateInputDevice(camera_params);
|
||||
ring_analog_device = Common::Input::CreateInputDevice(ring_params);
|
||||
nfc_devices = Common::Input::CreateInputDevice(nfc_params);
|
||||
std::ranges::transform(output_params, output_devices.begin(),
|
||||
Common::Input::CreateOutputDevice);
|
||||
@ -343,6 +345,13 @@ void EmulatedController::ReloadInput() {
|
||||
camera_devices->ForceUpdate();
|
||||
}
|
||||
|
||||
if (ring_analog_device) {
|
||||
ring_analog_device->SetCallback({
|
||||
.on_change =
|
||||
[this](const Common::Input::CallbackStatus& callback) { SetRingAnalog(callback); },
|
||||
});
|
||||
}
|
||||
|
||||
if (nfc_devices) {
|
||||
if (npad_id_type == NpadIdType::Handheld || npad_id_type == NpadIdType::Player1) {
|
||||
nfc_devices->SetCallback({
|
||||
@ -436,6 +445,7 @@ void EmulatedController::UnloadInput() {
|
||||
stick.reset();
|
||||
}
|
||||
camera_devices.reset();
|
||||
ring_analog_device.reset();
|
||||
nfc_devices.reset();
|
||||
}
|
||||
|
||||
@ -501,6 +511,7 @@ void EmulatedController::SaveCurrentConfig() {
|
||||
for (std::size_t index = 0; index < player.motions.size(); ++index) {
|
||||
player.motions[index] = motion_params[index].Serialize();
|
||||
}
|
||||
Settings::values.ringcon_analogs = ring_params.Serialize();
|
||||
}
|
||||
|
||||
void EmulatedController::RestoreConfig() {
|
||||
@ -1005,6 +1016,24 @@ void EmulatedController::SetCamera(const Common::Input::CallbackStatus& callback
|
||||
TriggerOnChange(ControllerTriggerType::IrSensor, true);
|
||||
}
|
||||
|
||||
void EmulatedController::SetRingAnalog(const Common::Input::CallbackStatus& callback) {
|
||||
std::unique_lock lock{mutex};
|
||||
const auto force_value = TransformToStick(callback);
|
||||
|
||||
controller.ring_analog_value = force_value.x;
|
||||
|
||||
if (is_configuring) {
|
||||
lock.unlock();
|
||||
TriggerOnChange(ControllerTriggerType::RingController, false);
|
||||
return;
|
||||
}
|
||||
|
||||
controller.ring_analog_state.force = force_value.x.value;
|
||||
|
||||
lock.unlock();
|
||||
TriggerOnChange(ControllerTriggerType::RingController, true);
|
||||
}
|
||||
|
||||
void EmulatedController::SetNfc(const Common::Input::CallbackStatus& callback) {
|
||||
std::unique_lock lock{mutex};
|
||||
controller.nfc_values = TransformToNfc(callback);
|
||||
@ -1104,6 +1133,15 @@ bool EmulatedController::SetCameraFormat(
|
||||
camera_format)) == Common::Input::CameraError::None;
|
||||
}
|
||||
|
||||
Common::ParamPackage EmulatedController::GetRingParam() const {
|
||||
return ring_params;
|
||||
}
|
||||
|
||||
void EmulatedController::SetRingParam(Common::ParamPackage param) {
|
||||
ring_params = std::move(param);
|
||||
ReloadInput();
|
||||
}
|
||||
|
||||
bool EmulatedController::HasNfc() const {
|
||||
const auto& nfc_output_device = output_devices[3];
|
||||
|
||||
@ -1395,6 +1433,10 @@ CameraValues EmulatedController::GetCameraValues() const {
|
||||
return controller.camera_values;
|
||||
}
|
||||
|
||||
RingAnalogValue EmulatedController::GetRingSensorValues() const {
|
||||
return controller.ring_analog_value;
|
||||
}
|
||||
|
||||
HomeButtonState EmulatedController::GetHomeButtons() const {
|
||||
std::scoped_lock lock{mutex};
|
||||
if (is_configuring) {
|
||||
@ -1478,6 +1520,10 @@ const CameraState& EmulatedController::GetCamera() const {
|
||||
return controller.camera_state;
|
||||
}
|
||||
|
||||
RingSensorForce EmulatedController::GetRingSensorForce() const {
|
||||
return controller.ring_analog_state;
|
||||
}
|
||||
|
||||
const NfcState& EmulatedController::GetNfc() const {
|
||||
std::scoped_lock lock{mutex};
|
||||
return controller.nfc_state;
|
||||
|
@ -38,6 +38,7 @@ using TriggerDevices =
|
||||
using BatteryDevices =
|
||||
std::array<std::unique_ptr<Common::Input::InputDevice>, max_emulated_controllers>;
|
||||
using CameraDevices = std::unique_ptr<Common::Input::InputDevice>;
|
||||
using RingAnalogDevice = std::unique_ptr<Common::Input::InputDevice>;
|
||||
using NfcDevices = std::unique_ptr<Common::Input::InputDevice>;
|
||||
using OutputDevices = std::array<std::unique_ptr<Common::Input::OutputDevice>, output_devices_size>;
|
||||
|
||||
@ -47,6 +48,7 @@ using ControllerMotionParams = std::array<Common::ParamPackage, Settings::Native
|
||||
using TriggerParams = std::array<Common::ParamPackage, Settings::NativeTrigger::NumTriggers>;
|
||||
using BatteryParams = std::array<Common::ParamPackage, max_emulated_controllers>;
|
||||
using CameraParams = Common::ParamPackage;
|
||||
using RingAnalogParams = Common::ParamPackage;
|
||||
using NfcParams = Common::ParamPackage;
|
||||
using OutputParams = std::array<Common::ParamPackage, output_devices_size>;
|
||||
|
||||
@ -58,6 +60,7 @@ using ControllerMotionValues = std::array<ControllerMotionInfo, Settings::Native
|
||||
using ColorValues = std::array<Common::Input::BodyColorStatus, max_emulated_controllers>;
|
||||
using BatteryValues = std::array<Common::Input::BatteryStatus, max_emulated_controllers>;
|
||||
using CameraValues = Common::Input::CameraStatus;
|
||||
using RingAnalogValue = Common::Input::AnalogStatus;
|
||||
using NfcValues = Common::Input::NfcStatus;
|
||||
using VibrationValues = std::array<Common::Input::VibrationStatus, max_emulated_controllers>;
|
||||
|
||||
@ -84,6 +87,10 @@ struct CameraState {
|
||||
std::size_t sample{};
|
||||
};
|
||||
|
||||
struct RingSensorForce {
|
||||
f32 force;
|
||||
};
|
||||
|
||||
struct NfcState {
|
||||
Common::Input::NfcState state{};
|
||||
std::vector<u8> data{};
|
||||
@ -116,6 +123,7 @@ struct ControllerStatus {
|
||||
BatteryValues battery_values{};
|
||||
VibrationValues vibration_values{};
|
||||
CameraValues camera_values{};
|
||||
RingAnalogValue ring_analog_value{};
|
||||
NfcValues nfc_values{};
|
||||
|
||||
// Data for HID serices
|
||||
@ -129,6 +137,7 @@ struct ControllerStatus {
|
||||
ControllerColors colors_state{};
|
||||
BatteryLevelState battery_state{};
|
||||
CameraState camera_state{};
|
||||
RingSensorForce ring_analog_state{};
|
||||
NfcState nfc_state{};
|
||||
};
|
||||
|
||||
@ -141,6 +150,7 @@ enum class ControllerTriggerType {
|
||||
Battery,
|
||||
Vibration,
|
||||
IrSensor,
|
||||
RingController,
|
||||
Nfc,
|
||||
Connected,
|
||||
Disconnected,
|
||||
@ -294,6 +304,9 @@ public:
|
||||
/// Returns the latest camera status from the controller with parameters
|
||||
CameraValues GetCameraValues() const;
|
||||
|
||||
/// Returns the latest status of analog input from the ring sensor with parameters
|
||||
RingAnalogValue GetRingSensorValues() const;
|
||||
|
||||
/// Returns the latest status of button input for the hid::HomeButton service
|
||||
HomeButtonState GetHomeButtons() const;
|
||||
|
||||
@ -324,6 +337,9 @@ public:
|
||||
/// Returns the latest camera status from the controller
|
||||
const CameraState& GetCamera() const;
|
||||
|
||||
/// Returns the latest ringcon force sensor value
|
||||
RingSensorForce GetRingSensorForce() const;
|
||||
|
||||
/// Returns the latest ntag status from the controller
|
||||
const NfcState& GetNfc() const;
|
||||
|
||||
@ -353,6 +369,15 @@ public:
|
||||
*/
|
||||
bool SetCameraFormat(Core::IrSensor::ImageTransferProcessorFormat camera_format);
|
||||
|
||||
// Returns the current mapped ring device
|
||||
Common::ParamPackage GetRingParam() const;
|
||||
|
||||
/**
|
||||
* Updates the current mapped ring device
|
||||
* @param param ParamPackage with ring sensor data to be mapped
|
||||
*/
|
||||
void SetRingParam(Common::ParamPackage param);
|
||||
|
||||
/// Returns true if the device has nfc support
|
||||
bool HasNfc() const;
|
||||
|
||||
@ -435,7 +460,7 @@ private:
|
||||
/**
|
||||
* Updates the battery status of the controller
|
||||
* @param callback A CallbackStatus containing the battery status
|
||||
* @param index Button ID of the to be updated
|
||||
* @param index battery ID of the to be updated
|
||||
*/
|
||||
void SetBattery(const Common::Input::CallbackStatus& callback, std::size_t index);
|
||||
|
||||
@ -445,6 +470,12 @@ private:
|
||||
*/
|
||||
void SetCamera(const Common::Input::CallbackStatus& callback);
|
||||
|
||||
/**
|
||||
* Updates the ring analog sensor status of the ring controller
|
||||
* @param callback A CallbackStatus containing the force status
|
||||
*/
|
||||
void SetRingAnalog(const Common::Input::CallbackStatus& callback);
|
||||
|
||||
/**
|
||||
* Updates the nfc status of the controller
|
||||
* @param callback A CallbackStatus containing the nfc status
|
||||
@ -485,6 +516,7 @@ private:
|
||||
TriggerParams trigger_params;
|
||||
BatteryParams battery_params;
|
||||
CameraParams camera_params;
|
||||
RingAnalogParams ring_params;
|
||||
NfcParams nfc_params;
|
||||
OutputParams output_params;
|
||||
|
||||
@ -494,6 +526,7 @@ private:
|
||||
TriggerDevices trigger_devices;
|
||||
BatteryDevices battery_devices;
|
||||
CameraDevices camera_devices;
|
||||
RingAnalogDevice ring_analog_device;
|
||||
NfcDevices nfc_devices;
|
||||
OutputDevices output_devices;
|
||||
|
||||
|
@ -14,7 +14,6 @@ EmulatedDevices::EmulatedDevices() = default;
|
||||
EmulatedDevices::~EmulatedDevices() = default;
|
||||
|
||||
void EmulatedDevices::ReloadFromSettings() {
|
||||
ring_params = Common::ParamPackage(Settings::values.ringcon_analogs);
|
||||
ReloadInput();
|
||||
}
|
||||
|
||||
@ -66,8 +65,6 @@ void EmulatedDevices::ReloadInput() {
|
||||
key_index++;
|
||||
}
|
||||
|
||||
ring_analog_device = Common::Input::CreateInputDevice(ring_params);
|
||||
|
||||
for (std::size_t index = 0; index < mouse_button_devices.size(); ++index) {
|
||||
if (!mouse_button_devices[index]) {
|
||||
continue;
|
||||
@ -122,13 +119,6 @@ void EmulatedDevices::ReloadInput() {
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
if (ring_analog_device) {
|
||||
ring_analog_device->SetCallback({
|
||||
.on_change =
|
||||
[this](const Common::Input::CallbackStatus& callback) { SetRingAnalog(callback); },
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
void EmulatedDevices::UnloadInput() {
|
||||
@ -145,7 +135,6 @@ void EmulatedDevices::UnloadInput() {
|
||||
for (auto& button : keyboard_modifier_devices) {
|
||||
button.reset();
|
||||
}
|
||||
ring_analog_device.reset();
|
||||
}
|
||||
|
||||
void EmulatedDevices::EnableConfiguration() {
|
||||
@ -165,7 +154,6 @@ void EmulatedDevices::SaveCurrentConfig() {
|
||||
if (!is_configuring) {
|
||||
return;
|
||||
}
|
||||
Settings::values.ringcon_analogs = ring_params.Serialize();
|
||||
}
|
||||
|
||||
void EmulatedDevices::RestoreConfig() {
|
||||
@ -175,15 +163,6 @@ void EmulatedDevices::RestoreConfig() {
|
||||
ReloadFromSettings();
|
||||
}
|
||||
|
||||
Common::ParamPackage EmulatedDevices::GetRingParam() const {
|
||||
return ring_params;
|
||||
}
|
||||
|
||||
void EmulatedDevices::SetRingParam(Common::ParamPackage param) {
|
||||
ring_params = std::move(param);
|
||||
ReloadInput();
|
||||
}
|
||||
|
||||
void EmulatedDevices::SetKeyboardButton(const Common::Input::CallbackStatus& callback,
|
||||
std::size_t index) {
|
||||
if (index >= device_status.keyboard_values.size()) {
|
||||
@ -430,23 +409,6 @@ void EmulatedDevices::SetMouseStick(const Common::Input::CallbackStatus& callbac
|
||||
TriggerOnChange(DeviceTriggerType::Mouse);
|
||||
}
|
||||
|
||||
void EmulatedDevices::SetRingAnalog(const Common::Input::CallbackStatus& callback) {
|
||||
std::lock_guard lock{mutex};
|
||||
const auto force_value = TransformToStick(callback);
|
||||
|
||||
device_status.ring_analog_value = force_value.x;
|
||||
|
||||
if (is_configuring) {
|
||||
device_status.ring_analog_value = {};
|
||||
TriggerOnChange(DeviceTriggerType::RingController);
|
||||
return;
|
||||
}
|
||||
|
||||
device_status.ring_analog_state.force = force_value.x.value;
|
||||
|
||||
TriggerOnChange(DeviceTriggerType::RingController);
|
||||
}
|
||||
|
||||
KeyboardValues EmulatedDevices::GetKeyboardValues() const {
|
||||
std::scoped_lock lock{mutex};
|
||||
return device_status.keyboard_values;
|
||||
@ -462,10 +424,6 @@ MouseButtonValues EmulatedDevices::GetMouseButtonsValues() const {
|
||||
return device_status.mouse_button_values;
|
||||
}
|
||||
|
||||
RingAnalogValue EmulatedDevices::GetRingSensorValues() const {
|
||||
return device_status.ring_analog_value;
|
||||
}
|
||||
|
||||
KeyboardKey EmulatedDevices::GetKeyboard() const {
|
||||
std::scoped_lock lock{mutex};
|
||||
return device_status.keyboard_state;
|
||||
@ -491,10 +449,6 @@ AnalogStickState EmulatedDevices::GetMouseWheel() const {
|
||||
return device_status.mouse_wheel_state;
|
||||
}
|
||||
|
||||
RingSensorForce EmulatedDevices::GetRingSensorForce() const {
|
||||
return device_status.ring_analog_state;
|
||||
}
|
||||
|
||||
void EmulatedDevices::TriggerOnChange(DeviceTriggerType type) {
|
||||
std::scoped_lock lock{callback_mutex};
|
||||
for (const auto& poller_pair : callback_list) {
|
||||
|
@ -26,11 +26,9 @@ using MouseButtonDevices = std::array<std::unique_ptr<Common::Input::InputDevice
|
||||
using MouseAnalogDevices = std::array<std::unique_ptr<Common::Input::InputDevice>,
|
||||
Settings::NativeMouseWheel::NumMouseWheels>;
|
||||
using MouseStickDevice = std::unique_ptr<Common::Input::InputDevice>;
|
||||
using RingAnalogDevice = std::unique_ptr<Common::Input::InputDevice>;
|
||||
|
||||
using MouseButtonParams =
|
||||
std::array<Common::ParamPackage, Settings::NativeMouseButton::NumMouseButtons>;
|
||||
using RingAnalogParams = Common::ParamPackage;
|
||||
|
||||
using KeyboardValues =
|
||||
std::array<Common::Input::ButtonStatus, Settings::NativeKeyboard::NumKeyboardKeys>;
|
||||
@ -41,17 +39,12 @@ using MouseButtonValues =
|
||||
using MouseAnalogValues =
|
||||
std::array<Common::Input::AnalogStatus, Settings::NativeMouseWheel::NumMouseWheels>;
|
||||
using MouseStickValue = Common::Input::TouchStatus;
|
||||
using RingAnalogValue = Common::Input::AnalogStatus;
|
||||
|
||||
struct MousePosition {
|
||||
f32 x;
|
||||
f32 y;
|
||||
};
|
||||
|
||||
struct RingSensorForce {
|
||||
f32 force;
|
||||
};
|
||||
|
||||
struct DeviceStatus {
|
||||
// Data from input_common
|
||||
KeyboardValues keyboard_values{};
|
||||
@ -59,7 +52,6 @@ struct DeviceStatus {
|
||||
MouseButtonValues mouse_button_values{};
|
||||
MouseAnalogValues mouse_analog_values{};
|
||||
MouseStickValue mouse_stick_value{};
|
||||
RingAnalogValue ring_analog_value{};
|
||||
|
||||
// Data for HID serices
|
||||
KeyboardKey keyboard_state{};
|
||||
@ -67,7 +59,6 @@ struct DeviceStatus {
|
||||
MouseButton mouse_button_state{};
|
||||
MousePosition mouse_position_state{};
|
||||
AnalogStickState mouse_wheel_state{};
|
||||
RingSensorForce ring_analog_state{};
|
||||
};
|
||||
|
||||
enum class DeviceTriggerType {
|
||||
@ -138,9 +129,6 @@ public:
|
||||
/// Returns the latest status of button input from the mouse with parameters
|
||||
MouseButtonValues GetMouseButtonsValues() const;
|
||||
|
||||
/// Returns the latest status of analog input from the ring sensor with parameters
|
||||
RingAnalogValue GetRingSensorValues() const;
|
||||
|
||||
/// Returns the latest status of button input from the keyboard
|
||||
KeyboardKey GetKeyboard() const;
|
||||
|
||||
@ -156,9 +144,6 @@ public:
|
||||
/// Returns the latest mouse wheel change
|
||||
AnalogStickState GetMouseWheel() const;
|
||||
|
||||
/// Returns the latest ringcon force sensor value
|
||||
RingSensorForce GetRingSensorForce() const;
|
||||
|
||||
/**
|
||||
* Adds a callback to the list of events
|
||||
* @param update_callback InterfaceUpdateCallback that will be triggered
|
||||
@ -224,14 +209,11 @@ private:
|
||||
|
||||
bool is_configuring{false};
|
||||
|
||||
RingAnalogParams ring_params;
|
||||
|
||||
KeyboardDevices keyboard_devices;
|
||||
KeyboardModifierDevices keyboard_modifier_devices;
|
||||
MouseButtonDevices mouse_button_devices;
|
||||
MouseAnalogDevices mouse_analog_devices;
|
||||
MouseStickDevice mouse_stick_device;
|
||||
RingAnalogDevice ring_analog_device;
|
||||
|
||||
mutable std::mutex mutex;
|
||||
mutable std::mutex callback_mutex;
|
||||
|
@ -1,7 +1,7 @@
|
||||
// SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#include "core/hid/emulated_devices.h"
|
||||
#include "core/hid/emulated_controller.h"
|
||||
#include "core/hid/hid_core.h"
|
||||
#include "core/hle/kernel/k_event.h"
|
||||
#include "core/hle/kernel/k_readable_event.h"
|
||||
@ -12,16 +12,18 @@ namespace Service::HID {
|
||||
RingController::RingController(Core::HID::HIDCore& hid_core_,
|
||||
KernelHelpers::ServiceContext& service_context_)
|
||||
: HidbusBase(service_context_) {
|
||||
input = hid_core_.GetEmulatedDevices();
|
||||
input = hid_core_.GetEmulatedController(Core::HID::NpadIdType::Player1);
|
||||
}
|
||||
|
||||
RingController::~RingController() = default;
|
||||
|
||||
void RingController::OnInit() {
|
||||
input->SetPollingMode(Common::Input::PollingMode::Ring);
|
||||
return;
|
||||
}
|
||||
|
||||
void RingController::OnRelease() {
|
||||
input->SetPollingMode(Common::Input::PollingMode::Active);
|
||||
return;
|
||||
};
|
||||
|
||||
|
@ -9,7 +9,7 @@
|
||||
#include "core/hle/service/hid/hidbus/hidbus_base.h"
|
||||
|
||||
namespace Core::HID {
|
||||
class EmulatedDevices;
|
||||
class EmulatedController;
|
||||
} // namespace Core::HID
|
||||
|
||||
namespace Service::HID {
|
||||
@ -248,6 +248,6 @@ private:
|
||||
.zero = {.value = idle_value, .crc = 225},
|
||||
};
|
||||
|
||||
Core::HID::EmulatedDevices* input;
|
||||
Core::HID::EmulatedController* input;
|
||||
};
|
||||
} // namespace Service::HID
|
||||
|
@ -6,7 +6,7 @@
|
||||
#include <QMenu>
|
||||
#include <QTimer>
|
||||
|
||||
#include "core/hid/emulated_devices.h"
|
||||
#include "core/hid/emulated_controller.h"
|
||||
#include "core/hid/hid_core.h"
|
||||
#include "input_common/drivers/keyboard.h"
|
||||
#include "input_common/drivers/mouse.h"
|
||||
@ -126,9 +126,9 @@ ConfigureRingController::ConfigureRingController(QWidget* parent,
|
||||
ui->buttonRingAnalogPush,
|
||||
};
|
||||
|
||||
emulated_device = hid_core_.GetEmulatedDevices();
|
||||
emulated_device->SaveCurrentConfig();
|
||||
emulated_device->EnableConfiguration();
|
||||
emulated_controller = hid_core_.GetEmulatedController(Core::HID::NpadIdType::Player1);
|
||||
emulated_controller->SaveCurrentConfig();
|
||||
emulated_controller->EnableConfiguration();
|
||||
|
||||
LoadConfiguration();
|
||||
|
||||
@ -143,9 +143,9 @@ ConfigureRingController::ConfigureRingController(QWidget* parent,
|
||||
HandleClick(
|
||||
analog_map_buttons[sub_button_id],
|
||||
[=, this](const Common::ParamPackage& params) {
|
||||
Common::ParamPackage param = emulated_device->GetRingParam();
|
||||
Common::ParamPackage param = emulated_controller->GetRingParam();
|
||||
SetAnalogParam(params, param, analog_sub_buttons[sub_button_id]);
|
||||
emulated_device->SetRingParam(param);
|
||||
emulated_controller->SetRingParam(param);
|
||||
},
|
||||
InputCommon::Polling::InputType::Stick);
|
||||
});
|
||||
@ -155,16 +155,16 @@ ConfigureRingController::ConfigureRingController(QWidget* parent,
|
||||
connect(analog_button, &QPushButton::customContextMenuRequested,
|
||||
[=, this](const QPoint& menu_location) {
|
||||
QMenu context_menu;
|
||||
Common::ParamPackage param = emulated_device->GetRingParam();
|
||||
Common::ParamPackage param = emulated_controller->GetRingParam();
|
||||
context_menu.addAction(tr("Clear"), [&] {
|
||||
emulated_device->SetRingParam({});
|
||||
emulated_controller->SetRingParam(param);
|
||||
analog_map_buttons[sub_button_id]->setText(tr("[not set]"));
|
||||
});
|
||||
context_menu.addAction(tr("Invert axis"), [&] {
|
||||
const bool invert_value = param.Get("invert_x", "+") == "-";
|
||||
const std::string invert_str = invert_value ? "+" : "-";
|
||||
param.Set("invert_x", invert_str);
|
||||
emulated_device->SetRingParam(param);
|
||||
emulated_controller->SetRingParam(param);
|
||||
for (int sub_button_id2 = 0; sub_button_id2 < ANALOG_SUB_BUTTONS_NUM;
|
||||
++sub_button_id2) {
|
||||
analog_map_buttons[sub_button_id2]->setText(
|
||||
@ -177,11 +177,11 @@ ConfigureRingController::ConfigureRingController(QWidget* parent,
|
||||
}
|
||||
|
||||
connect(ui->sliderRingAnalogDeadzone, &QSlider::valueChanged, [=, this] {
|
||||
Common::ParamPackage param = emulated_device->GetRingParam();
|
||||
Common::ParamPackage param = emulated_controller->GetRingParam();
|
||||
const auto slider_value = ui->sliderRingAnalogDeadzone->value();
|
||||
ui->labelRingAnalogDeadzone->setText(tr("Deadzone: %1%").arg(slider_value));
|
||||
param.Set("deadzone", slider_value / 100.0f);
|
||||
emulated_device->SetRingParam(param);
|
||||
emulated_controller->SetRingParam(param);
|
||||
});
|
||||
|
||||
connect(ui->restore_defaults_button, &QPushButton::clicked, this,
|
||||
@ -202,7 +202,7 @@ ConfigureRingController::ConfigureRingController(QWidget* parent,
|
||||
}
|
||||
|
||||
ConfigureRingController::~ConfigureRingController() {
|
||||
emulated_device->DisableConfiguration();
|
||||
emulated_controller->DisableConfiguration();
|
||||
};
|
||||
|
||||
void ConfigureRingController::changeEvent(QEvent* event) {
|
||||
@ -219,7 +219,7 @@ void ConfigureRingController::RetranslateUI() {
|
||||
|
||||
void ConfigureRingController::UpdateUI() {
|
||||
RetranslateUI();
|
||||
const Common::ParamPackage param = emulated_device->GetRingParam();
|
||||
const Common::ParamPackage param = emulated_controller->GetRingParam();
|
||||
|
||||
for (int sub_button_id = 0; sub_button_id < ANALOG_SUB_BUTTONS_NUM; ++sub_button_id) {
|
||||
auto* const analog_button = analog_map_buttons[sub_button_id];
|
||||
@ -240,9 +240,9 @@ void ConfigureRingController::UpdateUI() {
|
||||
}
|
||||
|
||||
void ConfigureRingController::ApplyConfiguration() {
|
||||
emulated_device->DisableConfiguration();
|
||||
emulated_device->SaveCurrentConfig();
|
||||
emulated_device->EnableConfiguration();
|
||||
emulated_controller->DisableConfiguration();
|
||||
emulated_controller->SaveCurrentConfig();
|
||||
emulated_controller->EnableConfiguration();
|
||||
}
|
||||
|
||||
void ConfigureRingController::LoadConfiguration() {
|
||||
@ -252,7 +252,7 @@ void ConfigureRingController::LoadConfiguration() {
|
||||
void ConfigureRingController::RestoreDefaults() {
|
||||
const std::string default_ring_string = InputCommon::GenerateAnalogParamFromKeys(
|
||||
0, 0, Config::default_ringcon_analogs[0], Config::default_ringcon_analogs[1], 0, 0.05f);
|
||||
emulated_device->SetRingParam(Common::ParamPackage(default_ring_string));
|
||||
emulated_controller->SetRingParam(Common::ParamPackage(default_ring_string));
|
||||
UpdateUI();
|
||||
}
|
||||
|
||||
|
@ -13,7 +13,7 @@ class InputSubsystem;
|
||||
|
||||
namespace Core::HID {
|
||||
class HIDCore;
|
||||
class EmulatedDevices;
|
||||
class EmulatedController;
|
||||
} // namespace Core::HID
|
||||
|
||||
namespace Ui {
|
||||
@ -78,7 +78,7 @@ private:
|
||||
std::optional<std::function<void(const Common::ParamPackage&)>> input_setter;
|
||||
|
||||
InputCommon::InputSubsystem* input_subsystem;
|
||||
Core::HID::EmulatedDevices* emulated_device;
|
||||
Core::HID::EmulatedController* emulated_controller;
|
||||
|
||||
std::unique_ptr<Ui::ConfigureRingController> ui;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user