1
0
mirror of https://github.com/Artemis-RGB/Artemis synced 2025-12-12 21:38:38 +00:00

Implemented Logitech driver check, enabled enable button (yes.)

This commit is contained in:
SpoinkyNL 2016-02-28 20:31:40 +01:00
parent 0584b8a943
commit 426ebac079
12 changed files with 118 additions and 119 deletions

View File

@ -2,42 +2,19 @@
<configuration>
<configSections>
<sectionGroup name="userSettings"
type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<section name="Artemis.Modules.Overlays.VolumeDisplay.VolumeDisplay" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
<section name="Artemis.Modules.Games.RocketLeague.RocketLeague"
type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
allowExeDefinition="MachineToLocalUser" requirePermission="false" />
<section name="Artemis.Settings.Offsets"
type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
allowExeDefinition="MachineToLocalUser" requirePermission="false" />
<section name="Artemis.Modules.Games.Witcher3.Witcher3"
type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
allowExeDefinition="MachineToLocalUser" requirePermission="false" />
<section name="Artemis.Modules.Effects.AudioVisualizer.AudioVisualization"
type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
allowExeDefinition="MachineToLocalUser" requirePermission="false" />
<section name="Artemis.Modules.Games.CounterStrike.CounterStrike"
type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
allowExeDefinition="MachineToLocalUser" requirePermission="false" />
<section name="Artemis.Settings.CounterStrike"
type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
allowExeDefinition="MachineToLocalUser" requirePermission="false" />
<section name="Artemis.Settings.AudioVisualization"
type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
allowExeDefinition="MachineToLocalUser" requirePermission="false" />
<section name="Artemis.Settings.RocketLeague"
type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
allowExeDefinition="MachineToLocalUser" requirePermission="false" />
<section name="Artemis.Properties.Settings"
type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
allowExeDefinition="MachineToLocalUser" requirePermission="false" />
<section name="Artemis.Settings.TypeWave"
type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
allowExeDefinition="MachineToLocalUser" requirePermission="false" />
<section name="Artemis.Settings.General"
type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
allowExeDefinition="MachineToLocalUser" requirePermission="false" />
<section name="Artemis.Modules.Games.RocketLeague.RocketLeague" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
<section name="Artemis.Settings.Offsets" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
<section name="Artemis.Modules.Games.Witcher3.Witcher3" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
<section name="Artemis.Modules.Effects.AudioVisualizer.AudioVisualization" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
<section name="Artemis.Modules.Games.CounterStrike.CounterStrike" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
<section name="Artemis.Settings.CounterStrike" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
<section name="Artemis.Settings.AudioVisualization" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
<section name="Artemis.Settings.RocketLeague" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
<section name="Artemis.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
<section name="Artemis.Settings.TypeWave" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
<section name="Artemis.Settings.General" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
</sectionGroup>
</configSections>
<connectionStrings />

View File

