diff options
Diffstat (limited to 'src/input_common')
| -rw-r--r-- | src/input_common/drivers/udp_client.cpp | 15 | ||||
| -rw-r--r-- | src/input_common/drivers/udp_client.h | 4 | ||||
| -rw-r--r-- | src/input_common/helpers/stick_from_buttons.cpp | 30 | ||||
| -rw-r--r-- | src/input_common/helpers/touch_from_buttons.cpp | 1 |
4 files changed, 42 insertions, 8 deletions
diff --git a/src/input_common/drivers/udp_client.cpp b/src/input_common/drivers/udp_client.cpp index d1cdb1ab2..333173e3d 100644 --- a/src/input_common/drivers/udp_client.cpp +++ b/src/input_common/drivers/udp_client.cpp | |||
| @@ -271,7 +271,7 @@ void UDPClient::OnPadData(Response::PadData data, std::size_t client) { | |||
| 271 | const auto touch_axis_y_id = | 271 | const auto touch_axis_y_id = |
| 272 | static_cast<int>(id == 0 ? PadAxes::Touch1Y : PadAxes::Touch2Y); | 272 | static_cast<int>(id == 0 ? PadAxes::Touch1Y : PadAxes::Touch2Y); |
| 273 | const auto touch_button_id = | 273 | const auto touch_button_id = |
| 274 | static_cast<int>(id == 0 ? PadButton::Touch1 : PadButton::touch2); | 274 | static_cast<int>(id == 0 ? PadButton::Touch1 : PadButton::Touch2); |
| 275 | 275 | ||
| 276 | // TODO: Use custom calibration per device | 276 | // TODO: Use custom calibration per device |
| 277 | const Common::ParamPackage touch_param(Settings::values.touch_device.GetValue()); | 277 | const Common::ParamPackage touch_param(Settings::values.touch_device.GetValue()); |
| @@ -319,6 +319,9 @@ void UDPClient::OnPadData(Response::PadData data, std::size_t client) { | |||
| 319 | SetButton(identifier, button, button_status); | 319 | SetButton(identifier, button, button_status); |
| 320 | } | 320 | } |
| 321 | 321 | ||
| 322 | SetButton(identifier, static_cast<int>(PadButton::Home), data.home != 0); | ||
| 323 | SetButton(identifier, static_cast<int>(PadButton::TouchHardPress), data.touch_hard_press != 0); | ||
| 324 | |||
| 322 | SetBattery(identifier, GetBatteryLevel(data.info.battery)); | 325 | SetBattery(identifier, GetBatteryLevel(data.info.battery)); |
| 323 | } | 326 | } |
| 324 | 327 | ||
| @@ -393,7 +396,7 @@ std::vector<Common::ParamPackage> UDPClient::GetInputDevices() const { | |||
| 393 | 396 | ||
| 394 | ButtonMapping UDPClient::GetButtonMappingForDevice(const Common::ParamPackage& params) { | 397 | ButtonMapping UDPClient::GetButtonMappingForDevice(const Common::ParamPackage& params) { |
| 395 | // This list excludes any button that can't be really mapped | 398 | // This list excludes any button that can't be really mapped |
| 396 | static constexpr std::array<std::pair<Settings::NativeButton::Values, PadButton>, 18> | 399 | static constexpr std::array<std::pair<Settings::NativeButton::Values, PadButton>, 20> |
| 397 | switch_to_dsu_button = { | 400 | switch_to_dsu_button = { |
| 398 | std::pair{Settings::NativeButton::A, PadButton::Circle}, | 401 | std::pair{Settings::NativeButton::A, PadButton::Circle}, |
| 399 | {Settings::NativeButton::B, PadButton::Cross}, | 402 | {Settings::NativeButton::B, PadButton::Cross}, |
| @@ -413,6 +416,8 @@ ButtonMapping UDPClient::GetButtonMappingForDevice(const Common::ParamPackage& p | |||
| 413 | {Settings::NativeButton::SR, PadButton::R2}, | 416 | {Settings::NativeButton::SR, PadButton::R2}, |
| 414 | {Settings::NativeButton::LStick, PadButton::L3}, | 417 | {Settings::NativeButton::LStick, PadButton::L3}, |
| 415 | {Settings::NativeButton::RStick, PadButton::R3}, | 418 | {Settings::NativeButton::RStick, PadButton::R3}, |
| 419 | {Settings::NativeButton::Home, PadButton::Home}, | ||
| 420 | {Settings::NativeButton::Screenshot, PadButton::TouchHardPress}, | ||
| 416 | }; | 421 | }; |
| 417 | if (!params.Has("guid") || !params.Has("port") || !params.Has("pad")) { | 422 | if (!params.Has("guid") || !params.Has("port") || !params.Has("pad")) { |
| 418 | return {}; | 423 | return {}; |
| @@ -517,6 +522,12 @@ Common::Input::ButtonNames UDPClient::GetUIButtonName(const Common::ParamPackage | |||
| 517 | return Common::Input::ButtonNames::Share; | 522 | return Common::Input::ButtonNames::Share; |
| 518 | case PadButton::Options: | 523 | case PadButton::Options: |
| 519 | return Common::Input::ButtonNames::Options; | 524 | return Common::Input::ButtonNames::Options; |
| 525 | case PadButton::Home: | ||
| 526 | return Common::Input::ButtonNames::Home; | ||
| 527 | case PadButton::Touch1: | ||
| 528 | case PadButton::Touch2: | ||
| 529 | case PadButton::TouchHardPress: | ||
| 530 | return Common::Input::ButtonNames::Touch; | ||
| 520 | default: | 531 | default: |
| 521 | return Common::Input::ButtonNames::Undefined; | 532 | return Common::Input::ButtonNames::Undefined; |
| 522 | } | 533 | } |
diff --git a/src/input_common/drivers/udp_client.h b/src/input_common/drivers/udp_client.h index 30d7c2682..e9c178139 100644 --- a/src/input_common/drivers/udp_client.h +++ b/src/input_common/drivers/udp_client.h | |||
| @@ -84,7 +84,9 @@ private: | |||
| 84 | Cross = 0x4000, | 84 | Cross = 0x4000, |
| 85 | Square = 0x8000, | 85 | Square = 0x8000, |
| 86 | Touch1 = 0x10000, | 86 | Touch1 = 0x10000, |
| 87 | touch2 = 0x20000, | 87 | Touch2 = 0x20000, |
| 88 | Home = 0x40000, | ||
| 89 | TouchHardPress = 0x80000, | ||
| 88 | }; | 90 | }; |
| 89 | 91 | ||
| 90 | enum class PadAxes : u8 { | 92 | enum class PadAxes : u8 { |
diff --git a/src/input_common/helpers/stick_from_buttons.cpp b/src/input_common/helpers/stick_from_buttons.cpp index e23394f5f..31e6f62ab 100644 --- a/src/input_common/helpers/stick_from_buttons.cpp +++ b/src/input_common/helpers/stick_from_buttons.cpp | |||
| @@ -167,12 +167,34 @@ public: | |||
| 167 | } | 167 | } |
| 168 | 168 | ||
| 169 | void UpdateModButtonStatus(const Common::Input::CallbackStatus& button_callback) { | 169 | void UpdateModButtonStatus(const Common::Input::CallbackStatus& button_callback) { |
| 170 | modifier_status = button_callback.button_status.value; | 170 | const auto& new_status = button_callback.button_status; |
| 171 | const bool new_button_value = new_status.inverted ? !new_status.value : new_status.value; | ||
| 172 | modifier_status.toggle = new_status.toggle; | ||
| 173 | |||
| 174 | // Update button status with current | ||
| 175 | if (!modifier_status.toggle) { | ||
| 176 | modifier_status.locked = false; | ||
| 177 | if (modifier_status.value != new_button_value) { | ||
| 178 | modifier_status.value = new_button_value; | ||
| 179 | } | ||
| 180 | } else { | ||
| 181 | // Toggle button and lock status | ||
| 182 | if (new_button_value && !modifier_status.locked) { | ||
| 183 | modifier_status.locked = true; | ||
| 184 | modifier_status.value = !modifier_status.value; | ||
| 185 | } | ||
| 186 | |||
| 187 | // Unlock button ready for next press | ||
| 188 | if (!new_button_value && modifier_status.locked) { | ||
| 189 | modifier_status.locked = false; | ||
| 190 | } | ||
| 191 | } | ||
| 192 | |||
| 171 | UpdateStatus(); | 193 | UpdateStatus(); |
| 172 | } | 194 | } |
| 173 | 195 | ||
| 174 | void UpdateStatus() { | 196 | void UpdateStatus() { |
| 175 | const float coef = modifier_status ? modifier_scale : 1.0f; | 197 | const float coef = modifier_status.value ? modifier_scale : 1.0f; |
| 176 | 198 | ||
| 177 | bool r = right_status; | 199 | bool r = right_status; |
| 178 | bool l = left_status; | 200 | bool l = left_status; |
| @@ -266,7 +288,7 @@ public: | |||
| 266 | if (down_status) { | 288 | if (down_status) { |
| 267 | --y; | 289 | --y; |
| 268 | } | 290 | } |
| 269 | const float coef = modifier_status ? modifier_scale : 1.0f; | 291 | const float coef = modifier_status.value ? modifier_scale : 1.0f; |
| 270 | status.x.raw_value = static_cast<float>(x) * coef * (y == 0 ? 1.0f : SQRT_HALF); | 292 | status.x.raw_value = static_cast<float>(x) * coef * (y == 0 ? 1.0f : SQRT_HALF); |
| 271 | status.y.raw_value = static_cast<float>(y) * coef * (x == 0 ? 1.0f : SQRT_HALF); | 293 | status.y.raw_value = static_cast<float>(y) * coef * (x == 0 ? 1.0f : SQRT_HALF); |
| 272 | return status; | 294 | return status; |
| @@ -287,9 +309,9 @@ private: | |||
| 287 | bool down_status{}; | 309 | bool down_status{}; |
| 288 | bool left_status{}; | 310 | bool left_status{}; |
| 289 | bool right_status{}; | 311 | bool right_status{}; |
| 290 | bool modifier_status{}; | ||
| 291 | float last_x_axis_value{}; | 312 | float last_x_axis_value{}; |
| 292 | float last_y_axis_value{}; | 313 | float last_y_axis_value{}; |
| 314 | Common::Input::ButtonStatus modifier_status{}; | ||
| 293 | const Common::Input::AnalogProperties properties{0.0f, 1.0f, 0.5f, 0.0f, false}; | 315 | const Common::Input::AnalogProperties properties{0.0f, 1.0f, 0.5f, 0.0f, false}; |
| 294 | std::chrono::time_point<std::chrono::steady_clock> last_update; | 316 | std::chrono::time_point<std::chrono::steady_clock> last_update; |
| 295 | }; | 317 | }; |
diff --git a/src/input_common/helpers/touch_from_buttons.cpp b/src/input_common/helpers/touch_from_buttons.cpp index ece1e3b32..f1b57d03a 100644 --- a/src/input_common/helpers/touch_from_buttons.cpp +++ b/src/input_common/helpers/touch_from_buttons.cpp | |||
| @@ -4,7 +4,6 @@ | |||
| 4 | 4 | ||
| 5 | #include <algorithm> | 5 | #include <algorithm> |
| 6 | #include "common/settings.h" | 6 | #include "common/settings.h" |
| 7 | #include "core/frontend/framebuffer_layout.h" | ||
| 8 | #include "input_common/helpers/touch_from_buttons.h" | 7 | #include "input_common/helpers/touch_from_buttons.h" |
| 9 | 8 | ||
| 10 | namespace InputCommon { | 9 | namespace InputCommon { |