Skip to content

Commit a13c2bc

Browse files
committed
Merge remote-tracking branch 'antonpup/dev' into LedLights
2 parents 1fcd2d3 + 762d8ad commit a13c2bc

15 files changed

+8700
-29
lines changed

Project-Aurora/Project-Aurora/Controls/ReorderableListBox.cs

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using System;
1+
using Aurora.Utils;
2+
using System;
23
using System.Collections;
34
using System.Collections.Generic;
45
using System.Collections.ObjectModel;
@@ -28,6 +29,11 @@ public class ReorderableListBox : ListBox {
2829
/// Used for drop index detection. Will not work properly if items are different heights.</summary>
2930
private double itemHeight = 0;
3031

32+
private ScrollViewer _scrollViewer;
33+
public ScrollViewer ScrollViewer => _scrollViewer ??= this.FindChildOfType<ScrollViewer>();
34+
35+
private Point ApplyScrollOffset(Point p) => new Point(p.X + ScrollViewer.HorizontalOffset, p.Y + ScrollViewer.VerticalOffset);
36+
3137
/// <summary>Get the ListBox style and create a new ReorderableListBox style based on it.</summary>
3238
/// <remarks>For whatever reason the style isn't inherited from the ListBox, even though we are extending it.</remarks>
3339
private static Style listBoxStyle = new Style(typeof(ReorderableListBox), Application.Current.TryFindResource(typeof(ListBox)) as Style);
@@ -36,7 +42,6 @@ public class ReorderableListBox : ListBox {
3642
/// this as a base for the items here.</summary>
3743
private static Style listboxItemStyle = Application.Current.TryFindResource(typeof(ListBoxItem)) as Style;
3844

39-
4045
public ReorderableListBox() : base() {
4146
// We want to use the custom ReorderableListBoxPanel with out ReorderableListBoxes
4247
ItemsPanel = new ItemsPanelTemplate(new FrameworkElementFactory(typeof(ReorderableListBoxPanel)));
@@ -82,7 +87,7 @@ private void ReorderableListBoxItem_PreviewMouseLeftButtonDown(object sender, Mo
8287
// Also check that if the developer has specified a "DragElementTag", the original source of the event (the actual clicked element, even if it is
8388
// inside the element with the attached listener, so in this case a particular object in the item template) has a tag that matches the provided one.
8489
if (sender is ListBoxItem item && (DragElementTag == null || DragElementTag.Equals((e.OriginalSource as FrameworkElement)?.Tag))) {
85-
startDragPoint = e.GetPosition(this);
90+
startDragPoint = ApplyScrollOffset(e.GetPosition(this));
8691
draggedItem = item;
8792
}
8893
}
@@ -94,7 +99,7 @@ private void ReorderableListBoxItem_PreviewMouseLeftButtonDown(object sender, Mo
9499
/// </summary>
95100
private void ReorderableListBox_MouseMove(object sender, MouseEventArgs e) {
96101
if (draggedItem != null) {
97-
var delta = e.GetPosition(this) - startDragPoint; // Calculate distacne between current mouse point and original mouse down point
102+
var delta = ApplyScrollOffset(e.GetPosition(this)) - startDragPoint; // Calculate distacne between current mouse point and original mouse down point
98103
if (Math.Abs(delta.X) >= SystemParameters.MinimumHorizontalDragDistance || Math.Abs(delta.Y) >= SystemParameters.MinimumVerticalDragDistance) // Check it's moved a certain distance
99104
BeginDragDrop();
100105
}
@@ -125,7 +130,7 @@ private void ReorderableListBox_DragOver(object sender, DragEventArgs e) {
125130
// Guard to ensure that the drag originated from this list box (if from elsewhere, draggedItem will be null)
126131
if (draggedItem == null) return;
127132

128-
var y = e.GetPosition(this).Y; // Y position of the mouse relative to `this` listbox
133+
var y = ApplyScrollOffset(e.GetPosition(this)).Y; // Y position of the mouse relative to `this` listbox
129134
panel.DropIndex = CalculateDropIndex(y); // Calculate the index that the item would be inserted if the user dropped here (and pass to panel for rendering)
130135
panel.DraggedY = y; // Also pass the relative Y coordinate to the panel, also for rendering
131136
}
@@ -139,7 +144,7 @@ private void ReorderableListBox_Drop(object sender, DragEventArgs e) {
139144

140145
var itemData = draggedItem.DataContext; // The actual data for the item that the user dragged is contained within the DataContext of draggedItem
141146
var oldIndex = Items.IndexOf(draggedItem.DataContext); // Get the old index of the item, based on the current index of the dragged item
142-
var newIndex = CalculateDropIndex(e.GetPosition(this).Y); // Get the new index of item, based on the user's mouse's Y location
147+
var newIndex = CalculateDropIndex(ApplyScrollOffset(e.GetPosition(this)).Y); // Get the new index of item, based on the user's mouse's Y location
143148

144149
// If the new index is after the old index, we must subtract one from it since it will change when we remove the item from the old index location.
145150
if (oldIndex < newIndex) newIndex--;

Project-Aurora/Project-Aurora/Devices/Logitech/LedMap.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,8 +173,8 @@ public static class LedMaps
173173
[DeviceKeys.PERIPHERAL_LIGHT2] = (DeviceType.Speaker, 1),
174174
[DeviceKeys.PERIPHERAL_LIGHT3] = (DeviceType.Speaker, 2),
175175
[DeviceKeys.PERIPHERAL_LIGHT4] = (DeviceType.Speaker, 3),
176-
[DeviceKeys.HEADSETLIGHT1] = (DeviceType.Headset, 0),
177-
[DeviceKeys.HEADSETLIGHT2] = (DeviceType.Headset, 1),
176+
[DeviceKeys.HEADSETLIGHT1] = (DeviceType.Headset, 0), //Remapped to match my Devicekeys Configuration
177+
[DeviceKeys.HEADSETLIGHT2] = (DeviceType.Headset, 1), //Remapped to match my Devicekeys Configuration
178178
};
179179
}
180180
}

Project-Aurora/Project-Aurora/Devices/OpenRGB/OpenRGBKeyNames.cs

Lines changed: 45 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ public static class OpenRGBKeyNames
171171
DK.MOUSEPADLIGHT3,
172172
DK.MOUSEPADLIGHT2,
173173
DK.MOUSEPADLIGHT1,
174-
////////////////////////////////////////////// Added 5 more Mousepad Lights
174+
////////////////////////////////////////////// Added 5 more Mousepad Lights for support newer models mousepad
175175
DK.MOUSEPADLIGHT16,
176176
DK.MOUSEPADLIGHT17,
177177
DK.MOUSEPADLIGHT18,
@@ -213,7 +213,7 @@ public static class OpenRGBKeyNames
213213
DK.ADDITIONALLIGHT30,
214214
DK.ADDITIONALLIGHT31,
215215
DK.ADDITIONALLIGHT32,
216-
////////////////////////////////////////////// Added 8 more Additional Lights
216+
////////////////////////////////////////////// Added 8 more Additional Lights to fit Hue plus devices
217217
DK.ADDITIONALLIGHT33,
218218
DK.ADDITIONALLIGHT34,
219219
DK.ADDITIONALLIGHT35,
@@ -225,7 +225,7 @@ public static class OpenRGBKeyNames
225225
});
226226

227227
public static readonly List<DK> PeripheralLights = new List<DK>(new[]
228-
{
228+
{
229229
DK.PERIPHERAL_LIGHT1,
230230
DK.PERIPHERAL_LIGHT2,
231231
DK.PERIPHERAL_LIGHT3,
@@ -249,21 +249,31 @@ public static class OpenRGBKeyNames
249249
});
250250

251251
public static readonly List<DK> RAMLights = new List<DK>(new[]
252-
{
252+
{
253253
DK.RAMLIGHT1,
254254
DK.RAMLIGHT2,
255255
DK.RAMLIGHT3,
256256
DK.RAMLIGHT4,
257257
DK.RAMLIGHT5,
258258
});
259259

260+
public static readonly List<DK> C1RAMLights = new List<DK>(new[]
261+
{
262+
DK.C1RAMLIGHT1,
263+
DK.C1RAMLIGHT2,
264+
DK.C1RAMLIGHT3,
265+
DK.C1RAMLIGHT4,
266+
DK.C1RAMLIGHT5,
267+
});
268+
269+
260270
public static readonly Dictionary<string, DK> MoboLogo = new Dictionary<string, DK>()
261271
{
262272
{ "Logo" , DK.Mobo_Logo },
263273
};
264274

265275
public static readonly List<DK> MainboardLights = new List<DK>(new[]
266-
{
276+
{
267277
DK.MOBOLIGHT1,
268278
DK.MOBOLIGHT2,
269279
DK.MOBOLIGHT3,
@@ -278,7 +288,7 @@ public static class OpenRGBKeyNames
278288
};
279289

280290
public static readonly List<DK> CoolerLights = new List<DK>(new[]
281-
{
291+
{
282292
DK.COOLERLIGHT1,
283293
DK.COOLERLIGHT2,
284294
DK.COOLERLIGHT3,
@@ -289,6 +299,35 @@ public static class OpenRGBKeyNames
289299
DK.COOLERLIGHT8,
290300
});
291301

302+
public static readonly List<DK> LedLightsC0 = new List<DK>(new[]
303+
{
304+
DK.C0LEDLIGHT1,
305+
DK.C0LEDLIGHT2,
306+
DK.C0LEDLIGHT3,
307+
DK.C0LEDLIGHT4,
308+
DK.C0LEDLIGHT5,
309+
DK.C0LEDLIGHT6,
310+
DK.C0LEDLIGHT7,
311+
DK.C0LEDLIGHT8,
312+
DK.C0LEDLIGHT9,
313+
DK.C0LEDLIGHT10,
314+
});
315+
316+
public static readonly List<DK> LedLightsC1 = new List<DK>(new[]
317+
{
318+
DK.C1LEDLIGHT1,
319+
DK.C1LEDLIGHT2,
320+
DK.C1LEDLIGHT3,
321+
DK.C1LEDLIGHT4,
322+
DK.C1LEDLIGHT5,
323+
DK.C1LEDLIGHT6,
324+
DK.C1LEDLIGHT7,
325+
DK.C1LEDLIGHT8,
326+
DK.C1LEDLIGHT9,
327+
DK.C1LEDLIGHT10,
328+
});
329+
330+
292331
public static readonly List<DK> LedLights = new List<DK>(new[]
293332
{
294333
DK.LEDLIGHT1,

Project-Aurora/Project-Aurora/Settings/Configuration.cs

Lines changed: 29 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -154,11 +154,24 @@ public enum PreferredKeyboard
154154
[Description("None")]
155155
None = 0,
156156

157+
// Custom Layouts here
158+
[Description("Custom Keyboard Layout 1")]
159+
Custom_Keyboard_Layout_1 = 1,
160+
[Description("Custom Keyboard Layout 2")]
161+
Custom_Keyboard_Layout_2 = 2,
162+
[Description("Custom Keyboard Layout 3")]
163+
Custom_Keyboard_Layout_3 = 3,
164+
165+
// Custom USER Layouts here
166+
[Description("Logitech - G910 - Codename-Antares Edition")]
167+
Logitech_G910_Codename_Antares_Edition = 4,
168+
157169
[Description("Generic Laptop")]
158-
GenericLaptop = 1,
170+
GenericLaptop = 5,
159171

160172
[Description("Generic Laptop (Numpad)")]
161-
GenericLaptopNumpad = 2,
173+
GenericLaptopNumpad = 6,
174+
162175
/*
163176
[Description("Logitech")]
164177
Logitech = 1,
@@ -173,10 +186,6 @@ public enum PreferredKeyboard
173186
CoolerMaster = 5,
174187
*/
175188

176-
// Custom Layouts here
177-
[Description("Logitech - G910 - Codename-Antares Edition")]
178-
Logitech_G910_Codename_Antares_Edition = 99,
179-
180189
//Logitech range is 100-199
181190
[Description("Logitech - G910")]
182191
Logitech_G910 = 100,
@@ -360,14 +369,22 @@ public enum PreferredMouse
360369
[Description("None")]
361370
None = 0,
362371

363-
[Description("Generic Peripheral")]
364-
Generic_Peripheral = 1,
365-
[Description("Razer/Corsair Mousepad + Mouse")]
366-
Generic_Mousepad = 2,
367-
368372
//Custom Layouts here
373+
[Description("Custom Mouse Layout 1")]
374+
Custom_Mouse_Layout_1 = 1,
375+
[Description("Custom Mouse Layout 2")]
376+
Custom_Mouse_Layout_2 = 2,
377+
[Description("Custom Mouse Layout 3")]
378+
Custom_Mouse_Layout_3 = 3,
379+
380+
//Custom User Layouts here
369381
[Description("Razer/Corsair Mousepad + Mouse - Codename Antares Edition")]
370-
Generic_Mousepad_Codename_Antares_Edition = 99,
382+
Generic_Mousepad_Codename_Antares_Edition = 4,
383+
384+
[Description("Generic Peripheral")]
385+
Generic_Peripheral = 5,
386+
[Description("Razer/Corsair Mousepad + Mouse")]
387+
Generic_Mousepad = 6,
371388

372389
//Logitech range is 100-199
373390
[Description("Logitech - G900")]

Project-Aurora/Project-Aurora/Settings/KeyboardLayoutManager.cs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -688,7 +688,13 @@ public void LoadBrand(PreferredKeyboard keyboard_preference = PreferredKeyboard.
688688

689689
var layoutConfigPath = "";
690690

691-
if (keyboard_preference == PreferredKeyboard.Logitech_G910)
691+
if (keyboard_preference == PreferredKeyboard.Custom_Keyboard_Layout_1)
692+
layoutConfigPath = Path.Combine(layoutsPath, "Custom_Keyboard_Layout_1.json");
693+
else if (keyboard_preference == PreferredKeyboard.Custom_Keyboard_Layout_2)
694+
layoutConfigPath = Path.Combine(layoutsPath, "Custom_Keyboard_Layout_2.json");
695+
else if (keyboard_preference == PreferredKeyboard.Custom_Keyboard_Layout_3)
696+
layoutConfigPath = Path.Combine(layoutsPath, "Custom_Keyboard_Layout_3.json");
697+
else if (keyboard_preference == PreferredKeyboard.Logitech_G910)
692698
layoutConfigPath = Path.Combine(layoutsPath, "logitech_g910.json");
693699
else if (keyboard_preference == PreferredKeyboard.Logitech_G910_Codename_Antares_Edition)
694700
layoutConfigPath = Path.Combine(layoutsPath, "logitech_g910_Codename_Antares_Edition.json");
@@ -863,6 +869,15 @@ public void LoadBrand(PreferredKeyboard keyboard_preference = PreferredKeyboard.
863869

864870
switch (mouse_preference)
865871
{
872+
case PreferredMouse.Custom_Mouse_Layout_1:
873+
mouse_feature_path = Path.Combine(layoutsPath, "Extra Features", "Custom_Mouse_Layout_1.json");
874+
break;
875+
case PreferredMouse.Custom_Mouse_Layout_2:
876+
mouse_feature_path = Path.Combine(layoutsPath, "Extra Features", "Custom_Mouse_Layout_2.json");
877+
break;
878+
case PreferredMouse.Custom_Mouse_Layout_3:
879+
mouse_feature_path = Path.Combine(layoutsPath, "Extra Features", "Custom_Mouse_Layout_3.json");
880+
break;
866881
case PreferredMouse.Generic_Peripheral:
867882
mouse_feature_path = Path.Combine(layoutsPath, "Extra Features", "generic_peripheral.json");
868883
break;

Project-Aurora/Project-Aurora/Utils/AudioDeviceProxy.cs

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ namespace Aurora.Utils {
1212
/// Will handle the creation of devices if required. If another AudioDevice is using that device, they will share the same reference.
1313
/// Can be hot-swapped to a different device, moving all events to the newly selected device.
1414
/// </summary>
15-
public sealed class AudioDeviceProxy : IDisposable {
15+
public sealed class AudioDeviceProxy : IDisposable, NAudio.CoreAudioApi.Interfaces.IMMNotificationClient {
1616

1717
public const string DEFAULT_DEVICE_ID = ""; // special ID to indicate the default device
1818

@@ -24,6 +24,7 @@ public sealed class AudioDeviceProxy : IDisposable {
2424

2525
// ID of currently selected device.
2626
private string deviceId;
27+
private bool defaultDeviceChanged = false;
2728

2829
static AudioDeviceProxy() {
2930
// Tried using a static class to update the device lists when they changed, but it caused an AccessViolation. Will try look into this again in future
@@ -38,6 +39,7 @@ public AudioDeviceProxy(DataFlow flow) : this(DEFAULT_DEVICE_ID, flow) { }
3839
public AudioDeviceProxy(string deviceId, DataFlow flow) {
3940
Flow = flow;
4041
DeviceId = deviceId ?? DEFAULT_DEVICE_ID;
42+
deviceEnumerator.RegisterEndpointNotificationCallback(this);
4143
}
4244

4345
/// <summary>Indicates recorded data is available on the selected device.</summary>
@@ -64,7 +66,8 @@ public string DeviceId {
6466
get => deviceId;
6567
set {
6668
value ??= DEFAULT_DEVICE_ID; // Ensure not-null (if null, assume default device)
67-
if (deviceId == value) return;
69+
if (deviceId == value && !(defaultDeviceChanged && deviceId == DEFAULT_DEVICE_ID)) return;
70+
defaultDeviceChanged = false;
6871
deviceId = value;
6972
UpdateDevice();
7073
}
@@ -120,13 +123,30 @@ private static void RefreshDeviceLists() {
120123
}
121124
#endregion
122125

126+
#region IMMNotificationClient Implementation
127+
128+
/// <summary>
129+
/// Update the device when changed by the system.
130+
/// </summary>
131+
public void OnDefaultDeviceChanged(DataFlow flow, Role role, string defaultDeviceId)
132+
=> defaultDeviceChanged = true;
133+
134+
// Methods from interface not used
135+
public void OnDeviceAdded(string pwstrDeviceId) { }
136+
public void OnDeviceRemoved(string deviceId) { }
137+
public void OnDeviceStateChanged(string deviceId, DeviceState newState) { }
138+
public void OnPropertyValueChanged(string pwstrDeviceId, PropertyKey key) { }
139+
140+
#endregion
141+
123142
#region IDisposable Implementation
124143
private bool disposedValue = false;
125144
public void Dispose() => Dispose(true);
126145
void Dispose(bool disposing) {
127146
if (!disposedValue) {
128147
if (disposing)
129148
DisposeCurrentDevice();
149+
deviceEnumerator.UnregisterEndpointNotificationCallback(this);
130150
disposedValue = true;
131151
}
132152
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"keys_to_remove": [],
3+
"key_modifications": {},
4+
"included_features": [
5+
"logitech_g910_left_bottom_features.json",
6+
"Custom_Keyboard_Layout_1_features.json"
7+
]
8+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"keys_to_remove": [],
3+
"key_modifications": {},
4+
"included_features": [
5+
"logitech_g910_left_bottom_features.json",
6+
"Custom_Keyboard_Layout_2_features.json"
7+
]
8+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"keys_to_remove": [],
3+
"key_modifications": {},
4+
"included_features": [
5+
"logitech_g910_left_bottom_features.json",
6+
"Custom_Keyboard_Layout_3_features.json"
7+
]
8+
}

0 commit comments

Comments
 (0)