Skip to content

Commit 8fcdff4

Browse files
committed
added custom mouse and mousepad settings
1 parent 47b4a3b commit 8fcdff4

3 files changed

Lines changed: 32 additions & 8 deletions

File tree

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -390,6 +390,9 @@ public enum PreferredMouse
390390

391391
[Description("Generic Openrgb Mouse")]
392392
Generic_Openrgb_Mouse = 2,
393+
394+
[Description("Custom Mouse")]
395+
Custom = 3,
393396

394397
//Logitech range is 100-199
395398
[Description("Logitech - G900")]
@@ -457,6 +460,9 @@ public enum PreferredMousepad
457460

458461
[Description("2 Zone + Logo Mousepad")]
459462
Two_Zone_Plus_Logo_Mousepad = 2,
463+
464+
[Description("Custom Mouse")]
465+
Custom = 3,
460466

461467
//Steelseries range is 100-299
462468
[Description("SteelSeries - QcK Prism Mousepad")]

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

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
using System.Threading;
99
using System.Windows;
1010
using System.Windows.Controls;
11-
using System.Windows.Forms;
1211
using System.Windows.Media;
1312
using System.Windows.Media.Imaging;
1413
using Aurora.Devices;
@@ -563,11 +562,27 @@ private void LoadBrand(PreferredKeyboard keyboardPreference = PreferredKeyboard.
563562
});
564563
}
565564

566-
private void LoadMousepad(MouseOrientationType mouseOrientation, string mousepadFeaturePath)
565+
private bool LoadLayout(string path, out VirtualGroup layout)
567566
{
568-
string featureContent = File.ReadAllText(mousepadFeaturePath, Encoding.UTF8);
569-
VirtualGroup featureConfig = JsonConvert.DeserializeObject<VirtualGroup>(featureContent,
567+
if (!File.Exists(path))
568+
{
569+
MessageBox.Show( path + " could not be found", "Layout not found", MessageBoxButton.OK);
570+
layout = null;
571+
return false;
572+
}
573+
574+
var featureContent = File.ReadAllText(path, Encoding.UTF8);
575+
layout = JsonConvert.DeserializeObject<VirtualGroup>(featureContent,
570576
new JsonSerializerSettings {ObjectCreationHandling = ObjectCreationHandling.Replace})!;
577+
return true;
578+
}
579+
580+
private void LoadMousepad(MouseOrientationType mouseOrientation, string mousepadFeaturePath)
581+
{
582+
if (!LoadLayout(mousepadFeaturePath, out var featureConfig))
583+
{
584+
return;
585+
}
571586

572587
if (mouseOrientation == MouseOrientationType.LeftHanded)
573588
{
@@ -638,9 +653,10 @@ private void LoadKeyboard(string layoutConfigPath)
638653

639654
private void LoadMouse(MouseOrientationType mouseOrientation, string mouseFeaturePath)
640655
{
641-
string featureContent = File.ReadAllText(mouseFeaturePath, Encoding.UTF8);
642-
VirtualGroup featureConfig = JsonConvert.DeserializeObject<VirtualGroup>(featureContent,
643-
new JsonSerializerSettings {ObjectCreationHandling = ObjectCreationHandling.Replace})!;
656+
if (!LoadLayout(mouseFeaturePath, out var featureConfig))
657+
{
658+
return;
659+
}
644660

645661
if (mouseOrientation == MouseOrientationType.LeftHanded)
646662
{

Project-Aurora/Project-Aurora/Settings/PeripheralLayoutMap.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,8 @@ public static class PeripheralLayoutMap
7878
private static readonly Dictionary<PreferredMouse, string> MouseLayouts = new()
7979
{
8080
{PreferredMouse.Generic_Peripheral, "generic_peripheral.json"},
81-
{PreferredMouse.Generic_Openrgb_Mouse, "generic_openrgb_mouse.json"},
81+
{PreferredMouse.Generic_Openrgb_Mouse, "custom_mouse.json"},
82+
{PreferredMouse.Custom, "custom_mouse.json"},
8283
{PreferredMouse.Logitech_G900, "logitech_g900_features.json"},
8384
{PreferredMouse.Logitech_G502, "logitech_g502_features.json"},
8485
{PreferredMouse.Logitech_G102, "logitech_g102_features.json"},
@@ -104,6 +105,7 @@ public static class PeripheralLayoutMap
104105
private static readonly Dictionary<PreferredMousepad, string> MousepadLayouts = new()
105106
{
106107
{PreferredMousepad.Generic_Mousepad, "generic_mousepad.json"},
108+
{PreferredMousepad.Custom, "custom_mousepad.json"},
107109
{PreferredMousepad.Two_Zone_Plus_Logo_Mousepad, "2zone_1logo_mousepad.json"},
108110
{PreferredMousepad.SteelSeries_QcK_Prism, "steelseries_qck_prism_features.json"},
109111
{PreferredMousepad.SteelSeries_QcK_2_Zone, "steelseries_qck_2zone_features.json"},

0 commit comments

Comments
 (0)