Fixed non-Apple builds

This commit is contained in:
Sam Lantinga 2021-11-07 11:35:12 -08:00
parent 637bcd0b72
commit 86bc65a741
3 changed files with 44 additions and 8 deletions

View File

@ -2675,4 +2675,26 @@ SDL_GameControllerHandleDelayedGuideButton(SDL_Joystick *joystick)
}
}
const char *
SDL_GameControllerGetAppleSFSymbolsNameForButton(SDL_GameController *gamecontroller, SDL_GameControllerButton button)
{
#if defined(SDL_JOYSTICK_MFI)
const char *IOS_SDL_GameControllerGetAppleSFSymbolsNameForButton(SDL_GameController *gamecontroller, SDL_GameControllerButton button);
return IOS_SDL_GameControllerGetAppleSFSymbolsNameForButton(gamecontroller, button);
#else
return NULL;
#endif
}
const char *
SDL_GameControllerGetAppleSFSymbolsNameForAxis(SDL_GameController *gamecontroller, SDL_GameControllerAxis axis)
{
#if defined(SDL_JOYSTICK_MFI)
const char *IOS_SDL_GameControllerGetAppleSFSymbolsNameForAxis(SDL_GameController *gamecontroller, SDL_GameControllerAxis axis);
return IOS_SDL_GameControllerGetAppleSFSymbolsNameForAxis(gamecontroller, axis);
#else
return NULL;
#endif
}
/* vi: set ts=4 sw=4 expandtab: */

View File

@ -1006,11 +1006,27 @@ HIDAPI_DriverSwitch_ActuallyRumbleJoystick(SDL_DriverSwitch_Context *ctx, Uint16
*
* More information about these values can be found here:
* https://github.com/dekuNukem/Nintendo_Switch_Reverse_Engineering/blob/master/rumble_data_table.md
*
* The switch's rumble doesn't act like a traditional controller with two separate motors attached to
* different sized weights. Instead, the two values are like two sine waves that get added together.
* You can play around with different combinations here https://www.desmos.com/calculator/0lqas9aq89
* There's a fairly narrow frequency range around 100-250Hz that really shakes the controller,
* everything else is quite weak. To get a low frequency rumble, you can offset two frequencies
* by a target low rumble frequency, which gets you a very noticeable variation in amplitude.
* (It'll be much clearer if you click that link and play around a bit)
* I picked 0xA4 and 0x3E based on a sweep of values ~40hz apart, because they produced the least rattle
* in my controller. This may not extend to other Switch controllers, however.
*/
const Uint16 k_usHighFreq = 0x0074;
const Uint8 k_ucHighFreqAmp = EncodeRumbleHighAmplitude(high_frequency_rumble);
const Uint8 k_ucLowFreq = 0x3D;
const Uint16 k_usLowFreqAmp = EncodeRumbleLowAmplitude(low_frequency_rumble);
/* Maximum low frequency is reached when both values are the same */
/* Maximum high frequency is reached with one value at zero */
const Uint32 lowOutput = low_frequency_rumble + high_frequency_rumble;
const Uint16 highOutput = low_frequency_rumble;
const Uint16 k_usHighFreq = 0xA4; /* ~194.4Hz */
const Uint8 k_ucHighFreqAmp = EncodeRumbleHighAmplitude(highOutput);
const Uint8 k_ucLowFreq = 0x3E; /* ~153.2Hz */
const Uint16 k_usLowFreqAmp = EncodeRumbleLowAmplitude(SDL_min(lowOutput, SDL_MAX_UINT16));
if (low_frequency_rumble || high_frequency_rumble) {
EncodeRumble(&ctx->m_RumblePacket.rumbleData[0], k_usHighFreq, k_ucHighFreqAmp, k_ucLowFreq, k_usLowFreqAmp);

View File

@ -1585,7 +1585,7 @@ GetDirectionalPadForController(GCController *controller)
static char elementName[256];
const char *
SDL_GameControllerGetAppleSFSymbolsNameForButton(SDL_GameController *gamecontroller, SDL_GameControllerButton button)
IOS_GameControllerGetAppleSFSymbolsNameForButton(SDL_GameController *gamecontroller, SDL_GameControllerButton button)
{
elementName[0] = '\0';
#if defined(SDL_JOYSTICK_MFI) && defined(ENABLE_PHYSICAL_INPUT_PROFILE)
@ -1697,9 +1697,8 @@ SDL_GameControllerGetAppleSFSymbolsNameForButton(SDL_GameController *gamecontrol
return elementName;
}
const char *
SDL_GameControllerGetAppleSFSymbolsNameForAxis(SDL_GameController *gamecontroller, SDL_GameControllerAxis axis)
IOS_GameControllerGetAppleSFSymbolsNameForAxis(SDL_GameController *gamecontroller, SDL_GameControllerAxis axis)
{
elementName[0] = '\0';
#if defined(SDL_JOYSTICK_MFI) && defined(ENABLE_PHYSICAL_INPUT_PROFILE)
@ -1739,7 +1738,6 @@ SDL_GameControllerGetAppleSFSymbolsNameForAxis(SDL_GameController *gamecontrolle
}
SDL_JoystickDriver SDL_IOS_JoystickDriver =
{
IOS_JoystickInit,