Add absolute mouse motion support

This commit is contained in:
Cameron Gutman 2020-04-11 15:40:50 -07:00
parent f0c3b57d11
commit ef7de27727
3 changed files with 40 additions and 3 deletions

View File

@ -26,7 +26,8 @@ typedef struct _NV_KEYBOARD_PACKET {
} NV_KEYBOARD_PACKET, *PNV_KEYBOARD_PACKET;
#define PACKET_TYPE_MOUSE_MOVE 0x08
#define MOUSE_MOVE_MAGIC 0x06
#define MOUSE_MOVE_ABS_MAGIC 0x05
#define MOUSE_MOVE_REL_MAGIC 0x06
typedef struct _NV_MOUSE_MOVE_PACKET {
NV_INPUT_HEADER header;
int magic;

View File

@ -440,7 +440,7 @@ int LiSendMouseMoveEvent(short deltaX, short deltaY) {
holder->packetLength = sizeof(NV_MOUSE_MOVE_PACKET);
holder->packet.mouseMove.header.packetType = htonl(PACKET_TYPE_MOUSE_MOVE);
holder->packet.mouseMove.magic = MOUSE_MOVE_MAGIC;
holder->packet.mouseMove.magic = MOUSE_MOVE_REL_MAGIC;
// On Gen 5 servers, the header code is incremented by one
if (AppVersionQuad[0] >= 5) {
holder->packet.mouseMove.magic++;
@ -456,6 +456,39 @@ int LiSendMouseMoveEvent(short deltaX, short deltaY) {
return err;
}
// Send a mouse position update to the streaming machine
int LiSendMousePositionEvent(short x, short y) {
PPACKET_HOLDER holder;
int err;
if (!initialized) {
return -2;
}
// TODO: Figure out the exact version where this was added
if (AppVersionQuad[0] < 7) {
return -3;
}
holder = malloc(sizeof(*holder));
if (holder == NULL) {
return -1;
}
holder->packetLength = sizeof(NV_MOUSE_MOVE_PACKET);
holder->packet.mouseMove.header.packetType = htonl(PACKET_TYPE_MOUSE_MOVE);
holder->packet.mouseMove.magic = MOUSE_MOVE_ABS_MAGIC;
holder->packet.mouseMove.deltaX = htons(x);
holder->packet.mouseMove.deltaY = htons(y);
err = LbqOfferQueueItem(&packetQueue, holder, &holder->entry);
if (err != LBQ_SUCCESS) {
free(holder);
}
return err;
}
// Send a mouse button event to the streaming machine
int LiSendMouseButtonEvent(char action, int button) {
PPACKET_HOLDER holder;

View File

@ -420,9 +420,12 @@ void LiInterruptConnection(void);
// from the integer passed to the ConnListenerStageXXX callbacks
const char* LiGetStageName(int stage);
// This function queues a mouse move event to be sent to the remote server.
// This function queues a relative mouse move event to be sent to the remote server.
int LiSendMouseMoveEvent(short deltaX, short deltaY);
// This function queues a mouse position update event to be sent to the remote server.
int LiSendMousePositionEvent(short x, short y);
// This function queues a mouse button event to be sent to the remote server.
#define BUTTON_ACTION_PRESS 0x07
#define BUTTON_ACTION_RELEASE 0x08