From d8df9a16bd4f4517b024c17446a94915493d7f3d Mon Sep 17 00:00:00 2001 From: german Date: Fri, 1 Jan 2021 12:32:29 -0600 Subject: Allow to return up to 16 touch inputs per engine --- src/input_common/udp/client.h | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) (limited to 'src/input_common/udp/client.h') diff --git a/src/input_common/udp/client.h b/src/input_common/udp/client.h index 00c8b09f5..1cd251ec8 100644 --- a/src/input_common/udp/client.h +++ b/src/input_common/udp/client.h @@ -29,6 +29,7 @@ namespace Response { struct PadData; struct PortInfo; struct Version; +struct TouchPad; } // namespace Response enum class PadMotion { @@ -50,7 +51,6 @@ struct UDPPadStatus { std::string host{"127.0.0.1"}; u16 port{26760}; std::size_t pad_index{}; - PadTouch touch{PadTouch::Undefined}; PadMotion motion{PadMotion::Undefined}; f32 motion_value{0.0f}; }; @@ -93,6 +93,9 @@ public: DeviceStatus& GetPadState(const std::string& host, u16 port, std::size_t pad); const DeviceStatus& GetPadState(const std::string& host, u16 port, std::size_t pad) const; + Input::TouchStatus& GetTouchState(); + const Input::TouchStatus& GetTouchState() const; + private: struct ClientData { std::string host{"127.0.0.1"}; @@ -122,14 +125,25 @@ private: void StartCommunication(std::size_t client, const std::string& host, u16 port, std::size_t pad_index, u32 client_id); void UpdateYuzuSettings(std::size_t client, const Common::Vec3& acc, - const Common::Vec3& gyro, bool touch); + const Common::Vec3& gyro); + + // Returns an unused finger id, if there is no fingers available std::nullopt will be + // returned + std::optional 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); bool configuring = false; // Allocate clients for 8 udp servers - const std::size_t max_udp_clients = 32; - std::array clients; - Common::SPSCQueue pad_queue; + static constexpr std::size_t MAX_UDP_CLIENTS = 4 * 8; + // Each client can have up 2 touch inputs + static constexpr std::size_t MAX_TOUCH_FINGERS = MAX_UDP_CLIENTS * 2; + std::array clients{}; + Common::SPSCQueue pad_queue{}; + Input::TouchStatus touch_status{}; + std::array finger_id{}; }; /// An async job allowing configuration of the touchpad calibration. -- cgit v1.2.3