diff options
Diffstat (limited to 'src/input_common')
| -rw-r--r-- | src/input_common/drivers/gc_adapter.cpp | 10 | ||||
| -rw-r--r-- | src/input_common/drivers/gc_adapter.h | 7 | ||||
| -rw-r--r-- | src/input_common/drivers/keyboard.h | 2 | ||||
| -rw-r--r-- | src/input_common/drivers/mouse.h | 2 | ||||
| -rw-r--r-- | src/input_common/drivers/sdl_driver.cpp | 16 | ||||
| -rw-r--r-- | src/input_common/drivers/sdl_driver.h | 7 | ||||
| -rw-r--r-- | src/input_common/drivers/touch_screen.h | 2 | ||||
| -rw-r--r-- | src/input_common/helpers/stick_from_buttons.cpp | 70 | ||||
| -rw-r--r-- | src/input_common/helpers/stick_from_buttons.h | 4 | ||||
| -rw-r--r-- | src/input_common/helpers/touch_from_buttons.cpp | 29 | ||||
| -rw-r--r-- | src/input_common/helpers/touch_from_buttons.h | 4 | ||||
| -rw-r--r-- | src/input_common/input_engine.h | 14 | ||||
| -rw-r--r-- | src/input_common/input_poller.cpp | 202 | ||||
| -rw-r--r-- | src/input_common/input_poller.h | 32 | ||||
| -rw-r--r-- | src/input_common/main.cpp | 76 |
15 files changed, 254 insertions, 223 deletions
diff --git a/src/input_common/drivers/gc_adapter.cpp b/src/input_common/drivers/gc_adapter.cpp index 62dc28711..2550f8cba 100644 --- a/src/input_common/drivers/gc_adapter.cpp +++ b/src/input_common/drivers/gc_adapter.cpp | |||
| @@ -248,7 +248,7 @@ bool GCAdapter::Setup() { | |||
| 248 | std::size_t port = 0; | 248 | std::size_t port = 0; |
| 249 | for (GCController& pad : pads) { | 249 | for (GCController& pad : pads) { |
| 250 | pad.identifier = { | 250 | pad.identifier = { |
| 251 | .guid = Common::UUID{""}, | 251 | .guid = Common::UUID{Common::INVALID_UUID}, |
| 252 | .port = port++, | 252 | .port = port++, |
| 253 | .pad = 0, | 253 | .pad = 0, |
| 254 | }; | 254 | }; |
| @@ -325,8 +325,8 @@ bool GCAdapter::GetGCEndpoint(libusb_device* device) { | |||
| 325 | return true; | 325 | return true; |
| 326 | } | 326 | } |
| 327 | 327 | ||
| 328 | Input::VibrationError GCAdapter::SetRumble(const PadIdentifier& identifier, | 328 | Common::Input::VibrationError GCAdapter::SetRumble(const PadIdentifier& identifier, |
| 329 | const Input::VibrationStatus vibration) { | 329 | const Common::Input::VibrationStatus vibration) { |
| 330 | const auto mean_amplitude = (vibration.low_amplitude + vibration.high_amplitude) * 0.5f; | 330 | const auto mean_amplitude = (vibration.low_amplitude + vibration.high_amplitude) * 0.5f; |
| 331 | const auto processed_amplitude = | 331 | const auto processed_amplitude = |
| 332 | static_cast<u8>((mean_amplitude + std::pow(mean_amplitude, 0.3f)) * 0.5f * 0x8); | 332 | static_cast<u8>((mean_amplitude + std::pow(mean_amplitude, 0.3f)) * 0.5f * 0x8); |
| @@ -334,9 +334,9 @@ Input::VibrationError GCAdapter::SetRumble(const PadIdentifier& identifier, | |||
| 334 | pads[identifier.port].rumble_amplitude = processed_amplitude; | 334 | pads[identifier.port].rumble_amplitude = processed_amplitude; |
| 335 | 335 | ||
| 336 | if (!rumble_enabled) { | 336 | if (!rumble_enabled) { |
| 337 | return Input::VibrationError::Disabled; | 337 | return Common::Input::VibrationError::Disabled; |
| 338 | } | 338 | } |
| 339 | return Input::VibrationError::None; | 339 | return Common::Input::VibrationError::None; |
| 340 | } | 340 | } |
| 341 | 341 | ||
| 342 | void GCAdapter::UpdateVibrations() { | 342 | void GCAdapter::UpdateVibrations() { |
diff --git a/src/input_common/drivers/gc_adapter.h b/src/input_common/drivers/gc_adapter.h index b82e4803d..fba90352e 100644 --- a/src/input_common/drivers/gc_adapter.h +++ b/src/input_common/drivers/gc_adapter.h | |||
| @@ -4,8 +4,11 @@ | |||
| 4 | 4 | ||
| 5 | #pragma once | 5 | #pragma once |
| 6 | 6 | ||
| 7 | #include <array> | ||
| 8 | #include <memory> | ||
| 7 | #include <mutex> | 9 | #include <mutex> |
| 8 | #include <stop_token> | 10 | #include <stop_token> |
| 11 | #include <string> | ||
| 9 | #include <thread> | 12 | #include <thread> |
| 10 | 13 | ||
| 11 | #include "input_common/input_engine.h" | 14 | #include "input_common/input_engine.h" |
| @@ -24,8 +27,8 @@ public: | |||
| 24 | explicit GCAdapter(const std::string input_engine_); | 27 | explicit GCAdapter(const std::string input_engine_); |
| 25 | ~GCAdapter(); | 28 | ~GCAdapter(); |
| 26 | 29 | ||
| 27 | Input::VibrationError SetRumble(const PadIdentifier& identifier, | 30 | Common::Input::VibrationError SetRumble( |
| 28 | const Input::VibrationStatus vibration) override; | 31 | const PadIdentifier& identifier, const Common::Input::VibrationStatus vibration) override; |
| 29 | 32 | ||
| 30 | /// Used for automapping features | 33 | /// Used for automapping features |
| 31 | std::vector<Common::ParamPackage> GetInputDevices() const override; | 34 | std::vector<Common::ParamPackage> GetInputDevices() const override; |
diff --git a/src/input_common/drivers/keyboard.h b/src/input_common/drivers/keyboard.h index a3e0d8a61..58df15050 100644 --- a/src/input_common/drivers/keyboard.h +++ b/src/input_common/drivers/keyboard.h | |||
| @@ -35,7 +35,7 @@ public: | |||
| 35 | 35 | ||
| 36 | private: | 36 | private: |
| 37 | const PadIdentifier identifier = { | 37 | const PadIdentifier identifier = { |
| 38 | .guid = Common::UUID{""}, | 38 | .guid = Common::UUID{Common::INVALID_UUID}, |
| 39 | .port = 0, | 39 | .port = 0, |
| 40 | .pad = 0, | 40 | .pad = 0, |
| 41 | }; | 41 | }; |
diff --git a/src/input_common/drivers/mouse.h b/src/input_common/drivers/mouse.h index d3178b1a9..cf0918409 100644 --- a/src/input_common/drivers/mouse.h +++ b/src/input_common/drivers/mouse.h | |||
| @@ -63,7 +63,7 @@ private: | |||
| 63 | void StopPanning(); | 63 | void StopPanning(); |
| 64 | 64 | ||
| 65 | const PadIdentifier identifier = { | 65 | const PadIdentifier identifier = { |
| 66 | .guid = Common::UUID{""}, | 66 | .guid = Common::UUID{Common::INVALID_UUID}, |
| 67 | .port = 0, | 67 | .port = 0, |
| 68 | .pad = 0, | 68 | .pad = 0, |
| 69 | }; | 69 | }; |
diff --git a/src/input_common/drivers/sdl_driver.cpp b/src/input_common/drivers/sdl_driver.cpp index 53e282ef3..1e3741e0f 100644 --- a/src/input_common/drivers/sdl_driver.cpp +++ b/src/input_common/drivers/sdl_driver.cpp | |||
| @@ -92,7 +92,7 @@ public: | |||
| 92 | return motion; | 92 | return motion; |
| 93 | } | 93 | } |
| 94 | 94 | ||
| 95 | bool RumblePlay(const Input::VibrationStatus vibration) { | 95 | bool RumblePlay(const Common::Input::VibrationStatus vibration) { |
| 96 | constexpr u32 rumble_max_duration_ms = 1000; | 96 | constexpr u32 rumble_max_duration_ms = 1000; |
| 97 | if (sdl_controller) { | 97 | if (sdl_controller) { |
| 98 | return SDL_GameControllerRumble( | 98 | return SDL_GameControllerRumble( |
| @@ -515,8 +515,8 @@ std::vector<Common::ParamPackage> SDLDriver::GetInputDevices() const { | |||
| 515 | } | 515 | } |
| 516 | return devices; | 516 | return devices; |
| 517 | } | 517 | } |
| 518 | Input::VibrationError SDLDriver::SetRumble(const PadIdentifier& identifier, | 518 | Common::Input::VibrationError SDLDriver::SetRumble(const PadIdentifier& identifier, |
| 519 | const Input::VibrationStatus vibration) { | 519 | const Common::Input::VibrationStatus vibration) { |
| 520 | const auto joystick = | 520 | const auto joystick = |
| 521 | GetSDLJoystickByGUID(identifier.guid.Format(), static_cast<int>(identifier.port)); | 521 | GetSDLJoystickByGUID(identifier.guid.Format(), static_cast<int>(identifier.port)); |
| 522 | const auto process_amplitude_exp = [](f32 amplitude, f32 factor) { | 522 | const auto process_amplitude_exp = [](f32 amplitude, f32 factor) { |
| @@ -527,7 +527,7 @@ Input::VibrationError SDLDriver::SetRumble(const PadIdentifier& identifier, | |||
| 527 | f32 factor = 0.35f; | 527 | f32 factor = 0.35f; |
| 528 | 528 | ||
| 529 | // If vibration is set as a linear output use a flatter value | 529 | // If vibration is set as a linear output use a flatter value |
| 530 | if (vibration.type == Input::VibrationAmplificationType::Linear) { | 530 | if (vibration.type == Common::Input::VibrationAmplificationType::Linear) { |
| 531 | factor = 0.5f; | 531 | factor = 0.5f; |
| 532 | } | 532 | } |
| 533 | 533 | ||
| @@ -536,19 +536,19 @@ Input::VibrationError SDLDriver::SetRumble(const PadIdentifier& identifier, | |||
| 536 | factor = 1.0f; | 536 | factor = 1.0f; |
| 537 | } | 537 | } |
| 538 | 538 | ||
| 539 | const Input::VibrationStatus new_vibration{ | 539 | const Common::Input::VibrationStatus new_vibration{ |
| 540 | .low_amplitude = process_amplitude_exp(vibration.low_amplitude, factor), | 540 | .low_amplitude = process_amplitude_exp(vibration.low_amplitude, factor), |
| 541 | .low_frequency = vibration.low_frequency, | 541 | .low_frequency = vibration.low_frequency, |
| 542 | .high_amplitude = process_amplitude_exp(vibration.high_amplitude, factor), | 542 | .high_amplitude = process_amplitude_exp(vibration.high_amplitude, factor), |
| 543 | .high_frequency = vibration.high_frequency, | 543 | .high_frequency = vibration.high_frequency, |
| 544 | .type = Input::VibrationAmplificationType::Exponential, | 544 | .type = Common::Input::VibrationAmplificationType::Exponential, |
| 545 | }; | 545 | }; |
| 546 | 546 | ||
| 547 | if (!joystick->RumblePlay(new_vibration)) { | 547 | if (!joystick->RumblePlay(new_vibration)) { |
| 548 | return Input::VibrationError::Unknown; | 548 | return Common::Input::VibrationError::Unknown; |
| 549 | } | 549 | } |
| 550 | 550 | ||
| 551 | return Input::VibrationError::None; | 551 | return Common::Input::VibrationError::None; |
| 552 | } | 552 | } |
| 553 | Common::ParamPackage SDLDriver::BuildAnalogParamPackageForButton(int port, std::string guid, | 553 | Common::ParamPackage SDLDriver::BuildAnalogParamPackageForButton(int port, std::string guid, |
| 554 | s32 axis, float value) const { | 554 | s32 axis, float value) const { |
diff --git a/src/input_common/drivers/sdl_driver.h b/src/input_common/drivers/sdl_driver.h index 1ff85f48d..b879df8ab 100644 --- a/src/input_common/drivers/sdl_driver.h +++ b/src/input_common/drivers/sdl_driver.h | |||
| @@ -58,8 +58,8 @@ public: | |||
| 58 | std::string GetHatButtonName(u8 direction_value) const override; | 58 | std::string GetHatButtonName(u8 direction_value) const override; |
| 59 | u8 GetHatButtonId(const std::string direction_name) const override; | 59 | u8 GetHatButtonId(const std::string direction_name) const override; |
| 60 | 60 | ||
| 61 | Input::VibrationError SetRumble(const PadIdentifier& identifier, | 61 | Common::Input::VibrationError SetRumble( |
| 62 | const Input::VibrationStatus vibration) override; | 62 | const PadIdentifier& identifier, const Common::Input::VibrationStatus vibration) override; |
| 63 | 63 | ||
| 64 | private: | 64 | private: |
| 65 | void InitJoystick(int joystick_index); | 65 | void InitJoystick(int joystick_index); |
| @@ -105,9 +105,6 @@ private: | |||
| 105 | /// Returns true if the button is on the left joycon | 105 | /// Returns true if the button is on the left joycon |
| 106 | bool IsButtonOnLeftSide(Settings::NativeButton::Values button) const; | 106 | bool IsButtonOnLeftSide(Settings::NativeButton::Values button) const; |
| 107 | 107 | ||
| 108 | // Set to true if SDL supports game controller subsystem | ||
| 109 | bool has_gamecontroller = false; | ||
| 110 | |||
| 111 | /// Map of GUID of a list of corresponding virtual Joysticks | 108 | /// Map of GUID of a list of corresponding virtual Joysticks |
| 112 | std::unordered_map<std::string, std::vector<std::shared_ptr<SDLJoystick>>> joystick_map; | 109 | std::unordered_map<std::string, std::vector<std::shared_ptr<SDLJoystick>>> joystick_map; |
| 113 | std::mutex joystick_map_mutex; | 110 | std::mutex joystick_map_mutex; |
diff --git a/src/input_common/drivers/touch_screen.h b/src/input_common/drivers/touch_screen.h index 5fbb2f47f..d297d253c 100644 --- a/src/input_common/drivers/touch_screen.h +++ b/src/input_common/drivers/touch_screen.h | |||
| @@ -41,7 +41,7 @@ public: | |||
| 41 | 41 | ||
| 42 | private: | 42 | private: |
| 43 | const PadIdentifier identifier = { | 43 | const PadIdentifier identifier = { |
| 44 | .guid = Common::UUID{""}, | 44 | .guid = Common::UUID{Common::INVALID_UUID}, |
| 45 | .port = 0, | 45 | .port = 0, |
| 46 | .pad = 0, | 46 | .pad = 0, |
| 47 | }; | 47 | }; |
diff --git a/src/input_common/helpers/stick_from_buttons.cpp b/src/input_common/helpers/stick_from_buttons.cpp index 806a0e8bb..1d5948f79 100644 --- a/src/input_common/helpers/stick_from_buttons.cpp +++ b/src/input_common/helpers/stick_from_buttons.cpp | |||
| @@ -10,25 +10,27 @@ | |||
| 10 | 10 | ||
| 11 | namespace InputCommon { | 11 | namespace InputCommon { |
| 12 | 12 | ||
| 13 | class Stick final : public Input::InputDevice { | 13 | class Stick final : public Common::Input::InputDevice { |
| 14 | public: | 14 | public: |
| 15 | using Button = std::unique_ptr<Input::InputDevice>; | 15 | using Button = std::unique_ptr<Common::Input::InputDevice>; |
| 16 | 16 | ||
| 17 | Stick(Button up_, Button down_, Button left_, Button right_, Button modifier_, | 17 | Stick(Button up_, Button down_, Button left_, Button right_, Button modifier_, |
| 18 | float modifier_scale_, float modifier_angle_) | 18 | float modifier_scale_, float modifier_angle_) |
| 19 | : up(std::move(up_)), down(std::move(down_)), left(std::move(left_)), | 19 | : up(std::move(up_)), down(std::move(down_)), left(std::move(left_)), |
| 20 | right(std::move(right_)), modifier(std::move(modifier_)), modifier_scale(modifier_scale_), | 20 | right(std::move(right_)), modifier(std::move(modifier_)), modifier_scale(modifier_scale_), |
| 21 | modifier_angle(modifier_angle_) { | 21 | modifier_angle(modifier_angle_) { |
| 22 | Input::InputCallback button_up_callback{ | 22 | Common::Input::InputCallback button_up_callback{ |
| 23 | [this](Input::CallbackStatus callback_) { UpdateUpButtonStatus(callback_); }}; | 23 | [this](Common::Input::CallbackStatus callback_) { UpdateUpButtonStatus(callback_); }}; |
| 24 | Input::InputCallback button_down_callback{ | 24 | Common::Input::InputCallback button_down_callback{ |
| 25 | [this](Input::CallbackStatus callback_) { UpdateDownButtonStatus(callback_); }}; | 25 | [this](Common::Input::CallbackStatus callback_) { UpdateDownButtonStatus(callback_); }}; |
| 26 | Input::InputCallback button_left_callback{ | 26 | Common::Input::InputCallback button_left_callback{ |
| 27 | [this](Input::CallbackStatus callback_) { UpdateLeftButtonStatus(callback_); }}; | 27 | [this](Common::Input::CallbackStatus callback_) { UpdateLeftButtonStatus(callback_); }}; |
| 28 | Input::InputCallback button_right_callback{ | 28 | Common::Input::InputCallback button_right_callback{ |
| 29 | [this](Input::CallbackStatus callback_) { UpdateRightButtonStatus(callback_); }}; | 29 | [this](Common::Input::CallbackStatus callback_) { |
| 30 | Input::InputCallback button_modifier_callback{ | 30 | UpdateRightButtonStatus(callback_); |
| 31 | [this](Input::CallbackStatus callback_) { UpdateModButtonStatus(callback_); }}; | 31 | }}; |
| 32 | Common::Input::InputCallback button_modifier_callback{ | ||
| 33 | [this](Common::Input::CallbackStatus callback_) { UpdateModButtonStatus(callback_); }}; | ||
| 32 | up->SetCallback(button_up_callback); | 34 | up->SetCallback(button_up_callback); |
| 33 | down->SetCallback(button_down_callback); | 35 | down->SetCallback(button_down_callback); |
| 34 | left->SetCallback(button_left_callback); | 36 | left->SetCallback(button_left_callback); |
| @@ -129,27 +131,27 @@ public: | |||
| 129 | } | 131 | } |
| 130 | } | 132 | } |
| 131 | 133 | ||
| 132 | void UpdateUpButtonStatus(Input::CallbackStatus button_callback) { | 134 | void UpdateUpButtonStatus(Common::Input::CallbackStatus button_callback) { |
| 133 | up_status = button_callback.button_status.value; | 135 | up_status = button_callback.button_status.value; |
| 134 | UpdateStatus(); | 136 | UpdateStatus(); |
| 135 | } | 137 | } |
| 136 | 138 | ||
| 137 | void UpdateDownButtonStatus(Input::CallbackStatus button_callback) { | 139 | void UpdateDownButtonStatus(Common::Input::CallbackStatus button_callback) { |
| 138 | down_status = button_callback.button_status.value; | 140 | down_status = button_callback.button_status.value; |
| 139 | UpdateStatus(); | 141 | UpdateStatus(); |
| 140 | } | 142 | } |
| 141 | 143 | ||
| 142 | void UpdateLeftButtonStatus(Input::CallbackStatus button_callback) { | 144 | void UpdateLeftButtonStatus(Common::Input::CallbackStatus button_callback) { |
| 143 | left_status = button_callback.button_status.value; | 145 | left_status = button_callback.button_status.value; |
| 144 | UpdateStatus(); | 146 | UpdateStatus(); |
| 145 | } | 147 | } |
| 146 | 148 | ||
| 147 | void UpdateRightButtonStatus(Input::CallbackStatus button_callback) { | 149 | void UpdateRightButtonStatus(Common::Input::CallbackStatus button_callback) { |
| 148 | right_status = button_callback.button_status.value; | 150 | right_status = button_callback.button_status.value; |
| 149 | UpdateStatus(); | 151 | UpdateStatus(); |
| 150 | } | 152 | } |
| 151 | 153 | ||
| 152 | void UpdateModButtonStatus(Input::CallbackStatus button_callback) { | 154 | void UpdateModButtonStatus(Common::Input::CallbackStatus button_callback) { |
| 153 | modifier_status = button_callback.button_status.value; | 155 | modifier_status = button_callback.button_status.value; |
| 154 | UpdateStatus(); | 156 | UpdateStatus(); |
| 155 | } | 157 | } |
| @@ -193,8 +195,8 @@ public: | |||
| 193 | } | 195 | } |
| 194 | 196 | ||
| 195 | last_update = now; | 197 | last_update = now; |
| 196 | Input::CallbackStatus status{ | 198 | Common::Input::CallbackStatus status{ |
| 197 | .type = Input::InputType::Stick, | 199 | .type = Common::Input::InputType::Stick, |
| 198 | .stick_status = GetStatus(), | 200 | .stick_status = GetStatus(), |
| 199 | }; | 201 | }; |
| 200 | TriggerOnChange(status); | 202 | TriggerOnChange(status); |
| @@ -209,15 +211,15 @@ public: | |||
| 209 | } | 211 | } |
| 210 | 212 | ||
| 211 | void SoftUpdate() override { | 213 | void SoftUpdate() override { |
| 212 | Input::CallbackStatus status{ | 214 | Common::Input::CallbackStatus status{ |
| 213 | .type = Input::InputType::Stick, | 215 | .type = Common::Input::InputType::Stick, |
| 214 | .stick_status = GetStatus(), | 216 | .stick_status = GetStatus(), |
| 215 | }; | 217 | }; |
| 216 | TriggerOnChange(status); | 218 | TriggerOnChange(status); |
| 217 | } | 219 | } |
| 218 | 220 | ||
| 219 | Input::StickStatus GetStatus() const { | 221 | Common::Input::StickStatus GetStatus() const { |
| 220 | Input::StickStatus status{}; | 222 | Common::Input::StickStatus status{}; |
| 221 | status.x.properties = properties; | 223 | status.x.properties = properties; |
| 222 | status.y.properties = properties; | 224 | status.y.properties = properties; |
| 223 | if (Settings::values.emulate_analog_keyboard) { | 225 | if (Settings::values.emulate_analog_keyboard) { |
| @@ -263,19 +265,23 @@ private: | |||
| 263 | bool left_status; | 265 | bool left_status; |
| 264 | bool right_status; | 266 | bool right_status; |
| 265 | bool modifier_status; | 267 | bool modifier_status; |
| 266 | const Input::AnalogProperties properties{0.0f, 1.0f, 0.5f, 0.0f, false}; | 268 | const Common::Input::AnalogProperties properties{0.0f, 1.0f, 0.5f, 0.0f, false}; |
| 267 | std::chrono::time_point<std::chrono::steady_clock> last_update; | 269 | std::chrono::time_point<std::chrono::steady_clock> last_update; |
| 268 | }; | 270 | }; |
| 269 | 271 | ||
| 270 | std::unique_ptr<Input::InputDevice> StickFromButton::Create(const Common::ParamPackage& params) { | 272 | std::unique_ptr<Common::Input::InputDevice> StickFromButton::Create( |
| 273 | const Common::ParamPackage& params) { | ||
| 271 | const std::string null_engine = Common::ParamPackage{{"engine", "null"}}.Serialize(); | 274 | const std::string null_engine = Common::ParamPackage{{"engine", "null"}}.Serialize(); |
| 272 | auto up = Input::CreateDeviceFromString<Input::InputDevice>(params.Get("up", null_engine)); | 275 | auto up = Common::Input::CreateDeviceFromString<Common::Input::InputDevice>( |
| 273 | auto down = Input::CreateDeviceFromString<Input::InputDevice>(params.Get("down", null_engine)); | 276 | params.Get("up", null_engine)); |
| 274 | auto left = Input::CreateDeviceFromString<Input::InputDevice>(params.Get("left", null_engine)); | 277 | auto down = Common::Input::CreateDeviceFromString<Common::Input::InputDevice>( |
| 275 | auto right = | 278 | params.Get("down", null_engine)); |
| 276 | Input::CreateDeviceFromString<Input::InputDevice>(params.Get("right", null_engine)); | 279 | auto left = Common::Input::CreateDeviceFromString<Common::Input::InputDevice>( |
| 277 | auto modifier = | 280 | params.Get("left", null_engine)); |
| 278 | Input::CreateDeviceFromString<Input::InputDevice>(params.Get("modifier", null_engine)); | 281 | auto right = Common::Input::CreateDeviceFromString<Common::Input::InputDevice>( |
| 282 | params.Get("right", null_engine)); | ||
| 283 | auto modifier = Common::Input::CreateDeviceFromString<Common::Input::InputDevice>( | ||
| 284 | params.Get("modifier", null_engine)); | ||
| 279 | auto modifier_scale = params.Get("modifier_scale", 0.5f); | 285 | auto modifier_scale = params.Get("modifier_scale", 0.5f); |
| 280 | auto modifier_angle = params.Get("modifier_angle", 5.5f); | 286 | auto modifier_angle = params.Get("modifier_angle", 5.5f); |
| 281 | return std::make_unique<Stick>(std::move(up), std::move(down), std::move(left), | 287 | return std::make_unique<Stick>(std::move(up), std::move(down), std::move(left), |
diff --git a/src/input_common/helpers/stick_from_buttons.h b/src/input_common/helpers/stick_from_buttons.h index 82dff5ca8..437ace4f7 100644 --- a/src/input_common/helpers/stick_from_buttons.h +++ b/src/input_common/helpers/stick_from_buttons.h | |||
| @@ -12,7 +12,7 @@ namespace InputCommon { | |||
| 12 | * An analog device factory that takes direction button devices and combines them into a analog | 12 | * An analog device factory that takes direction button devices and combines them into a analog |
| 13 | * device. | 13 | * device. |
| 14 | */ | 14 | */ |
| 15 | class StickFromButton final : public Input::Factory<Input::InputDevice> { | 15 | class StickFromButton final : public Common::Input::Factory<Common::Input::InputDevice> { |
| 16 | public: | 16 | public: |
| 17 | /** | 17 | /** |
| 18 | * Creates an analog device from direction button devices | 18 | * Creates an analog device from direction button devices |
| @@ -24,7 +24,7 @@ public: | |||
| 24 | * - "modifier": a serialized ParamPackage for creating a button device as the modifier | 24 | * - "modifier": a serialized ParamPackage for creating a button device as the modifier |
| 25 | * - "modifier_scale": a float for the multiplier the modifier gives to the position | 25 | * - "modifier_scale": a float for the multiplier the modifier gives to the position |
| 26 | */ | 26 | */ |
| 27 | std::unique_ptr<Input::InputDevice> Create(const Common::ParamPackage& params) override; | 27 | std::unique_ptr<Common::Input::InputDevice> Create(const Common::ParamPackage& params) override; |
| 28 | }; | 28 | }; |
| 29 | 29 | ||
| 30 | } // namespace InputCommon | 30 | } // namespace InputCommon |
diff --git a/src/input_common/helpers/touch_from_buttons.cpp b/src/input_common/helpers/touch_from_buttons.cpp index bb2bad5b1..fee41cae3 100644 --- a/src/input_common/helpers/touch_from_buttons.cpp +++ b/src/input_common/helpers/touch_from_buttons.cpp | |||
| @@ -9,22 +9,22 @@ | |||
| 9 | 9 | ||
| 10 | namespace InputCommon { | 10 | namespace InputCommon { |
| 11 | 11 | ||
| 12 | class TouchFromButtonDevice final : public Input::InputDevice { | 12 | class TouchFromButtonDevice final : public Common::Input::InputDevice { |
| 13 | public: | 13 | public: |
| 14 | using Button = std::unique_ptr<Input::InputDevice>; | 14 | using Button = std::unique_ptr<Common::Input::InputDevice>; |
| 15 | TouchFromButtonDevice(Button button_, u32 touch_id_, float x_, float y_) | 15 | TouchFromButtonDevice(Button button_, u32 touch_id_, float x_, float y_) |
| 16 | : button(std::move(button_)), touch_id(touch_id_), x(x_), y(y_) { | 16 | : button(std::move(button_)), touch_id(touch_id_), x(x_), y(y_) { |
| 17 | Input::InputCallback button_up_callback{ | 17 | Common::Input::InputCallback button_up_callback{ |
| 18 | [this](Input::CallbackStatus callback_) { UpdateButtonStatus(callback_); }}; | 18 | [this](Common::Input::CallbackStatus callback_) { UpdateButtonStatus(callback_); }}; |
| 19 | button->SetCallback(button_up_callback); | 19 | button->SetCallback(button_up_callback); |
| 20 | button->ForceUpdate(); | 20 | button->ForceUpdate(); |
| 21 | } | 21 | } |
| 22 | 22 | ||
| 23 | Input::TouchStatus GetStatus(bool pressed) const { | 23 | Common::Input::TouchStatus GetStatus(bool pressed) const { |
| 24 | const Input::ButtonStatus button_status{ | 24 | const Common::Input::ButtonStatus button_status{ |
| 25 | .value = pressed, | 25 | .value = pressed, |
| 26 | }; | 26 | }; |
| 27 | Input::TouchStatus status{ | 27 | Common::Input::TouchStatus status{ |
| 28 | .pressed = button_status, | 28 | .pressed = button_status, |
| 29 | .x = {}, | 29 | .x = {}, |
| 30 | .y = {}, | 30 | .y = {}, |
| @@ -42,9 +42,9 @@ public: | |||
| 42 | return status; | 42 | return status; |
| 43 | } | 43 | } |
| 44 | 44 | ||
| 45 | void UpdateButtonStatus(Input::CallbackStatus button_callback) { | 45 | void UpdateButtonStatus(Common::Input::CallbackStatus button_callback) { |
| 46 | const Input::CallbackStatus status{ | 46 | const Common::Input::CallbackStatus status{ |
| 47 | .type = Input::InputType::Touch, | 47 | .type = Common::Input::InputType::Touch, |
| 48 | .touch_status = GetStatus(button_callback.button_status.value), | 48 | .touch_status = GetStatus(button_callback.button_status.value), |
| 49 | }; | 49 | }; |
| 50 | TriggerOnChange(status); | 50 | TriggerOnChange(status); |
| @@ -55,13 +55,14 @@ private: | |||
| 55 | const u32 touch_id; | 55 | const u32 touch_id; |
| 56 | const float x; | 56 | const float x; |
| 57 | const float y; | 57 | const float y; |
| 58 | const Input::AnalogProperties properties{0.0f, 1.0f, 0.5f, 0.0f, false}; | 58 | const Common::Input::AnalogProperties properties{0.0f, 1.0f, 0.5f, 0.0f, false}; |
| 59 | }; | 59 | }; |
| 60 | 60 | ||
| 61 | std::unique_ptr<Input::InputDevice> TouchFromButton::Create(const Common::ParamPackage& params) { | 61 | std::unique_ptr<Common::Input::InputDevice> TouchFromButton::Create( |
| 62 | const Common::ParamPackage& params) { | ||
| 62 | const std::string null_engine = Common::ParamPackage{{"engine", "null"}}.Serialize(); | 63 | const std::string null_engine = Common::ParamPackage{{"engine", "null"}}.Serialize(); |
| 63 | auto button = | 64 | auto button = Common::Input::CreateDeviceFromString<Common::Input::InputDevice>( |
| 64 | Input::CreateDeviceFromString<Input::InputDevice>(params.Get("button", null_engine)); | 65 | params.Get("button", null_engine)); |
| 65 | const auto touch_id = params.Get("touch_id", 0); | 66 | const auto touch_id = params.Get("touch_id", 0); |
| 66 | const float x = params.Get("x", 0.0f) / 1280.0f; | 67 | const float x = params.Get("x", 0.0f) / 1280.0f; |
| 67 | const float y = params.Get("y", 0.0f) / 720.0f; | 68 | const float y = params.Get("y", 0.0f) / 720.0f; |
diff --git a/src/input_common/helpers/touch_from_buttons.h b/src/input_common/helpers/touch_from_buttons.h index 21b353728..628f18215 100644 --- a/src/input_common/helpers/touch_from_buttons.h +++ b/src/input_common/helpers/touch_from_buttons.h | |||
| @@ -11,12 +11,12 @@ namespace InputCommon { | |||
| 11 | /** | 11 | /** |
| 12 | * A touch device factory that takes a list of button devices and combines them into a touch device. | 12 | * A touch device factory that takes a list of button devices and combines them into a touch device. |
| 13 | */ | 13 | */ |
| 14 | class TouchFromButton final : public Input::Factory<Input::InputDevice> { | 14 | class TouchFromButton final : public Common::Input::Factory<Common::Input::InputDevice> { |
| 15 | public: | 15 | public: |
| 16 | /** | 16 | /** |
| 17 | * Creates a touch device from a list of button devices | 17 | * Creates a touch device from a list of button devices |
| 18 | */ | 18 | */ |
| 19 | std::unique_ptr<Input::InputDevice> Create(const Common::ParamPackage& params) override; | 19 | std::unique_ptr<Common::Input::InputDevice> Create(const Common::ParamPackage& params) override; |
| 20 | }; | 20 | }; |
| 21 | 21 | ||
| 22 | } // namespace InputCommon | 22 | } // namespace InputCommon |
diff --git a/src/input_common/input_engine.h b/src/input_common/input_engine.h index 31ce900d7..ed79d3d93 100644 --- a/src/input_common/input_engine.h +++ b/src/input_common/input_engine.h | |||
| @@ -116,22 +116,22 @@ public: | |||
| 116 | 116 | ||
| 117 | // Sets a led pattern for a controller | 117 | // Sets a led pattern for a controller |
| 118 | virtual void SetLeds([[maybe_unused]] const PadIdentifier& identifier, | 118 | virtual void SetLeds([[maybe_unused]] const PadIdentifier& identifier, |
| 119 | [[maybe_unused]] const Input::LedStatus led_status) { | 119 | [[maybe_unused]] const Common::Input::LedStatus led_status) { |
| 120 | return; | 120 | return; |
| 121 | } | 121 | } |
| 122 | 122 | ||
| 123 | // Sets rumble to a controller | 123 | // Sets rumble to a controller |
| 124 | virtual Input::VibrationError SetRumble( | 124 | virtual Common::Input::VibrationError SetRumble( |
| 125 | [[maybe_unused]] const PadIdentifier& identifier, | 125 | [[maybe_unused]] const PadIdentifier& identifier, |
| 126 | [[maybe_unused]] const Input::VibrationStatus vibration) { | 126 | [[maybe_unused]] const Common::Input::VibrationStatus vibration) { |
| 127 | return Input::VibrationError::NotSupported; | 127 | return Common::Input::VibrationError::NotSupported; |
| 128 | } | 128 | } |
| 129 | 129 | ||
| 130 | // Sets polling mode to a controller | 130 | // Sets polling mode to a controller |
| 131 | virtual Input::PollingError SetPollingMode( | 131 | virtual Common::Input::PollingError SetPollingMode( |
| 132 | [[maybe_unused]] const PadIdentifier& identifier, | 132 | [[maybe_unused]] const PadIdentifier& identifier, |
| 133 | [[maybe_unused]] const Input::PollingMode vibration) { | 133 | [[maybe_unused]] const Common::Input::PollingMode vibration) { |
| 134 | return Input::PollingError::NotSupported; | 134 | return Common::Input::PollingError::NotSupported; |
| 135 | } | 135 | } |
| 136 | 136 | ||
| 137 | // Returns the engine name | 137 | // Returns the engine name |
diff --git a/src/input_common/input_poller.cpp b/src/input_common/input_poller.cpp index 6edb8d900..2b3b77938 100644 --- a/src/input_common/input_poller.cpp +++ b/src/input_common/input_poller.cpp | |||
| @@ -10,13 +10,13 @@ | |||
| 10 | 10 | ||
| 11 | namespace InputCommon { | 11 | namespace InputCommon { |
| 12 | 12 | ||
| 13 | class DummyInput final : public Input::InputDevice { | 13 | class DummyInput final : public Common::Input::InputDevice { |
| 14 | public: | 14 | public: |
| 15 | explicit DummyInput() {} | 15 | explicit DummyInput() {} |
| 16 | ~DummyInput() {} | 16 | ~DummyInput() {} |
| 17 | }; | 17 | }; |
| 18 | 18 | ||
| 19 | class InputFromButton final : public Input::InputDevice { | 19 | class InputFromButton final : public Common::Input::InputDevice { |
| 20 | public: | 20 | public: |
| 21 | explicit InputFromButton(PadIdentifier identifier_, u32 button_, bool toggle_, bool inverted_, | 21 | explicit InputFromButton(PadIdentifier identifier_, u32 button_, bool toggle_, bool inverted_, |
| 22 | InputEngine* input_engine_) | 22 | InputEngine* input_engine_) |
| @@ -37,7 +37,7 @@ public: | |||
| 37 | input_engine->DeleteCallback(callback_key); | 37 | input_engine->DeleteCallback(callback_key); |
| 38 | } | 38 | } |
| 39 | 39 | ||
| 40 | Input::ButtonStatus GetStatus() const { | 40 | Common::Input::ButtonStatus GetStatus() const { |
| 41 | return { | 41 | return { |
| 42 | .value = input_engine->GetButton(identifier, button), | 42 | .value = input_engine->GetButton(identifier, button), |
| 43 | .inverted = inverted, | 43 | .inverted = inverted, |
| @@ -46,8 +46,8 @@ public: | |||
| 46 | } | 46 | } |
| 47 | 47 | ||
| 48 | void ForceUpdate() { | 48 | void ForceUpdate() { |
| 49 | const Input::CallbackStatus status{ | 49 | const Common::Input::CallbackStatus status{ |
| 50 | .type = Input::InputType::Button, | 50 | .type = Common::Input::InputType::Button, |
| 51 | .button_status = GetStatus(), | 51 | .button_status = GetStatus(), |
| 52 | }; | 52 | }; |
| 53 | 53 | ||
| @@ -56,8 +56,8 @@ public: | |||
| 56 | } | 56 | } |
| 57 | 57 | ||
| 58 | void OnChange() { | 58 | void OnChange() { |
| 59 | const Input::CallbackStatus status{ | 59 | const Common::Input::CallbackStatus status{ |
| 60 | .type = Input::InputType::Button, | 60 | .type = Common::Input::InputType::Button, |
| 61 | .button_status = GetStatus(), | 61 | .button_status = GetStatus(), |
| 62 | }; | 62 | }; |
| 63 | 63 | ||
| @@ -77,7 +77,7 @@ private: | |||
| 77 | InputEngine* input_engine; | 77 | InputEngine* input_engine; |
| 78 | }; | 78 | }; |
| 79 | 79 | ||
| 80 | class InputFromHatButton final : public Input::InputDevice { | 80 | class InputFromHatButton final : public Common::Input::InputDevice { |
| 81 | public: | 81 | public: |
| 82 | explicit InputFromHatButton(PadIdentifier identifier_, u32 button_, u8 direction_, bool toggle_, | 82 | explicit InputFromHatButton(PadIdentifier identifier_, u32 button_, u8 direction_, bool toggle_, |
| 83 | bool inverted_, InputEngine* input_engine_) | 83 | bool inverted_, InputEngine* input_engine_) |
| @@ -98,7 +98,7 @@ public: | |||
| 98 | input_engine->DeleteCallback(callback_key); | 98 | input_engine->DeleteCallback(callback_key); |
| 99 | } | 99 | } |
| 100 | 100 | ||
| 101 | Input::ButtonStatus GetStatus() const { | 101 | Common::Input::ButtonStatus GetStatus() const { |
| 102 | return { | 102 | return { |
| 103 | .value = input_engine->GetHatButton(identifier, button, direction), | 103 | .value = input_engine->GetHatButton(identifier, button, direction), |
| 104 | .inverted = inverted, | 104 | .inverted = inverted, |
| @@ -107,8 +107,8 @@ public: | |||
| 107 | } | 107 | } |
| 108 | 108 | ||
| 109 | void ForceUpdate() { | 109 | void ForceUpdate() { |
| 110 | const Input::CallbackStatus status{ | 110 | const Common::Input::CallbackStatus status{ |
| 111 | .type = Input::InputType::Button, | 111 | .type = Common::Input::InputType::Button, |
| 112 | .button_status = GetStatus(), | 112 | .button_status = GetStatus(), |
| 113 | }; | 113 | }; |
| 114 | 114 | ||
| @@ -117,8 +117,8 @@ public: | |||
| 117 | } | 117 | } |
| 118 | 118 | ||
| 119 | void OnChange() { | 119 | void OnChange() { |
| 120 | const Input::CallbackStatus status{ | 120 | const Common::Input::CallbackStatus status{ |
| 121 | .type = Input::InputType::Button, | 121 | .type = Common::Input::InputType::Button, |
| 122 | .button_status = GetStatus(), | 122 | .button_status = GetStatus(), |
| 123 | }; | 123 | }; |
| 124 | 124 | ||
| @@ -139,11 +139,12 @@ private: | |||
| 139 | InputEngine* input_engine; | 139 | InputEngine* input_engine; |
| 140 | }; | 140 | }; |
| 141 | 141 | ||
| 142 | class InputFromStick final : public Input::InputDevice { | 142 | class InputFromStick final : public Common::Input::InputDevice { |
| 143 | public: | 143 | public: |
| 144 | explicit InputFromStick(PadIdentifier identifier_, u32 axis_x_, u32 axis_y_, | 144 | explicit InputFromStick(PadIdentifier identifier_, u32 axis_x_, u32 axis_y_, |
| 145 | Input::AnalogProperties properties_x_, | 145 | Common::Input::AnalogProperties properties_x_, |
| 146 | Input::AnalogProperties properties_y_, InputEngine* input_engine_) | 146 | Common::Input::AnalogProperties properties_y_, |
| 147 | InputEngine* input_engine_) | ||
| 147 | : identifier(identifier_), axis_x(axis_x_), axis_y(axis_y_), properties_x(properties_x_), | 148 | : identifier(identifier_), axis_x(axis_x_), axis_y(axis_y_), properties_x(properties_x_), |
| 148 | properties_y(properties_y_), input_engine(input_engine_) { | 149 | properties_y(properties_y_), input_engine(input_engine_) { |
| 149 | UpdateCallback engine_callback{[this]() { OnChange(); }}; | 150 | UpdateCallback engine_callback{[this]() { OnChange(); }}; |
| @@ -170,8 +171,8 @@ public: | |||
| 170 | input_engine->DeleteCallback(callback_key_y); | 171 | input_engine->DeleteCallback(callback_key_y); |
| 171 | } | 172 | } |
| 172 | 173 | ||
| 173 | Input::StickStatus GetStatus() const { | 174 | Common::Input::StickStatus GetStatus() const { |
| 174 | Input::StickStatus status; | 175 | Common::Input::StickStatus status; |
| 175 | status.x = { | 176 | status.x = { |
| 176 | .raw_value = input_engine->GetAxis(identifier, axis_x), | 177 | .raw_value = input_engine->GetAxis(identifier, axis_x), |
| 177 | .properties = properties_x, | 178 | .properties = properties_x, |
| @@ -184,8 +185,8 @@ public: | |||
| 184 | } | 185 | } |
| 185 | 186 | ||
| 186 | void ForceUpdate() { | 187 | void ForceUpdate() { |
| 187 | const Input::CallbackStatus status{ | 188 | const Common::Input::CallbackStatus status{ |
| 188 | .type = Input::InputType::Stick, | 189 | .type = Common::Input::InputType::Stick, |
| 189 | .stick_status = GetStatus(), | 190 | .stick_status = GetStatus(), |
| 190 | }; | 191 | }; |
| 191 | 192 | ||
| @@ -195,8 +196,8 @@ public: | |||
| 195 | } | 196 | } |
| 196 | 197 | ||
| 197 | void OnChange() { | 198 | void OnChange() { |
| 198 | const Input::CallbackStatus status{ | 199 | const Common::Input::CallbackStatus status{ |
| 199 | .type = Input::InputType::Stick, | 200 | .type = Common::Input::InputType::Stick, |
| 200 | .stick_status = GetStatus(), | 201 | .stick_status = GetStatus(), |
| 201 | }; | 202 | }; |
| 202 | 203 | ||
| @@ -212,8 +213,8 @@ private: | |||
| 212 | const PadIdentifier identifier; | 213 | const PadIdentifier identifier; |
| 213 | const u32 axis_x; | 214 | const u32 axis_x; |
| 214 | const u32 axis_y; | 215 | const u32 axis_y; |
| 215 | const Input::AnalogProperties properties_x; | 216 | const Common::Input::AnalogProperties properties_x; |
| 216 | const Input::AnalogProperties properties_y; | 217 | const Common::Input::AnalogProperties properties_y; |
| 217 | int callback_key_x; | 218 | int callback_key_x; |
| 218 | int callback_key_y; | 219 | int callback_key_y; |
| 219 | float last_axis_x_value; | 220 | float last_axis_x_value; |
| @@ -221,12 +222,13 @@ private: | |||
| 221 | InputEngine* input_engine; | 222 | InputEngine* input_engine; |
| 222 | }; | 223 | }; |
| 223 | 224 | ||
| 224 | class InputFromTouch final : public Input::InputDevice { | 225 | class InputFromTouch final : public Common::Input::InputDevice { |
| 225 | public: | 226 | public: |
| 226 | explicit InputFromTouch(PadIdentifier identifier_, u32 touch_id_, u32 button_, bool toggle_, | 227 | explicit InputFromTouch(PadIdentifier identifier_, u32 touch_id_, u32 button_, bool toggle_, |
| 227 | bool inverted_, u32 axis_x_, u32 axis_y_, | 228 | bool inverted_, u32 axis_x_, u32 axis_y_, |
| 228 | Input::AnalogProperties properties_x_, | 229 | Common::Input::AnalogProperties properties_x_, |
| 229 | Input::AnalogProperties properties_y_, InputEngine* input_engine_) | 230 | Common::Input::AnalogProperties properties_y_, |
| 231 | InputEngine* input_engine_) | ||
| 230 | : identifier(identifier_), touch_id(touch_id_), button(button_), toggle(toggle_), | 232 | : identifier(identifier_), touch_id(touch_id_), button(button_), toggle(toggle_), |
| 231 | inverted(inverted_), axis_x(axis_x_), axis_y(axis_y_), properties_x(properties_x_), | 233 | inverted(inverted_), axis_x(axis_x_), axis_y(axis_y_), properties_x(properties_x_), |
| 232 | properties_y(properties_y_), input_engine(input_engine_) { | 234 | properties_y(properties_y_), input_engine(input_engine_) { |
| @@ -263,8 +265,8 @@ public: | |||
| 263 | input_engine->DeleteCallback(callback_key_y); | 265 | input_engine->DeleteCallback(callback_key_y); |
| 264 | } | 266 | } |
| 265 | 267 | ||
| 266 | Input::TouchStatus GetStatus() const { | 268 | Common::Input::TouchStatus GetStatus() const { |
| 267 | Input::TouchStatus status; | 269 | Common::Input::TouchStatus status; |
| 268 | status.id = touch_id; | 270 | status.id = touch_id; |
| 269 | status.pressed = { | 271 | status.pressed = { |
| 270 | .value = input_engine->GetButton(identifier, button), | 272 | .value = input_engine->GetButton(identifier, button), |
| @@ -283,8 +285,8 @@ public: | |||
| 283 | } | 285 | } |
| 284 | 286 | ||
| 285 | void OnChange() { | 287 | void OnChange() { |
| 286 | const Input::CallbackStatus status{ | 288 | const Common::Input::CallbackStatus status{ |
| 287 | .type = Input::InputType::Touch, | 289 | .type = Common::Input::InputType::Touch, |
| 288 | .touch_status = GetStatus(), | 290 | .touch_status = GetStatus(), |
| 289 | }; | 291 | }; |
| 290 | 292 | ||
| @@ -306,8 +308,8 @@ private: | |||
| 306 | const bool inverted; | 308 | const bool inverted; |
| 307 | const u32 axis_x; | 309 | const u32 axis_x; |
| 308 | const u32 axis_y; | 310 | const u32 axis_y; |
| 309 | const Input::AnalogProperties properties_x; | 311 | const Common::Input::AnalogProperties properties_x; |
| 310 | const Input::AnalogProperties properties_y; | 312 | const Common::Input::AnalogProperties properties_y; |
| 311 | int callback_key_button; | 313 | int callback_key_button; |
| 312 | int callback_key_x; | 314 | int callback_key_x; |
| 313 | int callback_key_y; | 315 | int callback_key_y; |
| @@ -317,10 +319,10 @@ private: | |||
| 317 | InputEngine* input_engine; | 319 | InputEngine* input_engine; |
| 318 | }; | 320 | }; |
| 319 | 321 | ||
| 320 | class InputFromTrigger final : public Input::InputDevice { | 322 | class InputFromTrigger final : public Common::Input::InputDevice { |
| 321 | public: | 323 | public: |
| 322 | explicit InputFromTrigger(PadIdentifier identifier_, u32 button_, bool toggle_, bool inverted_, | 324 | explicit InputFromTrigger(PadIdentifier identifier_, u32 button_, bool toggle_, bool inverted_, |
| 323 | u32 axis_, Input::AnalogProperties properties_, | 325 | u32 axis_, Common::Input::AnalogProperties properties_, |
| 324 | InputEngine* input_engine_) | 326 | InputEngine* input_engine_) |
| 325 | : identifier(identifier_), button(button_), toggle(toggle_), inverted(inverted_), | 327 | : identifier(identifier_), button(button_), toggle(toggle_), inverted(inverted_), |
| 326 | axis(axis_), properties(properties_), input_engine(input_engine_) { | 328 | axis(axis_), properties(properties_), input_engine(input_engine_) { |
| @@ -348,8 +350,8 @@ public: | |||
| 348 | input_engine->DeleteCallback(axis_callback_key); | 350 | input_engine->DeleteCallback(axis_callback_key); |
| 349 | } | 351 | } |
| 350 | 352 | ||
| 351 | Input::TriggerStatus GetStatus() const { | 353 | Common::Input::TriggerStatus GetStatus() const { |
| 352 | const Input::AnalogStatus analog_status{ | 354 | const Common::Input::AnalogStatus analog_status{ |
| 353 | .raw_value = input_engine->GetAxis(identifier, axis), | 355 | .raw_value = input_engine->GetAxis(identifier, axis), |
| 354 | .properties = properties, | 356 | .properties = properties, |
| 355 | }; | 357 | }; |
| @@ -360,8 +362,8 @@ public: | |||
| 360 | } | 362 | } |
| 361 | 363 | ||
| 362 | void OnChange() { | 364 | void OnChange() { |
| 363 | const Input::CallbackStatus status{ | 365 | const Common::Input::CallbackStatus status{ |
| 364 | .type = Input::InputType::Trigger, | 366 | .type = Common::Input::InputType::Trigger, |
| 365 | .trigger_status = GetStatus(), | 367 | .trigger_status = GetStatus(), |
| 366 | }; | 368 | }; |
| 367 | 369 | ||
| @@ -379,7 +381,7 @@ private: | |||
| 379 | const bool toggle; | 381 | const bool toggle; |
| 380 | const bool inverted; | 382 | const bool inverted; |
| 381 | const u32 axis; | 383 | const u32 axis; |
| 382 | const Input::AnalogProperties properties; | 384 | const Common::Input::AnalogProperties properties; |
| 383 | int callback_key_button; | 385 | int callback_key_button; |
| 384 | int axis_callback_key; | 386 | int axis_callback_key; |
| 385 | bool last_button_value; | 387 | bool last_button_value; |
| @@ -387,10 +389,11 @@ private: | |||
| 387 | InputEngine* input_engine; | 389 | InputEngine* input_engine; |
| 388 | }; | 390 | }; |
| 389 | 391 | ||
| 390 | class InputFromAnalog final : public Input::InputDevice { | 392 | class InputFromAnalog final : public Common::Input::InputDevice { |
| 391 | public: | 393 | public: |
| 392 | explicit InputFromAnalog(PadIdentifier identifier_, u32 axis_, | 394 | explicit InputFromAnalog(PadIdentifier identifier_, u32 axis_, |
| 393 | Input::AnalogProperties properties_, InputEngine* input_engine_) | 395 | Common::Input::AnalogProperties properties_, |
| 396 | InputEngine* input_engine_) | ||
| 394 | : identifier(identifier_), axis(axis_), properties(properties_), | 397 | : identifier(identifier_), axis(axis_), properties(properties_), |
| 395 | input_engine(input_engine_) { | 398 | input_engine(input_engine_) { |
| 396 | UpdateCallback engine_callback{[this]() { OnChange(); }}; | 399 | UpdateCallback engine_callback{[this]() { OnChange(); }}; |
| @@ -408,7 +411,7 @@ public: | |||
| 408 | input_engine->DeleteCallback(callback_key); | 411 | input_engine->DeleteCallback(callback_key); |
| 409 | } | 412 | } |
| 410 | 413 | ||
| 411 | Input::AnalogStatus GetStatus() const { | 414 | Common::Input::AnalogStatus GetStatus() const { |
| 412 | return { | 415 | return { |
| 413 | .raw_value = input_engine->GetAxis(identifier, axis), | 416 | .raw_value = input_engine->GetAxis(identifier, axis), |
| 414 | .properties = properties, | 417 | .properties = properties, |
| @@ -416,8 +419,8 @@ public: | |||
| 416 | } | 419 | } |
| 417 | 420 | ||
| 418 | void OnChange() { | 421 | void OnChange() { |
| 419 | const Input::CallbackStatus status{ | 422 | const Common::Input::CallbackStatus status{ |
| 420 | .type = Input::InputType::Analog, | 423 | .type = Common::Input::InputType::Analog, |
| 421 | .analog_status = GetStatus(), | 424 | .analog_status = GetStatus(), |
| 422 | }; | 425 | }; |
| 423 | 426 | ||
| @@ -430,13 +433,13 @@ public: | |||
| 430 | private: | 433 | private: |
| 431 | const PadIdentifier identifier; | 434 | const PadIdentifier identifier; |
| 432 | const u32 axis; | 435 | const u32 axis; |
| 433 | const Input::AnalogProperties properties; | 436 | const Common::Input::AnalogProperties properties; |
| 434 | int callback_key; | 437 | int callback_key; |
| 435 | float last_axis_value; | 438 | float last_axis_value; |
| 436 | InputEngine* input_engine; | 439 | InputEngine* input_engine; |
| 437 | }; | 440 | }; |
| 438 | 441 | ||
| 439 | class InputFromBattery final : public Input::InputDevice { | 442 | class InputFromBattery final : public Common::Input::InputDevice { |
| 440 | public: | 443 | public: |
| 441 | explicit InputFromBattery(PadIdentifier identifier_, InputEngine* input_engine_) | 444 | explicit InputFromBattery(PadIdentifier identifier_, InputEngine* input_engine_) |
| 442 | : identifier(identifier_), input_engine(input_engine_) { | 445 | : identifier(identifier_), input_engine(input_engine_) { |
| @@ -447,7 +450,7 @@ public: | |||
| 447 | .index = 0, | 450 | .index = 0, |
| 448 | .callback = engine_callback, | 451 | .callback = engine_callback, |
| 449 | }; | 452 | }; |
| 450 | last_battery_value = Input::BatteryStatus::Charging; | 453 | last_battery_value = Common::Input::BatteryStatus::Charging; |
| 451 | callback_key = input_engine->SetCallback(input_identifier); | 454 | callback_key = input_engine->SetCallback(input_identifier); |
| 452 | } | 455 | } |
| 453 | 456 | ||
| @@ -455,13 +458,13 @@ public: | |||
| 455 | input_engine->DeleteCallback(callback_key); | 458 | input_engine->DeleteCallback(callback_key); |
| 456 | } | 459 | } |
| 457 | 460 | ||
| 458 | Input::BatteryStatus GetStatus() const { | 461 | Common::Input::BatteryStatus GetStatus() const { |
| 459 | return static_cast<Input::BatteryLevel>(input_engine->GetBattery(identifier)); | 462 | return static_cast<Common::Input::BatteryLevel>(input_engine->GetBattery(identifier)); |
| 460 | } | 463 | } |
| 461 | 464 | ||
| 462 | void ForceUpdate() { | 465 | void ForceUpdate() { |
| 463 | const Input::CallbackStatus status{ | 466 | const Common::Input::CallbackStatus status{ |
| 464 | .type = Input::InputType::Battery, | 467 | .type = Common::Input::InputType::Battery, |
| 465 | .battery_status = GetStatus(), | 468 | .battery_status = GetStatus(), |
| 466 | }; | 469 | }; |
| 467 | 470 | ||
| @@ -470,8 +473,8 @@ public: | |||
| 470 | } | 473 | } |
| 471 | 474 | ||
| 472 | void OnChange() { | 475 | void OnChange() { |
| 473 | const Input::CallbackStatus status{ | 476 | const Common::Input::CallbackStatus status{ |
| 474 | .type = Input::InputType::Battery, | 477 | .type = Common::Input::InputType::Battery, |
| 475 | .battery_status = GetStatus(), | 478 | .battery_status = GetStatus(), |
| 476 | }; | 479 | }; |
| 477 | 480 | ||
| @@ -484,11 +487,11 @@ public: | |||
| 484 | private: | 487 | private: |
| 485 | const PadIdentifier identifier; | 488 | const PadIdentifier identifier; |
| 486 | int callback_key; | 489 | int callback_key; |
| 487 | Input::BatteryStatus last_battery_value; | 490 | Common::Input::BatteryStatus last_battery_value; |
| 488 | InputEngine* input_engine; | 491 | InputEngine* input_engine; |
| 489 | }; | 492 | }; |
| 490 | 493 | ||
| 491 | class InputFromMotion final : public Input::InputDevice { | 494 | class InputFromMotion final : public Common::Input::InputDevice { |
| 492 | public: | 495 | public: |
| 493 | explicit InputFromMotion(PadIdentifier identifier_, u32 motion_sensor_, | 496 | explicit InputFromMotion(PadIdentifier identifier_, u32 motion_sensor_, |
| 494 | InputEngine* input_engine_) | 497 | InputEngine* input_engine_) |
| @@ -507,10 +510,10 @@ public: | |||
| 507 | input_engine->DeleteCallback(callback_key); | 510 | input_engine->DeleteCallback(callback_key); |
| 508 | } | 511 | } |
| 509 | 512 | ||
| 510 | Input::MotionStatus GetStatus() const { | 513 | Common::Input::MotionStatus GetStatus() const { |
| 511 | const auto basic_motion = input_engine->GetMotion(identifier, motion_sensor); | 514 | const auto basic_motion = input_engine->GetMotion(identifier, motion_sensor); |
| 512 | Input::MotionStatus status{}; | 515 | Common::Input::MotionStatus status{}; |
| 513 | const Input::AnalogProperties properties = { | 516 | const Common::Input::AnalogProperties properties = { |
| 514 | .deadzone = 0.001f, | 517 | .deadzone = 0.001f, |
| 515 | .range = 1.0f, | 518 | .range = 1.0f, |
| 516 | .offset = 0.0f, | 519 | .offset = 0.0f, |
| @@ -526,8 +529,8 @@ public: | |||
| 526 | } | 529 | } |
| 527 | 530 | ||
| 528 | void OnChange() { | 531 | void OnChange() { |
| 529 | const Input::CallbackStatus status{ | 532 | const Common::Input::CallbackStatus status{ |
| 530 | .type = Input::InputType::Motion, | 533 | .type = Common::Input::InputType::Motion, |
| 531 | .motion_status = GetStatus(), | 534 | .motion_status = GetStatus(), |
| 532 | }; | 535 | }; |
| 533 | 536 | ||
| @@ -541,12 +544,13 @@ private: | |||
| 541 | InputEngine* input_engine; | 544 | InputEngine* input_engine; |
| 542 | }; | 545 | }; |
| 543 | 546 | ||
| 544 | class InputFromAxisMotion final : public Input::InputDevice { | 547 | class InputFromAxisMotion final : public Common::Input::InputDevice { |
| 545 | public: | 548 | public: |
| 546 | explicit InputFromAxisMotion(PadIdentifier identifier_, u32 axis_x_, u32 axis_y_, u32 axis_z_, | 549 | explicit InputFromAxisMotion(PadIdentifier identifier_, u32 axis_x_, u32 axis_y_, u32 axis_z_, |
| 547 | Input::AnalogProperties properties_x_, | 550 | Common::Input::AnalogProperties properties_x_, |
| 548 | Input::AnalogProperties properties_y_, | 551 | Common::Input::AnalogProperties properties_y_, |
| 549 | Input::AnalogProperties properties_z_, InputEngine* input_engine_) | 552 | Common::Input::AnalogProperties properties_z_, |
| 553 | InputEngine* input_engine_) | ||
| 550 | : identifier(identifier_), axis_x(axis_x_), axis_y(axis_y_), axis_z(axis_z_), | 554 | : identifier(identifier_), axis_x(axis_x_), axis_y(axis_y_), axis_z(axis_z_), |
| 551 | properties_x(properties_x_), properties_y(properties_y_), properties_z(properties_z_), | 555 | properties_x(properties_x_), properties_y(properties_y_), properties_z(properties_z_), |
| 552 | input_engine(input_engine_) { | 556 | input_engine(input_engine_) { |
| @@ -583,8 +587,8 @@ public: | |||
| 583 | input_engine->DeleteCallback(callback_key_z); | 587 | input_engine->DeleteCallback(callback_key_z); |
| 584 | } | 588 | } |
| 585 | 589 | ||
| 586 | Input::MotionStatus GetStatus() const { | 590 | Common::Input::MotionStatus GetStatus() const { |
| 587 | Input::MotionStatus status{}; | 591 | Common::Input::MotionStatus status{}; |
| 588 | status.gyro.x = { | 592 | status.gyro.x = { |
| 589 | .raw_value = input_engine->GetAxis(identifier, axis_x), | 593 | .raw_value = input_engine->GetAxis(identifier, axis_x), |
| 590 | .properties = properties_x, | 594 | .properties = properties_x, |
| @@ -601,8 +605,8 @@ public: | |||
| 601 | } | 605 | } |
| 602 | 606 | ||
| 603 | void ForceUpdate() { | 607 | void ForceUpdate() { |
| 604 | const Input::CallbackStatus status{ | 608 | const Common::Input::CallbackStatus status{ |
| 605 | .type = Input::InputType::Motion, | 609 | .type = Common::Input::InputType::Motion, |
| 606 | .motion_status = GetStatus(), | 610 | .motion_status = GetStatus(), |
| 607 | }; | 611 | }; |
| 608 | 612 | ||
| @@ -613,8 +617,8 @@ public: | |||
| 613 | } | 617 | } |
| 614 | 618 | ||
| 615 | void OnChange() { | 619 | void OnChange() { |
| 616 | const Input::CallbackStatus status{ | 620 | const Common::Input::CallbackStatus status{ |
| 617 | .type = Input::InputType::Motion, | 621 | .type = Common::Input::InputType::Motion, |
| 618 | .motion_status = GetStatus(), | 622 | .motion_status = GetStatus(), |
| 619 | }; | 623 | }; |
| 620 | 624 | ||
| @@ -633,9 +637,9 @@ private: | |||
| 633 | const u32 axis_x; | 637 | const u32 axis_x; |
| 634 | const u32 axis_y; | 638 | const u32 axis_y; |
| 635 | const u32 axis_z; | 639 | const u32 axis_z; |
| 636 | const Input::AnalogProperties properties_x; | 640 | const Common::Input::AnalogProperties properties_x; |
| 637 | const Input::AnalogProperties properties_y; | 641 | const Common::Input::AnalogProperties properties_y; |
| 638 | const Input::AnalogProperties properties_z; | 642 | const Common::Input::AnalogProperties properties_z; |
| 639 | int callback_key_x; | 643 | int callback_key_x; |
| 640 | int callback_key_y; | 644 | int callback_key_y; |
| 641 | int callback_key_z; | 645 | int callback_key_z; |
| @@ -645,20 +649,21 @@ private: | |||
| 645 | InputEngine* input_engine; | 649 | InputEngine* input_engine; |
| 646 | }; | 650 | }; |
| 647 | 651 | ||
| 648 | class OutputFromIdentifier final : public Input::OutputDevice { | 652 | class OutputFromIdentifier final : public Common::Input::OutputDevice { |
| 649 | public: | 653 | public: |
| 650 | explicit OutputFromIdentifier(PadIdentifier identifier_, InputEngine* input_engine_) | 654 | explicit OutputFromIdentifier(PadIdentifier identifier_, InputEngine* input_engine_) |
| 651 | : identifier(identifier_), input_engine(input_engine_) {} | 655 | : identifier(identifier_), input_engine(input_engine_) {} |
| 652 | 656 | ||
| 653 | virtual void SetLED(Input::LedStatus led_status) { | 657 | virtual void SetLED(Common::Input::LedStatus led_status) { |
| 654 | input_engine->SetLeds(identifier, led_status); | 658 | input_engine->SetLeds(identifier, led_status); |
| 655 | } | 659 | } |
| 656 | 660 | ||
| 657 | virtual Input::VibrationError SetVibration(Input::VibrationStatus vibration_status) { | 661 | virtual Common::Input::VibrationError SetVibration( |
| 662 | Common::Input::VibrationStatus vibration_status) { | ||
| 658 | return input_engine->SetRumble(identifier, vibration_status); | 663 | return input_engine->SetRumble(identifier, vibration_status); |
| 659 | } | 664 | } |
| 660 | 665 | ||
| 661 | virtual Input::PollingError SetPollingMode(Input::PollingMode polling_mode) { | 666 | virtual Common::Input::PollingError SetPollingMode(Common::Input::PollingMode polling_mode) { |
| 662 | return input_engine->SetPollingMode(identifier, polling_mode); | 667 | return input_engine->SetPollingMode(identifier, polling_mode); |
| 663 | } | 668 | } |
| 664 | 669 | ||
| @@ -667,7 +672,7 @@ private: | |||
| 667 | InputEngine* input_engine; | 672 | InputEngine* input_engine; |
| 668 | }; | 673 | }; |
| 669 | 674 | ||
| 670 | std::unique_ptr<Input::InputDevice> InputFactory::CreateButtonDevice( | 675 | std::unique_ptr<Common::Input::InputDevice> InputFactory::CreateButtonDevice( |
| 671 | const Common::ParamPackage& params) { | 676 | const Common::ParamPackage& params) { |
| 672 | const PadIdentifier identifier = { | 677 | const PadIdentifier identifier = { |
| 673 | .guid = Common::UUID{params.Get("guid", "")}, | 678 | .guid = Common::UUID{params.Get("guid", "")}, |
| @@ -690,7 +695,7 @@ std::unique_ptr<Input::InputDevice> InputFactory::CreateButtonDevice( | |||
| 690 | input_engine.get()); | 695 | input_engine.get()); |
| 691 | } | 696 | } |
| 692 | 697 | ||
| 693 | std::unique_ptr<Input::InputDevice> InputFactory::CreateHatButtonDevice( | 698 | std::unique_ptr<Common::Input::InputDevice> InputFactory::CreateHatButtonDevice( |
| 694 | const Common::ParamPackage& params) { | 699 | const Common::ParamPackage& params) { |
| 695 | const PadIdentifier identifier = { | 700 | const PadIdentifier identifier = { |
| 696 | .guid = Common::UUID{params.Get("guid", "")}, | 701 | .guid = Common::UUID{params.Get("guid", "")}, |
| @@ -709,7 +714,7 @@ std::unique_ptr<Input::InputDevice> InputFactory::CreateHatButtonDevice( | |||
| 709 | input_engine.get()); | 714 | input_engine.get()); |
| 710 | } | 715 | } |
| 711 | 716 | ||
| 712 | std::unique_ptr<Input::InputDevice> InputFactory::CreateStickDevice( | 717 | std::unique_ptr<Common::Input::InputDevice> InputFactory::CreateStickDevice( |
| 713 | const Common::ParamPackage& params) { | 718 | const Common::ParamPackage& params) { |
| 714 | const auto deadzone = std::clamp(params.Get("deadzone", 0.15f), 0.0f, 1.0f); | 719 | const auto deadzone = std::clamp(params.Get("deadzone", 0.15f), 0.0f, 1.0f); |
| 715 | const auto range = std::clamp(params.Get("range", 1.0f), 0.25f, 1.50f); | 720 | const auto range = std::clamp(params.Get("range", 1.0f), 0.25f, 1.50f); |
| @@ -721,7 +726,7 @@ std::unique_ptr<Input::InputDevice> InputFactory::CreateStickDevice( | |||
| 721 | }; | 726 | }; |
| 722 | 727 | ||
| 723 | const auto axis_x = static_cast<u32>(params.Get("axis_x", 0)); | 728 | const auto axis_x = static_cast<u32>(params.Get("axis_x", 0)); |
| 724 | const Input::AnalogProperties properties_x = { | 729 | const Common::Input::AnalogProperties properties_x = { |
| 725 | .deadzone = deadzone, | 730 | .deadzone = deadzone, |
| 726 | .range = range, | 731 | .range = range, |
| 727 | .threshold = threshold, | 732 | .threshold = threshold, |
| @@ -730,7 +735,7 @@ std::unique_ptr<Input::InputDevice> InputFactory::CreateStickDevice( | |||
| 730 | }; | 735 | }; |
| 731 | 736 | ||
| 732 | const auto axis_y = static_cast<u32>(params.Get("axis_y", 1)); | 737 | const auto axis_y = static_cast<u32>(params.Get("axis_y", 1)); |
| 733 | const Input::AnalogProperties properties_y = { | 738 | const Common::Input::AnalogProperties properties_y = { |
| 734 | .deadzone = deadzone, | 739 | .deadzone = deadzone, |
| 735 | .range = range, | 740 | .range = range, |
| 736 | .threshold = threshold, | 741 | .threshold = threshold, |
| @@ -744,7 +749,7 @@ std::unique_ptr<Input::InputDevice> InputFactory::CreateStickDevice( | |||
| 744 | input_engine.get()); | 749 | input_engine.get()); |
| 745 | } | 750 | } |
| 746 | 751 | ||
| 747 | std::unique_ptr<Input::InputDevice> InputFactory::CreateAnalogDevice( | 752 | std::unique_ptr<Common::Input::InputDevice> InputFactory::CreateAnalogDevice( |
| 748 | const Common::ParamPackage& params) { | 753 | const Common::ParamPackage& params) { |
| 749 | const PadIdentifier identifier = { | 754 | const PadIdentifier identifier = { |
| 750 | .guid = Common::UUID{params.Get("guid", "")}, | 755 | .guid = Common::UUID{params.Get("guid", "")}, |
| @@ -753,7 +758,7 @@ std::unique_ptr<Input::InputDevice> InputFactory::CreateAnalogDevice( | |||
| 753 | }; | 758 | }; |
| 754 | 759 | ||
| 755 | const auto axis = static_cast<u32>(params.Get("axis", 0)); | 760 | const auto axis = static_cast<u32>(params.Get("axis", 0)); |
| 756 | const Input::AnalogProperties properties = { | 761 | const Common::Input::AnalogProperties properties = { |
| 757 | .deadzone = std::clamp(params.Get("deadzone", 0.0f), 0.0f, 1.0f), | 762 | .deadzone = std::clamp(params.Get("deadzone", 0.0f), 0.0f, 1.0f), |
| 758 | .range = std::clamp(params.Get("range", 1.0f), 0.25f, 1.50f), | 763 | .range = std::clamp(params.Get("range", 1.0f), 0.25f, 1.50f), |
| 759 | .threshold = std::clamp(params.Get("threshold", 0.5f), 0.0f, 1.0f), | 764 | .threshold = std::clamp(params.Get("threshold", 0.5f), 0.0f, 1.0f), |
| @@ -765,7 +770,7 @@ std::unique_ptr<Input::InputDevice> InputFactory::CreateAnalogDevice( | |||
| 765 | return std::make_unique<InputFromAnalog>(identifier, axis, properties, input_engine.get()); | 770 | return std::make_unique<InputFromAnalog>(identifier, axis, properties, input_engine.get()); |
| 766 | } | 771 | } |
| 767 | 772 | ||
| 768 | std::unique_ptr<Input::InputDevice> InputFactory::CreateTriggerDevice( | 773 | std::unique_ptr<Common::Input::InputDevice> InputFactory::CreateTriggerDevice( |
| 769 | const Common::ParamPackage& params) { | 774 | const Common::ParamPackage& params) { |
| 770 | const PadIdentifier identifier = { | 775 | const PadIdentifier identifier = { |
| 771 | .guid = Common::UUID{params.Get("guid", "")}, | 776 | .guid = Common::UUID{params.Get("guid", "")}, |
| @@ -778,7 +783,7 @@ std::unique_ptr<Input::InputDevice> InputFactory::CreateTriggerDevice( | |||
| 778 | const auto inverted = params.Get("inverted", false); | 783 | const auto inverted = params.Get("inverted", false); |
| 779 | 784 | ||
| 780 | const auto axis = static_cast<u32>(params.Get("axis", 0)); | 785 | const auto axis = static_cast<u32>(params.Get("axis", 0)); |
| 781 | const Input::AnalogProperties properties = { | 786 | const Common::Input::AnalogProperties properties = { |
| 782 | .deadzone = std::clamp(params.Get("deadzone", 0.0f), 0.0f, 1.0f), | 787 | .deadzone = std::clamp(params.Get("deadzone", 0.0f), 0.0f, 1.0f), |
| 783 | .range = std::clamp(params.Get("range", 1.0f), 0.25f, 2.50f), | 788 | .range = std::clamp(params.Get("range", 1.0f), 0.25f, 2.50f), |
| 784 | .threshold = std::clamp(params.Get("threshold", 0.5f), 0.0f, 1.0f), | 789 | .threshold = std::clamp(params.Get("threshold", 0.5f), 0.0f, 1.0f), |
| @@ -792,7 +797,7 @@ std::unique_ptr<Input::InputDevice> InputFactory::CreateTriggerDevice( | |||
| 792 | properties, input_engine.get()); | 797 | properties, input_engine.get()); |
| 793 | } | 798 | } |
| 794 | 799 | ||
| 795 | std::unique_ptr<Input::InputDevice> InputFactory::CreateTouchDevice( | 800 | std::unique_ptr<Common::Input::InputDevice> InputFactory::CreateTouchDevice( |
| 796 | const Common::ParamPackage& params) { | 801 | const Common::ParamPackage& params) { |
| 797 | const auto touch_id = params.Get("touch_id", 0); | 802 | const auto touch_id = params.Get("touch_id", 0); |
| 798 | const auto deadzone = std::clamp(params.Get("deadzone", 0.0f), 0.0f, 1.0f); | 803 | const auto deadzone = std::clamp(params.Get("deadzone", 0.0f), 0.0f, 1.0f); |
| @@ -809,7 +814,7 @@ std::unique_ptr<Input::InputDevice> InputFactory::CreateTouchDevice( | |||
| 809 | const auto inverted = params.Get("inverted", false); | 814 | const auto inverted = params.Get("inverted", false); |
| 810 | 815 | ||
| 811 | const auto axis_x = static_cast<u32>(params.Get("axis_x", 0)); | 816 | const auto axis_x = static_cast<u32>(params.Get("axis_x", 0)); |
| 812 | const Input::AnalogProperties properties_x = { | 817 | const Common::Input::AnalogProperties properties_x = { |
| 813 | .deadzone = deadzone, | 818 | .deadzone = deadzone, |
| 814 | .range = range, | 819 | .range = range, |
| 815 | .threshold = threshold, | 820 | .threshold = threshold, |
| @@ -818,7 +823,7 @@ std::unique_ptr<Input::InputDevice> InputFactory::CreateTouchDevice( | |||
| 818 | }; | 823 | }; |
| 819 | 824 | ||
| 820 | const auto axis_y = static_cast<u32>(params.Get("axis_y", 1)); | 825 | const auto axis_y = static_cast<u32>(params.Get("axis_y", 1)); |
| 821 | const Input::AnalogProperties properties_y = { | 826 | const Common::Input::AnalogProperties properties_y = { |
| 822 | .deadzone = deadzone, | 827 | .deadzone = deadzone, |
| 823 | .range = range, | 828 | .range = range, |
| 824 | .threshold = threshold, | 829 | .threshold = threshold, |
| @@ -833,7 +838,7 @@ std::unique_ptr<Input::InputDevice> InputFactory::CreateTouchDevice( | |||
| 833 | axis_y, properties_x, properties_y, input_engine.get()); | 838 | axis_y, properties_x, properties_y, input_engine.get()); |
| 834 | } | 839 | } |
| 835 | 840 | ||
| 836 | std::unique_ptr<Input::InputDevice> InputFactory::CreateBatteryDevice( | 841 | std::unique_ptr<Common::Input::InputDevice> InputFactory::CreateBatteryDevice( |
| 837 | const Common::ParamPackage& params) { | 842 | const Common::ParamPackage& params) { |
| 838 | const PadIdentifier identifier = { | 843 | const PadIdentifier identifier = { |
| 839 | .guid = Common::UUID{params.Get("guid", "")}, | 844 | .guid = Common::UUID{params.Get("guid", "")}, |
| @@ -845,7 +850,8 @@ std::unique_ptr<Input::InputDevice> InputFactory::CreateBatteryDevice( | |||
| 845 | return std::make_unique<InputFromBattery>(identifier, input_engine.get()); | 850 | return std::make_unique<InputFromBattery>(identifier, input_engine.get()); |
| 846 | } | 851 | } |
| 847 | 852 | ||
| 848 | std::unique_ptr<Input::InputDevice> InputFactory::CreateMotionDevice(Common::ParamPackage params) { | 853 | std::unique_ptr<Common::Input::InputDevice> InputFactory::CreateMotionDevice( |
| 854 | Common::ParamPackage params) { | ||
| 849 | const PadIdentifier identifier = { | 855 | const PadIdentifier identifier = { |
| 850 | .guid = Common::UUID{params.Get("guid", "")}, | 856 | .guid = Common::UUID{params.Get("guid", "")}, |
| 851 | .port = static_cast<std::size_t>(params.Get("port", 0)), | 857 | .port = static_cast<std::size_t>(params.Get("port", 0)), |
| @@ -864,7 +870,7 @@ std::unique_ptr<Input::InputDevice> InputFactory::CreateMotionDevice(Common::Par | |||
| 864 | const auto threshold = std::clamp(params.Get("threshold", 0.5f), 0.0f, 1.0f); | 870 | const auto threshold = std::clamp(params.Get("threshold", 0.5f), 0.0f, 1.0f); |
| 865 | 871 | ||
| 866 | const auto axis_x = static_cast<u32>(params.Get("axis_x", 0)); | 872 | const auto axis_x = static_cast<u32>(params.Get("axis_x", 0)); |
| 867 | const Input::AnalogProperties properties_x = { | 873 | const Common::Input::AnalogProperties properties_x = { |
| 868 | .deadzone = deadzone, | 874 | .deadzone = deadzone, |
| 869 | .range = range, | 875 | .range = range, |
| 870 | .threshold = threshold, | 876 | .threshold = threshold, |
| @@ -873,7 +879,7 @@ std::unique_ptr<Input::InputDevice> InputFactory::CreateMotionDevice(Common::Par | |||
| 873 | }; | 879 | }; |
| 874 | 880 | ||
| 875 | const auto axis_y = static_cast<u32>(params.Get("axis_y", 1)); | 881 | const auto axis_y = static_cast<u32>(params.Get("axis_y", 1)); |
| 876 | const Input::AnalogProperties properties_y = { | 882 | const Common::Input::AnalogProperties properties_y = { |
| 877 | .deadzone = deadzone, | 883 | .deadzone = deadzone, |
| 878 | .range = range, | 884 | .range = range, |
| 879 | .threshold = threshold, | 885 | .threshold = threshold, |
| @@ -882,7 +888,7 @@ std::unique_ptr<Input::InputDevice> InputFactory::CreateMotionDevice(Common::Par | |||
| 882 | }; | 888 | }; |
| 883 | 889 | ||
| 884 | const auto axis_z = static_cast<u32>(params.Get("axis_z", 1)); | 890 | const auto axis_z = static_cast<u32>(params.Get("axis_z", 1)); |
| 885 | const Input::AnalogProperties properties_z = { | 891 | const Common::Input::AnalogProperties properties_z = { |
| 886 | .deadzone = deadzone, | 892 | .deadzone = deadzone, |
| 887 | .range = range, | 893 | .range = range, |
| 888 | .threshold = threshold, | 894 | .threshold = threshold, |
| @@ -900,7 +906,8 @@ std::unique_ptr<Input::InputDevice> InputFactory::CreateMotionDevice(Common::Par | |||
| 900 | InputFactory::InputFactory(std::shared_ptr<InputEngine> input_engine_) | 906 | InputFactory::InputFactory(std::shared_ptr<InputEngine> input_engine_) |
| 901 | : input_engine(std::move(input_engine_)) {} | 907 | : input_engine(std::move(input_engine_)) {} |
| 902 | 908 | ||
| 903 | std::unique_ptr<Input::InputDevice> InputFactory::Create(const Common::ParamPackage& params) { | 909 | std::unique_ptr<Common::Input::InputDevice> InputFactory::Create( |
| 910 | const Common::ParamPackage& params) { | ||
| 904 | if (params.Has("battery")) { | 911 | if (params.Has("battery")) { |
| 905 | return CreateBatteryDevice(params); | 912 | return CreateBatteryDevice(params); |
| 906 | } | 913 | } |
| @@ -935,7 +942,8 @@ std::unique_ptr<Input::InputDevice> InputFactory::Create(const Common::ParamPack | |||
| 935 | OutputFactory::OutputFactory(std::shared_ptr<InputEngine> input_engine_) | 942 | OutputFactory::OutputFactory(std::shared_ptr<InputEngine> input_engine_) |
| 936 | : input_engine(std::move(input_engine_)) {} | 943 | : input_engine(std::move(input_engine_)) {} |
| 937 | 944 | ||
| 938 | std::unique_ptr<Input::OutputDevice> OutputFactory::Create(const Common::ParamPackage& params) { | 945 | std::unique_ptr<Common::Input::OutputDevice> OutputFactory::Create( |
| 946 | const Common::ParamPackage& params) { | ||
| 939 | const PadIdentifier identifier = { | 947 | const PadIdentifier identifier = { |
| 940 | .guid = Common::UUID{params.Get("guid", "")}, | 948 | .guid = Common::UUID{params.Get("guid", "")}, |
| 941 | .port = static_cast<std::size_t>(params.Get("port", 0)), | 949 | .port = static_cast<std::size_t>(params.Get("port", 0)), |
diff --git a/src/input_common/input_poller.h b/src/input_common/input_poller.h index 1357e104b..573f09fde 100644 --- a/src/input_common/input_poller.h +++ b/src/input_common/input_poller.h | |||
| @@ -17,7 +17,7 @@ class InputEngine; | |||
| 17 | * An Input factory. It receives input events and forward them to all input devices it created. | 17 | * An Input factory. It receives input events and forward them to all input devices it created. |
| 18 | */ | 18 | */ |
| 19 | 19 | ||
| 20 | class OutputFactory final : public Input::Factory<Input::OutputDevice> { | 20 | class OutputFactory final : public Common::Input::Factory<Common::Input::OutputDevice> { |
| 21 | public: | 21 | public: |
| 22 | explicit OutputFactory(std::shared_ptr<InputEngine> input_engine_); | 22 | explicit OutputFactory(std::shared_ptr<InputEngine> input_engine_); |
| 23 | 23 | ||
| @@ -29,13 +29,14 @@ public: | |||
| 29 | * @param - "pad": slot of the connected controller | 29 | * @param - "pad": slot of the connected controller |
| 30 | * @return an unique ouput device with the parameters specified | 30 | * @return an unique ouput device with the parameters specified |
| 31 | */ | 31 | */ |
| 32 | std::unique_ptr<Input::OutputDevice> Create(const Common::ParamPackage& params) override; | 32 | std::unique_ptr<Common::Input::OutputDevice> Create( |
| 33 | const Common::ParamPackage& params) override; | ||
| 33 | 34 | ||
| 34 | private: | 35 | private: |
| 35 | std::shared_ptr<InputEngine> input_engine; | 36 | std::shared_ptr<InputEngine> input_engine; |
| 36 | }; | 37 | }; |
| 37 | 38 | ||
| 38 | class InputFactory final : public Input::Factory<Input::InputDevice> { | 39 | class InputFactory final : public Common::Input::Factory<Common::Input::InputDevice> { |
| 39 | public: | 40 | public: |
| 40 | explicit InputFactory(std::shared_ptr<InputEngine> input_engine_); | 41 | explicit InputFactory(std::shared_ptr<InputEngine> input_engine_); |
| 41 | 42 | ||
| @@ -64,7 +65,7 @@ public: | |||
| 64 | * @param - "battery": Only used as a placeholder to set the input type | 65 | * @param - "battery": Only used as a placeholder to set the input type |
| 65 | * @return an unique input device with the parameters specified | 66 | * @return an unique input device with the parameters specified |
| 66 | */ | 67 | */ |
| 67 | std::unique_ptr<Input::InputDevice> Create(const Common::ParamPackage& params) override; | 68 | std::unique_ptr<Common::Input::InputDevice> Create(const Common::ParamPackage& params) override; |
| 68 | 69 | ||
| 69 | private: | 70 | private: |
| 70 | /** | 71 | /** |
| @@ -79,7 +80,8 @@ private: | |||
| 79 | * @param - "pad": slot of the connected controller | 80 | * @param - "pad": slot of the connected controller |
| 80 | * @return an unique input device with the parameters specified | 81 | * @return an unique input device with the parameters specified |
| 81 | */ | 82 | */ |
| 82 | std::unique_ptr<Input::InputDevice> CreateButtonDevice(const Common::ParamPackage& params); | 83 | std::unique_ptr<Common::Input::InputDevice> CreateButtonDevice( |
| 84 | const Common::ParamPackage& params); | ||
| 83 | 85 | ||
| 84 | /** | 86 | /** |
| 85 | * Creates a hat button device from the parameters given. | 87 | * Creates a hat button device from the parameters given. |
| @@ -93,7 +95,8 @@ private: | |||
| 93 | * @param - "pad": slot of the connected controller | 95 | * @param - "pad": slot of the connected controller |
| 94 | * @return an unique input device with the parameters specified | 96 | * @return an unique input device with the parameters specified |
| 95 | */ | 97 | */ |
| 96 | std::unique_ptr<Input::InputDevice> CreateHatButtonDevice(const Common::ParamPackage& params); | 98 | std::unique_ptr<Common::Input::InputDevice> CreateHatButtonDevice( |
| 99 | const Common::ParamPackage& params); | ||
| 97 | 100 | ||
| 98 | /** | 101 | /** |
| 99 | * Creates a stick device from the parameters given. | 102 | * Creates a stick device from the parameters given. |
| @@ -112,7 +115,8 @@ private: | |||
| 112 | * @param - "pad": slot of the connected controller | 115 | * @param - "pad": slot of the connected controller |
| 113 | * @return an unique input device with the parameters specified | 116 | * @return an unique input device with the parameters specified |
| 114 | */ | 117 | */ |
| 115 | std::unique_ptr<Input::InputDevice> CreateStickDevice(const Common::ParamPackage& params); | 118 | std::unique_ptr<Common::Input::InputDevice> CreateStickDevice( |
| 119 | const Common::ParamPackage& params); | ||
| 116 | 120 | ||
| 117 | /** | 121 | /** |
| 118 | * Creates an analog device from the parameters given. | 122 | * Creates an analog device from the parameters given. |
| @@ -128,7 +132,8 @@ private: | |||
| 128 | * @param - "pad": slot of the connected controller | 132 | * @param - "pad": slot of the connected controller |
| 129 | * @return an unique input device with the parameters specified | 133 | * @return an unique input device with the parameters specified |
| 130 | */ | 134 | */ |
| 131 | std::unique_ptr<Input::InputDevice> CreateAnalogDevice(const Common::ParamPackage& params); | 135 | std::unique_ptr<Common::Input::InputDevice> CreateAnalogDevice( |
| 136 | const Common::ParamPackage& params); | ||
| 132 | 137 | ||
| 133 | /** | 138 | /** |
| 134 | * Creates a trigger device from the parameters given. | 139 | * Creates a trigger device from the parameters given. |
| @@ -148,7 +153,8 @@ private: | |||
| 148 | * @param - "pad": slot of the connected controller | 153 | * @param - "pad": slot of the connected controller |
| 149 | * @return an unique input device with the parameters specified | 154 | * @return an unique input device with the parameters specified |
| 150 | */ | 155 | */ |
| 151 | std::unique_ptr<Input::InputDevice> CreateTriggerDevice(const Common::ParamPackage& params); | 156 | std::unique_ptr<Common::Input::InputDevice> CreateTriggerDevice( |
| 157 | const Common::ParamPackage& params); | ||
| 152 | 158 | ||
| 153 | /** | 159 | /** |
| 154 | * Creates a touch device from the parameters given. | 160 | * Creates a touch device from the parameters given. |
| @@ -171,7 +177,8 @@ private: | |||
| 171 | * @param - "pad": slot of the connected controller | 177 | * @param - "pad": slot of the connected controller |
| 172 | * @return an unique input device with the parameters specified | 178 | * @return an unique input device with the parameters specified |
| 173 | */ | 179 | */ |
| 174 | std::unique_ptr<Input::InputDevice> CreateTouchDevice(const Common::ParamPackage& params); | 180 | std::unique_ptr<Common::Input::InputDevice> CreateTouchDevice( |
| 181 | const Common::ParamPackage& params); | ||
| 175 | 182 | ||
| 176 | /** | 183 | /** |
| 177 | * Creates a battery device from the parameters given. | 184 | * Creates a battery device from the parameters given. |
| @@ -181,7 +188,8 @@ private: | |||
| 181 | * @param - "pad": slot of the connected controller | 188 | * @param - "pad": slot of the connected controller |
| 182 | * @return an unique input device with the parameters specified | 189 | * @return an unique input device with the parameters specified |
| 183 | */ | 190 | */ |
| 184 | std::unique_ptr<Input::InputDevice> CreateBatteryDevice(const Common::ParamPackage& params); | 191 | std::unique_ptr<Common::Input::InputDevice> CreateBatteryDevice( |
| 192 | const Common::ParamPackage& params); | ||
| 185 | 193 | ||
| 186 | /** | 194 | /** |
| 187 | * Creates a motion device from the parameters given. | 195 | * Creates a motion device from the parameters given. |
| @@ -202,7 +210,7 @@ private: | |||
| 202 | * @param - "pad": slot of the connected controller | 210 | * @param - "pad": slot of the connected controller |
| 203 | * @return an unique input device with the parameters specified | 211 | * @return an unique input device with the parameters specified |
| 204 | */ | 212 | */ |
| 205 | std::unique_ptr<Input::InputDevice> CreateMotionDevice(Common::ParamPackage params); | 213 | std::unique_ptr<Common::Input::InputDevice> CreateMotionDevice(Common::ParamPackage params); |
| 206 | 214 | ||
| 207 | std::shared_ptr<InputEngine> input_engine; | 215 | std::shared_ptr<InputEngine> input_engine; |
| 208 | }; | 216 | }; |
diff --git a/src/input_common/main.cpp b/src/input_common/main.cpp index 07d514ad7..df36a337c 100644 --- a/src/input_common/main.cpp +++ b/src/input_common/main.cpp | |||
| @@ -33,89 +33,97 @@ struct InputSubsystem::Impl { | |||
| 33 | keyboard->SetMappingCallback(mapping_callback); | 33 | keyboard->SetMappingCallback(mapping_callback); |
| 34 | keyboard_factory = std::make_shared<InputFactory>(keyboard); | 34 | keyboard_factory = std::make_shared<InputFactory>(keyboard); |
| 35 | keyboard_output_factory = std::make_shared<OutputFactory>(keyboard); | 35 | keyboard_output_factory = std::make_shared<OutputFactory>(keyboard); |
| 36 | Input::RegisterFactory<Input::InputDevice>(keyboard->GetEngineName(), keyboard_factory); | 36 | Common::Input::RegisterFactory<Common::Input::InputDevice>(keyboard->GetEngineName(), |
| 37 | Input::RegisterFactory<Input::OutputDevice>(keyboard->GetEngineName(), | 37 | keyboard_factory); |
| 38 | keyboard_output_factory); | 38 | Common::Input::RegisterFactory<Common::Input::OutputDevice>(keyboard->GetEngineName(), |
| 39 | keyboard_output_factory); | ||
| 39 | 40 | ||
| 40 | mouse = std::make_shared<Mouse>("mouse"); | 41 | mouse = std::make_shared<Mouse>("mouse"); |
| 41 | mouse->SetMappingCallback(mapping_callback); | 42 | mouse->SetMappingCallback(mapping_callback); |
| 42 | mouse_factory = std::make_shared<InputFactory>(mouse); | 43 | mouse_factory = std::make_shared<InputFactory>(mouse); |
| 43 | mouse_output_factory = std::make_shared<OutputFactory>(mouse); | 44 | mouse_output_factory = std::make_shared<OutputFactory>(mouse); |
| 44 | Input::RegisterFactory<Input::InputDevice>(mouse->GetEngineName(), mouse_factory); | 45 | Common::Input::RegisterFactory<Common::Input::InputDevice>(mouse->GetEngineName(), |
| 45 | Input::RegisterFactory<Input::OutputDevice>(mouse->GetEngineName(), mouse_output_factory); | 46 | mouse_factory); |
| 47 | Common::Input::RegisterFactory<Common::Input::OutputDevice>(mouse->GetEngineName(), | ||
| 48 | mouse_output_factory); | ||
| 46 | 49 | ||
| 47 | touch_screen = std::make_shared<TouchScreen>("touch"); | 50 | touch_screen = std::make_shared<TouchScreen>("touch"); |
| 48 | touch_screen_factory = std::make_shared<InputFactory>(touch_screen); | 51 | touch_screen_factory = std::make_shared<InputFactory>(touch_screen); |
| 49 | Input::RegisterFactory<Input::InputDevice>(touch_screen->GetEngineName(), | 52 | Common::Input::RegisterFactory<Common::Input::InputDevice>(touch_screen->GetEngineName(), |
| 50 | touch_screen_factory); | 53 | touch_screen_factory); |
| 51 | 54 | ||
| 52 | gcadapter = std::make_shared<GCAdapter>("gcpad"); | 55 | gcadapter = std::make_shared<GCAdapter>("gcpad"); |
| 53 | gcadapter->SetMappingCallback(mapping_callback); | 56 | gcadapter->SetMappingCallback(mapping_callback); |
| 54 | gcadapter_input_factory = std::make_shared<InputFactory>(gcadapter); | 57 | gcadapter_input_factory = std::make_shared<InputFactory>(gcadapter); |
| 55 | gcadapter_output_factory = std::make_shared<OutputFactory>(gcadapter); | 58 | gcadapter_output_factory = std::make_shared<OutputFactory>(gcadapter); |
| 56 | Input::RegisterFactory<Input::InputDevice>(gcadapter->GetEngineName(), | 59 | Common::Input::RegisterFactory<Common::Input::InputDevice>(gcadapter->GetEngineName(), |
| 57 | gcadapter_input_factory); | 60 | gcadapter_input_factory); |
| 58 | Input::RegisterFactory<Input::OutputDevice>(gcadapter->GetEngineName(), | 61 | Common::Input::RegisterFactory<Common::Input::OutputDevice>(gcadapter->GetEngineName(), |
| 59 | gcadapter_output_factory); | 62 | gcadapter_output_factory); |
| 60 | 63 | ||
| 61 | udp_client = std::make_shared<CemuhookUDP::UDPClient>("cemuhookudp"); | 64 | udp_client = std::make_shared<CemuhookUDP::UDPClient>("cemuhookudp"); |
| 62 | udp_client->SetMappingCallback(mapping_callback); | 65 | udp_client->SetMappingCallback(mapping_callback); |
| 63 | udp_client_factory = std::make_shared<InputFactory>(udp_client); | 66 | udp_client_factory = std::make_shared<InputFactory>(udp_client); |
| 64 | Input::RegisterFactory<Input::InputDevice>(udp_client->GetEngineName(), udp_client_factory); | 67 | Common::Input::RegisterFactory<Common::Input::InputDevice>(udp_client->GetEngineName(), |
| 68 | udp_client_factory); | ||
| 65 | 69 | ||
| 66 | tas_input = std::make_shared<TasInput::Tas>("tas"); | 70 | tas_input = std::make_shared<TasInput::Tas>("tas"); |
| 67 | tas_input->SetMappingCallback(mapping_callback); | 71 | tas_input->SetMappingCallback(mapping_callback); |
| 68 | tas_input_factory = std::make_shared<InputFactory>(tas_input); | 72 | tas_input_factory = std::make_shared<InputFactory>(tas_input); |
| 69 | tas_output_factory = std::make_shared<OutputFactory>(tas_input); | 73 | tas_output_factory = std::make_shared<OutputFactory>(tas_input); |
| 70 | Input::RegisterFactory<Input::InputDevice>(tas_input->GetEngineName(), tas_input_factory); | 74 | Common::Input::RegisterFactory<Common::Input::InputDevice>(tas_input->GetEngineName(), |
| 71 | Input::RegisterFactory<Input::OutputDevice>(tas_input->GetEngineName(), tas_output_factory); | 75 | tas_input_factory); |
| 76 | Common::Input::RegisterFactory<Common::Input::OutputDevice>(tas_input->GetEngineName(), | ||
| 77 | tas_output_factory); | ||
| 72 | 78 | ||
| 73 | #ifdef HAVE_SDL2 | 79 | #ifdef HAVE_SDL2 |
| 74 | sdl = std::make_shared<SDLDriver>("sdl"); | 80 | sdl = std::make_shared<SDLDriver>("sdl"); |
| 75 | sdl->SetMappingCallback(mapping_callback); | 81 | sdl->SetMappingCallback(mapping_callback); |
| 76 | sdl_input_factory = std::make_shared<InputFactory>(sdl); | 82 | sdl_input_factory = std::make_shared<InputFactory>(sdl); |
| 77 | sdl_output_factory = std::make_shared<OutputFactory>(sdl); | 83 | sdl_output_factory = std::make_shared<OutputFactory>(sdl); |
| 78 | Input::RegisterFactory<Input::InputDevice>(sdl->GetEngineName(), sdl_input_factory); | 84 | Common::Input::RegisterFactory<Common::Input::InputDevice>(sdl->GetEngineName(), |
| 79 | Input::RegisterFactory<Input::OutputDevice>(sdl->GetEngineName(), sdl_output_factory); | 85 | sdl_input_factory); |
| 86 | Common::Input::RegisterFactory<Common::Input::OutputDevice>(sdl->GetEngineName(), | ||
| 87 | sdl_output_factory); | ||
| 80 | #endif | 88 | #endif |
| 81 | 89 | ||
| 82 | Input::RegisterFactory<Input::InputDevice>("touch_from_button", | 90 | Common::Input::RegisterFactory<Common::Input::InputDevice>( |
| 83 | std::make_shared<TouchFromButton>()); | 91 | "touch_from_button", std::make_shared<TouchFromButton>()); |
| 84 | Input::RegisterFactory<Input::InputDevice>("analog_from_button", | 92 | Common::Input::RegisterFactory<Common::Input::InputDevice>( |
| 85 | std::make_shared<StickFromButton>()); | 93 | "analog_from_button", std::make_shared<StickFromButton>()); |
| 86 | } | 94 | } |
| 87 | 95 | ||
| 88 | void Shutdown() { | 96 | void Shutdown() { |
| 89 | Input::UnregisterFactory<Input::InputDevice>(keyboard->GetEngineName()); | 97 | Common::Input::UnregisterFactory<Common::Input::InputDevice>(keyboard->GetEngineName()); |
| 90 | Input::UnregisterFactory<Input::OutputDevice>(keyboard->GetEngineName()); | 98 | Common::Input::UnregisterFactory<Common::Input::OutputDevice>(keyboard->GetEngineName()); |
| 91 | keyboard.reset(); | 99 | keyboard.reset(); |
| 92 | 100 | ||
| 93 | Input::UnregisterFactory<Input::InputDevice>(mouse->GetEngineName()); | 101 | Common::Input::UnregisterFactory<Common::Input::InputDevice>(mouse->GetEngineName()); |
| 94 | Input::UnregisterFactory<Input::OutputDevice>(mouse->GetEngineName()); | 102 | Common::Input::UnregisterFactory<Common::Input::OutputDevice>(mouse->GetEngineName()); |
| 95 | mouse.reset(); | 103 | mouse.reset(); |
| 96 | 104 | ||
| 97 | Input::UnregisterFactory<Input::InputDevice>(touch_screen->GetEngineName()); | 105 | Common::Input::UnregisterFactory<Common::Input::InputDevice>(touch_screen->GetEngineName()); |
| 98 | touch_screen.reset(); | 106 | touch_screen.reset(); |
| 99 | 107 | ||
| 100 | Input::UnregisterFactory<Input::InputDevice>(gcadapter->GetEngineName()); | 108 | Common::Input::UnregisterFactory<Common::Input::InputDevice>(gcadapter->GetEngineName()); |
| 101 | Input::UnregisterFactory<Input::OutputDevice>(gcadapter->GetEngineName()); | 109 | Common::Input::UnregisterFactory<Common::Input::OutputDevice>(gcadapter->GetEngineName()); |
| 102 | gcadapter.reset(); | 110 | gcadapter.reset(); |
| 103 | 111 | ||
| 104 | Input::UnregisterFactory<Input::InputDevice>(udp_client->GetEngineName()); | 112 | Common::Input::UnregisterFactory<Common::Input::InputDevice>(udp_client->GetEngineName()); |
| 105 | udp_client.reset(); | 113 | udp_client.reset(); |
| 106 | 114 | ||
| 107 | Input::UnregisterFactory<Input::InputDevice>(tas_input->GetEngineName()); | 115 | Common::Input::UnregisterFactory<Common::Input::InputDevice>(tas_input->GetEngineName()); |
| 108 | Input::UnregisterFactory<Input::OutputDevice>(tas_input->GetEngineName()); | 116 | Common::Input::UnregisterFactory<Common::Input::OutputDevice>(tas_input->GetEngineName()); |
| 109 | tas_input.reset(); | 117 | tas_input.reset(); |
| 110 | 118 | ||
| 111 | #ifdef HAVE_SDL2 | 119 | #ifdef HAVE_SDL2 |
| 112 | Input::UnregisterFactory<Input::InputDevice>(sdl->GetEngineName()); | 120 | Common::Input::UnregisterFactory<Common::Input::InputDevice>(sdl->GetEngineName()); |
| 113 | Input::UnregisterFactory<Input::OutputDevice>(sdl->GetEngineName()); | 121 | Common::Input::UnregisterFactory<Common::Input::OutputDevice>(sdl->GetEngineName()); |
| 114 | sdl.reset(); | 122 | sdl.reset(); |
| 115 | #endif | 123 | #endif |
| 116 | 124 | ||
| 117 | Input::UnregisterFactory<Input::InputDevice>("touch_from_button"); | 125 | Common::Input::UnregisterFactory<Common::Input::InputDevice>("touch_from_button"); |
| 118 | Input::UnregisterFactory<Input::InputDevice>("analog_from_button"); | 126 | Common::Input::UnregisterFactory<Common::Input::InputDevice>("analog_from_button"); |
| 119 | } | 127 | } |
| 120 | 128 | ||
| 121 | [[nodiscard]] std::vector<Common::ParamPackage> GetInputDevices() const { | 129 | [[nodiscard]] std::vector<Common::ParamPackage> GetInputDevices() const { |