Compare commits

...

22 Commits

Author SHA1 Message Date
Otozinclus
892c9cd14c Merge 72d5af8b46 into c06f16c5e6 2025-01-24 01:02:43 +00:00
Evan Husted
72d5af8b46 Update LED as its changed in the UI 2025-01-23 19:02:35 -06:00
Evan Husted
cfe42563f2 Add the LED functionality to the base IGamepad interface 2025-01-23 18:33:52 -06:00
Evan Husted
5712e83a11 UI: enable LED changing 2025-01-23 17:22:25 -06:00
Evan Husted
8e642f0fe9 Merge branch 'master' into Change-Controller-LED-Color 2025-01-23 17:19:15 -06:00
Evan Husted
5276991517 Update SDL2Gamepad.cs 2025-01-22 22:37:03 -06:00
Evan Husted
898153ae13 Update SDL2Gamepad.cs 2025-01-22 22:35:09 -06:00
mika
96e9e3611d move logic around 2025-01-23 05:29:18 +01:00
mika
9aa834c268 maybe this works 2025-01-23 05:02:11 +01:00
mika
97dfeae99f test2 2025-01-23 04:24:01 +01:00
mika
740e35872d test 2025-01-23 03:40:45 +01:00
mika
2c4236f733 test 2025-01-23 03:39:33 +01:00
mika
e945565259 just testing if git works 2025-01-23 03:38:00 +01:00
mika
bdaaddb591 just testing if git is working 2025-01-23 03:38:00 +01:00
Otozinclus
488b09f974 Check if controller has a controllable LED 2025-01-23 03:38:00 +01:00
Evan Husted
f4c3a2e487 fix formatting & styling 2025-01-23 03:37:59 +01:00
Otozinclus
eff11f52a8 Change controller LED color
This changes the controller LED color. Now I need to add the option to change it in the settings
2025-01-23 03:37:59 +01:00
mika
c21aa86a7b just testing if git works 2025-01-23 00:09:07 +01:00
mika
861531f431 just testing if git is working 2025-01-23 00:06:24 +01:00
Otozinclus
6c0526c59f Check if controller has a controllable LED 2025-01-22 23:18:41 +01:00
Evan Husted
e861204078 fix formatting & styling 2025-01-22 16:04:57 -06:00
Otozinclus
8904397685 Change controller LED color
This changes the controller LED color. Now I need to add the option to change it in the settings
2025-01-22 21:55:53 +01:00
10 changed files with 70 additions and 4 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 SDL2;
using System;
using System.Collections.Generic;
@@ -86,7 +87,7 @@ namespace Ryujinx.Input.SDL2
Id = driverId;
Features = GetFeaturesFlag();
_triggerThreshold = 0.0f;
// Enable motion tracking
if (Features.HasFlag(GamepadFeaturesFlag.Motion))
{
@@ -102,6 +103,17 @@ namespace Ryujinx.Input.SDL2
}
}
public void SetLed(uint packedRgb)
{
if (!Features.HasFlag(GamepadFeaturesFlag.Led)) return;
byte red = (byte)(packedRgb >> 16);
byte green = (byte)(packedRgb >> 8);
byte blue = (byte)(packedRgb % 256);
SDL_GameControllerSetLED(_gamepadHandle, red, green, blue);
}
private GamepadFeaturesFlag GetFeaturesFlag()
{
GamepadFeaturesFlag result = GamepadFeaturesFlag.None;
@@ -220,6 +232,9 @@ namespace Ryujinx.Input.SDL2
{
_configuration = (StandardControllerInputConfig)configuration;
if (Features.HasFlag(GamepadFeaturesFlag.Led) && _configuration.Led.EnableLed)
SetLed(_configuration.Led.LedColor);
_buttonsUserMapping.Clear();
// First update sticks

View File

@@ -1,5 +1,6 @@
using Ryujinx.Common.Configuration.Hid;
using Ryujinx.Common.Configuration.Hid.Keyboard;
using Ryujinx.Common.Logging;
using System;
using System.Collections.Generic;
using System.Numerics;
@@ -385,6 +386,11 @@ namespace Ryujinx.Input.SDL2
}
}
public void SetLed(uint packedRgb)
{
Logger.Info?.Print(LogClass.UI, "SetLed called on an SDL2Keyboard");
}
public void SetTriggerThreshold(float triggerThreshold)
{
// No operations

View File

@@ -1,4 +1,5 @@
using Ryujinx.Common.Configuration.Hid;
using Ryujinx.Common.Logging;
using System;
using System.Drawing;
using System.Numerics;
@@ -76,6 +77,11 @@ namespace Ryujinx.Input.SDL2
throw new NotImplementedException();
}
public void SetLed(uint packedRgb)
{
Logger.Info?.Print(LogClass.UI, "SetLed called on an SDL2Mouse");
}
public void SetTriggerThreshold(float triggerThreshold)
{
throw new NotImplementedException();

View File

@@ -65,6 +65,13 @@ namespace Ryujinx.Input
/// <param name="configuration">The configuration of the gamepad</param>
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>
/// Starts a rumble effect on the gamepad.
/// </summary>

View File

@@ -1,5 +1,6 @@
using Ryujinx.Common.Configuration.Hid;
using Ryujinx.Common.Configuration.Hid.Keyboard;
using Ryujinx.Common.Logging;
using Ryujinx.Input;
using System;
using System.Collections.Generic;
@@ -143,6 +144,11 @@ namespace Ryujinx.Ava.Input
}
}
public void SetLed(uint packedRgb)
{
Logger.Info?.Print(LogClass.UI, "SetLed called on an AvaloniaKeyboard");
}
public void SetTriggerThreshold(float triggerThreshold) { }
public void Rumble(float lowFrequency, float highFrequency, uint durationMs) { }

