Fixed non-Apple builds
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99
diff --git a/src/joystick/SDL_gamecontroller.c b/src/joystick/SDL_gamecontroller.c
index e6ae4fb..d65439b 100644
--- a/src/joystick/SDL_gamecontroller.c
+++ b/src/joystick/SDL_gamecontroller.c
@@ -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: */
diff --git a/src/joystick/hidapi/SDL_hidapi_switch.c b/src/joystick/hidapi/SDL_hidapi_switch.c
index 70fa710..f26ec24 100644
--- a/src/joystick/hidapi/SDL_hidapi_switch.c
+++ b/src/joystick/hidapi/SDL_hidapi_switch.c
@@ -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);
diff --git a/src/joystick/iphoneos/SDL_mfijoystick.m b/src/joystick/iphoneos/SDL_mfijoystick.m
index aa01657..74cb39b 100644
--- a/src/joystick/iphoneos/SDL_mfijoystick.m
+++ b/src/joystick/iphoneos/SDL_mfijoystick.m
@@ -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,