From de0efa861a05ff24a54f2c2650492c47305698c8 Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Sat, 24 Jun 2023 21:25:48 -0500 Subject: [PATCH] Several fixes for touch and pen APIs --- src/Input.h | 4 ++-- src/InputStream.c | 6 +++--- src/Limelight.h | 18 ++++++++++-------- 3 files changed, 15 insertions(+), 13 deletions(-) diff --git a/src/Input.h b/src/Input.h index 2c50aee..3635d9d 100644 --- a/src/Input.h +++ b/src/Input.h @@ -145,8 +145,8 @@ typedef struct _SS_PEN_PACKET { netfloat y; netfloat pressure; uint16_t rotation; - int8_t tiltX; - int8_t tiltY; + int8_t tilt; + uint8_t zero2[1]; } SS_PEN_PACKET, *PSS_PEN_PACKET; #define SS_CONTROLLER_ARRIVAL_MAGIC 0x55000004 diff --git a/src/InputStream.c b/src/InputStream.c index 5f406e0..a1c4850 100644 --- a/src/InputStream.c +++ b/src/InputStream.c @@ -1194,7 +1194,7 @@ int LiSendTouchEvent(uint8_t eventType, uint32_t pointerId, float x, float y, fl int LiSendPenEvent(uint8_t eventType, uint8_t toolType, uint8_t penButtons, float x, float y, float pressure, - uint16_t rotation, int8_t tiltX, int8_t tiltY) { + uint16_t rotation, int8_t tilt) { PPACKET_HOLDER holder; int err; @@ -1222,8 +1222,8 @@ int LiSendPenEvent(uint8_t eventType, uint8_t toolType, uint8_t penButtons, floatToNetfloat(y, holder->packet.touch.y); floatToNetfloat(pressure, holder->packet.touch.pressure); holder->packet.pen.rotation = LE16(rotation); - holder->packet.pen.tiltX = tiltX; - holder->packet.pen.tiltY = tiltY; + holder->packet.pen.tilt = tilt; + memset(holder->packet.pen.zero2, 0, sizeof(holder->packet.pen.zero2)); err = LbqOfferQueueItem(&packetQueue, holder, &holder->entry); if (err != LBQ_SUCCESS) { diff --git a/src/Limelight.h b/src/Limelight.h index 467d61c..4530950 100644 --- a/src/Limelight.h +++ b/src/Limelight.h @@ -580,26 +580,28 @@ int LiSendMouseMoveAsMousePositionEvent(short deltaX, short deltaY, short refere // // 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 -#define LI_TOUCH_EVENT_DOWN 0x01 -#define LI_TOUCH_EVENT_UP 0x02 -#define LI_TOUCH_EVENT_MOVE 0x03 -#define LI_TOUCH_EVENT_CANCEL 0x04 +#define LI_TOUCH_EVENT_HOVER 0x00 +#define LI_TOUCH_EVENT_DOWN 0x01 +#define LI_TOUCH_EVENT_UP 0x02 +#define LI_TOUCH_EVENT_MOVE 0x03 +#define LI_TOUCH_EVENT_CANCEL 0x04 +#define LI_TOUCH_EVENT_BUTTON_ONLY 0x05 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 -// (parallel to screen) and tilt is in degrees from vertical in Z dimension (perpendicular to screen). +// (parallel to screen, 0..359) and tilt is in degrees from vertical in Z dimension (perpendicular +// to screen, -90..90). #define LI_TOOL_TYPE_PEN 0x01 #define LI_TOOL_TYPE_ERASER 0x02 #define LI_PEN_BUTTON_PRIMARY 0x01 #define LI_PEN_BUTTON_SECONDARY 0x02 #define LI_PEN_BUTTON_TERTIARY 0x04 +#define LI_ROT_UNKNOWN 0xFFFF #define LI_TILT_UNKNOWN 0xFF -#define LI_ROT_UNKNOWN 0xFF int LiSendPenEvent(uint8_t eventType, uint8_t toolType, uint8_t penButtons, float x, float y, float pressure, - uint16_t rotation, int8_t tiltX, int8_t tiltY); + uint16_t rotation, int8_t tilt); // This function queues a mouse button event to be sent to the remote server. #define BUTTON_ACTION_PRESS 0x07