diff options
| author | 2022-11-28 09:19:01 -0500 | |
|---|---|---|
| committer | 2022-11-28 10:00:37 -0500 | |
| commit | 2ec7d0b5fda0fe6cbafcc235e3d8cc91b0dc81e0 (patch) | |
| tree | c61fdcf120b96a0487e24f16c6f48b5fb44fafb5 /src/core | |
| parent | common/input: Pass ParamPackage by const reference in CreateDevice (diff) | |
| download | yuzu-2ec7d0b5fda0fe6cbafcc235e3d8cc91b0dc81e0.tar.gz yuzu-2ec7d0b5fda0fe6cbafcc235e3d8cc91b0dc81e0.tar.xz yuzu-2ec7d0b5fda0fe6cbafcc235e3d8cc91b0dc81e0.zip | |
common/input: Add helpers functions for creating input and output devices
Avoids the redundancy of needing to explictly specify the common
namespace and the type.
Diffstat (limited to 'src/core')
| -rw-r--r-- | src/core/hid/emulated_console.cpp | 4 | ||||
| -rw-r--r-- | src/core/hid/emulated_controller.cpp | 20 | ||||
| -rw-r--r-- | src/core/hid/emulated_devices.cpp | 14 |
3 files changed, 19 insertions, 19 deletions
diff --git a/src/core/hid/emulated_console.cpp b/src/core/hid/emulated_console.cpp index fb7e5802a..b6c8cc58d 100644 --- a/src/core/hid/emulated_console.cpp +++ b/src/core/hid/emulated_console.cpp | |||
| @@ -68,7 +68,7 @@ void EmulatedConsole::ReloadInput() { | |||
| 68 | // If you load any device here add the equivalent to the UnloadInput() function | 68 | // If you load any device here add the equivalent to the UnloadInput() function |
| 69 | SetTouchParams(); | 69 | SetTouchParams(); |
| 70 | 70 | ||
| 71 | motion_devices = Common::Input::CreateDevice<Common::Input::InputDevice>(motion_params); | 71 | motion_devices = Common::Input::CreateInputDevice(motion_params); |
| 72 | if (motion_devices) { | 72 | if (motion_devices) { |
| 73 | motion_devices->SetCallback({ | 73 | motion_devices->SetCallback({ |
| 74 | .on_change = | 74 | .on_change = |
| @@ -79,7 +79,7 @@ void EmulatedConsole::ReloadInput() { | |||
| 79 | // Unique index for identifying touch device source | 79 | // Unique index for identifying touch device source |
| 80 | std::size_t index = 0; | 80 | std::size_t index = 0; |
| 81 | for (auto& touch_device : touch_devices) { | 81 | for (auto& touch_device : touch_devices) { |
| 82 | touch_device = Common::Input::CreateDevice<Common::Input::InputDevice>(touch_params[index]); | 82 | touch_device = Common::Input::CreateInputDevice(touch_params[index]); |
| 83 | if (!touch_device) { | 83 | if (!touch_device) { |
| 84 | continue; | 84 | continue; |
| 85 | } | 85 | } |
diff --git a/src/core/hid/emulated_controller.cpp b/src/core/hid/emulated_controller.cpp index ec1364452..b3188f256 100644 --- a/src/core/hid/emulated_controller.cpp +++ b/src/core/hid/emulated_controller.cpp | |||
| @@ -146,27 +146,27 @@ void EmulatedController::LoadDevices() { | |||
| 146 | 146 | ||
| 147 | std::transform(button_params.begin() + Settings::NativeButton::BUTTON_HID_BEGIN, | 147 | std::transform(button_params.begin() + Settings::NativeButton::BUTTON_HID_BEGIN, |
| 148 | button_params.begin() + Settings::NativeButton::BUTTON_NS_END, | 148 | button_params.begin() + Settings::NativeButton::BUTTON_NS_END, |
| 149 | button_devices.begin(), Common::Input::CreateDevice<Common::Input::InputDevice>); | 149 | button_devices.begin(), Common::Input::CreateInputDevice); |
| 150 | std::transform(stick_params.begin() + Settings::NativeAnalog::STICK_HID_BEGIN, | 150 | std::transform(stick_params.begin() + Settings::NativeAnalog::STICK_HID_BEGIN, |
| 151 | stick_params.begin() + Settings::NativeAnalog::STICK_HID_END, | 151 | stick_params.begin() + Settings::NativeAnalog::STICK_HID_END, |
| 152 | stick_devices.begin(), Common::Input::CreateDevice<Common::Input::InputDevice>); | 152 | stick_devices.begin(), Common::Input::CreateInputDevice); |
| 153 | std::transform(motion_params.begin() + Settings::NativeMotion::MOTION_HID_BEGIN, | 153 | std::transform(motion_params.begin() + Settings::NativeMotion::MOTION_HID_BEGIN, |
| 154 | motion_params.begin() + Settings::NativeMotion::MOTION_HID_END, | 154 | motion_params.begin() + Settings::NativeMotion::MOTION_HID_END, |
| 155 | motion_devices.begin(), Common::Input::CreateDevice<Common::Input::InputDevice>); | 155 | motion_devices.begin(), Common::Input::CreateInputDevice); |
| 156 | std::transform(trigger_params.begin(), trigger_params.end(), trigger_devices.begin(), | 156 | std::transform(trigger_params.begin(), trigger_params.end(), trigger_devices.begin(), |
| 157 | Common::Input::CreateDevice<Common::Input::InputDevice>); | 157 | Common::Input::CreateInputDevice); |
| 158 | std::transform(battery_params.begin(), battery_params.end(), battery_devices.begin(), | 158 | std::transform(battery_params.begin(), battery_params.end(), battery_devices.begin(), |
| 159 | Common::Input::CreateDevice<Common::Input::InputDevice>); | 159 | Common::Input::CreateInputDevice); |
| 160 | camera_devices = Common::Input::CreateDevice<Common::Input::InputDevice>(camera_params); | 160 | camera_devices = Common::Input::CreateInputDevice(camera_params); |
| 161 | nfc_devices = Common::Input::CreateDevice<Common::Input::InputDevice>(nfc_params); | 161 | nfc_devices = Common::Input::CreateInputDevice(nfc_params); |
| 162 | std::transform(output_params.begin(), output_params.end(), output_devices.begin(), | 162 | std::transform(output_params.begin(), output_params.end(), output_devices.begin(), |
| 163 | Common::Input::CreateDevice<Common::Input::OutputDevice>); | 163 | Common::Input::CreateOutputDevice); |
| 164 | 164 | ||
| 165 | // Initialize TAS devices | 165 | // Initialize TAS devices |
| 166 | std::transform(tas_button_params.begin(), tas_button_params.end(), tas_button_devices.begin(), | 166 | std::transform(tas_button_params.begin(), tas_button_params.end(), tas_button_devices.begin(), |
| 167 | Common::Input::CreateDevice<Common::Input::InputDevice>); | 167 | Common::Input::CreateInputDevice); |
| 168 | std::transform(tas_stick_params.begin(), tas_stick_params.end(), tas_stick_devices.begin(), | 168 | std::transform(tas_stick_params.begin(), tas_stick_params.end(), tas_stick_devices.begin(), |
| 169 | Common::Input::CreateDevice<Common::Input::InputDevice>); | 169 | Common::Input::CreateInputDevice); |
| 170 | } | 170 | } |
| 171 | 171 | ||
| 172 | void EmulatedController::LoadTASParams() { | 172 | void EmulatedController::LoadTASParams() { |
diff --git a/src/core/hid/emulated_devices.cpp b/src/core/hid/emulated_devices.cpp index 658dbd318..e421828d2 100644 --- a/src/core/hid/emulated_devices.cpp +++ b/src/core/hid/emulated_devices.cpp | |||
| @@ -25,12 +25,12 @@ void EmulatedDevices::ReloadInput() { | |||
| 25 | Common::ParamPackage mouse_params; | 25 | Common::ParamPackage mouse_params; |
| 26 | mouse_params.Set("engine", "mouse"); | 26 | mouse_params.Set("engine", "mouse"); |
| 27 | mouse_params.Set("button", static_cast<int>(key_index)); | 27 | mouse_params.Set("button", static_cast<int>(key_index)); |
| 28 | mouse_device = Common::Input::CreateDevice<Common::Input::InputDevice>(mouse_params); | 28 | mouse_device = Common::Input::CreateInputDevice(mouse_params); |
| 29 | key_index++; | 29 | key_index++; |
| 30 | } | 30 | } |
| 31 | 31 | ||
| 32 | mouse_stick_device = Common::Input::CreateDeviceFromString<Common::Input::InputDevice>( | 32 | mouse_stick_device = |
| 33 | "engine:mouse,axis_x:0,axis_y:1"); | 33 | Common::Input::CreateInputDeviceFromString("engine:mouse,axis_x:0,axis_y:1"); |
| 34 | 34 | ||
| 35 | // First two axis are reserved for mouse position | 35 | // First two axis are reserved for mouse position |
| 36 | key_index = 2; | 36 | key_index = 2; |
| @@ -38,7 +38,7 @@ void EmulatedDevices::ReloadInput() { | |||
| 38 | Common::ParamPackage mouse_params; | 38 | Common::ParamPackage mouse_params; |
| 39 | mouse_params.Set("engine", "mouse"); | 39 | mouse_params.Set("engine", "mouse"); |
| 40 | mouse_params.Set("axis", static_cast<int>(key_index)); | 40 | mouse_params.Set("axis", static_cast<int>(key_index)); |
| 41 | mouse_device = Common::Input::CreateDevice<Common::Input::InputDevice>(mouse_params); | 41 | mouse_device = Common::Input::CreateInputDevice(mouse_params); |
| 42 | key_index++; | 42 | key_index++; |
| 43 | } | 43 | } |
| 44 | 44 | ||
| @@ -50,7 +50,7 @@ void EmulatedDevices::ReloadInput() { | |||
| 50 | keyboard_params.Set("button", static_cast<int>(key_index)); | 50 | keyboard_params.Set("button", static_cast<int>(key_index)); |
| 51 | keyboard_params.Set("port", 1); | 51 | keyboard_params.Set("port", 1); |
| 52 | keyboard_params.Set("pad", 0); | 52 | keyboard_params.Set("pad", 0); |
| 53 | keyboard_device = Common::Input::CreateDevice<Common::Input::InputDevice>(keyboard_params); | 53 | keyboard_device = Common::Input::CreateInputDevice(keyboard_params); |
| 54 | key_index++; | 54 | key_index++; |
| 55 | } | 55 | } |
| 56 | 56 | ||
| @@ -62,11 +62,11 @@ void EmulatedDevices::ReloadInput() { | |||
| 62 | keyboard_params.Set("button", static_cast<int>(key_index)); | 62 | keyboard_params.Set("button", static_cast<int>(key_index)); |
| 63 | keyboard_params.Set("port", 1); | 63 | keyboard_params.Set("port", 1); |
| 64 | keyboard_params.Set("pad", 1); | 64 | keyboard_params.Set("pad", 1); |
| 65 | keyboard_device = Common::Input::CreateDevice<Common::Input::InputDevice>(keyboard_params); | 65 | keyboard_device = Common::Input::CreateInputDevice(keyboard_params); |
| 66 | key_index++; | 66 | key_index++; |
| 67 | } | 67 | } |
| 68 | 68 | ||
| 69 | ring_analog_device = Common::Input::CreateDevice<Common::Input::InputDevice>(ring_params); | 69 | ring_analog_device = Common::Input::CreateInputDevice(ring_params); |
| 70 | 70 | ||
| 71 | for (std::size_t index = 0; index < mouse_button_devices.size(); ++index) { | 71 | for (std::size_t index = 0; index < mouse_button_devices.size(); ++index) { |
| 72 | if (!mouse_button_devices[index]) { | 72 | if (!mouse_button_devices[index]) { |