@ -25,7 +25,7 @@
<IsWebBootstrapper>false</IsWebBootstrapper>
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
<PublishUrl>C:\Users\spoin\Desktop\Artemis builds\</PublishUrl>
<PublishUrl>C:\Users\Robert\Desktop\Artemis builds\</PublishUrl>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>
<UpdateEnabled>false</UpdateEnabled>
@ -36,7 +36,7 @@
<UpdateRequired>false</UpdateRequired>
<MapFileExtensions>true</MapFileExtensions>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>1.0.0.0</ApplicationVersion>
<ApplicationVersion>1.0.2.0</ApplicationVersion>
<UseApplicationTrust>false</UseApplicationTrust>
<PublishWizardCompleted>true</PublishWizardCompleted>
<BootstrapperEnabled>true</BootstrapperEnabled>
@ -135,8 +135,8 @@
<HintPath>..\packages\Colore.4.0.0\lib\net35\Corale.Colore.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="CUE.NET, Version=1.0.2.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\CUE.NET.1.0.2\lib\net45\CUE.NET.dll</HintPath>
<Reference Include="CUE.NET, Version=1.0.2.1, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\CUE.NET.1.0.2.1\lib\net45\CUE.NET.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Gma.System.MouseKeyHook, Version=5.4.0.0, Culture=neutral, processorArchitecture=MSIL">
@ -540,12 +540,12 @@
</BootstrapperPackage>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="..\packages\CUE.NET.1.0.2\build\net45\CUE.NET.targets" Condition="Exists('..\packages\CUE.NET.1.0.2\build\net45\CUE.NET.targets')" />
<Import Project="..\packages\CUE.NET.1.0.2.1\build\net45\CUE.NET.targets" Condition="Exists('..\packages\CUE.NET.1.0.2.1\build\net45\CUE.NET.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\packages\CUE.NET.1.0.2\build\net45\CUE.NET.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\CUE.NET.1.0.2\build\net45\CUE.NET.targets'))" />
<Error Condition="!Exists('..\packages\CUE.NET.1.0.2.1\build\net45\CUE.NET.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\CUE.NET.1.0.2.1\build\net45\CUE.NET.targets'))" />
</Target>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.

View File