View File

@@ -1,4 +1,5 @@
using Ryujinx.Common.Configuration.Hid;
using Ryujinx.Common.Logging;
using Ryujinx.Input;
using System;
using System.Drawing;
@@ -74,6 +75,11 @@ namespace Ryujinx.Ava.Input
throw new NotImplementedException();
}
public void SetLed(uint packedRgb)
{
Logger.Info?.Print(LogClass.UI, "SetLed called on an AvaloniaMouse");
}
public void SetTriggerThreshold(float triggerThreshold)
{
throw new NotImplementedException();

View File

@@ -1,5 +1,6 @@
using Avalonia.Svg.Skia;
using CommunityToolkit.Mvvm.ComponentModel;
using FluentAvalonia.UI.Controls;
using Ryujinx.Ava.UI.Models.Input;
using Ryujinx.Ava.UI.Views.Input;

View File

@@ -69,8 +69,7 @@ namespace Ryujinx.Ava.UI.ViewModels.Input
public bool IsRight { get; set; }
public bool IsLeft { get; set; }
public bool HasLed => false; //temporary
//SelectedGamepad.Features.HasFlag(GamepadFeaturesFlag.Led);
public bool HasLed => SelectedGamepad.Features.HasFlag(GamepadFeaturesFlag.Led);
public bool IsModified { get; set; }
public event Action NotifyChangesEvent;

View File

@@ -429,7 +429,7 @@
</StackPanel>
</StackPanel>
</Border>
<!-- Motion + Rumble -->
<!-- Motion, Rumble, LED -->
<StackPanel
Margin="0,10,0,0"
Spacing="5"
@@ -514,6 +514,8 @@
UseColorWheel="False"
ShowAcceptDismissButtons="False"
IsAlphaEnabled="False"
AttachedToVisualTree="ColorPickerButton_OnAttachedToVisualTree"
ColorChanged="ColorPickerButton_OnColorChanged"
Color="{Binding Config.LedColor, Mode=TwoWay}">
</ui:ColorPickerButton>
</Grid>

View File

@@ -4,6 +4,7 @@ using Avalonia.Controls.Primitives;
using Avalonia.Input;
using Avalonia.Interactivity;
using Avalonia.LogicalTree;
using FluentAvalonia.UI.Controls;
using Ryujinx.Ava.UI.Helpers;
using Ryujinx.Ava.UI.ViewModels.Input;
using Ryujinx.Common.Configuration.Hid.Controller;
@@ -234,5 +235,22 @@ namespace Ryujinx.Ava.UI.Views.Input
_currentAssigner?.Cancel();
_currentAssigner = null;
}
private void ColorPickerButton_OnColorChanged(ColorPickerButton sender, ColorButtonColorChangedEventArgs args)
{
if (!args.NewColor.HasValue) return;
if (DataContext is not ControllerInputViewModel cVm) return;
if (!cVm.Config.EnableLedChanging) return;
cVm.ParentModel.SelectedGamepad.SetLed(args.NewColor.Value.ToUInt32());
}
private void ColorPickerButton_OnAttachedToVisualTree(object sender, VisualTreeAttachmentEventArgs e)
{
if (DataContext is not ControllerInputViewModel cVm) return;
if (!cVm.Config.EnableLedChanging) return;
cVm.ParentModel.SelectedGamepad.SetLed(cVm.Config.LedColor.ToUInt32());
}
}
}