Expand button flags to support additional buttons with Sunshine

This commit is contained in:
Cameron Gutman
2023-06-18 14:03:29 -05:00
parent 7eea7a7971
commit 372eb94ed0
3 changed files with 18 additions and 7 deletions

View File

@@ -88,7 +88,7 @@ typedef struct _NV_CONTROLLER_PACKET {
#define MULTI_CONTROLLER_MAGIC_GEN5 0x0000000C
#define MC_HEADER_B 0x001A
#define MC_MID_B 0x0014
#define MC_TAIL_A 0x0000009C
#define MC_TAIL_A 0x009C
#define MC_TAIL_B 0x0055
typedef struct _NV_MULTI_CONTROLLER_PACKET {
NV_INPUT_HEADER header;
@@ -103,7 +103,8 @@ typedef struct _NV_MULTI_CONTROLLER_PACKET {
short leftStickY;
short rightStickX;
short rightStickY;
int tailA;
short tailA;
short buttonFlags2; // Sunshine protocol extension (always 0 for GFE)
short tailB;
} NV_MULTI_CONTROLLER_PACKET, *PNV_MULTI_CONTROLLER_PACKET;

View File

@@ -317,6 +317,7 @@ static void inputSendThreadProc(void* context) {
// calls to LiSendMultiControllerEvent() with different values for analog sticks (max -> zero).
newPkt = &controllerBatchHolder->packet.multiController;
if (newPkt->buttonFlags != origPkt->buttonFlags ||
newPkt->buttonFlags2 != origPkt->buttonFlags2 ||
newPkt->controllerNumber != origPkt->controllerNumber ||
newPkt->activeGamepadMask != origPkt->activeGamepadMask) {
// Batching not allowed
@@ -837,7 +838,7 @@ int LiSendUtf8TextEvent(const char *text, unsigned int length) {
}
static int sendControllerEventInternal(short controllerNumber, short activeGamepadMask,
short buttonFlags, unsigned char leftTrigger, unsigned char rightTrigger,
int buttonFlags, unsigned char leftTrigger, unsigned char rightTrigger,
short leftStickX, short leftStickY, short rightStickX, short rightStickY)
{
PPACKET_HOLDER holder;
@@ -882,14 +883,15 @@ static int sendControllerEventInternal(short controllerNumber, short activeGamep
holder->packet.multiController.controllerNumber = LE16(controllerNumber);
holder->packet.multiController.activeGamepadMask = LE16(activeGamepadMask);
holder->packet.multiController.midB = LE16(MC_MID_B);
holder->packet.multiController.buttonFlags = LE16(buttonFlags);
holder->packet.multiController.buttonFlags = LE16((short)buttonFlags);
holder->packet.multiController.leftTrigger = leftTrigger;
holder->packet.multiController.rightTrigger = rightTrigger;
holder->packet.multiController.leftStickX = LE16(leftStickX);
holder->packet.multiController.leftStickY = LE16(leftStickY);
holder->packet.multiController.rightStickX = LE16(rightStickX);
holder->packet.multiController.rightStickY = LE16(rightStickY);
holder->packet.multiController.tailA = LE32(MC_TAIL_A);
holder->packet.multiController.tailA = LE16(MC_TAIL_A);
holder->packet.multiController.buttonFlags2 = IS_SUNSHINE() ? LE16((short)(buttonFlags >> 16)) : 0;
holder->packet.multiController.tailB = LE16(MC_TAIL_B);
}
@@ -913,7 +915,7 @@ int LiSendControllerEvent(short buttonFlags, unsigned char leftTrigger, unsigned
// Send a controller event to the streaming machine
int LiSendMultiControllerEvent(short controllerNumber, short activeGamepadMask,
short buttonFlags, unsigned char leftTrigger, unsigned char rightTrigger,
int buttonFlags, unsigned char leftTrigger, unsigned char rightTrigger,
short leftStickX, short leftStickY, short rightStickX, short rightStickY)
{
return sendControllerEventInternal(controllerNumber, activeGamepadMask,

View File

@@ -648,6 +648,14 @@ int LiSendUtf8TextEvent(const char *text, unsigned int length);
#define RS_CLK_FLAG 0x0080
#define SPECIAL_FLAG 0x0400
// Extended buttons (Sunshine only)
#define PADDLE1_FLAG 0x010000
#define PADDLE2_FLAG 0x020000
#define PADDLE3_FLAG 0x040000
#define PADDLE4_FLAG 0x080000
#define TOUCHPAD_FLAG 0x100000 // Touchpad buttons on Sony controllers
#define MISC_FLAG 0x200000 // Share/Mic/Capture/Mute buttons on various controllers
// This function queues a controller event to be sent to the remote server. It will
// be seen by the computer as the first controller.
int LiSendControllerEvent(short buttonFlags, unsigned char leftTrigger, unsigned char rightTrigger,
@@ -659,7 +667,7 @@ int LiSendControllerEvent(short buttonFlags, unsigned char leftTrigger, unsigned
// these will be sent as controller 0 regardless of the controllerNumber parameter. The activeGamepadMask
// parameter is a bitfield with bits set for each controller present up to a maximum of 4 (0xF).
int LiSendMultiControllerEvent(short controllerNumber, short activeGamepadMask,
short buttonFlags, unsigned char leftTrigger, unsigned char rightTrigger,
int buttonFlags, unsigned char leftTrigger, unsigned char rightTrigger,
short leftStickX, short leftStickY, short rightStickX, short rightStickY);
// This function provides a method of informing the host of the available buttons and capabilities