Input: Implement HD Rumble for compatible Nin devices (#40)

This PR addresses [this issue](https://github.com/Ryubing/Issues/issues/231) and implements HD Rumble for compatible Nin devices.
## New Features
- Add the option for Gamepads to implement HD Rumble
- Add the HD rumble capability to SDL3Gamepad and SDL3JoyCon when they meet certain requirements

Reviewed-on: https://git.ryujinx.app/projects/Ryubing/pulls/40
This commit is contained in:
cookieso
2026-05-13 23:57:30 +00:00
committed by sh0inx
parent 49891ba7af
commit e7aa6775af
5 changed files with 202 additions and 3 deletions

View File

@@ -1,6 +1,7 @@
using Ryujinx.Common.Configuration.Hid;
using Ryujinx.Common.Configuration.Hid.Controller;
using Ryujinx.Common.Logging;
using Ryujinx.HLE.HOS.Services.Hid;
using System;
using System.Collections.Generic;
using System.Numerics;
@@ -61,6 +62,8 @@ namespace Ryujinx.Input.SDL3
public GamepadFeaturesFlag Features { get; }
private SDL_Gamepad* _gamepadHandle;
private NpadHdRumble _hdRumble;
private enum JoyConType
{
@@ -76,6 +79,7 @@ namespace Ryujinx.Input.SDL3
public SDL3JoyCon(SDL_Gamepad* gamepadHandle, string driverId)
{
_gamepadHandle = gamepadHandle;
_hdRumble = NpadHdRumble.Create(gamepadHandle);
_buttonsUserMapping = new List<ButtonMappingEntry>(10);
Name = SDL_GetGamepadName(_gamepadHandle);
@@ -139,6 +143,10 @@ namespace Ryujinx.Input.SDL3
protected virtual void Dispose(bool disposing)
{
if (disposing && _hdRumble != null)
{
_hdRumble.Dispose();
}
if (disposing && _gamepadHandle != null)
{
SDL_CloseGamepad(_gamepadHandle);
@@ -156,6 +164,11 @@ namespace Ryujinx.Input.SDL3
{
}
public bool HDRumble(VibrationValue left, VibrationValue right)
{
return _hdRumble?.HdRumble(left, right) ?? false;
}
public void Rumble(float lowFrequency, float highFrequency, uint durationMs)
{