Reuse pressure field in touch/pen events to provide hover distance

This commit is contained in:
Cameron Gutman 2023-07-22 12:33:19 -05:00
parent 27428e655b
commit d8b2b04bb2
3 changed files with 13 additions and 8 deletions

View File

@ -131,7 +131,7 @@ typedef struct _SS_TOUCH_PACKET {
uint32_t pointerId;
netfloat x;
netfloat y;
netfloat pressure;
netfloat pressureOrDistance;
} SS_TOUCH_PACKET, *PSS_TOUCH_PACKET;
#define SS_PEN_MAGIC 0x55000003
@ -143,7 +143,7 @@ typedef struct _SS_PEN_PACKET {
uint8_t zero[1]; // Alignment/reserved
netfloat x;
netfloat y;
netfloat pressure;
netfloat pressureOrDistance;
uint16_t rotation;
uint8_t tilt;
uint8_t zero2[1];

View File

@ -1216,7 +1216,7 @@ int LiSendHScrollEvent(signed char scrollClicks) {
return LiSendHighResHScrollEvent(scrollClicks * LI_WHEEL_DELTA);
}
int LiSendTouchEvent(uint8_t eventType, uint32_t pointerId, float x, float y, float pressure) {
int LiSendTouchEvent(uint8_t eventType, uint32_t pointerId, float x, float y, float pressureOrDistance) {
PPACKET_HOLDER holder;
int err;
@ -1247,7 +1247,7 @@ int LiSendTouchEvent(uint8_t eventType, uint32_t pointerId, float x, float y, fl
memset(holder->packet.touch.zero, 0, sizeof(holder->packet.touch.zero));
floatToNetfloat(x, holder->packet.touch.x);
floatToNetfloat(y, holder->packet.touch.y);
floatToNetfloat(pressure, holder->packet.touch.pressure);
floatToNetfloat(pressureOrDistance, holder->packet.touch.pressureOrDistance);
err = LbqOfferQueueItem(&packetQueue, holder, &holder->entry);
if (err != LBQ_SUCCESS) {
@ -1260,7 +1260,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,
float x, float y, float pressureOrDistance,
uint16_t rotation, uint8_t tilt) {
PPACKET_HOLDER holder;
int err;
@ -1294,7 +1294,7 @@ int LiSendPenEvent(uint8_t eventType, uint8_t toolType, uint8_t penButtons,
memset(holder->packet.pen.zero, 0, sizeof(holder->packet.pen.zero));
floatToNetfloat(x, holder->packet.pen.x);
floatToNetfloat(y, holder->packet.pen.y);
floatToNetfloat(pressure, holder->packet.pen.pressure);
floatToNetfloat(pressureOrDistance, holder->packet.pen.pressureOrDistance);
holder->packet.pen.rotation = LE16(rotation);
holder->packet.pen.tilt = tilt;
memset(holder->packet.pen.zero2, 0, sizeof(holder->packet.pen.zero2));

View File

@ -595,6 +595,11 @@ 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.
//
// For hover events, the pressure value is treated as a 1.0 to 0.0 range of distance from the touch
// surface where 1.0 is the farthest measurable distance and 0.0 is actually touching the display
// (which is invalid for a hover event). Reporting distance 0.0 for a hover event indicates the
// actual distance 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.
//
@ -607,7 +612,7 @@ int LiSendMouseMoveAsMousePositionEvent(short deltaX, short deltaY, short refere
#define LI_TOUCH_EVENT_CANCEL 0x04
#define LI_TOUCH_EVENT_BUTTON_ONLY 0x05
#define LI_TOUCH_EVENT_HOVER_LEAVE 0x06
int LiSendTouchEvent(uint8_t eventType, uint32_t pointerId, float x, float y, float pressure);
int LiSendTouchEvent(uint8_t eventType, uint32_t pointerId, float x, float y, float pressureOrDistance);
// 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
@ -625,7 +630,7 @@ int LiSendTouchEvent(uint8_t eventType, uint32_t pointerId, float x, float y, fl
#define LI_ROT_UNKNOWN 0xFFFF
#define LI_TILT_UNKNOWN 0xFF
int LiSendPenEvent(uint8_t eventType, uint8_t toolType, uint8_t penButtons,
float x, float y, float pressure,
float x, float y, float pressureOrDistance,
uint16_t rotation, uint8_t tilt);
// This function queues a mouse button event to be sent to the remote server.