From 0c53d9a1ee8369f93a2d7ddb4b7b1038fa6ee664 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Mon, 18 Nov 2024 18:26:07 -0800 Subject: [PATCH] Implemented SendEffect for Steam Controllers --- src/joystick/hidapi/SDL_hidapi_steam.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/joystick/hidapi/SDL_hidapi_steam.c b/src/joystick/hidapi/SDL_hidapi_steam.c index ec93dff110..7f68e07e51 100644 --- a/src/joystick/hidapi/SDL_hidapi_steam.c +++ b/src/joystick/hidapi/SDL_hidapi_steam.c @@ -296,7 +296,7 @@ static int WriteSegmentToSteamControllerPacketAssembler(SteamControllerPacketAss #define BLE_MAX_READ_RETRIES 8 -static int SetFeatureReport(SDL_HIDAPI_Device *dev, unsigned char uBuffer[65], int nActualDataLen) +static int SetFeatureReport(SDL_HIDAPI_Device *dev, const unsigned char uBuffer[65], int nActualDataLen) { int nRet = -1; @@ -305,7 +305,7 @@ static int SetFeatureReport(SDL_HIDAPI_Device *dev, unsigned char uBuffer[65], i if (dev->is_bluetooth) { int nSegmentNumber = 0; uint8_t uPacketBuffer[MAX_REPORT_SEGMENT_SIZE]; - unsigned char *pBufferPtr = uBuffer + 1; + const unsigned char *pBufferPtr = uBuffer + 1; if (nActualDataLen < 1) { return -1; @@ -1243,6 +1243,12 @@ static bool HIDAPI_DriverSteam_SetJoystickLED(SDL_HIDAPI_Device *device, SDL_Joy static bool HIDAPI_DriverSteam_SendJoystickEffect(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, const void *data, int size) { + if (size == 65) { + if (SetFeatureReport(device, data, size) < 0) { + return SDL_SetError("Couldn't write feature report"); + } + return true; + } return SDL_Unsupported(); }