From 329c55d52f637997d50e39d916929c19974de38a Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Sun, 18 Jun 2023 13:48:14 -0500 Subject: [PATCH] Send pointer IDs instead of touch indices --- src/Input.h | 8 ++++---- src/InputStream.c | 8 ++++---- src/Limelight.h | 7 +++++-- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/src/Input.h b/src/Input.h index f6041b4..36bba7f 100644 --- a/src/Input.h +++ b/src/Input.h @@ -126,8 +126,8 @@ typedef struct _SS_HSCROLL_PACKET { typedef struct _SS_TOUCH_PACKET { NV_INPUT_HEADER header; uint8_t eventType; - uint8_t touchIndex; - uint8_t zero[2]; // Alignment/reserved + uint8_t zero[3]; // Alignment/reserved + uint32_t pointerId; netfloat x; netfloat y; netfloat pressure; @@ -162,8 +162,8 @@ typedef struct _SS_CONTROLLER_TOUCH_PACKET { NV_INPUT_HEADER header; uint8_t controllerNumber; uint8_t eventType; - uint8_t touchIndex; - uint8_t zero[1]; // Alignment/reserved + uint8_t zero[2]; // Alignment/reserved + uint32_t pointerId; netfloat x; netfloat y; netfloat pressure; diff --git a/src/InputStream.c b/src/InputStream.c index 2c97fb8..5c1de5a 100644 --- a/src/InputStream.c +++ b/src/InputStream.c @@ -1056,7 +1056,7 @@ int LiSendHScrollEvent(signed char scrollClicks) { return LiSendHighResHScrollEvent(scrollClicks * LI_WHEEL_DELTA); } -int LiSendTouchEvent(uint8_t eventType, uint8_t touchIndex, float x, float y, float pressure) { +int LiSendTouchEvent(uint8_t eventType, uint32_t pointerId, float x, float y, float pressure) { PPACKET_HOLDER holder; int err; @@ -1077,7 +1077,7 @@ int LiSendTouchEvent(uint8_t eventType, uint8_t touchIndex, float x, float y, fl holder->packet.touch.header.size = BE32(sizeof(SS_TOUCH_PACKET) - sizeof(uint32_t)); holder->packet.touch.header.magic = LE32(SS_TOUCH_MAGIC); holder->packet.touch.eventType = eventType; - holder->packet.touch.touchIndex = touchIndex; + holder->packet.touch.pointerId = LE32(pointerId); memset(holder->packet.touch.zero, 0, sizeof(holder->packet.touch.zero)); floatToNetfloat(x, holder->packet.touch.x); floatToNetfloat(y, holder->packet.touch.y); @@ -1172,7 +1172,7 @@ int LiSendControllerArrivalEvent(uint8_t controllerNumber, uint16_t activeGamepa return LiSendMultiControllerEvent(controllerNumber, activeGamepadMask, 0, 0, 0, 0, 0, 0, 0); } -int LiSendControllerTouchEvent(uint8_t controllerNumber, uint8_t eventType, uint8_t touchIndex, float x, float y, float pressure) { +int LiSendControllerTouchEvent(uint8_t controllerNumber, uint8_t eventType, uint32_t pointerId, float x, float y, float pressure) { PPACKET_HOLDER holder; int err; @@ -1194,8 +1194,8 @@ int LiSendControllerTouchEvent(uint8_t controllerNumber, uint8_t eventType, uint holder->packet.controllerTouch.header.magic = LE32(SS_CONTROLLER_TOUCH_MAGIC); holder->packet.controllerTouch.controllerNumber = controllerNumber; holder->packet.controllerTouch.eventType = eventType; - holder->packet.controllerTouch.touchIndex = touchIndex; memset(holder->packet.controllerTouch.zero, 0, sizeof(holder->packet.controllerTouch.zero)); + holder->packet.controllerTouch.pointerId = LE32(pointerId); floatToNetfloat(x, holder->packet.controllerTouch.x); floatToNetfloat(y, holder->packet.controllerTouch.y); floatToNetfloat(pressure, holder->packet.controllerTouch.pressure); diff --git a/src/Limelight.h b/src/Limelight.h index d25a7b6..423328d 100644 --- a/src/Limelight.h +++ b/src/Limelight.h @@ -575,6 +575,9 @@ int LiSendMouseMoveAsMousePositionEvent(short deltaX, short deltaY, short refere // // Sending a down/move event with a pressure of 0.0 indicates the actual pressure is unknown. // +// Pointer ID is an opaque ID that must uniquely identify each active touch on screen. It must +// remain constant through any down/up/move/cancel events involved in a single touch interaction. +// // If unsupported by the host, this will return LI_ERR_UNSUPPORTED and the caller should consider // falling back to other functions to send this input (such as LiSendMousePositionEvent()). #define LI_TOUCH_EVENT_HOVER 0x00 @@ -582,7 +585,7 @@ int LiSendMouseMoveAsMousePositionEvent(short deltaX, short deltaY, short refere #define LI_TOUCH_EVENT_UP 0x02 #define LI_TOUCH_EVENT_MOVE 0x03 #define LI_TOUCH_EVENT_CANCEL 0x04 -int LiSendTouchEvent(uint8_t eventType, uint8_t touchIndex, float x, float y, float pressure); +int LiSendTouchEvent(uint8_t eventType, uint32_t pointerId, float x, float y, float pressure); // This function is similar to LiSendTouchEvent() but allows additional parameters relevant for pen // input, including rotation, tilt, and buttons. Rotation is in degrees from vertical in Y dimension @@ -686,7 +689,7 @@ int LiSendControllerArrivalEvent(uint8_t controllerNumber, uint16_t activeGamepa // // If unsupported by the host, this will return LI_ERR_UNSUPPORTED and the caller should consider // using this touch input to simulate trackpad input. -int LiSendControllerTouchEvent(uint8_t controllerNumber, uint8_t eventType, uint8_t touchIndex, float x, float y, float pressure); +int LiSendControllerTouchEvent(uint8_t controllerNumber, uint8_t eventType, uint32_t pointerId, float x, float y, float pressure); // This function allows clients to send controller-associated motion events to a supported host. //