internal static void AddDevice(int deviceId) { IntPtr device = SDLController.Open(deviceId); IntPtr hapticDevice = SDL.Haptic.OpenFromJoystick(SDLController.GetJoystick(device)); int hapticType = 0; var id = 0; while (GamePads.ContainsKey(id)) { id++; } if (hapticDevice != IntPtr.Zero) { try { if (SDL.Haptic.EffectSupported(hapticDevice, ref _hapticLeftRightEffect) == 1) { SDL.Haptic.NewEffect(hapticDevice, ref _hapticLeftRightEffect); hapticType = 1; } else if (SDL.Haptic.RumbleSupported(hapticDevice) == 1) { SDL.Haptic.RumbleInit(hapticDevice); hapticType = 2; } else { SDL.Haptic.Close(hapticDevice); } } catch { SDL.Haptic.Close(hapticDevice); hapticDevice = IntPtr.Zero; SDL.ClearError(); } } GamePads.Add(id, new GamePadInfo(device, hapticDevice, hapticType)); RefreshTranslationTable(); }
/// <inheritdoc/> public void Cleanup() { SDL.ClearError(); }