diff options
Diffstat (limited to 'src/input_common/drivers')
| -rw-r--r-- | src/input_common/drivers/gc_adapter.cpp | 4 | ||||
| -rw-r--r-- | src/input_common/drivers/udp_client.cpp | 27 |
2 files changed, 29 insertions, 2 deletions
diff --git a/src/input_common/drivers/gc_adapter.cpp b/src/input_common/drivers/gc_adapter.cpp index 4fb6ab5af..25b66f528 100644 --- a/src/input_common/drivers/gc_adapter.cpp +++ b/src/input_common/drivers/gc_adapter.cpp | |||
| @@ -209,7 +209,7 @@ void GCAdapter::UpdateStateAxes(std::size_t port, const AdapterPayload& adapter_ | |||
| 209 | pads[port].axis_origin[index] = axis_value; | 209 | pads[port].axis_origin[index] = axis_value; |
| 210 | pads[port].reset_origin_counter++; | 210 | pads[port].reset_origin_counter++; |
| 211 | } | 211 | } |
| 212 | const f32 axis_status = (axis_value - pads[port].axis_origin[index]) / 110.0f; | 212 | const f32 axis_status = (axis_value - pads[port].axis_origin[index]) / 100.0f; |
| 213 | SetAxis(pads[port].identifier, static_cast<int>(index), axis_status); | 213 | SetAxis(pads[port].identifier, static_cast<int>(index), axis_status); |
| 214 | } | 214 | } |
| 215 | } | 215 | } |
| @@ -530,7 +530,7 @@ std::string GCAdapter::GetUIName(const Common::ParamPackage& params) const { | |||
| 530 | return fmt::format("Button {}", GetUIButtonName(params)); | 530 | return fmt::format("Button {}", GetUIButtonName(params)); |
| 531 | } | 531 | } |
| 532 | if (params.Has("axis")) { | 532 | if (params.Has("axis")) { |
| 533 | return fmt::format("Axis {}", params.Get("axis",0)); | 533 | return fmt::format("Axis {}", params.Get("axis", 0)); |
| 534 | } | 534 | } |
| 535 | 535 | ||
| 536 | return "Bad GC Adapter"; | 536 | return "Bad GC Adapter"; |
diff --git a/src/input_common/drivers/udp_client.cpp b/src/input_common/drivers/udp_client.cpp index 6fcc3a01b..f0c0a6b8b 100644 --- a/src/input_common/drivers/udp_client.cpp +++ b/src/input_common/drivers/udp_client.cpp | |||
| @@ -243,6 +243,33 @@ void UDPClient::OnPadData(Response::PadData data, std::size_t client) { | |||
| 243 | }; | 243 | }; |
| 244 | const PadIdentifier identifier = GetPadIdentifier(pad_index); | 244 | const PadIdentifier identifier = GetPadIdentifier(pad_index); |
| 245 | SetMotion(identifier, 0, motion); | 245 | SetMotion(identifier, 0, motion); |
| 246 | |||
| 247 | for (std::size_t id = 0; id < data.touch.size(); ++id) { | ||
| 248 | const auto touch_pad = data.touch[id]; | ||
| 249 | const int touch_id = static_cast<int>(client * 2 + id); | ||
| 250 | |||
| 251 | // TODO: Use custom calibration per device | ||
| 252 | const Common::ParamPackage touch_param(Settings::values.touch_device.GetValue()); | ||
| 253 | const u16 min_x = static_cast<u16>(touch_param.Get("min_x", 100)); | ||
| 254 | const u16 min_y = static_cast<u16>(touch_param.Get("min_y", 50)); | ||
| 255 | const u16 max_x = static_cast<u16>(touch_param.Get("max_x", 1800)); | ||
| 256 | const u16 max_y = static_cast<u16>(touch_param.Get("max_y", 850)); | ||
| 257 | |||
| 258 | const f32 x = | ||
| 259 | static_cast<f32>(std::clamp(static_cast<u16>(touch_pad.x), min_x, max_x) - min_x) / | ||
| 260 | static_cast<f32>(max_x - min_x); | ||
| 261 | const f32 y = | ||
| 262 | static_cast<f32>(std::clamp(static_cast<u16>(touch_pad.y), min_y, max_y) - min_y) / | ||
| 263 | static_cast<f32>(max_y - min_y); | ||
| 264 | |||
| 265 | if (touch_pad.is_active) { | ||
| 266 | SetAxis(identifier, touch_id * 2, x); | ||
| 267 | SetAxis(identifier, touch_id * 2 + 1, y); | ||
| 268 | SetButton(identifier, touch_id, true); | ||
| 269 | continue; | ||
| 270 | } | ||
| 271 | SetButton(identifier, touch_id, false); | ||
| 272 | } | ||
| 246 | } | 273 | } |
| 247 | 274 | ||
| 248 | void UDPClient::StartCommunication(std::size_t client, const std::string& host, u16 port) { | 275 | void UDPClient::StartCommunication(std::size_t client, const std::string& host, u16 port) { |