core: hid: Migrate ring from emulated devices to emulated controller
This commit is contained in:
parent
18c9f8eeed
commit
a4074001fe
8 changed files with 105 additions and 88 deletions
|
@ -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) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue