diff options
Diffstat (limited to 'src/input_common/drivers')
| -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 |
7 files changed, 23 insertions, 23 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 | }; |