aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.Input.SDL2/SDL2Gamepad.cs
diff options
context:
space:
mode:
authormpnico <mpnico@gmail.com>2021-08-05 00:39:40 +0200
committerGitHub <noreply@github.com>2021-08-05 00:39:40 +0200
commit70f79e689bc947313aab11c41e59928ce43be517 (patch)
treedb4aecd13e2895c650a6cf2cd84966ab06b44648 /Ryujinx.Input.SDL2/SDL2Gamepad.cs
parent46ffc81d90bd3a8f2d24c2997166d22f12ecbbb6 (diff)
Implement vibrations (#2468)
* First working vibration implementation * Fix Infinite Rumble in SDL2Mouse * Stop ignoring one vibValues every 2 * Remove RumbleInfinity as suggested * Reworked all the vibration handle / calculation * Revert HidVibrationDevicePosition changes * Add UI to enable and tune rumble * Remove some stub logs * Add PlayerIndex in rumble debug log * Fix all requested changes * Implements hid::GetVibrationDeviceInfo * Better implements HidVibrationValue.Equals/GetHashCode * Added requested changes from code review * Last fixes from review * Update configuration file version for rebase
Diffstat (limited to 'Ryujinx.Input.SDL2/SDL2Gamepad.cs')
-rw-r--r--Ryujinx.Input.SDL2/SDL2Gamepad.cs14
1 files changed, 13 insertions, 1 deletions
diff --git a/Ryujinx.Input.SDL2/SDL2Gamepad.cs b/Ryujinx.Input.SDL2/SDL2Gamepad.cs
index 26a808e4..0ccd8bb3 100644
--- a/Ryujinx.Input.SDL2/SDL2Gamepad.cs
+++ b/Ryujinx.Input.SDL2/SDL2Gamepad.cs
@@ -1,5 +1,6 @@
using Ryujinx.Common.Configuration.Hid;
using Ryujinx.Common.Configuration.Hid.Controller;
+using Ryujinx.Common.Logging;
using System;
using System.Collections.Generic;
using System.Numerics;
@@ -151,7 +152,18 @@ namespace Ryujinx.Input.SDL2
ushort lowFrequencyRaw = (ushort)(lowFrequency * ushort.MaxValue);
ushort highFrequencyRaw = (ushort)(highFrequency * ushort.MaxValue);
- SDL_GameControllerRumble(_gamepadHandle, lowFrequencyRaw, highFrequencyRaw, durationMs);
+ if (durationMs == uint.MaxValue)
+ {
+ SDL_GameControllerRumble(_gamepadHandle, lowFrequencyRaw, highFrequencyRaw, SDL_HAPTIC_INFINITY);
+ }
+ else if (durationMs > SDL_HAPTIC_INFINITY)
+ {
+ Logger.Error?.Print(LogClass.Hid, $"Unsupported rumble duration {durationMs}");
+ }
+ else
+ {
+ SDL_GameControllerRumble(_gamepadHandle, lowFrequencyRaw, highFrequencyRaw, durationMs);
+ }
}
}