diff options
Diffstat (limited to 'src/input_common')
| -rw-r--r-- | src/input_common/helpers/touch_from_buttons.cpp | 9 | ||||
| -rw-r--r-- | src/input_common/input_poller.cpp | 18 |
2 files changed, 10 insertions, 17 deletions
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_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( |