Skip to content

Commit 17125c2

Browse files
authored
Merge pull request #5 from DataNext27/dev
Partial rework from dev
2 parents 114a225 + b797aef commit 17125c2

File tree

68 files changed

+2239
-1655
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+2239
-1655
lines changed

README.md

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,44 +11,47 @@
1111
> This library is **NOT** affiliated in any way with **SteelSeries**
1212
> I've made it because it was interesting and funny to do, also I wanted to share this project for people to use it for their own projects
1313
14-
This library allows you to take control over the SteelSeries GG app.
14+
This library allows you to take control over the SteelSeries GG app (only Sonar for now).
1515

16-
The API is available via a [nuget package](https://www.nuget.org/packages/Steelseries-NET-API).
16+
The library is available via a [nuget package](https://www.nuget.org/packages/Steelseries-NET-API).
1717
It is also available in the [Releases](https://github.com/mpaperno/SteelSeries-NET-API/releases) tab as a .zip archive for each supported .NET version.
1818

1919
## Features
2020
- Full Sonar control
21+
- Mode
22+
- Volume
23+
- Mute
24+
- ChatMix
25+
- Configs (Can't edit a config)
26+
- Playback Devices
27+
- Streamer mode Personal & Stream Mixes
28+
- Streamer mode Audience Monitoring
2129

2230
## Getting Started
2331
To get started, you only need to create a Sonar Object.
2432
`````csharp
2533
// Create Sonar object
2634
SonarBridge sonarManager = new SonarBridge();
2735

36+
// Wait for GG to start before continuing
37+
sonarManager.WaitUntilSteelSeriesStarted();
38+
2839
// Wait for sonar to start before continuing
2940
sonarManager.WaitUntilSonarStarted();
3041

3142
// Start listening to Sonar Events (optional and require admin rights)
3243
sonarManager.StartListener();
3344
sonarManager.SonarEventManager.OnSonarModeChange += OnModeChangeHandler; // Register event
3445
35-
Mode currentMode = sonarManager.GetMode(); // Returns the current mode
36-
sonarManager.SetVolume(0.5, Device.Game); // Set the Game Device volume
46+
Mode currentMode = sonarManager.Mode.Get(); // Returns the current mode
47+
sonarManager.VolumeSettings.SetVolume(0.5, Device.Game); // Set the Game Device volume
3748
...
3849
`````
39-
For more example, you can check the [Tests](https://github.com/DataNext27/SteelSeries-NET-API/tree/main/SteelSeriesAPI.Tests) and the [Sample](https://github.com/DataNext27/SteelSeries-NET-API/tree/main/SteelSeriesAPI.Sample) folders.
50+
For more example, you can check the [Sample](SteelSeriesAPI.Sample/Program.cs) and the [Tests](SteelSeriesAPI.Tests/Program.cs) folders.
4051
If you need any sort of Documentation, go check the [Repo's Wiki](https://github.com/DataNext27/SteelSeries-NET-API/wiki) for more information.
4152

42-
### Some Vocabulary
43-
- Mode : Classic/Stream
44-
- Device : Master/Game/Chat/Media/Aux/Mic
45-
- Channel : *(Streamer mode)* Monitoring/Stream
46-
- Audio Configs : It's in the name
47-
- Redirection States : *(Streamer mode)* Button above sliders to un/mute a channel of a device
48-
- Redirection Device : Device where the sound got by GG is redirected (your headset for example)
49-
5053
## Todo
51-
(Actually not possible, maybe one day i guess :/ )
54+
(Actually not planned as not possible, maybe one day I guess :/ )
5255
- Moments
5356
- Engine
5457
- Settings

SteelSeriesAPI.Sample/Program.cs

Lines changed: 84 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using SteelSeriesAPI.Events;
1+
using SteelSeriesAPI.Sonar;
2+
using SteelSeriesAPI.Sonar.Events;
23
using SteelSeriesAPI.Sonar.Enums;
34
using SteelSeriesAPI.Sonar.Models;
45

@@ -11,81 +12,97 @@ static void Main(string[] args)
1112
// Create a Sonar Object to control Sonar
1213
SonarBridge sonarManager = new SonarBridge();
1314

15+
// Wait until GG is started before continuing
16+
sonarManager.WaitUntilSteelSeriesStarted();
1417
// Wait until GG and Sonar are both started before continuing
1518
sonarManager.WaitUntilSonarStarted();
1619

17-
// If I want to detect changes made on GG, I can use the listener (require admin rights)
20+
// If you want to detect changes made on GG, you can use the listener (require admin rights)
1821
sonarManager.StartListener();
19-
// Then I register the events I want (I've put them all to demonstrate)
20-
sonarManager.SonarEventManager.OnSonarModeChange += OnModeChangeHandler; // When the mode is change
21-
sonarManager.SonarEventManager.OnSonarVolumeChange += OnVolumeChangeHandler; // When the volume of a Sonar Device or Channel is changed
22-
sonarManager.SonarEventManager.OnSonarMuteChange += OnMuteChangeHandler; // When a Sonar Device or Channel is muted or unmuted
23-
sonarManager.SonarEventManager.OnSonarConfigChange += OnConfigChangeHandler; // When a new config is set to a Sonar Device
24-
sonarManager.SonarEventManager.OnSonarChatMixChange += OnChatMixChangeHandler; // When the ChatMix value is changed
25-
sonarManager.SonarEventManager.OnSonarRedirectionDeviceChange += OnRedirectionDeviceChangeHandler; // When the Redirection Device of a Sonar Device is changed
26-
sonarManager.SonarEventManager.OnSonarRedirectionStateChange += OnRedirectionStateChangeHandler; // When the Redirection of a Sonar Channel is muted or unmuted
27-
sonarManager.SonarEventManager.OnSonarAudienceMonitoringChange += OnAudienceMonitoringChangeHandler; // When the Audience Monitoring is muted or unmuted
22+
// Then you register the events you need (I've put them all to demonstrate)
23+
sonarManager.Events.OnSonarModeChange += OnModeChangeHandler; // When the mode gets changed
24+
sonarManager.Events.OnSonarVolumeChange += OnVolumeChangeHandler; // When the volume of a Sonar Channel or Mix gets changed
25+
sonarManager.Events.OnSonarMuteChange += OnMuteChangeHandler; // When a Sonar Channel or Mix gets muted or unmuted
26+
sonarManager.Events.OnSonarConfigChange += OnConfigChangeHandler; // When a new config is set to a Sonar Channel
27+
sonarManager.Events.OnSonarChatMixChange += OnChatMixChangeHandler; // When the ChatMix value gets changed
28+
sonarManager.Events.OnSonarPlaybackDeviceChange += OnPlaybackDeviceChangeHandler; // When the Redirection Channel of a Sonar Channel is changed
29+
sonarManager.Events.OnSonarRoutedProcessChange += OnRoutedProcessChangeHandler; // When a routed process gets routed to a new Sonar Channel
30+
sonarManager.Events.OnSonarMixChange += OnMixChangeHandler; // When the Mix of a Sonar Channem gets activated or deactivated
31+
sonarManager.Events.OnSonarAudienceMonitoringChange += OnAudienceMonitoringChangeHandler; // When the Audience Monitoring gets muted or unmuted
2832

2933
// Get current sonar mode
30-
Mode mode = sonarManager.GetMode();
34+
Mode mode = sonarManager.Mode.Get();
3135
// Change sonar mode to Streamer
32-
sonarManager.SetMode(Mode.Streamer);
36+
sonarManager.Mode.Set(Mode.STREAMER);
3337

34-
// Get current volume of a Sonar Device
35-
double vol = sonarManager.GetVolume(Device.Media);
3638
// Get current volume of a Sonar Channel
37-
double vol2 = sonarManager.GetVolume(Device.Chat, Channel.Stream);
38-
// Set the volume of a Sonar Device
39-
sonarManager.SetVolume(0.75, Device.Game);
39+
double vol = sonarManager.VolumeSettings.GetVolume(Channel.MEDIA);
40+
// Get current volume of a Sonar Mix
41+
double vol2 = sonarManager.VolumeSettings.GetVolume(Channel.CHAT, Mix.STREAM);
4042
// Set the volume of a Sonar Channel
41-
sonarManager.SetVolume(0.1, Device.Media, Channel.Monitoring);
43+
sonarManager.VolumeSettings.SetVolume(0.75, Channel.GAME);
44+
// Set the volume of a Sonar Mix
45+
sonarManager.VolumeSettings.SetVolume(0.1, Channel.MEDIA, Mix.PERSONAL);
4246

43-
// Get the current mute state of a Sonar Device
44-
bool state = sonarManager.GetMute(Device.Chat);
45-
bool state2 = sonarManager.GetMute(Device.Master, Channel.Monitoring);
46-
// Set the current mute state of a Sonar Device
47-
sonarManager.SetMute(true, Device.Chat); // Mute chat
47+
// Get the current mute state of a Sonar Channel
48+
bool state = sonarManager.VolumeSettings.GetMute(Channel.CHAT);
49+
bool state2 = sonarManager.VolumeSettings.GetMute(Channel.MASTER, Mix.PERSONAL);
50+
// Set the current mute state of a Sonar Channel
51+
sonarManager.VolumeSettings.SetMute(true, Channel.CHAT); // Mute chat
4852

4953
// Get audio configs
50-
List<SonarAudioConfiguration> allConfigs = sonarManager.GetAllAudioConfigurations().ToList(); // Return all configs (A SonarAudioConfiguration contains an Id, a Name and an AssociatedDevice)
51-
List<SonarAudioConfiguration> mediaConfigs = sonarManager.GetAudioConfigurations(Device.Media).ToList(); // Return all configs of a Sonar Device
52-
SonarAudioConfiguration currentConfig = sonarManager.GetSelectedAudioConfiguration(Device.Media); // Return the currently used config of a Sonar Device
53-
// Set the config of a Sonar Device
54-
sonarManager.SetConfig(Device.Media, "Podcast"); // Using its name
55-
sonarManager.SetConfig(currentConfig.Id); // Using its id (no need to precise which Sonar Device, one id goes to one Sonar Device)
54+
List<SonarAudioConfiguration> allConfigs = sonarManager.Configurations.GetAllAudioConfigurations().ToList(); // Return all configs (A SonarAudioConfiguration contains an Id, a Name and an AssociatedChannel)
55+
List<SonarAudioConfiguration> mediaConfigs = sonarManager.Configurations.GetAudioConfigurations(Channel.MEDIA).ToList(); // Return all configs of a Sonar Channel
56+
SonarAudioConfiguration currentConfig = sonarManager.Configurations.GetSelectedAudioConfiguration(Channel.MEDIA); // Return the currently used config of a Sonar Channel
57+
// Set the config of a Sonar Channel
58+
sonarManager.Configurations.SetConfigByName(Channel.MEDIA, "Podcast"); // Using its name
59+
sonarManager.Configurations.SetConfig(currentConfig); // Using directly the config object
60+
sonarManager.Configurations.SetConfig(currentConfig.Id); // Or Using its id (no need to precise which Sonar Channel, one id = one config = one Sonar Channel)
5661

5762
// Get ChatMix info
58-
double chatMixBalance = sonarManager.GetChatMixBalance(); // The ChatMix value between -1 and 1
59-
bool chatMixState = sonarManager.GetChatMixState(); // If ChatMix is usable or not
63+
double chatMixBalance = sonarManager.ChatMix.GetBalance(); // The ChatMix value between -1 and 1
64+
bool chatMixState = sonarManager.ChatMix.GetState(); // If ChatMix is usable or not
6065
// Change ChatMix value
61-
sonarManager.SetChatMixBalance(0.5); // 0.5 is halfway to Chat
66+
sonarManager.ChatMix.SetBalance(0.5); // 0.5 is halfway to Chat
6267

63-
// Get redirection devices (Windows devices)
64-
List<RedirectionDevice> inputDevices = sonarManager.GetRedirectionDevices(Direction.Input).ToList(); // Input devices (Mics...)
65-
sonarManager.GetRedirectionDevices(Direction.Output); // Output devices (headset, speakers...)
66-
sonarManager.GetRedirectionDeviceFromId("{0.0.0.00000000}.{192b4f5b-9cc1-4eb2-b752-c5e15b99d548}"); // Get a redirection device from its id
67-
RedirectionDevice gameRDevice = sonarManager.GetClassicRedirectionDevice(Device.Game); // Give currently used Redirection Device for classic mode
68-
sonarManager.GetStreamRedirectionDevice(Channel.Monitoring); // Give currently used Redirection Device for Streamer mode
69-
sonarManager.GetStreamRedirectionDevice(Device.Mic); // Give currently used Redirection Device for Mic in streamer mode
70-
// Change redirection devices using their id
71-
sonarManager.SetClassicRedirectionDevice(gameRDevice.Id, Device.Game);
72-
sonarManager.SetStreamRedirectionDevice(gameRDevice.Id, Channel.Monitoring);
73-
sonarManager.SetStreamRedirectionDevice(inputDevices[0].Id, Device.Mic);
68+
// Get playback devices (Windows devices)
69+
List<PlaybackDevice> playbackDevices = sonarManager.PlaybackDevices.GetAllPlaybackDevices().ToList(); // All playback devices
70+
List<PlaybackDevice> inputDevices = sonarManager.PlaybackDevices.GetInputPlaybackDevices().ToList(); // Input devices (Mics...)
71+
List<PlaybackDevice> outputDevices = sonarManager.PlaybackDevices.GetOutputPlaybackDevices().ToList(); // Output devices (headset, speakers...)
72+
PlaybackDevice gameDevice = sonarManager.PlaybackDevices.GetPlaybackDevice(Channel.GAME); // Get the currently used Playback device of a Channel
73+
sonarManager.PlaybackDevices.GetPlaybackDevice(Mix.STREAM); // Get the currently used Playback device of a Mix
74+
sonarManager.PlaybackDevices.GetPlaybackDevice(Channel.MIC, Mode.STREAMER); // Get the currently used Playback device of the streamer mode Mic
75+
sonarManager.PlaybackDevices.GetPlaybackDevice("{0.0.0.00000000}.{192b4f5b-9cc1-4eb2-b752-c5e15b99d548}"); // Get a playback device from its id
76+
// Change playback devices
77+
sonarManager.PlaybackDevices.SetPlaybackDevice(gameDevice, Channel.GAME); // Using the playback device object
78+
sonarManager.PlaybackDevices.SetPlaybackDevice("{0.0.0.00000000}.{192b4f5b-9cc1-4eb2-b752-c5e15b99d548}", Channel.AUX); // Using the playback device ID
7479

75-
// Get the redirections states
76-
sonarManager.GetRedirectionState(Device.Media, Channel.Monitoring);
77-
// Change the redirections states
78-
sonarManager.SetRedirectionState(false, Device.Media, Channel.Monitoring);
80+
// Get the mixes states
81+
sonarManager.Mix.GetState(Channel.MEDIA, Mix.PERSONAL);
82+
// Change the mixes states
83+
sonarManager.Mix.Activate(Channel.MEDIA, Mix.PERSONAL);
84+
sonarManager.Mix.Deactivate(Channel.CHAT, Mix.STREAM);
85+
sonarManager.Mix.SetState(false, Channel.MEDIA, Mix.PERSONAL); // Same as deactivating here
7986

8087
// Get Audience Monitoring state
81-
sonarManager.GetAudienceMonitoringState();
88+
sonarManager.AudienceMonitoring.GetState();
8289
// Change Audience Monitoring state
83-
sonarManager.SetAudienceMonitoringState(false);
84-
85-
// Get routed processes of a Sonar Device
86-
List<RoutedProcess> mediaProcesses = sonarManager.GetRoutedProcess(Device.Media).ToList(); // Will surely return apps like Google Chrome or Spotify
87-
// Route a process to a Sonar Device using its process ID (pid)
88-
sonarManager.SetProcessToDeviceRouting(mediaProcesses[0].PId, Device.Media);
90+
sonarManager.AudienceMonitoring.SetState(false);
91+
92+
// Get all routed processes whether they are active, inactive or expired
93+
List<RoutedProcess> allProcesses = sonarManager.RoutedProcesses.GetAllRoutedProcesses().ToList();
94+
// Get all active routed processes (currently in use)
95+
List<RoutedProcess> allActiveProcesses = sonarManager.RoutedProcesses.GetAllActiveRoutedProcesses().ToList();
96+
// Same but for a specific channel
97+
List<RoutedProcess> gameProcesses = sonarManager.RoutedProcesses.GetRoutedProcesses(Channel.GAME).ToList(); // Will surely return apps like Minecraft...
98+
List<RoutedProcess> mediaActiveProcesses = sonarManager.RoutedProcesses.GetActiveRoutedProcesses(Channel.MEDIA).ToList(); // Will surely return apps like Google Chrome or Spotify
99+
// Same idea but by giving the ID of an audio process
100+
sonarManager.RoutedProcesses.GetRoutedProcessesById(2063);
101+
sonarManager.RoutedProcesses.GetActiveRoutedProcessesById(10548);
102+
// Route a process to a Sonar Channel using the RoutedProcess object
103+
sonarManager.RoutedProcesses.RouteProcessToChannel(mediaActiveProcesses[0], Channel.AUX);
104+
// Route a process to a Sonar Channel using its process ID (pid)
105+
sonarManager.RoutedProcesses.RouteProcessToChannel(15482, Channel.MEDIA);
89106
}
90107

91108
static void OnModeChangeHandler(object? sender, SonarModeEvent eventArgs)
@@ -95,12 +112,12 @@ static void OnModeChangeHandler(object? sender, SonarModeEvent eventArgs)
95112

96113
static void OnVolumeChangeHandler(object? sender, SonarVolumeEvent eventArgs)
97114
{
98-
Console.WriteLine("Received Volume Event : " + eventArgs.Volume + ", " + eventArgs.Mode + ", " + eventArgs.Device + ", " + eventArgs.Channel);
115+
Console.WriteLine("Received Volume Event : " + eventArgs.Volume + ", " + eventArgs.Mode + ", " + eventArgs.Channel + ", " + eventArgs.Mix);
99116
}
100117

101118
static void OnMuteChangeHandler(object? sender, SonarMuteEvent eventArgs)
102119
{
103-
Console.WriteLine("Received Mute Event : " + eventArgs.Muted + ", " + eventArgs.Mode + ", " + eventArgs.Device + ", " + eventArgs.Channel);
120+
Console.WriteLine("Received Mute Event : " + eventArgs.Muted + ", " + eventArgs.Mode + ", " + eventArgs.Channel + ", " + eventArgs.Mix);
104121
}
105122

106123
static void OnConfigChangeHandler(object? sender, SonarConfigEvent eventArgs)
@@ -113,18 +130,23 @@ static void OnChatMixChangeHandler(object? sender, SonarChatMixEvent eventArgs)
113130
Console.WriteLine("Received ChatMix Event : " + eventArgs.Balance);
114131
}
115132

116-
static void OnRedirectionDeviceChangeHandler(object? sender, SonarRedirectionDeviceEvent eventArgs)
133+
static void OnPlaybackDeviceChangeHandler(object? sender, SonarPlaybackDeviceEvent eventArgs)
134+
{
135+
Console.WriteLine("Received Redirection Channel Event : " + eventArgs.PlaybackDeviceId + ", " + eventArgs.Mode + ", " + eventArgs.Channel + ", " + eventArgs.Mix);
136+
}
137+
138+
static void OnRoutedProcessChangeHandler(object? sender, SonarRoutedProcessEvent eventArgs)
117139
{
118-
Console.WriteLine("Received Redirection Device Event : " + eventArgs.RedirectionDeviceId + ", " + eventArgs.Mode + ", " + eventArgs.Device + ", " + eventArgs.Channel);
140+
Console.WriteLine("Received Routed Process Event : " + eventArgs.ProcessId + ", " + eventArgs.NewChannel);
119141
}
120142

121-
static void OnRedirectionStateChangeHandler(object? sender, SonarRedirectionStateEvent eventArgs)
143+
static void OnMixChangeHandler(object? sender, SonarMixEvent eventArgs)
122144
{
123-
Console.WriteLine("Received Redirection State Event : " + eventArgs.State + ", " + eventArgs.Device + ", " + eventArgs.Channel);
145+
Console.WriteLine("Received Redirection State Event : " + eventArgs.NewState + ", " + eventArgs.Channel + ", " + eventArgs.Mix);
124146
}
125147

126148
static void OnAudienceMonitoringChangeHandler(object? sender, SonarAudienceMonitoringEvent eventArgs)
127149
{
128-
Console.WriteLine("Received Audience Monitoring Event : " + eventArgs.AudienceMonitoringState);
150+
Console.WriteLine("Received Audience Monitoring Event : " + eventArgs.NewState);
129151
}
130152
}

0 commit comments

Comments
 (0)