Skip to content

Commit

Permalink
Added support for Razer Headsets (#34)
Browse files Browse the repository at this point in the history
* Update LICENSE

* New installer

* Change gitignore

* Update to a prerelease version of Colore

* Added support for Razer Headsets
  • Loading branch information
nicojeske authored Sep 30, 2020
1 parent 090fbc3 commit 67a3590
Show file tree
Hide file tree
Showing 21 changed files with 4,626 additions and 210 deletions.
12 changes: 12 additions & 0 deletions Ambilight.sln
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,28 @@ VisualStudioVersion = 16.0.30225.117
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Ambilight", "Ambilight\Ambilight.csproj", "{3705D85C-E977-4912-A3F4-54D09EB45EFC}"
EndProject
Project("{54435603-DBB4-11D2-8724-00A0C9A8B90C}") = "Installer", "Installer\Installer.vdproj", "{057FBCC5-792A-4B06-BCD2-E7A0A0BF8495}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|x86 = Debug|x86
Release|Any CPU = Release|Any CPU
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{3705D85C-E977-4912-A3F4-54D09EB45EFC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3705D85C-E977-4912-A3F4-54D09EB45EFC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3705D85C-E977-4912-A3F4-54D09EB45EFC}.Debug|x86.ActiveCfg = Debug|Any CPU
{3705D85C-E977-4912-A3F4-54D09EB45EFC}.Debug|x86.Build.0 = Debug|Any CPU
{3705D85C-E977-4912-A3F4-54D09EB45EFC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3705D85C-E977-4912-A3F4-54D09EB45EFC}.Release|Any CPU.Build.0 = Release|Any CPU
{3705D85C-E977-4912-A3F4-54D09EB45EFC}.Release|x86.ActiveCfg = Release|Any CPU
{3705D85C-E977-4912-A3F4-54D09EB45EFC}.Release|x86.Build.0 = Release|Any CPU
{057FBCC5-792A-4B06-BCD2-E7A0A0BF8495}.Debug|Any CPU.ActiveCfg = Debug
{057FBCC5-792A-4B06-BCD2-E7A0A0BF8495}.Debug|x86.ActiveCfg = Debug
{057FBCC5-792A-4B06-BCD2-E7A0A0BF8495}.Release|Any CPU.ActiveCfg = Release
{057FBCC5-792A-4B06-BCD2-E7A0A0BF8495}.Release|x86.ActiveCfg = Release
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
38 changes: 19 additions & 19 deletions Ambilight/Ambilight.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
<TargetFrameworkProfile />
<PublishUrl>E:\GH\Releases\RazerAmbilight\</PublishUrl>
<PublishUrl>C:\Users\nicoj\RiderProjects\RazerAmbilight\release\</PublishUrl>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>
<UpdateEnabled>false</UpdateEnabled>
Expand All @@ -28,11 +28,11 @@
<MapFileExtensions>false</MapFileExtensions>
<TargetCulture>en</TargetCulture>
<ProductName>Ambiligth for Razer Keyboards</ProductName>
<PublisherName>Sancas</PublisherName>
<PublisherName>Nico Jeske</PublisherName>
<OpenBrowserOnPublish>false</OpenBrowserOnPublish>
<AutorunEnabled>true</AutorunEnabled>
<ApplicationRevision>4</ApplicationRevision>
<ApplicationVersion>1.4.0.%2a</ApplicationVersion>
<ApplicationRevision>5</ApplicationRevision>
<ApplicationVersion>2.4.0.%2a</ApplicationVersion>
<UseApplicationTrust>false</UseApplicationTrust>
<PublishWizardCompleted>true</PublishWizardCompleted>
<BootstrapperEnabled>true</BootstrapperEnabled>
Expand Down Expand Up @@ -69,13 +69,14 @@
<ApplicationManifest>Properties\app.manifest</ApplicationManifest>
</PropertyGroup>
<PropertyGroup>
<SignManifests>false</SignManifests>
<SignManifests>true</SignManifests>
</PropertyGroup>
<PropertyGroup>
<ManifestCertificateThumbprint>A5C545B202B71D9711F987C62BF1C7FC5C1820D8</ManifestCertificateThumbprint>
<ManifestCertificateThumbprint>50AB1BEC0F68DF70AC56EEC4C1F0F011F932A595</ManifestCertificateThumbprint>
</PropertyGroup>
<PropertyGroup>
<ManifestKeyFile>Ambilight_1_TemporaryKey.pfx</ManifestKeyFile>
<ManifestKeyFile>
</ManifestKeyFile>
</PropertyGroup>
<PropertyGroup>
<SignAssembly>false</SignAssembly>
Expand All @@ -87,8 +88,9 @@
<Reference Include="AutoUpdater.NET, Version=1.6.3.0, Culture=neutral, PublicKeyToken=501435c91b35f4bc, processorArchitecture=MSIL">
<HintPath>..\packages\Autoupdater.NET.Official.1.6.3\lib\net45\AutoUpdater.NET.dll</HintPath>
</Reference>
<Reference Include="Corale.Colore, Version=5.2.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Colore.5.2.0\lib\net35\Corale.Colore.dll</HintPath>
<Reference Include="Colore, Version=6.0.0.14, Culture=neutral, PublicKeyToken=null">
<HintPath>..\packages\Colore.6.0.0-rc0014\lib\net452\Colore.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Costura, Version=4.1.0.0, Culture=neutral, PublicKeyToken=9919ef960d84173d, processorArchitecture=MSIL">
<HintPath>..\packages\Costura.Fody.4.1.0\lib\net40\Costura.dll</HintPath>
Expand All @@ -103,8 +105,9 @@
<Reference Include="Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.12.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="NLog, Version=4.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
<HintPath>..\packages\NLog.4.7.4\lib\net45\NLog.dll</HintPath>
<Reference Include="NLog, Version=4.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c">
<HintPath>..\packages\NLog.4.7.5\lib\net45\NLog.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Polly, Version=7.0.0.0, Culture=neutral, PublicKeyToken=c8a3ffc3f8f825cc, processorArchitecture=MSIL">
<HintPath>..\packages\Polly.7.2.1\lib\net461\Polly.dll</HintPath>
Expand Down Expand Up @@ -178,6 +181,8 @@
<Compile Include="GUI\KeyboardSizeControl.Designer.cs">
<DependentUpon>KeyboardSizeControl.cs</DependentUpon>
</Compile>
<Compile Include="Logic\HeadsetLogic.cs" />
<Compile Include="Logic\IDeviceLogic.cs" />
<Compile Include="Logic\KeyboardLogic.cs" />
<Compile Include="Logic\LinkLogic.cs" />
<Compile Include="Logic\LogicManager.cs" />
Expand Down Expand Up @@ -205,13 +210,7 @@
<None Include="App.config">
<SubType>Designer</SubType>
</None>
<Content Include="NLog.config">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<SubType>Designer</SubType>
</Content>
<None Include="NLog.xsd">
<SubType>Designer</SubType>
</None>
<None Include="NLog.config" />
<None Include="packages.config" />
<None Include="Properties\app.manifest" />
<None Include="Properties\Settings.settings">
Expand All @@ -222,7 +221,7 @@
<ItemGroup>
<BootstrapperPackage Include=".NETFramework,Version=v4.6.1">
<Visible>False</Visible>
<ProductName>Microsoft .NET Framework 4.6.1 %28x86 y x64%29</ProductName>
<ProductName>Microsoft .NET Framework 4.6.1 %28x86 und x64%29</ProductName>
<Install>true</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
Expand All @@ -238,6 +237,7 @@
<Content Include="FodyWeavers.xml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="NLog.xsd" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="GUI\KeyboardSizeControl.resx">
Expand Down
2 changes: 1 addition & 1 deletion Ambilight/Ambilight.csproj.user
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<PublishUrlHistory>C:\Users\sanch\OneDrive\Desktop\PublicacionAmbilight\</PublishUrlHistory>
<PublishUrlHistory>C:\Users\nicoj\RiderProjects\RazerAmbilight\release\|C:\Users\sanch\OneDrive\Desktop\PublicacionAmbilight\</PublishUrlHistory>
<InstallUrlHistory />
<SupportUrlHistory />
<UpdateUrlHistory />
Expand Down
2 changes: 1 addition & 1 deletion Ambilight/DesktopDuplication/DesktopDuplicatorReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ private Bitmap GetNextFrame(Bitmap reusableBitmap)
{
if (_desktopDuplicator == null)
{
_desktopDuplicator = new DesktopDuplicator(0, settings.Monitor);
_desktopDuplicator = new DesktopDuplicator(0, settings.SelectedMonitor);
}

try
Expand Down
6 changes: 3 additions & 3 deletions Ambilight/GUI/KeyboardSizeControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using KeyboardConstants = Corale.Colore.Razer.Keyboard.Constants;
using Colore.Effects.Keyboard;

namespace Ambilight
{
Expand Down Expand Up @@ -64,8 +64,8 @@ private void saveBtn_Click(object sender, EventArgs e)

private void defaultButtonClicked(object sender, EventArgs e)
{
this.widthTxt.Text = Corale.Colore.Razer.Keyboard.Constants.MaxColumns.ToString();
this.heightTxt.Text = Corale.Colore.Razer.Keyboard.Constants.MaxRows.ToString();
this.widthTxt.Text = KeyboardConstants.MaxColumns.ToString();
this.heightTxt.Text = KeyboardConstants.MaxRows.ToString();
saveBtn_Click(this, null);
}

Expand Down
83 changes: 50 additions & 33 deletions Ambilight/GUI/TraySettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
using Colore.Effects.Keyboard;

namespace Ambilight.GUI
{
Expand All @@ -23,14 +24,15 @@ public class TraySettings
public float Saturation { get; private set; }
public int KeyboardWidth { get; private set; }
public int KeyboardHeight { get; private set; }
public bool KeyboardEnabledBool { get; private set; }
public bool MouseEnabledBool { get; private set; }
public bool LinkEnabledBool { get; private set; }
public bool PadEnabledBool { get; private set; }
public bool AmbiModeBool { get; private set; }
public bool UltrawideModeBool { get; private set; }
public bool AutostartEnabledBool { get; private set; }
public int Monitor { get; set; }
public bool KeyboardEnabled { get; private set; }
public bool MouseEnabled { get; private set; }
public bool LinkEnabled { get; private set; }
public bool PadEnabled { get; private set; }
public bool HeadsetEnabled { get; private set; }
public bool AmbiModeEnabled { get; private set; }
public bool UltrawideModeEnabled { get; private set; }
public bool AutostartEnabled { get; private set; }
public int SelectedMonitor { get; set; }

private NotifyIcon notifyIcon;

Expand All @@ -39,8 +41,8 @@ public class TraySettings

public TraySettings()
{
KeyboardWidth = Corale.Colore.Razer.Keyboard.Constants.MaxColumns;
KeyboardHeight = Corale.Colore.Razer.Keyboard.Constants.MaxRows;
KeyboardWidth = KeyboardConstants.MaxColumns;
KeyboardHeight = KeyboardConstants.MaxRows;
loadConfig();
Thread trayThread = new Thread(InitializeTray);
trayThread.Start();
Expand All @@ -57,27 +59,27 @@ private void loadConfig()
Saturation = Properties.Settings.Default.saturation;
int _keyboardHeightProperty = Properties.Settings.Default.keyboardHeight;
int _keyboardWidthProperty = Properties.Settings.Default.keyboardWidth;
AutostartEnabledBool = Properties.Settings.Default.autostartEnabled;
Monitor = Properties.Settings.Default.monitor;
AutostartEnabled = Properties.Settings.Default.autostartEnabled;
SelectedMonitor = Properties.Settings.Default.monitor;



if (_keyboardWidthProperty >= 0 && _keyboardWidthProperty < Corale.Colore.Razer.Keyboard.Constants.MaxColumns)
if (_keyboardWidthProperty >= 0 && _keyboardWidthProperty < KeyboardConstants.MaxColumns)
{
KeyboardWidth = _keyboardWidthProperty;
} else
{
logger.Warn("Invalid keyboardWidth changing back to default value");
KeyboardWidth = Corale.Colore.Razer.Keyboard.Constants.MaxColumns;
KeyboardWidth = KeyboardConstants.MaxColumns;
}

if (_keyboardHeightProperty >= 0 && _keyboardHeightProperty < Corale.Colore.Razer.Keyboard.Constants.MaxRows)
if (_keyboardHeightProperty >= 0 && _keyboardHeightProperty < KeyboardConstants.MaxRows)
{
KeyboardHeight = _keyboardHeightProperty;
} else
{
logger.Warn("Invalid keyboardHeight changing back to default value");
KeyboardHeight = Corale.Colore.Razer.Keyboard.Constants.MaxRows;
KeyboardHeight = KeyboardConstants.MaxRows;
}
}
catch (SettingsPropertyNotFoundException)
Expand All @@ -86,7 +88,7 @@ private void loadConfig()
Saturation = 1f;
}

logger.Info("Autostart: " + AutostartEnabledBool);
logger.Info("Autostart: " + AutostartEnabled);
logger.Info("Keyboard width: " + KeyboardWidth);
logger.Info("Keyboard height: " + KeyboardHeight);
logger.Info("Max FPS: " + Tickrate);
Expand All @@ -102,47 +104,55 @@ private void InitializeTray()
{
EnableMenuItemOnClick(sender, args);
Properties.Settings.Default.keyboardEnabled = (sender as MenuItem).Checked;
KeyboardEnabledBool = (sender as MenuItem).Checked;
KeyboardEnabled = (sender as MenuItem).Checked;
Properties.Settings.Default.Save();
});

MenuItem _mouseEnabled = new MenuItem("Mouse enabled", (sender, args) =>
{
EnableMenuItemOnClick(sender, args);
Properties.Settings.Default.mouseEnabled = (sender as MenuItem).Checked;
MouseEnabledBool = (sender as MenuItem).Checked;
MouseEnabled = (sender as MenuItem).Checked;
Properties.Settings.Default.Save();
});

MenuItem _mousematEnabled = new MenuItem("Mousemat enabled", (sender, args) =>
{
EnableMenuItemOnClick(sender, args);
Properties.Settings.Default.mousematEnabled = (sender as MenuItem).Checked;
PadEnabledBool = (sender as MenuItem).Checked;
PadEnabled = (sender as MenuItem).Checked;
Properties.Settings.Default.Save();
});

MenuItem _headsetEnabled = new MenuItem("Headset enabled", (sender, args) =>
{
EnableMenuItemOnClick(sender, args);
Properties.Settings.Default.headsetEnabled = (sender as MenuItem).Checked;
HeadsetEnabled = (sender as MenuItem).Checked;
Properties.Settings.Default.Save();
});

MenuItem _linkEnabled = new MenuItem("LinkChroma enabled", (sender, args) =>
{
EnableMenuItemOnClick(sender, args);
Properties.Settings.Default.linkEnabled = (sender as MenuItem).Checked;
LinkEnabledBool = (sender as MenuItem).Checked;
LinkEnabled = (sender as MenuItem).Checked;
Properties.Settings.Default.Save();
});

MenuItem _ambiModeEnabled = new MenuItem("'Real' Ambilight mode", (sender, args) =>
{
EnableMenuItemOnClick(sender, args);
Properties.Settings.Default.ambiEnabled = (sender as MenuItem).Checked;
AmbiModeBool = (sender as MenuItem).Checked;
AmbiModeEnabled = (sender as MenuItem).Checked;
Properties.Settings.Default.Save();
});

MenuItem _ultrawideModeEnabled = new MenuItem("Ultrawide Monitor mode", (sender, args) =>
{
EnableMenuItemOnClick(sender, args);
Properties.Settings.Default.ultrawideEnabled = (sender as MenuItem).Checked;
UltrawideModeBool = (sender as MenuItem).Checked;
UltrawideModeEnabled = (sender as MenuItem).Checked;
Properties.Settings.Default.Save();
});

Expand All @@ -151,29 +161,30 @@ private void InitializeTray()
EnableMenuItemOnClick(sender, args);
Properties.Settings.Default.autostartEnabled = (sender as MenuItem).Checked;
changeAutoStart();
AutostartEnabledBool = (sender as MenuItem).Checked;
AutostartEnabled = (sender as MenuItem).Checked;
Properties.Settings.Default.Save();
});

