summaryrefslogtreecommitdiff
path: root/src/input_common
diff options
context:
space:
mode:
Diffstat (limited to 'src/input_common')
-rw-r--r--src/input_common/udp/client.cpp17
-rw-r--r--src/input_common/udp/protocol.cpp1
-rw-r--r--src/input_common/udp/udp.cpp3
3 files changed, 15 insertions, 6 deletions
diff --git a/src/input_common/udp/client.cpp b/src/input_common/udp/client.cpp
index 2228571a6..da5227058 100644
--- a/src/input_common/udp/client.cpp
+++ b/src/input_common/udp/client.cpp
@@ -32,8 +32,16 @@ public:
32 SocketCallback callback) 32 SocketCallback callback)
33 : callback(std::move(callback)), timer(io_service), 33 : callback(std::move(callback)), timer(io_service),
34 socket(io_service, udp::endpoint(udp::v4(), 0)), client_id(client_id), 34 socket(io_service, udp::endpoint(udp::v4(), 0)), client_id(client_id),
35 pad_index(pad_index), 35 pad_index(pad_index) {
36 send_endpoint(udp::endpoint(boost::asio::ip::make_address_v4(host), port)) {} 36 boost::system::error_code ec{};
37 auto ipv4 = boost::asio::ip::make_address_v4(host, ec);
38 if (ec.value() != boost::system::errc::success) {
39 LOG_ERROR(Input, "Invalid IPv4 address \"{}\" provided to socket", host);
40 ipv4 = boost::asio::ip::address_v4{};
41 }
42
43 send_endpoint = {udp::endpoint(ipv4, port)};
44 }
37 45
38 void Stop() { 46 void Stop() {
39 io_service.stop(); 47 io_service.stop();
@@ -85,17 +93,18 @@ private:
85 } 93 }
86 94
87 void HandleSend(const boost::system::error_code& error) { 95 void HandleSend(const boost::system::error_code& error) {
96 boost::system::error_code _ignored{};
88 // Send a request for getting port info for the pad 97 // Send a request for getting port info for the pad
89 Request::PortInfo port_info{1, {pad_index, 0, 0, 0}}; 98 Request::PortInfo port_info{1, {pad_index, 0, 0, 0}};
90 const auto port_message = Request::Create(port_info, client_id); 99 const auto port_message = Request::Create(port_info, client_id);
91 std::memcpy(&send_buffer1, &port_message, PORT_INFO_SIZE); 100 std::memcpy(&send_buffer1, &port_message, PORT_INFO_SIZE);
92 socket.send_to(boost::asio::buffer(send_buffer1), send_endpoint); 101 socket.send_to(boost::asio::buffer(send_buffer1), send_endpoint, {}, _ignored);
93 102
94 // Send a request for getting pad data for the pad 103 // Send a request for getting pad data for the pad
95 Request::PadData pad_data{Request::PadData::Flags::Id, pad_index, EMPTY_MAC_ADDRESS}; 104 Request::PadData pad_data{Request::PadData::Flags::Id, pad_index, EMPTY_MAC_ADDRESS};
96 const auto pad_message = Request::Create(pad_data, client_id); 105 const auto pad_message = Request::Create(pad_data, client_id);
97 std::memcpy(send_buffer2.data(), &pad_message, PAD_DATA_SIZE); 106 std::memcpy(send_buffer2.data(), &pad_message, PAD_DATA_SIZE);
98 socket.send_to(boost::asio::buffer(send_buffer2), send_endpoint); 107 socket.send_to(boost::asio::buffer(send_buffer2), send_endpoint, {}, _ignored);
99 StartSend(timer.expiry()); 108 StartSend(timer.expiry());
100 } 109 }
101 110
diff --git a/src/input_common/udp/protocol.cpp b/src/input_common/udp/protocol.cpp
index a982ac49d..5e50bd612 100644
--- a/src/input_common/udp/protocol.cpp
+++ b/src/input_common/udp/protocol.cpp
@@ -31,7 +31,6 @@ namespace Response {
31 */ 31 */
32std::optional<Type> Validate(u8* data, std::size_t size) { 32std::optional<Type> Validate(u8* data, std::size_t size) {
33 if (size < sizeof(Header)) { 33 if (size < sizeof(Header)) {
34 LOG_DEBUG(Input, "Invalid UDP packet received");
35 return std::nullopt; 34 return std::nullopt;
36 } 35 }
37 Header header{}; 36 Header header{};
diff --git a/src/input_common/udp/udp.cpp b/src/input_common/udp/udp.cpp
index ca99cc22f..8c6ef1394 100644
--- a/src/input_common/udp/udp.cpp
+++ b/src/input_common/udp/udp.cpp
@@ -3,6 +3,7 @@
3// Refer to the license.txt file included. 3// Refer to the license.txt file included.
4 4
5#include <mutex> 5#include <mutex>
6#include <optional>
6#include <tuple> 7#include <tuple>
7 8
8#include "common/param_package.h" 9#include "common/param_package.h"
@@ -44,7 +45,7 @@ public:
44 std::unique_ptr<Input::TouchDevice> Create(const Common::ParamPackage& params) override { 45 std::unique_ptr<Input::TouchDevice> Create(const Common::ParamPackage& params) override {
45 { 46 {
46 std::lock_guard guard(status->update_mutex); 47 std::lock_guard guard(status->update_mutex);
47 status->touch_calibration.emplace(); 48 status->touch_calibration = DeviceStatus::CalibrationData{};
48 // These default values work well for DS4 but probably not other touch inputs 49 // These default values work well for DS4 but probably not other touch inputs
49 status->touch_calibration->min_x = params.Get("min_x", 100); 50 status->touch_calibration->min_x = params.Get("min_x", 100);
50 status->touch_calibration->min_y = params.Get("min_y", 50); 51 status->touch_calibration->min_y = params.Get("min_y", 50);