@ -1,52 +1,63 @@
using System.Collections.Generic;
using System.Drawing;
using System.Threading;
using Artemis.KeyboardProviders.Logitech.Utilities;
namespace Artemis.KeyboardProviders.Logitech
{
internal class Orion : KeyboardProvider
{
public Orion()
{
Name = "Logitech G910 RGB";
CantEnableText = "Couldn't connect to your Logitech G910.\n " +
"Please check your cables and updating the Logitech Gaming Software.\n\n " +
"If needed, you can select a different keyboard in Artemis under settings.";
Height = 6;
Width = 21;
KeyboardRegions = new List<KeyboardRegion> {new KeyboardRegion("TopRow", new Point(0, 0), new Point(0, 16))};
}
public override bool CanEnable()
{
// TODO
return true;
}
public override void Enable()
{
// Initialize the SDK
LogitechGSDK.LogiLedInit();
Thread.Sleep(200);
LogitechGSDK.LogiLedSaveCurrentLighting();
LogitechGSDK.LogiLedSetTargetDevice(LogitechGSDK.LOGI_DEVICETYPE_PERKEY_RGB);
// Disable keys we can't color
LogitechGSDK.LogiLedSetLighting(0, 0, 0);
}
public override void Disable()
{
// Shutdown the SDK
LogitechGSDK.LogiLedRestoreLighting();
LogitechGSDK.LogiLedShutdown();
}
public override void DrawBitmap(Bitmap bitmap)
{
LogitechGSDK.LogiLedSetLightingFromBitmap(OrionUtilities.BitmapToByteArray(bitmap));
}
}
using System.Collections.Generic;
using System.Drawing;
using System.Threading;
using System.Windows.Forms;
using Artemis.KeyboardProviders.Logitech.Utilities;
namespace Artemis.KeyboardProviders.Logitech
{
internal class Orion : KeyboardProvider
{
public Orion()
{
Name = "Logitech G910 RGB";
CantEnableText = "Couldn't connect to your Logitech G910.\n " +
"Please check your cables and updating the Logitech Gaming Software\n" +
"A minimum version of 8.81.15 is required).\n\n " +
"If needed, you can select a different keyboard in Artemis under settings.";
Height = 6;
Width = 21;
KeyboardRegions = new List<KeyboardRegion> {new KeyboardRegion("TopRow", new Point(0, 0), new Point(0, 16))};
}
public override bool CanEnable()
{
int majorNum = 0, minorNum = 0, buildNum = 0;
LogitechGSDK.LogiLedInit();
LogitechGSDK.LogiLedSetLightingForKeyWithKeyName(KeyboardNames.A, 100, 100, 100);
LogitechGSDK.LogiLedGetSdkVersion(ref majorNum, ref minorNum, ref buildNum);
LogitechGSDK.LogiLedRestoreLighting();
LogitechGSDK.LogiLedShutdown();
// Turn it into one long number...
var version = int.Parse($"{majorNum}{minorNum}{buildNum}");
return version >= 88115;
}
public override void Enable()
{
// Initialize the SDK
LogitechGSDK.LogiLedInit();
Thread.Sleep(200);
LogitechGSDK.LogiLedSaveCurrentLighting();
LogitechGSDK.LogiLedSetTargetDevice(LogitechGSDK.LOGI_DEVICETYPE_PERKEY_RGB);
// Disable keys we can't color
LogitechGSDK.LogiLedSetLighting(0, 0, 0);
}
public override void Disable()
{
// Shutdown the SDK
LogitechGSDK.LogiLedRestoreLighting();
LogitechGSDK.LogiLedShutdown();
}
public override void DrawBitmap(Bitmap bitmap)
{
LogitechGSDK.LogiLedSetLightingFromBitmap(OrionUtilities.BitmapToByteArray(bitmap));
}
}
}

View File

@ -54,7 +54,8 @@ namespace Artemis.Managers
/// Disables the current effect and changes it to the provided effect.
/// </summary>
/// <param name="effectModel"></param>
public void ChangeEffect(EffectModel effectModel)
/// <param name="force">Changes the effect, even if it's already running (effectively restarting it)</param>
public void ChangeEffect(EffectModel effectModel, bool force = false)
{
if (effectModel is OverlayModel)
throw new ArgumentException("Can't set an Overlay effect as the active effect");
@ -66,7 +67,7 @@ namespace Artemis.Managers
return;
if (ActiveEffect != null)
if (effectModel.Name == ActiveEffect.Name)
if (effectModel.Name == ActiveEffect.Name && !force)
return;
// If the main manager is running, pause it and safely change the effect

View File

@ -2,6 +2,7 @@
using System.Diagnostics;
using System.Linq;
using System.Threading;
using System.Windows.Forms;
using Artemis.Events;
using Artemis.Models;
using Artemis.Utilities.GameState;
@ -15,7 +16,6 @@ namespace Artemis.Managers
public delegate void PauseCallbackHandler();
private readonly int _fps;
private readonly BackgroundWorker _processWorker;
private bool _paused;
public MainManager(IEventAggregator events)
@ -28,16 +28,16 @@ namespace Artemis.Managers
_fps = 25;
UpdateWorker = new BackgroundWorker {WorkerSupportsCancellation = true};
_processWorker = new BackgroundWorker();
ProcessWorker = new BackgroundWorker { WorkerSupportsCancellation = true };
UpdateWorker.DoWork += UpdateWorker_DoWork;
UpdateWorker.RunWorkerCompleted += BackgroundWorkerExceptionCatcher;
_processWorker.DoWork += ProcessWorker_DoWork;
_processWorker.RunWorkerCompleted += BackgroundWorkerExceptionCatcher;
ProcessWorker.DoWork += ProcessWorker_DoWork;
ProcessWorker.RunWorkerCompleted += BackgroundWorkerExceptionCatcher;
// Process worker will always run (and just do nothing when ProgramEnabled is false)
_processWorker.RunWorkerAsync();
ProcessWorker.RunWorkerAsync();
ProgramEnabled = false;
Running = false;
@ -48,6 +48,7 @@ namespace Artemis.Managers
}
public BackgroundWorker UpdateWorker { get; set; }
public BackgroundWorker ProcessWorker { get; set; }
public KeyboardManager KeyboardManager { get; set; }
public EffectManager EffectManager { get; set; }
@ -221,7 +222,7 @@ namespace Artemis.Managers
private void ProcessWorker_DoWork(object sender, DoWorkEventArgs e)
{
while (true)
while (!ProcessWorker.CancellationPending)
{
if (!ProgramEnabled)
{
@ -254,5 +255,12 @@ namespace Artemis.Managers
}
#endregion
public void Shutdown()
{
Stop();
ProcessWorker.CancelAsync();
GameStateWebServer.Stop();
}
}
}

View File

@ -34,7 +34,7 @@ namespace Artemis.Utilities.GameState
_listener.Prefixes.Add($"http://localhost:{Port}/");
_listener.Start();
ThreadPool.QueueUserWorkItem(o =>
{
try
@ -74,6 +74,11 @@ namespace Artemis.Utilities.GameState
Running = true;
}
public void Stop()
{
_listener.Stop();
}
private string HandleRequest(HttpListenerRequest request)
{
object json;

View File

@ -58,7 +58,7 @@ namespace Artemis.ViewModels.Abstract
return;
// Restart the effect if it's currently running to apply settings.
MainManager.EffectManager.ChangeEffect(EffectModel);
MainManager.EffectManager.ChangeEffect(EffectModel, true);
}
public void ResetSettings()

View File

@ -58,19 +58,19 @@ namespace Artemis.ViewModels.Flyouts
public bool Enabled
{
get { return _enabled; }
get { return MainManager.ProgramEnabled; }
set
{
if (value == _enabled) return;
_enabled = value;
NotifyOfPropertyChange(() => Enabled);
if (value)
MainManager.EnableProgram();
else
MainManager.DisableProgram();
}
}
public void Handle(ToggleEnabled message)
{
Enabled = message.Enabled;
NotifyOfPropertyChange(() => Enabled);
}
public void ToggleEnabled()

View File

@ -45,12 +45,6 @@ namespace Artemis.ViewModels
ActiveItem = _welcomeVm;
}
public void OnClose(EventArgs e)
{
MainManager.Stop();
Application.Current.Shutdown();
}
public void Settings()
{
Flyouts.First().IsOpen = !Flyouts.First().IsOpen;

View File

@ -1,4 +1,5 @@
using System.Windows;
using System;
using System.Windows;
using Artemis.Events;
using Caliburn.Micro;
@ -104,8 +105,11 @@ namespace Artemis.ViewModels
public void ExitApplication()
{
_shellViewModel.MainManager.Stop();
_shellViewModel.MainManager.Shutdown();
Application.Current.Shutdown();
// Sometimes you need to be rough.
Environment.Exit(0);
}
}
}