_keyboardEnabled.Checked = Properties.Settings.Default.keyboardEnabled;
KeyboardEnabledBool = Properties.Settings.Default.keyboardEnabled;
KeyboardEnabled = Properties.Settings.Default.keyboardEnabled;
_mouseEnabled.Checked = Properties.Settings.Default.mouseEnabled;
MouseEnabledBool = Properties.Settings.Default.mouseEnabled;
MouseEnabled = Properties.Settings.Default.mouseEnabled;
_mousematEnabled.Checked = Properties.Settings.Default.mousematEnabled;
PadEnabledBool = Properties.Settings.Default.mousematEnabled;
PadEnabled = Properties.Settings.Default.mousematEnabled;
_headsetEnabled.Checked = Properties.Settings.Default.headsetEnabled;
HeadsetEnabled = Properties.Settings.Default.headsetEnabled;
_linkEnabled.Checked = Properties.Settings.Default.linkEnabled;
LinkEnabledBool = Properties.Settings.Default.linkEnabled;
LinkEnabled = Properties.Settings.Default.linkEnabled;
_ambiModeEnabled.Checked = Properties.Settings.Default.ambiEnabled;
AmbiModeBool = Properties.Settings.Default.ambiEnabled;
AmbiModeEnabled = Properties.Settings.Default.ambiEnabled;
_ultrawideModeEnabled.Checked = Properties.Settings.Default.ambiEnabled;
UltrawideModeBool = Properties.Settings.Default.ultrawideEnabled;
UltrawideModeEnabled = Properties.Settings.Default.ultrawideEnabled;
_autostart.Checked = checkAutostart(Environment.GetFolderPath(Environment.SpecialFolder.Startup) + "/Ambilight.lnk");
AutostartEnabledBool = Properties.Settings.Default.autostartEnabled;
AutostartEnabled = Properties.Settings.Default.autostartEnabled;

