summaryrefslogtreecommitdiffstats
path: root/src/input_common
diff options
context:
space:
mode:
authorgerman <german@thesoftwareartisans.com>2021-01-03 05:04:50 +0100
committergerman <german@thesoftwareartisans.com>2021-01-15 16:05:17 +0100
commit8495e1bd8373fed993975e40c360c87409455e9e (patch)
treefffff1304673212280dc0e927b69efa3ca4fc8b3 /src/input_common
parentAllow to return up to 16 touch inputs per engine (diff)
downloadyuzu-8495e1bd8373fed993975e40c360c87409455e9e.tar
yuzu-8495e1bd8373fed993975e40c360c87409455e9e.tar.gz
yuzu-8495e1bd8373fed993975e40c360c87409455e9e.tar.bz2
yuzu-8495e1bd8373fed993975e40c360c87409455e9e.tar.lz
yuzu-8495e1bd8373fed993975e40c360c87409455e9e.tar.xz
yuzu-8495e1bd8373fed993975e40c360c87409455e9e.tar.zst
yuzu-8495e1bd8373fed993975e40c360c87409455e9e.zip
Diffstat (limited to 'src/input_common')
-rw-r--r--src/input_common/touch_from_button.cpp4
-rw-r--r--src/input_common/udp/client.cpp19
-rw-r--r--src/input_common/udp/client.h8
3 files changed, 14 insertions, 17 deletions
diff --git a/src/input_common/touch_from_button.cpp b/src/input_common/touch_from_button.cpp
index 5226e70df..ffbe4f2ed 100644
--- a/src/input_common/touch_from_button.cpp
+++ b/src/input_common/touch_from_button.cpp
@@ -26,8 +26,8 @@ public:
}
Input::TouchStatus GetStatus() const override {
- Input::TouchStatus touch_status = {};
- for (size_t id = 0; id < map.size() && id < touch_status.size(); id++) {
+ Input::TouchStatus touch_status{};
+ for (std::size_t id = 0; id < map.size() && id < touch_status.size(); ++id) {
const bool state = std::get<0>(map[id])->GetStatus();
if (state) {
const float x = static_cast<float>(std::get<1>(map[id])) /
diff --git a/src/input_common/udp/client.cpp b/src/input_common/udp/client.cpp
index 53648cb53..5e39fdce2 100644
--- a/src/input_common/udp/client.cpp
+++ b/src/input_common/udp/client.cpp
@@ -136,8 +136,8 @@ static void SocketLoop(Socket* socket) {
Client::Client() {
LOG_INFO(Input, "Udp Initialization started");
- for (size_t id = 0; id < MAX_TOUCH_FINGERS; id++) {
- finger_id[id] = MAX_UDP_CLIENTS * 2;
+ for (std::size_t id = 0; id < MAX_TOUCH_FINGERS; ++id) {
+ finger_id[id] = MAX_TOUCH_FINGERS;
}
ReloadSockets();
}
@@ -262,7 +262,7 @@ void Client::OnPadData(Response::PadData data, std::size_t client) {
std::lock_guard guard(clients[client].status.update_mutex);
clients[client].status.motion_status = clients[client].motion.GetMotion();
- for (size_t id = 0; id < data.touch.size(); id++) {
+ for (std::size_t id = 0; id < data.touch.size(); ++id) {
UpdateTouchInput(data.touch[id], client, id);
}
@@ -314,7 +314,7 @@ void Client::UpdateYuzuSettings(std::size_t client, const Common::Vec3<float>& a
.port = clients[client].port,
.pad_index = clients[client].pad_index,
};
- for (size_t i = 0; i < 3; ++i) {
+ for (std::size_t i = 0; i < 3; ++i) {
if (gyro[i] > 5.0f || gyro[i] < -5.0f) {
pad.motion = static_cast<PadMotion>(i);
pad.motion_value = gyro[i];
@@ -328,8 +328,8 @@ void Client::UpdateYuzuSettings(std::size_t client, const Common::Vec3<float>& a
}
}
-std::optional<size_t> Client::GetUnusedFingerID() const {
- size_t first_free_id = 0;
+std::optional<std::size_t> Client::GetUnusedFingerID() const {
+ std::size_t first_free_id = 0;
while (first_free_id < MAX_TOUCH_FINGERS) {
if (!std::get<2>(touch_status[first_free_id])) {
return first_free_id;
@@ -340,7 +340,7 @@ std::optional<size_t> Client::GetUnusedFingerID() const {
return std::nullopt;
}
-void Client::UpdateTouchInput(Response::TouchPad& touch_pad, size_t client, size_t id) {
+void Client::UpdateTouchInput(Response::TouchPad& touch_pad, std::size_t client, std::size_t id) {
// TODO: Use custom calibration per device
const Common::ParamPackage touch_param(Settings::values.touch_device);
const u16 min_x = static_cast<u16>(touch_param.Get("min_x", 100));
@@ -367,10 +367,7 @@ void Client::UpdateTouchInput(Response::TouchPad& touch_pad, size_t client, size
}
if (finger_id[client * 2 + id] != MAX_TOUCH_FINGERS) {
- auto& [x, y, pressed] = touch_status[finger_id[client * 2 + id]];
- x = 0;
- y = 0;
- pressed = false;
+ touch_status[finger_id[client * 2 + id]] = {};
finger_id[client * 2 + id] = MAX_TOUCH_FINGERS;
}
}
diff --git a/src/input_common/udp/client.h b/src/input_common/udp/client.h
index 1cd251ec8..822f9c550 100644
--- a/src/input_common/udp/client.h
+++ b/src/input_common/udp/client.h
@@ -28,8 +28,8 @@ class Socket;
namespace Response {
struct PadData;
struct PortInfo;
-struct Version;
struct TouchPad;
+struct Version;
} // namespace Response
enum class PadMotion {
@@ -129,10 +129,10 @@ private:
// Returns an unused finger id, if there is no fingers available std::nullopt will be
// returned
- std::optional<size_t> GetUnusedFingerID() const;
+ std::optional<std::size_t> GetUnusedFingerID() const;
// Merges and updates all touch inputs into the touch_status array
- void UpdateTouchInput(Response::TouchPad& touch_pad, size_t client, size_t id);
+ void UpdateTouchInput(Response::TouchPad& touch_pad, std::size_t client, std::size_t id);
bool configuring = false;
@@ -143,7 +143,7 @@ private:
std::array<ClientData, MAX_UDP_CLIENTS> clients{};
Common::SPSCQueue<UDPPadStatus> pad_queue{};
Input::TouchStatus touch_status{};
- std::array<size_t, MAX_TOUCH_FINGERS> finger_id{};
+ std::array<std::size_t, MAX_TOUCH_FINGERS> finger_id{};
};
/// An async job allowing configuration of the touchpad calibration.