diff options
author | bunnei <bunneidev@gmail.com> | 2020-02-03 17:41:04 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-02-03 17:41:04 +0100 |
commit | 2cd51fc9fd11cce6aeea44dc0158f6bfde5456ec (patch) | |
tree | dfd9cc0b10283da66259842b584e920697d6196b | |
parent | Merge pull request #3370 from ReinUsesLisp/node-shared-ptr (diff) | |
parent | input_common/udp: Ensure that UDP is shut down within Shutdown() (diff) | |
download | yuzu-2cd51fc9fd11cce6aeea44dc0158f6bfde5456ec.tar yuzu-2cd51fc9fd11cce6aeea44dc0158f6bfde5456ec.tar.gz yuzu-2cd51fc9fd11cce6aeea44dc0158f6bfde5456ec.tar.bz2 yuzu-2cd51fc9fd11cce6aeea44dc0158f6bfde5456ec.tar.lz yuzu-2cd51fc9fd11cce6aeea44dc0158f6bfde5456ec.tar.xz yuzu-2cd51fc9fd11cce6aeea44dc0158f6bfde5456ec.tar.zst yuzu-2cd51fc9fd11cce6aeea44dc0158f6bfde5456ec.zip |
-rw-r--r-- | src/input_common/main.cpp | 1 | ||||
-rw-r--r-- | src/input_common/udp/client.cpp | 15 | ||||
-rw-r--r-- | src/input_common/udp/client.h | 1 | ||||
-rw-r--r-- | src/input_common/udp/protocol.h | 1 | ||||
-rw-r--r-- | src/input_common/udp/udp.cpp | 8 | ||||
-rw-r--r-- | src/input_common/udp/udp.h | 8 |
6 files changed, 16 insertions, 18 deletions
diff --git a/src/input_common/main.cpp b/src/input_common/main.cpp index 9e028da89..c98c848cf 100644 --- a/src/input_common/main.cpp +++ b/src/input_common/main.cpp @@ -41,6 +41,7 @@ void Shutdown() { Input::UnregisterFactory<Input::MotionDevice>("motion_emu"); motion_emu.reset(); sdl.reset(); + udp.reset(); } Keyboard* GetKeyboard() { diff --git a/src/input_common/udp/client.cpp b/src/input_common/udp/client.cpp index 5f5a9989c..2228571a6 100644 --- a/src/input_common/udp/client.cpp +++ b/src/input_common/udp/client.cpp @@ -14,7 +14,6 @@ #include "input_common/udp/client.h" #include "input_common/udp/protocol.h" -using boost::asio::ip::address_v4; using boost::asio::ip::udp; namespace InputCommon::CemuhookUDP { @@ -31,10 +30,10 @@ public: explicit Socket(const std::string& host, u16 port, u8 pad_index, u32 client_id, SocketCallback callback) - : client_id(client_id), timer(io_service), - send_endpoint(udp::endpoint(address_v4::from_string(host), port)), - socket(io_service, udp::endpoint(udp::v4(), 0)), pad_index(pad_index), - callback(std::move(callback)) {} + : callback(std::move(callback)), timer(io_service), + socket(io_service, udp::endpoint(udp::v4(), 0)), client_id(client_id), + pad_index(pad_index), + send_endpoint(udp::endpoint(boost::asio::ip::make_address_v4(host), port)) {} void Stop() { io_service.stop(); @@ -126,7 +125,7 @@ static void SocketLoop(Socket* socket) { Client::Client(std::shared_ptr<DeviceStatus> status, const std::string& host, u16 port, u8 pad_index, u32 client_id) - : status(status) { + : status(std::move(status)) { StartCommunication(host, port, pad_index, client_id); } @@ -207,7 +206,7 @@ void TestCommunication(const std::string& host, u16 port, u8 pad_index, u32 clie Common::Event success_event; SocketCallback callback{[](Response::Version version) {}, [](Response::PortInfo info) {}, [&](Response::PadData data) { success_event.Set(); }}; - Socket socket{host, port, pad_index, client_id, callback}; + Socket socket{host, port, pad_index, client_id, std::move(callback)}; std::thread worker_thread{SocketLoop, &socket}; bool result = success_event.WaitFor(std::chrono::seconds(8)); socket.Stop(); @@ -267,7 +266,7 @@ CalibrationConfigurationJob::CalibrationConfigurationJob( complete_event.Set(); } }}; - Socket socket{host, port, pad_index, client_id, callback}; + Socket socket{host, port, pad_index, client_id, std::move(callback)}; std::thread worker_thread{SocketLoop, &socket}; complete_event.Wait(); socket.Stop(); diff --git a/src/input_common/udp/client.h b/src/input_common/udp/client.h index 0b21f4da6..b8c654755 100644 --- a/src/input_common/udp/client.h +++ b/src/input_common/udp/client.h @@ -11,7 +11,6 @@ #include <string> #include <thread> #include <tuple> -#include <vector> #include "common/common_types.h" #include "common/thread.h" #include "common/vector_math.h" diff --git a/src/input_common/udp/protocol.h b/src/input_common/udp/protocol.h index 1b521860a..3ba4d1fc8 100644 --- a/src/input_common/udp/protocol.h +++ b/src/input_common/udp/protocol.h @@ -7,7 +7,6 @@ #include <array> #include <optional> #include <type_traits> -#include <vector> #include <boost/crc.hpp> #include "common/bit_field.h" #include "common/swap.h" diff --git a/src/input_common/udp/udp.cpp b/src/input_common/udp/udp.cpp index a80f38614..ca99cc22f 100644 --- a/src/input_common/udp/udp.cpp +++ b/src/input_common/udp/udp.cpp @@ -2,7 +2,9 @@ // Licensed under GPLv2 or any later version // Refer to the license.txt file included. -#include "common/logging/log.h" +#include <mutex> +#include <tuple> + #include "common/param_package.h" #include "core/frontend/input.h" #include "core/settings.h" @@ -14,7 +16,7 @@ namespace InputCommon::CemuhookUDP { class UDPTouchDevice final : public Input::TouchDevice { public: explicit UDPTouchDevice(std::shared_ptr<DeviceStatus> status_) : status(std::move(status_)) {} - std::tuple<float, float, bool> GetStatus() const { + std::tuple<float, float, bool> GetStatus() const override { std::lock_guard guard(status->update_mutex); return status->touch_status; } @@ -26,7 +28,7 @@ private: class UDPMotionDevice final : public Input::MotionDevice { public: explicit UDPMotionDevice(std::shared_ptr<DeviceStatus> status_) : status(std::move(status_)) {} - std::tuple<Common::Vec3<float>, Common::Vec3<float>> GetStatus() const { + std::tuple<Common::Vec3<float>, Common::Vec3<float>> GetStatus() const override { std::lock_guard guard(status->update_mutex); return status->motion_status; } diff --git a/src/input_common/udp/udp.h b/src/input_common/udp/udp.h index ea3de60bb..4f83f0441 100644 --- a/src/input_common/udp/udp.h +++ b/src/input_common/udp/udp.h @@ -2,15 +2,13 @@ // Licensed under GPLv2 or any later version // Refer to the license.txt file included. +#pragma once + #include <memory> -#include <unordered_map> -#include "input_common/main.h" -#include "input_common/udp/client.h" namespace InputCommon::CemuhookUDP { -class UDPTouchDevice; -class UDPMotionDevice; +class Client; class State { public: |