diff options
| author | 2021-10-15 19:07:47 -0500 | |
|---|---|---|
| committer | 2021-11-24 20:30:24 -0600 | |
| commit | e0da5c1bbcdf85676f968b63c8ae2587f0464193 (patch) | |
| tree | 588837d1181d6b9d3bd4536fd4d2c5877335632d /src/input_common | |
| parent | core/hid: Add output devices (diff) | |
| download | yuzu-e0da5c1bbcdf85676f968b63c8ae2587f0464193.tar.gz yuzu-e0da5c1bbcdf85676f968b63c8ae2587f0464193.tar.xz yuzu-e0da5c1bbcdf85676f968b63c8ae2587f0464193.zip | |
kraken: Fix errors from rebase and format files
Diffstat (limited to 'src/input_common')
| -rw-r--r-- | src/input_common/drivers/gc_adapter.cpp | 3 | ||||
| -rw-r--r-- | src/input_common/drivers/gc_adapter.h | 2 | ||||
| -rw-r--r-- | src/input_common/drivers/sdl_driver.h | 2 | ||||
| -rw-r--r-- | src/input_common/helpers/stick_from_buttons.cpp | 3 | ||||
| -rw-r--r-- | src/input_common/helpers/stick_from_buttons.h | 3 | ||||
| -rw-r--r-- | src/input_common/helpers/touch_from_buttons.cpp | 4 | ||||
| -rw-r--r-- | src/input_common/input_engine.h | 10 | ||||
| -rw-r--r-- | src/input_common/input_poller.cpp | 8 | ||||
| -rw-r--r-- | src/input_common/input_poller.h | 10 | ||||
| -rw-r--r-- | src/input_common/main.cpp | 6 |
10 files changed, 24 insertions, 27 deletions
diff --git a/src/input_common/drivers/gc_adapter.cpp b/src/input_common/drivers/gc_adapter.cpp index 2aa5a16a6..4a56abb99 100644 --- a/src/input_common/drivers/gc_adapter.cpp +++ b/src/input_common/drivers/gc_adapter.cpp | |||
| @@ -322,7 +322,8 @@ bool GCAdapter::GetGCEndpoint(libusb_device* device) { | |||
| 322 | return true; | 322 | return true; |
| 323 | } | 323 | } |
| 324 | 324 | ||
| 325 | Input::VibrationError GCAdapter::SetRumble(const PadIdentifier& identifier, const Input::VibrationStatus vibration) { | 325 | Input::VibrationError GCAdapter::SetRumble(const PadIdentifier& identifier, |
| 326 | const Input::VibrationStatus vibration) { | ||
| 326 | const auto mean_amplitude = (vibration.low_amplitude + vibration.high_amplitude) * 0.5f; | 327 | const auto mean_amplitude = (vibration.low_amplitude + vibration.high_amplitude) * 0.5f; |
| 327 | const auto processed_amplitude = | 328 | const auto processed_amplitude = |
| 328 | static_cast<u8>((mean_amplitude + std::pow(mean_amplitude, 0.3f)) * 0.5f * 0x8); | 329 | static_cast<u8>((mean_amplitude + std::pow(mean_amplitude, 0.3f)) * 0.5f * 0x8); |
diff --git a/src/input_common/drivers/gc_adapter.h b/src/input_common/drivers/gc_adapter.h index dd23dd9f3..dd0e4aa1d 100644 --- a/src/input_common/drivers/gc_adapter.h +++ b/src/input_common/drivers/gc_adapter.h | |||
| @@ -25,7 +25,7 @@ public: | |||
| 25 | ~GCAdapter(); | 25 | ~GCAdapter(); |
| 26 | 26 | ||
| 27 | Input::VibrationError SetRumble(const PadIdentifier& identifier, | 27 | Input::VibrationError SetRumble(const PadIdentifier& identifier, |
| 28 | const Input::VibrationStatus vibration) override; | 28 | const Input::VibrationStatus vibration) override; |
| 29 | 29 | ||
| 30 | /// Used for automapping features | 30 | /// Used for automapping features |
| 31 | std::vector<Common::ParamPackage> GetInputDevices() const override; | 31 | std::vector<Common::ParamPackage> GetInputDevices() const override; |
diff --git a/src/input_common/drivers/sdl_driver.h b/src/input_common/drivers/sdl_driver.h index f66b33c77..1ff85f48d 100644 --- a/src/input_common/drivers/sdl_driver.h +++ b/src/input_common/drivers/sdl_driver.h | |||
| @@ -59,7 +59,7 @@ public: | |||
| 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 | Input::VibrationError SetRumble(const PadIdentifier& identifier, |
| 62 | const Input::VibrationStatus vibration) override; | 62 | const Input::VibrationStatus vibration) override; |
| 63 | 63 | ||
| 64 | private: | 64 | private: |
| 65 | void InitJoystick(int joystick_index); | 65 | void InitJoystick(int joystick_index); |
diff --git a/src/input_common/helpers/stick_from_buttons.cpp b/src/input_common/helpers/stick_from_buttons.cpp index 89ba4aeb1..38f150746 100644 --- a/src/input_common/helpers/stick_from_buttons.cpp +++ b/src/input_common/helpers/stick_from_buttons.cpp | |||
| @@ -251,8 +251,7 @@ private: | |||
| 251 | std::chrono::time_point<std::chrono::steady_clock> last_update; | 251 | std::chrono::time_point<std::chrono::steady_clock> last_update; |
| 252 | }; | 252 | }; |
| 253 | 253 | ||
| 254 | std::unique_ptr<Input::InputDevice> StickFromButton::Create( | 254 | std::unique_ptr<Input::InputDevice> StickFromButton::Create(const Common::ParamPackage& params) { |
| 255 | const Common::ParamPackage& params) { | ||
| 256 | const std::string null_engine = Common::ParamPackage{{"engine", "null"}}.Serialize(); | 255 | const std::string null_engine = Common::ParamPackage{{"engine", "null"}}.Serialize(); |
| 257 | auto up = Input::CreateDeviceFromString<Input::InputDevice>(params.Get("up", null_engine)); | 256 | auto up = Input::CreateDeviceFromString<Input::InputDevice>(params.Get("up", null_engine)); |
| 258 | auto down = Input::CreateDeviceFromString<Input::InputDevice>(params.Get("down", null_engine)); | 257 | auto down = Input::CreateDeviceFromString<Input::InputDevice>(params.Get("down", null_engine)); |
diff --git a/src/input_common/helpers/stick_from_buttons.h b/src/input_common/helpers/stick_from_buttons.h index 87165e022..1d6e24c98 100644 --- a/src/input_common/helpers/stick_from_buttons.h +++ b/src/input_common/helpers/stick_from_buttons.h | |||
| @@ -25,8 +25,7 @@ public: | |||
| 25 | * - "modifier": a serialized ParamPackage for creating a button device as the modifier | 25 | * - "modifier": a serialized ParamPackage for creating a button device as the modifier |
| 26 | * - "modifier_scale": a float for the multiplier the modifier gives to the position | 26 | * - "modifier_scale": a float for the multiplier the modifier gives to the position |
| 27 | */ | 27 | */ |
| 28 | std::unique_ptr<Input::InputDevice> Create( | 28 | std::unique_ptr<Input::InputDevice> Create(const Common::ParamPackage& params) override; |
| 29 | const Common::ParamPackage& params) override; | ||
| 30 | }; | 29 | }; |
| 31 | 30 | ||
| 32 | } // namespace InputCommon | 31 | } // namespace InputCommon |
diff --git a/src/input_common/helpers/touch_from_buttons.cpp b/src/input_common/helpers/touch_from_buttons.cpp index 6c9046ffb..2abfaf841 100644 --- a/src/input_common/helpers/touch_from_buttons.cpp +++ b/src/input_common/helpers/touch_from_buttons.cpp | |||
| @@ -57,9 +57,7 @@ private: | |||
| 57 | const Input::AnalogProperties properties{0.0f, 1.0f, 0.5f, 0.0f, false}; | 57 | const Input::AnalogProperties properties{0.0f, 1.0f, 0.5f, 0.0f, false}; |
| 58 | }; | 58 | }; |
| 59 | 59 | ||
| 60 | 60 | std::unique_ptr<Input::InputDevice> TouchFromButton::Create(const Common::ParamPackage& params) { | |
| 61 | std::unique_ptr<Input::InputDevice> TouchFromButton::Create( | ||
| 62 | const Common::ParamPackage& params) { | ||
| 63 | const std::string null_engine = Common::ParamPackage{{"engine", "null"}}.Serialize(); | 61 | const std::string null_engine = Common::ParamPackage{{"engine", "null"}}.Serialize(); |
| 64 | auto button = | 62 | auto button = |
| 65 | Input::CreateDeviceFromString<Input::InputDevice>(params.Get("button", null_engine)); | 63 | Input::CreateDeviceFromString<Input::InputDevice>(params.Get("button", null_engine)); |
diff --git a/src/input_common/input_engine.h b/src/input_common/input_engine.h index 8a953c382..31ce900d7 100644 --- a/src/input_common/input_engine.h +++ b/src/input_common/input_engine.h | |||
| @@ -121,14 +121,16 @@ public: | |||
| 121 | } | 121 | } |
| 122 | 122 | ||
| 123 | // Sets rumble to a controller | 123 | // Sets rumble to a controller |
| 124 | virtual Input::VibrationError SetRumble([[maybe_unused]] const PadIdentifier& identifier, | 124 | virtual Input::VibrationError SetRumble( |
| 125 | [[maybe_unused]] const Input::VibrationStatus vibration) { | 125 | [[maybe_unused]] const PadIdentifier& identifier, |
| 126 | [[maybe_unused]] const Input::VibrationStatus vibration) { | ||
| 126 | return Input::VibrationError::NotSupported; | 127 | return Input::VibrationError::NotSupported; |
| 127 | } | 128 | } |
| 128 | 129 | ||
| 129 | // Sets polling mode to a controller | 130 | // Sets polling mode to a controller |
| 130 | virtual Input::PollingError SetPollingMode([[maybe_unused]] const PadIdentifier& identifier, | 131 | virtual Input::PollingError SetPollingMode( |
| 131 | [[maybe_unused]] const Input::PollingMode vibration) { | 132 | [[maybe_unused]] const PadIdentifier& identifier, |
| 133 | [[maybe_unused]] const Input::PollingMode vibration) { | ||
| 132 | return Input::PollingError::NotSupported; | 134 | return Input::PollingError::NotSupported; |
| 133 | } | 135 | } |
| 134 | 136 | ||
diff --git a/src/input_common/input_poller.cpp b/src/input_common/input_poller.cpp index 781012886..62ade951c 100644 --- a/src/input_common/input_poller.cpp +++ b/src/input_common/input_poller.cpp | |||
| @@ -597,7 +597,7 @@ public: | |||
| 597 | explicit OutputFromIdentifier(PadIdentifier identifier_, InputEngine* input_engine_) | 597 | explicit OutputFromIdentifier(PadIdentifier identifier_, InputEngine* input_engine_) |
| 598 | : identifier(identifier_), input_engine(input_engine_) {} | 598 | : identifier(identifier_), input_engine(input_engine_) {} |
| 599 | 599 | ||
| 600 | virtual void SetLED( Input::LedStatus led_status) { | 600 | virtual void SetLED(Input::LedStatus led_status) { |
| 601 | input_engine->SetLeds(identifier, led_status); | 601 | input_engine->SetLeds(identifier, led_status); |
| 602 | } | 602 | } |
| 603 | 603 | ||
| @@ -847,8 +847,7 @@ std::unique_ptr<Input::InputDevice> InputFactory::CreateMotionDevice(Common::Par | |||
| 847 | InputFactory::InputFactory(std::shared_ptr<InputEngine> input_engine_) | 847 | InputFactory::InputFactory(std::shared_ptr<InputEngine> input_engine_) |
| 848 | : input_engine(std::move(input_engine_)) {} | 848 | : input_engine(std::move(input_engine_)) {} |
| 849 | 849 | ||
| 850 | std::unique_ptr<Input::InputDevice> InputFactory::Create( | 850 | std::unique_ptr<Input::InputDevice> InputFactory::Create(const Common::ParamPackage& params) { |
| 851 | const Common::ParamPackage& params) { | ||
| 852 | if (params.Has("button") && params.Has("axis")) { | 851 | if (params.Has("button") && params.Has("axis")) { |
| 853 | return CreateTriggerDevice(params); | 852 | return CreateTriggerDevice(params); |
| 854 | } | 853 | } |
| @@ -883,8 +882,7 @@ std::unique_ptr<Input::InputDevice> InputFactory::Create( | |||
| 883 | OutputFactory::OutputFactory(std::shared_ptr<InputEngine> input_engine_) | 882 | OutputFactory::OutputFactory(std::shared_ptr<InputEngine> input_engine_) |
| 884 | : input_engine(std::move(input_engine_)) {} | 883 | : input_engine(std::move(input_engine_)) {} |
| 885 | 884 | ||
| 886 | std::unique_ptr<Input::OutputDevice> OutputFactory::Create( | 885 | std::unique_ptr<Input::OutputDevice> OutputFactory::Create(const Common::ParamPackage& params) { |
| 887 | const Common::ParamPackage& params) { | ||
| 888 | const PadIdentifier identifier = { | 886 | const PadIdentifier identifier = { |
| 889 | .guid = Common::UUID{params.Get("guid", "")}, | 887 | .guid = Common::UUID{params.Get("guid", "")}, |
| 890 | .port = static_cast<std::size_t>(params.Get("port", 0)), | 888 | .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 16cade5fa..1357e104b 100644 --- a/src/input_common/input_poller.h +++ b/src/input_common/input_poller.h | |||
| @@ -29,8 +29,7 @@ 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( | 32 | std::unique_ptr<Input::OutputDevice> Create(const Common::ParamPackage& params) override; |
| 33 | const Common::ParamPackage& params) override; | ||
| 34 | 33 | ||
| 35 | private: | 34 | private: |
| 36 | std::shared_ptr<InputEngine> input_engine; | 35 | std::shared_ptr<InputEngine> input_engine; |
| @@ -41,8 +40,8 @@ public: | |||
| 41 | explicit InputFactory(std::shared_ptr<InputEngine> input_engine_); | 40 | explicit InputFactory(std::shared_ptr<InputEngine> input_engine_); |
| 42 | 41 | ||
| 43 | /** | 42 | /** |
| 44 | * Creates an input device from the parameters given. Identifies the type of input to be returned | 43 | * Creates an input device from the parameters given. Identifies the type of input to be |
| 45 | * if it contains the following parameters: | 44 | * returned if it contains the following parameters: |
| 46 | * - button: Contains "button" or "code" | 45 | * - button: Contains "button" or "code" |
| 47 | * - hat_button: Contains "hat" | 46 | * - hat_button: Contains "hat" |
| 48 | * - analog: Contains "axis" | 47 | * - analog: Contains "axis" |
| @@ -65,8 +64,7 @@ public: | |||
| 65 | * @param - "battery": Only used as a placeholder to set the input type | 64 | * @param - "battery": Only used as a placeholder to set the input type |
| 66 | * @return an unique input device with the parameters specified | 65 | * @return an unique input device with the parameters specified |
| 67 | */ | 66 | */ |
| 68 | std::unique_ptr<Input::InputDevice> Create( | 67 | std::unique_ptr<Input::InputDevice> Create(const Common::ParamPackage& params) override; |
| 69 | const Common::ParamPackage& params) override; | ||
| 70 | 68 | ||
| 71 | private: | 69 | private: |
| 72 | /** | 70 | /** |
diff --git a/src/input_common/main.cpp b/src/input_common/main.cpp index b7fe9cb37..7807dd38f 100644 --- a/src/input_common/main.cpp +++ b/src/input_common/main.cpp | |||
| @@ -48,8 +48,10 @@ struct InputSubsystem::Impl { | |||
| 48 | gcadapter->SetMappingCallback(mapping_callback); | 48 | gcadapter->SetMappingCallback(mapping_callback); |
| 49 | gcadapter_input_factory = std::make_shared<InputFactory>(gcadapter); | 49 | gcadapter_input_factory = std::make_shared<InputFactory>(gcadapter); |
| 50 | gcadapter_output_factory = std::make_shared<OutputFactory>(gcadapter); | 50 | gcadapter_output_factory = std::make_shared<OutputFactory>(gcadapter); |
| 51 | Input::RegisterFactory<Input::InputDevice>(gcadapter->GetEngineName(), gcadapter_input_factory); | 51 | Input::RegisterFactory<Input::InputDevice>(gcadapter->GetEngineName(), |
| 52 | Input::RegisterFactory<Input::OutputDevice>(gcadapter->GetEngineName(), gcadapter_output_factory); | 52 | gcadapter_input_factory); |
| 53 | Input::RegisterFactory<Input::OutputDevice>(gcadapter->GetEngineName(), | ||
| 54 | gcadapter_output_factory); | ||
| 53 | 55 | ||
| 54 | udp_client = std::make_shared<CemuhookUDP::UDPClient>("cemuhookudp"); | 56 | udp_client = std::make_shared<CemuhookUDP::UDPClient>("cemuhookudp"); |
| 55 | udp_client->SetMappingCallback(mapping_callback); | 57 | udp_client->SetMappingCallback(mapping_callback); |