-
Notifications
You must be signed in to change notification settings - Fork 79
Expand file tree
/
Copy pathDualSenseRGBDevice.cs
More file actions
65 lines (53 loc) · 2.39 KB
/
DualSenseRGBDevice.cs
File metadata and controls
65 lines (53 loc) · 2.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
using RGB.NET.Core;
namespace RGB.NET.Devices.PlayStation;
/// <inheritdoc />
/// <summary>
/// Represents a Sony DualSense controller (PS5 / DualSense Edge).
/// </summary>
public sealed class DualSenseRGBDevice : AbstractRGBDevice<PlayStationDeviceInfo>
{
#region Properties & Fields
private readonly DualSenseUpdateQueue _updateQueue;
#endregion
#region Constructors
internal DualSenseRGBDevice(PlayStationDeviceInfo deviceInfo, DualSenseUpdateQueue updateQueue)
: base(deviceInfo, updateQueue)
{
_updateQueue = updateQueue;
InitializeLayout();
}
#endregion
#region Methods
// DualSense LED layout (left→right when looking at the controller):
// - The lightbar runs along the bottom edge of the touchpad in two
// mirrored strips. Modelled as one wide rectangle (Custom1).
// - The 5 player indicator LEDs sit in a row directly below the
// touchpad. Bit 0 = leftmost, bit 4 = rightmost from the player's
// POV (matches Linux's player_leds bit ordering).
//
// Note: the mic-mute LED is intentionally NOT exposed. The controller
// firmware drives that LED to track mic-mute toggle state — pressing
// the mute button mutes the microphone AND lights the LED, regardless
// of any host involvement. Taking host control of the LED would only
// suppress that visual feedback for an action that still happens, so
// we leave the firmware default in place. See DualSenseUpdateQueue
// header for the protocol detail (we deliberately don't set the
// MIC_MUTE_LED_CONTROL_ENABLE bit in valid_flag1).
//
// Coordinates are arbitrary visual approximations for layout consumers —
// they don't drive any hardware addressing.
private void InitializeLayout()
{
Led? lightbar = AddLed(LedId.Custom1, new Point(0, 0), new Size(80, 8));
if (lightbar != null) lightbar.Shape = Shape.Rectangle;
// Five player indicator dots, evenly spaced beneath the lightbar.
for (int i = 0; i < 5; i++)
{
Led? led = AddLed((LedId)(LedId.Custom2 + i), new Point(20 + (i * 12), 16), new Size(6));
if (led != null) led.Shape = Shape.Circle;
}
}
internal void SuspendWrites() => _updateQueue.SuspendWrites();
internal void Shutdown(bool sendOffFrame = true) => _updateQueue.Shutdown(sendOffFrame);
#endregion
}