Add the LED functionality to the base IGamepad interface

This commit is contained in:
Evan Husted 2025-01-23 18:33:52 -06:00
parent 5712e83a11
commit cfe42563f2
6 changed files with 22 additions and 7 deletions

View File

@ -103,15 +103,15 @@ namespace Ryujinx.Input.SDL2
} }
} }
public void SetLedColor() public void SetLed(uint packedRgb)
{ {
if (!Features.HasFlag(GamepadFeaturesFlag.Led)) return;
if (!HasConfiguration) return; if (!HasConfiguration) return;
if (!_configuration.Led.EnableLed) return; if (!_configuration.Led.EnableLed) return;
uint _rawColor = _configuration.Led.LedColor; byte red = (byte)(packedRgb >> 16);
byte red = (byte)(_rawColor >> 16); byte green = (byte)(packedRgb >> 8);
byte green = (byte)(_rawColor >> 8); byte blue = (byte)(packedRgb % 256);
byte blue = (byte)(_rawColor % 256);
SDL_GameControllerSetLED(_gamepadHandle, red, green, blue); SDL_GameControllerSetLED(_gamepadHandle, red, green, blue);
} }
@ -235,7 +235,7 @@ namespace Ryujinx.Input.SDL2
_configuration = (StandardControllerInputConfig)configuration; _configuration = (StandardControllerInputConfig)configuration;
if (Features.HasFlag(GamepadFeaturesFlag.Led)) if (Features.HasFlag(GamepadFeaturesFlag.Led))
SetLedColor(); SetLed(_configuration.Led.LedColor);
_buttonsUserMapping.Clear(); _buttonsUserMapping.Clear();

View File

@ -385,6 +385,8 @@ namespace Ryujinx.Input.SDL2
} }
} }
public void SetLed(uint packedRgb) {}
public void SetTriggerThreshold(float triggerThreshold) public void SetTriggerThreshold(float triggerThreshold)
{ {
// No operations // No operations

View File

@ -76,6 +76,8 @@ namespace Ryujinx.Input.SDL2
throw new NotImplementedException(); throw new NotImplementedException();
} }
public void SetLed(uint packedRgb) {}
public void SetTriggerThreshold(float triggerThreshold) public void SetTriggerThreshold(float triggerThreshold)
{ {
throw new NotImplementedException(); throw new NotImplementedException();

View File

@ -65,6 +65,13 @@ namespace Ryujinx.Input
/// <param name="configuration">The configuration of the gamepad</param> /// <param name="configuration">The configuration of the gamepad</param>
void SetConfiguration(InputConfig configuration); void SetConfiguration(InputConfig configuration);
/// <summary>
/// Set the LED on the gamepad to a given color.
/// </summary>
/// <remarks>Does nothing on a controller without LED functionality.</remarks>
/// <param name="packedRgb">The packed RGB integer.</param>
void SetLed(uint packedRgb);
/// <summary> /// <summary>
/// Starts a rumble effect on the gamepad. /// Starts a rumble effect on the gamepad.
/// </summary> /// </summary>

View File

@ -143,6 +143,8 @@ namespace Ryujinx.Ava.Input
} }
} }
public void SetLed(uint packedRgb) { }
public void SetTriggerThreshold(float triggerThreshold) { } public void SetTriggerThreshold(float triggerThreshold) { }
public void Rumble(float lowFrequency, float highFrequency, uint durationMs) { } public void Rumble(float lowFrequency, float highFrequency, uint durationMs) { }

View File

@ -74,6 +74,8 @@ namespace Ryujinx.Ava.Input
throw new NotImplementedException(); throw new NotImplementedException();
} }
public void SetLed(uint packedRgb) { }
public void SetTriggerThreshold(float triggerThreshold) public void SetTriggerThreshold(float triggerThreshold)
{ {
throw new NotImplementedException(); throw new NotImplementedException();