Allow the application to send commands to Nintendo Switch controllers
This commit is contained in:
parent
7c55845c80
commit
9837653b9d
1 changed files with 16 additions and 3 deletions
|
@ -393,7 +393,7 @@ static SDL_bool ReadProprietaryReply(SDL_DriverSwitch_Context *ctx, ESwitchPropr
|
||||||
return SDL_FALSE;
|
return SDL_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ConstructSubcommand(SDL_DriverSwitch_Context *ctx, ESwitchSubcommandIDs ucCommandID, Uint8 *pBuf, Uint8 ucLen, SwitchSubcommandOutputPacket_t *outPacket)
|
static void ConstructSubcommand(SDL_DriverSwitch_Context *ctx, ESwitchSubcommandIDs ucCommandID, const Uint8 *pBuf, Uint8 ucLen, SwitchSubcommandOutputPacket_t *outPacket)
|
||||||
{
|
{
|
||||||
SDL_memset(outPacket, 0, sizeof(*outPacket));
|
SDL_memset(outPacket, 0, sizeof(*outPacket));
|
||||||
|
|
||||||
|
@ -432,7 +432,7 @@ static SDL_bool WritePacket(SDL_DriverSwitch_Context *ctx, void *pBuf, Uint8 ucL
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static SDL_bool WriteSubcommand(SDL_DriverSwitch_Context *ctx, ESwitchSubcommandIDs ucCommandID, Uint8 *pBuf, Uint8 ucLen, SwitchSubcommandInputPacket_t **ppReply)
|
static SDL_bool WriteSubcommand(SDL_DriverSwitch_Context *ctx, ESwitchSubcommandIDs ucCommandID, const Uint8 *pBuf, Uint8 ucLen, SwitchSubcommandInputPacket_t **ppReply)
|
||||||
{
|
{
|
||||||
SwitchSubcommandInputPacket_t *reply = NULL;
|
SwitchSubcommandInputPacket_t *reply = NULL;
|
||||||
int nTries;
|
int nTries;
|
||||||
|
@ -648,7 +648,7 @@ static SDL_bool SetVibrationEnabled(SDL_DriverSwitch_Context *ctx, Uint8 enabled
|
||||||
}
|
}
|
||||||
static SDL_bool SetInputMode(SDL_DriverSwitch_Context *ctx, Uint8 input_mode)
|
static SDL_bool SetInputMode(SDL_DriverSwitch_Context *ctx, Uint8 input_mode)
|
||||||
{
|
{
|
||||||
return WriteSubcommand(ctx, k_eSwitchSubcommandIDs_SetInputReportMode, &input_mode, 1, NULL);
|
return WriteSubcommand(ctx, k_eSwitchSubcommandIDs_SetInputReportMode, &input_mode, sizeof(input_mode), NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static SDL_bool SetHomeLED(SDL_DriverSwitch_Context *ctx, Uint8 brightness)
|
static SDL_bool SetHomeLED(SDL_DriverSwitch_Context *ctx, Uint8 brightness)
|
||||||
|
@ -1579,6 +1579,19 @@ static int HIDAPI_DriverSwitch_SendJoystickEffect(SDL_HIDAPI_Device *device, SDL
|
||||||
ctx->m_bRumblePending = SDL_FALSE;
|
ctx->m_bRumblePending = SDL_FALSE;
|
||||||
ctx->m_bRumbleZeroPending = SDL_FALSE;
|
ctx->m_bRumbleZeroPending = SDL_FALSE;
|
||||||
return 0;
|
return 0;
|
||||||
|
} else if (size >= 2 && size <= 256) {
|
||||||
|
const Uint8 *payload = (const Uint8 *)data;
|
||||||
|
ESwitchSubcommandIDs cmd = (ESwitchSubcommandIDs)payload[0];
|
||||||
|
|
||||||
|
if (cmd == k_eSwitchSubcommandIDs_SetInputReportMode && !device->is_bluetooth) {
|
||||||
|
/* Going into simple mode over USB disables input reports, so don't do that */
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!WriteSubcommand(ctx, cmd, &payload[1], (Uint8)(size - 1), NULL)) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
return SDL_Unsupported();
|
return SDL_Unsupported();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue