summaryrefslogtreecommitdiff
path: root/src/core/hid/emulated_controller.cpp
diff options
context:
space:
mode:
authorGravatar german772021-10-24 20:28:54 -0500
committerGravatar Narr the Reg2021-11-24 20:30:26 -0600
commitc6c32daf40ae1c720f0a2897c538bb1117371ea5 (patch)
tree26879cbeb2162e706086818ad501a8f2730206d5 /src/core/hid/emulated_controller.cpp
parentservice/hid: Fix memory allocated incorrectly (diff)
downloadyuzu-c6c32daf40ae1c720f0a2897c538bb1117371ea5.tar.gz
yuzu-c6c32daf40ae1c720f0a2897c538bb1117371ea5.tar.xz
yuzu-c6c32daf40ae1c720f0a2897c538bb1117371ea5.zip
input_common: Add manual update options to input devices
Diffstat (limited to 'src/core/hid/emulated_controller.cpp')
-rw-r--r--src/core/hid/emulated_controller.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/core/hid/emulated_controller.cpp b/src/core/hid/emulated_controller.cpp
index bd0b89c05..48add394b 100644
--- a/src/core/hid/emulated_controller.cpp
+++ b/src/core/hid/emulated_controller.cpp
@@ -122,6 +122,7 @@ void EmulatedController::ReloadInput() {
122 Input::InputCallback button_callback{ 122 Input::InputCallback button_callback{
123 [this, index](Input::CallbackStatus callback) { SetButton(callback, index); }}; 123 [this, index](Input::CallbackStatus callback) { SetButton(callback, index); }};
124 button_devices[index]->SetCallback(button_callback); 124 button_devices[index]->SetCallback(button_callback);
125 button_devices[index]->ForceUpdate();
125 } 126 }
126 127
127 for (std::size_t index = 0; index < stick_devices.size(); ++index) { 128 for (std::size_t index = 0; index < stick_devices.size(); ++index) {
@@ -131,6 +132,7 @@ void EmulatedController::ReloadInput() {
131 Input::InputCallback stick_callback{ 132 Input::InputCallback stick_callback{
132 [this, index](Input::CallbackStatus callback) { SetStick(callback, index); }}; 133 [this, index](Input::CallbackStatus callback) { SetStick(callback, index); }};
133 stick_devices[index]->SetCallback(stick_callback); 134 stick_devices[index]->SetCallback(stick_callback);
135 stick_devices[index]->ForceUpdate();
134 } 136 }
135 137
136 for (std::size_t index = 0; index < trigger_devices.size(); ++index) { 138 for (std::size_t index = 0; index < trigger_devices.size(); ++index) {
@@ -140,6 +142,7 @@ void EmulatedController::ReloadInput() {
140 Input::InputCallback trigger_callback{ 142 Input::InputCallback trigger_callback{
141 [this, index](Input::CallbackStatus callback) { SetTrigger(callback, index); }}; 143 [this, index](Input::CallbackStatus callback) { SetTrigger(callback, index); }};
142 trigger_devices[index]->SetCallback(trigger_callback); 144 trigger_devices[index]->SetCallback(trigger_callback);
145 trigger_devices[index]->ForceUpdate();
143 } 146 }
144 147
145 for (std::size_t index = 0; index < battery_devices.size(); ++index) { 148 for (std::size_t index = 0; index < battery_devices.size(); ++index) {
@@ -149,6 +152,7 @@ void EmulatedController::ReloadInput() {
149 Input::InputCallback battery_callback{ 152 Input::InputCallback battery_callback{
150 [this, index](Input::CallbackStatus callback) { SetBattery(callback, index); }}; 153 [this, index](Input::CallbackStatus callback) { SetBattery(callback, index); }};
151 battery_devices[index]->SetCallback(battery_callback); 154 battery_devices[index]->SetCallback(battery_callback);
155 battery_devices[index]->ForceUpdate();
152 } 156 }
153 157
154 for (std::size_t index = 0; index < motion_devices.size(); ++index) { 158 for (std::size_t index = 0; index < motion_devices.size(); ++index) {
@@ -158,6 +162,7 @@ void EmulatedController::ReloadInput() {
158 Input::InputCallback motion_callback{ 162 Input::InputCallback motion_callback{
159 [this, index](Input::CallbackStatus callback) { SetMotion(callback, index); }}; 163 [this, index](Input::CallbackStatus callback) { SetMotion(callback, index); }};
160 motion_devices[index]->SetCallback(motion_callback); 164 motion_devices[index]->SetCallback(motion_callback);
165 motion_devices[index]->ForceUpdate();
161 } 166 }
162} 167}
163 168
@@ -843,6 +848,10 @@ AnalogSticks EmulatedController::GetSticks() const {
843 if (is_configuring) { 848 if (is_configuring) {
844 return {}; 849 return {};
845 } 850 }
851 // Some drivers like stick from buttons need constant refreshing
852 for (auto& device : stick_devices) {
853 device->SoftUpdate();
854 }
846 return controller.analog_stick_state; 855 return controller.analog_stick_state;
847} 856}
848 857