diff options
Diffstat (limited to '')
| -rw-r--r-- | src/input_common/drivers/virtual_amiibo.cpp | 15 | ||||
| -rw-r--r-- | src/input_common/drivers/virtual_amiibo.h | 3 | ||||
| -rw-r--r-- | src/input_common/helpers/touch_from_buttons.cpp | 9 | ||||
| -rw-r--r-- | src/input_common/input_engine.h | 2 | ||||
| -rw-r--r-- | src/input_common/input_poller.cpp | 18 |
5 files changed, 29 insertions, 18 deletions
diff --git a/src/input_common/drivers/virtual_amiibo.cpp b/src/input_common/drivers/virtual_amiibo.cpp index 0cd5129da..564a188e5 100644 --- a/src/input_common/drivers/virtual_amiibo.cpp +++ b/src/input_common/drivers/virtual_amiibo.cpp | |||
| @@ -60,6 +60,8 @@ Common::Input::NfcState VirtualAmiibo::WriteNfcData( | |||
| 60 | return Common::Input::NfcState::WriteFailed; | 60 | return Common::Input::NfcState::WriteFailed; |
| 61 | } | 61 | } |
| 62 | 62 | ||
| 63 | amiibo_data = data; | ||
| 64 | |||
| 63 | return Common::Input::NfcState::Success; | 65 | return Common::Input::NfcState::Success; |
| 64 | } | 66 | } |
| 65 | 67 | ||
| @@ -91,6 +93,15 @@ VirtualAmiibo::Info VirtualAmiibo::LoadAmiibo(const std::string& filename) { | |||
| 91 | return Info::Success; | 93 | return Info::Success; |
| 92 | } | 94 | } |
| 93 | 95 | ||
| 96 | VirtualAmiibo::Info VirtualAmiibo::ReloadAmiibo() { | ||
| 97 | if (state == State::AmiiboIsOpen) { | ||
| 98 | SetNfc(identifier, {Common::Input::NfcState::NewAmiibo, amiibo_data}); | ||
| 99 | return Info::Success; | ||
| 100 | } | ||
| 101 | |||
| 102 | return LoadAmiibo(file_path); | ||
| 103 | } | ||
| 104 | |||
| 94 | VirtualAmiibo::Info VirtualAmiibo::CloseAmiibo() { | 105 | VirtualAmiibo::Info VirtualAmiibo::CloseAmiibo() { |
| 95 | state = polling_mode == Common::Input::PollingMode::NFC ? State::WaitingForAmiibo | 106 | state = polling_mode == Common::Input::PollingMode::NFC ? State::WaitingForAmiibo |
| 96 | : State::Initialized; | 107 | : State::Initialized; |
| @@ -98,4 +109,8 @@ VirtualAmiibo::Info VirtualAmiibo::CloseAmiibo() { | |||
| 98 | return Info::Success; | 109 | return Info::Success; |
| 99 | } | 110 | } |
| 100 | 111 | ||
| 112 | std::string VirtualAmiibo::GetLastFilePath() const { | ||
| 113 | return file_path; | ||
| 114 | } | ||
| 115 | |||
| 101 | } // namespace InputCommon | 116 | } // namespace InputCommon |
diff --git a/src/input_common/drivers/virtual_amiibo.h b/src/input_common/drivers/virtual_amiibo.h index 9eac07544..9baeb3997 100644 --- a/src/input_common/drivers/virtual_amiibo.h +++ b/src/input_common/drivers/virtual_amiibo.h | |||
| @@ -47,8 +47,11 @@ public: | |||
| 47 | State GetCurrentState() const; | 47 | State GetCurrentState() const; |
| 48 | 48 | ||
| 49 | Info LoadAmiibo(const std::string& amiibo_file); | 49 | Info LoadAmiibo(const std::string& amiibo_file); |
| 50 | Info ReloadAmiibo(); | ||
| 50 | Info CloseAmiibo(); | 51 | Info CloseAmiibo(); |
| 51 | 52 | ||
| 53 | std::string GetLastFilePath() const; | ||
| 54 | |||
| 52 | private: | 55 | private: |
| 53 | static constexpr std::size_t amiibo_size = 0x21C; | 56 | static constexpr std::size_t amiibo_size = 0x21C; |
| 54 | static constexpr std::size_t amiibo_size_without_password = amiibo_size - 0x8; | 57 | static constexpr std::size_t amiibo_size_without_password = amiibo_size - 0x8; |
diff --git a/src/input_common/helpers/touch_from_buttons.cpp b/src/input_common/helpers/touch_from_buttons.cpp index da4a3dca5..003a38da5 100644 --- a/src/input_common/helpers/touch_from_buttons.cpp +++ b/src/input_common/helpers/touch_from_buttons.cpp | |||
| @@ -10,8 +10,8 @@ namespace InputCommon { | |||
| 10 | class TouchFromButtonDevice final : public Common::Input::InputDevice { | 10 | class TouchFromButtonDevice final : public Common::Input::InputDevice { |
| 11 | public: | 11 | public: |
| 12 | using Button = std::unique_ptr<Common::Input::InputDevice>; | 12 | using Button = std::unique_ptr<Common::Input::InputDevice>; |
| 13 | TouchFromButtonDevice(Button button_, int touch_id_, float x_, float y_) | 13 | TouchFromButtonDevice(Button button_, float x_, float y_) |
| 14 | : button(std::move(button_)), touch_id(touch_id_), x(x_), y(y_) { | 14 | : button(std::move(button_)), x(x_), y(y_) { |
| 15 | last_button_value = false; | 15 | last_button_value = false; |
| 16 | button->SetCallback({ | 16 | button->SetCallback({ |
| 17 | .on_change = | 17 | .on_change = |
| @@ -34,7 +34,6 @@ public: | |||
| 34 | .pressed = button_status, | 34 | .pressed = button_status, |
| 35 | .x = {}, | 35 | .x = {}, |
| 36 | .y = {}, | 36 | .y = {}, |
| 37 | .id = touch_id, | ||
| 38 | }; | 37 | }; |
| 39 | status.x.properties = properties; | 38 | status.x.properties = properties; |
| 40 | status.y.properties = properties; | 39 | status.y.properties = properties; |
| @@ -62,7 +61,6 @@ public: | |||
| 62 | private: | 61 | private: |
| 63 | Button button; | 62 | Button button; |
| 64 | bool last_button_value; | 63 | bool last_button_value; |
| 65 | const int touch_id; | ||
| 66 | const float x; | 64 | const float x; |
| 67 | const float y; | 65 | const float y; |
| 68 | const Common::Input::AnalogProperties properties{0.0f, 1.0f, 0.5f, 0.0f, false}; | 66 | const Common::Input::AnalogProperties properties{0.0f, 1.0f, 0.5f, 0.0f, false}; |
| @@ -73,10 +71,9 @@ std::unique_ptr<Common::Input::InputDevice> TouchFromButton::Create( | |||
| 73 | const std::string null_engine = Common::ParamPackage{{"engine", "null"}}.Serialize(); | 71 | const std::string null_engine = Common::ParamPackage{{"engine", "null"}}.Serialize(); |
| 74 | auto button = Common::Input::CreateDeviceFromString<Common::Input::InputDevice>( | 72 | auto button = Common::Input::CreateDeviceFromString<Common::Input::InputDevice>( |
| 75 | params.Get("button", null_engine)); | 73 | params.Get("button", null_engine)); |
| 76 | const auto touch_id = params.Get("touch_id", 0); | ||
| 77 | const float x = params.Get("x", 0.0f) / 1280.0f; | 74 | const float x = params.Get("x", 0.0f) / 1280.0f; |
| 78 | const float y = params.Get("y", 0.0f) / 720.0f; | 75 | const float y = params.Get("y", 0.0f) / 720.0f; |
| 79 | return std::make_unique<TouchFromButtonDevice>(std::move(button), touch_id, x, y); | 76 | return std::make_unique<TouchFromButtonDevice>(std::move(button), x, y); |
| 80 | } | 77 | } |
| 81 | 78 | ||
| 82 | } // namespace InputCommon | 79 | } // namespace InputCommon |
diff --git a/src/input_common/input_engine.h b/src/input_common/input_engine.h index d4c264a8e..6cbcf5207 100644 --- a/src/input_common/input_engine.h +++ b/src/input_common/input_engine.h | |||
| @@ -133,7 +133,7 @@ public: | |||
| 133 | return Common::Input::CameraError::NotSupported; | 133 | return Common::Input::CameraError::NotSupported; |
| 134 | } | 134 | } |
| 135 | 135 | ||
| 136 | // Request nfc data from a controller | 136 | // Returns success if nfc is supported |
| 137 | virtual Common::Input::NfcState SupportsNfc( | 137 | virtual Common::Input::NfcState SupportsNfc( |
| 138 | [[maybe_unused]] const PadIdentifier& identifier) const { | 138 | [[maybe_unused]] const PadIdentifier& identifier) const { |
| 139 | return Common::Input::NfcState::NotSupported; | 139 | return Common::Input::NfcState::NotSupported; |
diff --git a/src/input_common/input_poller.cpp b/src/input_common/input_poller.cpp index 4ac182147..fb8be42e2 100644 --- a/src/input_common/input_poller.cpp +++ b/src/input_common/input_poller.cpp | |||
| @@ -229,13 +229,12 @@ private: | |||
| 229 | 229 | ||
| 230 | class InputFromTouch final : public Common::Input::InputDevice { | 230 | class InputFromTouch final : public Common::Input::InputDevice { |
| 231 | public: | 231 | public: |
| 232 | explicit InputFromTouch(PadIdentifier identifier_, int touch_id_, int button_, bool toggle_, | 232 | explicit InputFromTouch(PadIdentifier identifier_, int button_, bool toggle_, bool inverted_, |
| 233 | bool inverted_, int axis_x_, int axis_y_, | 233 | int axis_x_, int axis_y_, Common::Input::AnalogProperties properties_x_, |
| 234 | Common::Input::AnalogProperties properties_x_, | ||
| 235 | Common::Input::AnalogProperties properties_y_, | 234 | Common::Input::AnalogProperties properties_y_, |
| 236 | InputEngine* input_engine_) | 235 | InputEngine* input_engine_) |
| 237 | : identifier(identifier_), touch_id(touch_id_), button(button_), toggle(toggle_), | 236 | : identifier(identifier_), button(button_), toggle(toggle_), inverted(inverted_), |
| 238 | inverted(inverted_), axis_x(axis_x_), axis_y(axis_y_), properties_x(properties_x_), | 237 | axis_x(axis_x_), axis_y(axis_y_), properties_x(properties_x_), |
| 239 | properties_y(properties_y_), input_engine(input_engine_) { | 238 | properties_y(properties_y_), input_engine(input_engine_) { |
| 240 | UpdateCallback engine_callback{[this]() { OnChange(); }}; | 239 | UpdateCallback engine_callback{[this]() { OnChange(); }}; |
| 241 | const InputIdentifier button_input_identifier{ | 240 | const InputIdentifier button_input_identifier{ |
| @@ -271,8 +270,7 @@ public: | |||
| 271 | } | 270 | } |
| 272 | 271 | ||
| 273 | Common::Input::TouchStatus GetStatus() const { | 272 | Common::Input::TouchStatus GetStatus() const { |
| 274 | Common::Input::TouchStatus status; | 273 | Common::Input::TouchStatus status{}; |
| 275 | status.id = touch_id; | ||
| 276 | status.pressed = { | 274 | status.pressed = { |
| 277 | .value = input_engine->GetButton(identifier, button), | 275 | .value = input_engine->GetButton(identifier, button), |
| 278 | .inverted = inverted, | 276 | .inverted = inverted, |
| @@ -307,7 +305,6 @@ public: | |||
| 307 | 305 | ||
| 308 | private: | 306 | private: |
| 309 | const PadIdentifier identifier; | 307 | const PadIdentifier identifier; |
| 310 | const int touch_id; | ||
| 311 | const int button; | 308 | const int button; |
| 312 | const bool toggle; | 309 | const bool toggle; |
| 313 | const bool inverted; | 310 | const bool inverted; |
| @@ -919,7 +916,6 @@ std::unique_ptr<Common::Input::InputDevice> InputFactory::CreateTriggerDevice( | |||
| 919 | 916 | ||
| 920 | std::unique_ptr<Common::Input::InputDevice> InputFactory::CreateTouchDevice( | 917 | std::unique_ptr<Common::Input::InputDevice> InputFactory::CreateTouchDevice( |
| 921 | const Common::ParamPackage& params) { | 918 | const Common::ParamPackage& params) { |
| 922 | const auto touch_id = params.Get("touch_id", 0); | ||
| 923 | const auto deadzone = std::clamp(params.Get("deadzone", 0.0f), 0.0f, 1.0f); | 919 | const auto deadzone = std::clamp(params.Get("deadzone", 0.0f), 0.0f, 1.0f); |
| 924 | const auto range = std::clamp(params.Get("range", 1.0f), 0.25f, 1.50f); | 920 | const auto range = std::clamp(params.Get("range", 1.0f), 0.25f, 1.50f); |
| 925 | const auto threshold = std::clamp(params.Get("threshold", 0.5f), 0.0f, 1.0f); | 921 | const auto threshold = std::clamp(params.Get("threshold", 0.5f), 0.0f, 1.0f); |
| @@ -954,8 +950,8 @@ std::unique_ptr<Common::Input::InputDevice> InputFactory::CreateTouchDevice( | |||
| 954 | input_engine->PreSetAxis(identifier, axis_x); | 950 | input_engine->PreSetAxis(identifier, axis_x); |
| 955 | input_engine->PreSetAxis(identifier, axis_y); | 951 | input_engine->PreSetAxis(identifier, axis_y); |
| 956 | input_engine->PreSetButton(identifier, button); | 952 | input_engine->PreSetButton(identifier, button); |
| 957 | return std::make_unique<InputFromTouch>(identifier, touch_id, button, toggle, inverted, axis_x, | 953 | return std::make_unique<InputFromTouch>(identifier, button, toggle, inverted, axis_x, axis_y, |
| 958 | axis_y, properties_x, properties_y, input_engine.get()); | 954 | properties_x, properties_y, input_engine.get()); |
| 959 | } | 955 | } |
| 960 | 956 | ||
| 961 | std::unique_ptr<Common::Input::InputDevice> InputFactory::CreateBatteryDevice( | 957 | std::unique_ptr<Common::Input::InputDevice> InputFactory::CreateBatteryDevice( |