diff options
| author | 2021-10-20 23:18:04 -0500 | |
|---|---|---|
| committer | 2021-11-24 20:30:25 -0600 | |
| commit | 85052b8662d9512077780f717fb2e168390ed705 (patch) | |
| tree | 0d966f3f0fdcb7dbe85fe6e2ca83cf25c492ae4c /src/input_common/drivers/udp_client.cpp | |
| parent | configuration: Migrate controller settings to emulated controller (diff) | |
| download | yuzu-85052b8662d9512077780f717fb2e168390ed705.tar.gz yuzu-85052b8662d9512077780f717fb2e168390ed705.tar.xz yuzu-85052b8662d9512077780f717fb2e168390ed705.zip | |
service/hid: Fix gesture input
Diffstat (limited to 'src/input_common/drivers/udp_client.cpp')
| -rw-r--r-- | src/input_common/drivers/udp_client.cpp | 27 |
1 files changed, 27 insertions, 0 deletions
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) { |