Commit a9cfac38353609eb93af14eddd0c9d4e15177980

Sam Lantinga 2020-06-09T10:47:23

Controller: Deadzone improvements

diff --git a/src/joystick/controller_type.h b/src/joystick/controller_type.h
index c044d2b..3b6fc4d 100644
--- a/src/joystick/controller_type.h
+++ b/src/joystick/controller_type.h
@@ -660,5 +660,31 @@ static SDL_INLINE const char *GuessControllerName( int nVID, int nPID )
 
 #undef MAKE_CONTROLLER_ID
 
+static inline int GetDefaultDeadzoneSizeForControllerType( EControllerType eControllerType )
+{
+	switch ( eControllerType )
+	{
+	case k_eControllerType_UnknownNonSteamController:
+	case k_eControllerType_XBoxOneController:
+	case k_eControllerType_XBox360Controller:
+	case k_eControllerType_AppleController:
+	case k_eControllerType_AndroidController:
+	case k_eControllerType_PS3Controller:
+		return 10000;
+	case k_eControllerType_SteamControllerV2:
+		return 8192;
+	case k_eControllerType_PS4Controller:
+		return 4096;
+	case k_eControllerType_SwitchJoyConLeft:
+	case k_eControllerType_SwitchJoyConRight:
+    case k_eControllerType_SwitchJoyConPair:
+		return 8192; // Actual dead-zone should be 15% of full-scale, but we use this to account for variances in 3rd-party controllers
+	case k_eControllerType_SwitchProController:
+		return 8192; // Actual dead-zone should be closer to 10% of full-scale, but we use this to account for variances in 3rd-party controllers
+	default:
+		return 8192;
+	}
+}
+
 #endif // CONSTANTS_H