mirror of
https://github.com/moonlight-stream/moonlight-common-c.git
synced 2025-08-18 01:15:46 +00:00
Request haptics data from server
This commit is contained in:
parent
fa86e76978
commit
ad5dd9c940
@ -6,6 +6,15 @@ typedef struct _NV_INPUT_HEADER {
|
||||
int packetType;
|
||||
} NV_INPUT_HEADER, PNV_INPUT_HEADER;
|
||||
|
||||
#define PACKET_TYPE_HAPTICS 0x06
|
||||
#define H_MAGIC_A 0x0000000D
|
||||
#define H_MAGIC_B 0x00000001
|
||||
typedef struct _NV_HAPTICS_PACKET {
|
||||
NV_INPUT_HEADER header;
|
||||
int magicA;
|
||||
int magicB;
|
||||
} NV_HAPTICS_PACKET, *PNV_HAPTICS_PACKET;
|
||||
|
||||
#define PACKET_TYPE_KEYBOARD 0x0A
|
||||
typedef struct _NV_KEYBOARD_PACKET {
|
||||
NV_INPUT_HEADER header;
|
||||
|
@ -30,6 +30,7 @@ typedef struct _PACKET_HOLDER {
|
||||
NV_CONTROLLER_PACKET controller;
|
||||
NV_MULTI_CONTROLLER_PACKET multiController;
|
||||
NV_SCROLL_PACKET scroll;
|
||||
NV_HAPTICS_PACKET haptics;
|
||||
} packet;
|
||||
LINKED_BLOCKING_QUEUE_ENTRY entry;
|
||||
} PACKET_HOLDER, *PPACKET_HOLDER;
|
||||
@ -343,6 +344,35 @@ static void inputSendThreadProc(void* context) {
|
||||
}
|
||||
}
|
||||
|
||||
// This function tells GFE that we support haptics and it should send rumble events to us
|
||||
static int sendEnableHaptics(void) {
|
||||
PPACKET_HOLDER holder;
|
||||
int err;
|
||||
|
||||
// Avoid sending this on earlier server versions, since they may terminate
|
||||
// the connection upon receiving an unexpected packet.
|
||||
if (AppVersionQuad[0] < 7 || (AppVersionQuad[0] == 7 && AppVersionQuad[1] < 1)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
holder = malloc(sizeof(*holder));
|
||||
if (holder == NULL) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
holder->packetLength = sizeof(NV_HAPTICS_PACKET);
|
||||
holder->packet.haptics.header.packetType = htonl(PACKET_TYPE_HAPTICS);
|
||||
holder->packet.haptics.magicA = H_MAGIC_A;
|
||||
holder->packet.haptics.magicB = H_MAGIC_B;
|
||||
|
||||
err = LbqOfferQueueItem(&packetQueue, holder, &holder->entry);
|
||||
if (err != LBQ_SUCCESS) {
|
||||
free(holder);
|
||||
}
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
// Begin the input stream
|
||||
int startInputStream(void) {
|
||||
int err;
|
||||
@ -367,6 +397,9 @@ int startInputStream(void) {
|
||||
return err;
|
||||
}
|
||||
|
||||
// GFE will not send haptics events without this magic packet first
|
||||
sendEnableHaptics();
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user