summaryrefslogtreecommitdiffstats
path: root/src/input_common/drivers
diff options
context:
space:
mode:
authorgerman77 <juangerman-13@hotmail.com>2021-10-21 06:18:04 +0200
committerNarr the Reg <juangerman-13@hotmail.com>2021-11-25 03:30:25 +0100
commit85052b8662d9512077780f717fb2e168390ed705 (patch)
tree0d966f3f0fdcb7dbe85fe6e2ca83cf25c492ae4c /src/input_common/drivers
parentconfiguration: Migrate controller settings to emulated controller (diff)
downloadyuzu-85052b8662d9512077780f717fb2e168390ed705.tar
yuzu-85052b8662d9512077780f717fb2e168390ed705.tar.gz
yuzu-85052b8662d9512077780f717fb2e168390ed705.tar.bz2
yuzu-85052b8662d9512077780f717fb2e168390ed705.tar.lz
yuzu-85052b8662d9512077780f717fb2e168390ed705.tar.xz
yuzu-85052b8662d9512077780f717fb2e168390ed705.tar.zst
yuzu-85052b8662d9512077780f717fb2e168390ed705.zip
Diffstat (limited to 'src/input_common/drivers')
-rw-r--r--src/input_common/drivers/gc_adapter.cpp4
-rw-r--r--src/input_common/drivers/udp_client.cpp27
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_
pads[port].axis_origin[index] = axis_value;
pads[port].reset_origin_counter++;
}
- const f32 axis_status = (axis_value - pads[port].axis_origin[index]) / 110.0f;
+ const f32 axis_status = (axis_value - pads[port].axis_origin[index]) / 100.0f;
SetAxis(pads[port].identifier, static_cast<int>(index), axis_status);
}
}
@@ -530,7 +530,7 @@ std::string GCAdapter::GetUIName(const Common::ParamPackage& params) const {
return fmt::format("Button {}", GetUIButtonName(params));
}
if (params.Has("axis")) {
- return fmt::format("Axis {}", params.Get("axis",0));
+ return fmt::format("Axis {}", params.Get("axis", 0));
}
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) {
};
const PadIdentifier identifier = GetPadIdentifier(pad_index);
SetMotion(identifier, 0, motion);
+
+ for (std::size_t id = 0; id < data.touch.size(); ++id) {
+ const auto touch_pad = data.touch[id];
+ const int touch_id = static_cast<int>(client * 2 + id);
+
+ // TODO: Use custom calibration per device
+ const Common::ParamPackage touch_param(Settings::values.touch_device.GetValue());
+ const u16 min_x = static_cast<u16>(touch_param.Get("min_x", 100));
+ const u16 min_y = static_cast<u16>(touch_param.Get("min_y", 50));
+ const u16 max_x = static_cast<u16>(touch_param.Get("max_x", 1800));
+ const u16 max_y = static_cast<u16>(touch_param.Get("max_y", 850));
+
+ const f32 x =
+ static_cast<f32>(std::clamp(static_cast<u16>(touch_pad.x), min_x, max_x) - min_x) /
+ static_cast<f32>(max_x - min_x);
+ const f32 y =
+ static_cast<f32>(std::clamp(static_cast<u16>(touch_pad.y), min_y, max_y) - min_y) /
+ static_cast<f32>(max_y - min_y);
+
+ if (touch_pad.is_active) {
+ SetAxis(identifier, touch_id * 2, x);
+ SetAxis(identifier, touch_id * 2 + 1, y);
+ SetButton(identifier, touch_id, true);
+ continue;
+ }
+ SetButton(identifier, touch_id, false);
+ }
}
void UDPClient::StartCommunication(std::size_t client, const std::string& host, u16 port) {