var components = new System.ComponentModel.Container();
var contextMenu = new ContextMenu();

contextMenu.MenuItems.Add("Exit", (sender, args) => { notifyIcon.Dispose();Environment.Exit(0); });
contextMenu.MenuItems.Add("Change max fps", ChangeTickrateHandler);
contextMenu.MenuItems.Add("Change Saturation", ChangeSaturationHandler);
contextMenu.MenuItems.Add("Set Manual keyboard size", changeKeyboardSizeHandler);
Expand All @@ -187,7 +198,12 @@ private void InitializeTray()
contextMenu.MenuItems.Add(_keyboardEnabled);
contextMenu.MenuItems.Add(_mouseEnabled);
contextMenu.MenuItems.Add(_mousematEnabled);
contextMenu.MenuItems.Add(_headsetEnabled);
contextMenu.MenuItems.Add(_linkEnabled);

contextMenu.MenuItems.Add("-");
contextMenu.MenuItems.Add("Exit", (sender, args) => { notifyIcon.Dispose();Environment.Exit(0); });


notifyIcon = new NotifyIcon(components)
{
Expand All @@ -199,6 +215,7 @@ private void InitializeTray()
logger.Info("Keyboard Enabled: " + _keyboardEnabled.Checked);
logger.Info("Mouse Enabled: " + _mouseEnabled.Checked);
logger.Info("Mousemat Enabled: " + _mousematEnabled.Checked);
logger.Info("Headset Enabled: " + _headsetEnabled.Checked);
logger.Info("ChromaLink Enabled: " + _linkEnabled.Checked);
logger.Info("Ambilight mode: " + _ambiModeEnabled.Checked);
logger.Info("Ultrawide mode: " + _ultrawideModeEnabled.Checked);
Expand Down Expand Up @@ -285,7 +302,7 @@ private void keyboardSizeChangedHandler(object sender, EventArgs e)
int KeyboardWidthSetting = k.GetTxtWidth();
int KeyboardHeightSetting = k.GetTxtHeight();

if (KeyboardWidthSetting < 0 || KeyboardWidthSetting > Corale.Colore.Razer.Keyboard.Constants.MaxColumns || KeyboardHeightSetting < 0 || KeyboardHeightSetting > Corale.Colore.Razer.Keyboard.Constants.MaxRows)
if (KeyboardWidthSetting < 0 || KeyboardWidthSetting > KeyboardConstants.MaxColumns || KeyboardHeightSetting < 0 || KeyboardHeightSetting > KeyboardConstants.MaxRows)
{
k.errorReport("Input invalid");
return;
Expand Down
Loading

0 comments on commit 67a3590

Please sign in to comment.