diff --git a/src/Input.h b/src/Input.h index b07b3b9..1c5166d 100644 --- a/src/Input.h +++ b/src/Input.h @@ -168,7 +168,8 @@ typedef struct _SS_CONTROLLER_TOUCH_PACKET { NV_INPUT_HEADER header; uint8_t controllerNumber; uint8_t eventType; - uint8_t zero[2]; // Alignment/reserved + uint8_t zero; // Alignment/reserved + uint8_t touchpadIndex; uint32_t pointerId; netfloat x; netfloat y; diff --git a/src/InputStream.c b/src/InputStream.c index e8e60a4..5994836 100644 --- a/src/InputStream.c +++ b/src/InputStream.c @@ -1435,6 +1435,11 @@ int LiSendControllerArrivalEvent(uint8_t controllerNumber, uint16_t activeGamepa // Sunshine supports up to 16 controllers controllerNumber %= MAX_GAMEPADS; + // Always set the older touchpad cap if we have dual touchpads + if (capabilities & LI_CCAP_DUAL_TOUCHPAD) { + capabilities |= LI_CCAP_TOUCHPAD; + } + // The arrival event is only supported by Sunshine if (IS_SUNSHINE()) { holder = allocatePacketHolder(0); @@ -1466,7 +1471,7 @@ int LiSendControllerArrivalEvent(uint8_t controllerNumber, uint16_t activeGamepa return LiSendMultiControllerEvent(controllerNumber, activeGamepadMask, 0, 0, 0, 0, 0, 0, 0); } -int LiSendControllerTouchEvent(uint8_t controllerNumber, uint8_t eventType, uint32_t pointerId, float x, float y, float pressure) { +int LiSendControllerTouchEvent2(uint8_t controllerNumber, uint8_t eventType, uint8_t touchpadIndex, uint32_t pointerId, float x, float y, float pressure) { PPACKET_HOLDER holder; int err; @@ -1498,7 +1503,8 @@ int LiSendControllerTouchEvent(uint8_t controllerNumber, uint8_t eventType, uint holder->packet.controllerTouch.header.magic = LE32(SS_CONTROLLER_TOUCH_MAGIC); holder->packet.controllerTouch.controllerNumber = controllerNumber; holder->packet.controllerTouch.eventType = eventType; - memset(holder->packet.controllerTouch.zero, 0, sizeof(holder->packet.controllerTouch.zero)); + memset(&holder->packet.controllerTouch.zero, 0, sizeof(holder->packet.controllerTouch.zero)); + holder->packet.controllerTouch.touchpadIndex = touchpadIndex; holder->packet.controllerTouch.pointerId = LE32(pointerId); floatToNetfloat(x, holder->packet.controllerTouch.x); floatToNetfloat(y, holder->packet.controllerTouch.y); @@ -1514,6 +1520,10 @@ int LiSendControllerTouchEvent(uint8_t controllerNumber, uint8_t eventType, uint return err; } +int LiSendControllerTouchEvent(uint8_t controllerNumber, uint8_t eventType, uint32_t pointerId, float x, float y, float pressure) { + return LiSendControllerTouchEvent2(controllerNumber, eventType, 0, pointerId, x, y, pressure); +} + int LiSendControllerMotionEvent(uint8_t controllerNumber, uint8_t motionType, float x, float y, float z) { PPACKET_HOLDER holder; int err; diff --git a/src/Limelight.h b/src/Limelight.h index ac87a4b..e622bea 100644 --- a/src/Limelight.h +++ b/src/Limelight.h @@ -781,6 +781,7 @@ int LiSendMultiControllerEvent(short controllerNumber, short activeGamepadMask, #define LI_CCAP_GYRO 0x20 // Can report gyroscope events via LiSendControllerMotionEvent() #define LI_CCAP_BATTERY_STATE 0x40 // Reports battery state via LiSendControllerBatteryEvent() #define LI_CCAP_RGB_LED 0x80 // Can set RGB LED state via ConnListenerSetControllerLED() +#define LI_CCAP_DUAL_TOUCHPAD 0x100 // Reports touchpad events from 2 separate touchpads int LiSendControllerArrivalEvent(uint8_t controllerNumber, uint16_t activeGamepadMask, uint8_t type, uint32_t supportedButtonFlags, uint16_t capabilities); @@ -794,6 +795,13 @@ int LiSendControllerArrivalEvent(uint8_t controllerNumber, uint16_t activeGamepa // and check for the LI_FF_CONTROLLER_TOUCH_EVENTS flag. int LiSendControllerTouchEvent(uint8_t controllerNumber, uint8_t eventType, uint32_t pointerId, float x, float y, float pressure); +// This function is similar to LiSendControllerTouchEvent(), but it allows the touchpad index to be +// provided for use with controllers that have multiple touchpads (like the Steam Controller). +// +// The only valid touchpad indices are currently 0 (support indicated by LI_CCAP_TOUCHPAD) and 1 +// (support indicated by LI_CCAP_DUAL_TOUCHPAD). +int LiSendControllerTouchEvent2(uint8_t controllerNumber, uint8_t eventType, uint8_t touchpadIndex, uint32_t pointerId, float x, float y, float pressure); + // This function allows clients to send controller-associated motion events to a supported host. // // For power and performance reasons, motion sensors should not be enabled unless the host has