summaryrefslogtreecommitdiff
path: root/src/core/hid/emulated_console.cpp
diff options
context:
space:
mode:
authorGravatar german772021-10-20 23:18:04 -0500
committerGravatar Narr the Reg2021-11-24 20:30:25 -0600
commit85052b8662d9512077780f717fb2e168390ed705 (patch)
tree0d966f3f0fdcb7dbe85fe6e2ca83cf25c492ae4c /src/core/hid/emulated_console.cpp
parentconfiguration: Migrate controller settings to emulated controller (diff)
downloadyuzu-85052b8662d9512077780f717fb2e168390ed705.tar.gz
yuzu-85052b8662d9512077780f717fb2e168390ed705.tar.xz
yuzu-85052b8662d9512077780f717fb2e168390ed705.zip
service/hid: Fix gesture input
Diffstat (limited to 'src/core/hid/emulated_console.cpp')
-rw-r--r--src/core/hid/emulated_console.cpp57
1 files changed, 34 insertions, 23 deletions
diff --git a/src/core/hid/emulated_console.cpp b/src/core/hid/emulated_console.cpp
index 7f7c8fd59..e82cf5990 100644
--- a/src/core/hid/emulated_console.cpp
+++ b/src/core/hid/emulated_console.cpp
@@ -20,27 +20,21 @@ void EmulatedConsole::ReloadFromSettings() {
20 ReloadInput(); 20 ReloadInput();
21} 21}
22 22
23void EmulatedConsole::ReloadInput() { 23void EmulatedConsole::SetTouchParams() {
24 motion_devices = Input::CreateDevice<Input::InputDevice>(motion_params); 24 // TODO(german77): Support any number of fingers
25 if (motion_devices) {
26 Input::InputCallback motion_callback{
27 [this](Input::CallbackStatus callback) { SetMotion(callback); }};
28 motion_devices->SetCallback(motion_callback);
29 }
30
31 // TODO: Fix this mess
32 std::size_t index = 0; 25 std::size_t index = 0;
33 const std::string mouse_device_string = 26
34 fmt::format("engine:mouse,axis_x:10,axis_y:11,button:{}", index); 27 // Hardcode mouse, touchscreen and cemuhook parameters
35 touch_devices[index] = Input::CreateDeviceFromString<Input::InputDevice>(mouse_device_string); 28 touch_params[index++] = Common::ParamPackage{"engine:mouse,axis_x:10,axis_y:11,button:0"};
36 Input::InputCallback trigger_callbackk{ 29 touch_params[index++] = Common::ParamPackage{"engine:touch,axis_x:0,axis_y:1,button:0"};
37 [this, index](Input::CallbackStatus callback) { SetTouch(callback, index); }}; 30 touch_params[index++] = Common::ParamPackage{"engine:touch,axis_x:2,axis_y:3,button:1"};
38 touch_devices[index]->SetCallback(trigger_callbackk); 31 touch_params[index++] = Common::ParamPackage{"engine:cemuhookudp,axis_x:0,axis_y:1,button:0"};
39 32 touch_params[index++] = Common::ParamPackage{"engine:cemuhookudp,axis_x:2,axis_y:3,button:1"};
40 index++; 33
41 const auto button_index = 34 const auto button_index =
42 static_cast<u64>(Settings::values.touch_from_button_map_index.GetValue()); 35 static_cast<u64>(Settings::values.touch_from_button_map_index.GetValue());
43 const auto& touch_buttons = Settings::values.touch_from_button_maps[button_index].buttons; 36 const auto& touch_buttons = Settings::values.touch_from_button_maps[button_index].buttons;
37
44 for (const auto& config_entry : touch_buttons) { 38 for (const auto& config_entry : touch_buttons) {
45 Common::ParamPackage params{config_entry}; 39 Common::ParamPackage params{config_entry};
46 Common::ParamPackage touch_button_params; 40 Common::ParamPackage touch_button_params;
@@ -53,15 +47,32 @@ void EmulatedConsole::ReloadInput() {
53 touch_button_params.Set("x", x); 47 touch_button_params.Set("x", x);
54 touch_button_params.Set("y", y); 48 touch_button_params.Set("y", y);
55 touch_button_params.Set("touch_id", static_cast<int>(index)); 49 touch_button_params.Set("touch_id", static_cast<int>(index));
56 touch_devices[index] = 50 touch_params[index] = touch_button_params;
57 Input::CreateDeviceFromString<Input::InputDevice>(touch_button_params.Serialize()); 51 index++;
58 if (!touch_devices[index]) { 52 if (index >= touch_params.size()) {
59 continue; 53 return;
60 } 54 }
55 }
56}
61 57
62 Input::InputCallback trigger_callback{ 58void EmulatedConsole::ReloadInput() {
59 SetTouchParams();
60 motion_devices = Input::CreateDevice<Input::InputDevice>(motion_params);
61 if (motion_devices) {
62 Input::InputCallback motion_callback{
63 [this](Input::CallbackStatus callback) { SetMotion(callback); }};
64 motion_devices->SetCallback(motion_callback);
65 }
66
67 std::size_t index = 0;
68 for (auto& touch_device : touch_devices) {
69 touch_device = Input::CreateDevice<Input::InputDevice>(touch_params[index]);
70 if (!touch_device) {
71 continue;
72 }
73 Input::InputCallback touch_callback{
63 [this, index](Input::CallbackStatus callback) { SetTouch(callback, index); }}; 74 [this, index](Input::CallbackStatus callback) { SetTouch(callback, index); }};
64 touch_devices[index]->SetCallback(trigger_callback); 75 touch_device->SetCallback(touch_callback);
65 index++; 76 index++;
66 } 77 }
67} 78}