View File

@ -32,7 +32,7 @@
Content="Enable Artemis:" />
<controls:ToggleSwitch Grid.Row="0" Grid.Column="1" Margin="5" OnLabel="Yes" OffLabel="No"
VerticalAlignment="Center" HorizontalAlignment="Right" Width="125"
IsChecked="{Binding Path=Enabled, Mode=OneWay}" />
IsChecked="{Binding Path=Enabled, Mode=TwoWay}"/>
<!-- Startup with Windows -->
<Label Grid.Row="1" Grid.Column="0" Margin="5" VerticalAlignment="Center" HorizontalAlignment="Left"

View File

@ -1,12 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Autofac" version="4.0.0-rc1-177" targetFramework="net452" />
<package id="Caliburn.Micro" version="2.0.2" targetFramework="net452" />
<package id="Caliburn.Micro.AutofacBootstrap" version="2.0.9-beta" targetFramework="net452" />
<package id="Caliburn.Micro.Core" version="2.0.2" targetFramework="net452" />
<package id="Colore" version="4.0.0" targetFramework="net452" />
<package id="CUE.NET" version="1.0.2" targetFramework="net452" />
<package id="CUE.NET" version="1.0.2.1" targetFramework="net452" />
<package id="Extended.Wpf.Toolkit" version="2.6" targetFramework="net452" />
<package id="Hardcodet.NotifyIcon.Wpf" version="1.0.5" targetFramework="net452" />
<package id="log4net" version="2.0.5" targetFramework="net452" />