mirror of
https://github.com/Artemis-RGB/Artemis
synced 2025-12-13 05:48:35 +00:00
2.0 initial commit
This commit is contained in:
parent
309d9b9d2c
commit
8c34fb3c50
63
.gitattributes
vendored
Normal file
63
.gitattributes
vendored
Normal file
@ -0,0 +1,63 @@
|
||||
###############################################################################
|
||||
# Set default behavior to automatically normalize line endings.
|
||||
###############################################################################
|
||||
* text=auto
|
||||
|
||||
###############################################################################
|
||||
# Set default behavior for command prompt diff.
|
||||
#
|
||||
# This is need for earlier builds of msysgit that does not have it on by
|
||||
# default for csharp files.
|
||||
# Note: This is only used by command line
|
||||
###############################################################################
|
||||
#*.cs diff=csharp
|
||||
|
||||
###############################################################################
|
||||
# Set the merge driver for project and solution files
|
||||
#
|
||||
# Merging from the command prompt will add diff markers to the files if there
|
||||
# are conflicts (Merging from VS is not affected by the settings below, in VS
|
||||
# the diff markers are never inserted). Diff markers may cause the following
|
||||
# file extensions to fail to load in VS. An alternative would be to treat
|
||||
# these files as binary and thus will always conflict and require user
|
||||
# intervention with every merge. To do so, just uncomment the entries below
|
||||
###############################################################################
|
||||
#*.sln merge=binary
|
||||
#*.csproj merge=binary
|
||||
#*.vbproj merge=binary
|
||||
#*.vcxproj merge=binary
|
||||
#*.vcproj merge=binary
|
||||
#*.dbproj merge=binary
|
||||
#*.fsproj merge=binary
|
||||
#*.lsproj merge=binary
|
||||
#*.wixproj merge=binary
|
||||
#*.modelproj merge=binary
|
||||
#*.sqlproj merge=binary
|
||||
#*.wwaproj merge=binary
|
||||
|
||||
###############################################################################
|
||||
# behavior for image files
|
||||
#
|
||||
# image files are treated as binary by default.
|
||||
###############################################################################
|
||||
#*.jpg binary
|
||||
#*.png binary
|
||||
#*.gif binary
|
||||
|
||||
###############################################################################
|
||||
# diff behavior for common document formats
|
||||
#
|
||||
# Convert binary document formats to text before diffing them. This feature
|
||||
# is only available from the command line. Turn it on by uncommenting the
|
||||
# entries below.
|
||||
###############################################################################
|
||||
#*.doc diff=astextplain
|
||||
#*.DOC diff=astextplain
|
||||
#*.docx diff=astextplain
|
||||
#*.DOCX diff=astextplain
|
||||
#*.dot diff=astextplain
|
||||
#*.DOT diff=astextplain
|
||||
#*.pdf diff=astextplain
|
||||
#*.PDF diff=astextplain
|
||||
#*.rtf diff=astextplain
|
||||
#*.RTF diff=astextplain
|
||||
@ -1,77 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" DefaultTargets="Build" InitialTargets="EnsureWixToolsetInstalled" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
|
||||
<ProductVersion>3.10</ProductVersion>
|
||||
<ProjectGuid>a34f9047-8464-4423-89ef-a2f43e089e93</ProjectGuid>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<OutputName>Artemis</OutputName>
|
||||
<OutputType>Package</OutputType>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
|
||||
<OutputPath>bin\$(Configuration)\</OutputPath>
|
||||
<IntermediateOutputPath>obj\$(Configuration)\</IntermediateOutputPath>
|
||||
<DefineConstants>Debug</DefineConstants>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
|
||||
<OutputPath>bin\$(Configuration)\</OutputPath>
|
||||
<IntermediateOutputPath>obj\$(Configuration)\</IntermediateOutputPath>
|
||||
<CompilerAdditionalOptions>-arch x64</CompilerAdditionalOptions>
|
||||
<SuppressPdbOutput>False</SuppressPdbOutput>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<DefineConstants>HarvestPath=..\Artemis\bin\Release</DefineConstants>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Product.wxs" />
|
||||
<Compile Include="HeatGeneratedFileList.wxs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Artemis\Artemis.csproj">
|
||||
<Name>Artemis</Name>
|
||||
<Project>{ed9997a2-e54c-4e9f-9350-62be672c3abe}</Project>
|
||||
<Private>True</Private>
|
||||
<DoNotHarvest>True</DoNotHarvest>
|
||||
<RefProjectOutputGroups>Binaries;Content;Satellites</RefProjectOutputGroups>
|
||||
<RefTargetDir>INSTALLFOLDER</RefTargetDir>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<WixExtension Include="WixUtilExtension">
|
||||
<HintPath>$(WixExtDir)\WixUtilExtension.dll</HintPath>
|
||||
<Name>WixUtilExtension</Name>
|
||||
</WixExtension>
|
||||
<WixExtension Include="WixUIExtension">
|
||||
<HintPath>$(WixExtDir)\WixUIExtension.dll</HintPath>
|
||||
<Name>WixUIExtension</Name>
|
||||
</WixExtension>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="banner.bmp" />
|
||||
<Content Include="dialog.bmp" />
|
||||
<Content Include="logo.ico" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(WixTargetsPath)" Condition=" '$(WixTargetsPath)' != '' " />
|
||||
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\WiX\v3.x\Wix.targets" Condition=" '$(WixTargetsPath)' == '' AND Exists('$(MSBuildExtensionsPath32)\Microsoft\WiX\v3.x\Wix.targets') " />
|
||||
<Target Name="EnsureWixToolsetInstalled" Condition=" '$(WixTargetsImported)' != 'true' ">
|
||||
<Error Text="The WiX Toolset v3.11 (or newer) build tools must be installed to build this project. To download the WiX Toolset, see http://wixtoolset.org/releases/" />
|
||||
</Target>
|
||||
<Target Name="BeforeBuild">
|
||||
<HeatDirectory Directory="..\Artemis\bin\Release" PreprocessorVariable="var.HarvestPath" OutputFile="HeatGeneratedFileList.wxs" ComponentGroupName="HeatGenerated" DirectoryRefId="INSTALLFOLDER" AutogenerateGuids="true" ToolPath="$(WixToolPath)" SuppressFragments="true" SuppressRegistry="true" SuppressRootDirectory="true" />
|
||||
</Target>
|
||||
<PropertyGroup>
|
||||
<PreBuildEvent />
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<PostBuildEvent />
|
||||
</PropertyGroup>
|
||||
<!--
|
||||
To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Wix.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
</Project>
|
||||
@ -1,281 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
|
||||
<Fragment>
|
||||
<DirectoryRef Id="INSTALLFOLDER">
|
||||
<Component Id="cmp9B04FAC2BF56F13B71858D3F9539F8FE" Guid="*">
|
||||
<File Id="filD726820CC88B0C2D4EF316CD550D5B65" KeyPath="yes" Source="$(var.HarvestPath)\Artemis.exe" />
|
||||
</Component>
|
||||
<Component Id="cmp84F8E8E529BEF2230424503D7A54F566" Guid="*">
|
||||
<File Id="filD2707A8AC696576A770C8B73326D813A" KeyPath="yes" Source="$(var.HarvestPath)\Artemis.exe.config" />
|
||||
</Component>
|
||||
<Component Id="cmp98E421B03991EBFA9D74DA1DE5FDCEB4" Guid="*">
|
||||
<File Id="filBA9DA8A767D5D8787963532477ABAF1E" KeyPath="yes" Source="$(var.HarvestPath)\Artemis.pdb" />
|
||||
</Component>
|
||||
<Component Id="cmp5978FBD119D600B675CF51F7CB5B1DB8" Guid="*">
|
||||
<File Id="fil0FAF37CC520EA9F71EA79A34018196AF" KeyPath="yes" Source="$(var.HarvestPath)\AssettoCorsaSharedMemory.dll" />
|
||||
</Component>
|
||||
<Component Id="cmp4688F61692F1E1A7C8A650F257BA3780" Guid="*">
|
||||
<File Id="fil9411AC6E5E07C4214E2EC84F18310DFC" KeyPath="yes" Source="$(var.HarvestPath)\Betwixt.dll" />
|
||||
</Component>
|
||||
<Component Id="cmpF6DB600EAE4F92B06118C49F01583429" Guid="*">
|
||||
<File Id="fil58D641A69C1F9F9B3767F37A52968AEA" KeyPath="yes" Source="$(var.HarvestPath)\Caliburn.Micro.dll" />
|
||||
</Component>
|
||||
<Component Id="cmp3ADD63EC603C0189D3C536D6FE228F29" Guid="*">
|
||||
<File Id="fil22BB2F1FEFE5A4C8C7066B4FFB40BA50" KeyPath="yes" Source="$(var.HarvestPath)\Caliburn.Micro.Platform.Core.dll" />
|
||||
</Component>
|
||||
<Component Id="cmp6E4F12F91C4B75E02675BB4C94196438" Guid="*">
|
||||
<File Id="fil347D66AF0F2351A1DF20454796FF4F18" KeyPath="yes" Source="$(var.HarvestPath)\Caliburn.Micro.Platform.Core.xml" />
|
||||
</Component>
|
||||
<Component Id="cmp1C206319B53EA02514D73AF8086C62B4" Guid="*">
|
||||
<File Id="filA7E995C50EC209623795FDBA9E10F3FA" KeyPath="yes" Source="$(var.HarvestPath)\Caliburn.Micro.Platform.dll" />
|
||||
</Component>
|
||||
<Component Id="cmp3E3AA980BDCF05810907BC4EB3821194" Guid="*">
|
||||
<File Id="fil979D2E4B61E2F3E59B8E1F13EA8C35C4" KeyPath="yes" Source="$(var.HarvestPath)\Caliburn.Micro.Platform.xml" />
|
||||
</Component>
|
||||
<Component Id="cmp17D9A8147FAEAB525E5B8101916313BA" Guid="*">
|
||||
<File Id="filF38A8DADF810A6008E9C37F6AB2942EF" KeyPath="yes" Source="$(var.HarvestPath)\Caliburn.Micro.xml" />
|
||||
</Component>
|
||||
<Component Id="cmpA643245E2404309B3DABA70BB912DCCB" Guid="*">
|
||||
<File Id="filB4B2021C4282D7C64C5B4AD0AF512DCA" KeyPath="yes" Source="$(var.HarvestPath)\ColorBox.dll" />
|
||||
</Component>
|
||||
<Component Id="cmpFBDA3E7CEA190733BF9F05003E25D5AF" Guid="*">
|
||||
<File Id="filB20254A9D5C181C3E378CFFA814C5E33" KeyPath="yes" Source="$(var.HarvestPath)\Corale.Colore.dll" />
|
||||
</Component>
|
||||
<Component Id="cmp0215030D177DFD73F427CC3D7CA19238" Guid="*">
|
||||
<File Id="fil695315177E22D73E3A5F737D5C5785A9" KeyPath="yes" Source="$(var.HarvestPath)\Corale.Colore.xml" />
|
||||
</Component>
|
||||
<Component Id="cmpA1F7266A1B0ADDC69DE569177E196895" Guid="*">
|
||||
<File Id="filB4EB8106E7EFC9E0CA5D90C8F250515B" KeyPath="yes" Source="$(var.HarvestPath)\CSCore.dll" />
|
||||
</Component>
|
||||
<Component Id="cmp55AF7BD4F37A05E9BB3300FB06BC8083" Guid="*">
|
||||
<File Id="fil5451886D2CAE8B7C5ED260A04095C66C" KeyPath="yes" Source="$(var.HarvestPath)\CSCore.xml" />
|
||||
</Component>
|
||||
<Component Id="cmp8D9BC4E9081E35E49D1317948B71CF9E" Guid="*">
|
||||
<File Id="filF8266F348553A462902D15B083602F6B" KeyPath="yes" Source="$(var.HarvestPath)\CUE.NET.dll" />
|
||||
</Component>
|
||||
<Component Id="cmp6527C67EBA0A64B342B4DFD472F51344" Guid="*">
|
||||
<File Id="fil334DC2BC7971B5B5C5404021140CB4BB" KeyPath="yes" Source="$(var.HarvestPath)\CUE.NET.xml" />
|
||||
</Component>
|
||||
<Component Id="cmp51BF717902634148759143BD6AD539B0" Guid="*">
|
||||
<File Id="fil13BFD35B4184B1F8F1AAB29A7C3686BC" KeyPath="yes" Source="$(var.HarvestPath)\DynamicExpresso.Core.dll" />
|
||||
</Component>
|
||||
<Component Id="cmpF91C67D347AB218E39A848636AB895E3" Guid="*">
|
||||
<File Id="fil92C151A1E3668BA2B0166FD3BDCDE7CB" KeyPath="yes" Source="$(var.HarvestPath)\DynamicExpresso.Core.xml" />
|
||||
</Component>
|
||||
<Component Id="cmpFDA802159822E5F335299869D8F57A96" Guid="*">
|
||||
<File Id="fil4D5F85087EDF31C493CBC20A757D0BEE" KeyPath="yes" Source="$(var.HarvestPath)\Gma.System.MouseKeyHook.dll" />
|
||||
</Component>
|
||||
<Component Id="cmp781EEA928029B571EC5B4E7090BD7946" Guid="*">
|
||||
<File Id="fil093D81EF2D0F558E4AF6DBB696C8B611" KeyPath="yes" Source="$(var.HarvestPath)\GongSolutions.Wpf.DragDrop.dll" />
|
||||
</Component>
|
||||
<Component Id="cmp349050BDBF99EA8BFA2BA8F9E31ED252" Guid="*">
|
||||
<File Id="filAB2DEF8A4601402AB380F6101D5A66E0" KeyPath="yes" Source="$(var.HarvestPath)\GongSolutions.Wpf.DragDrop.xml" />
|
||||
</Component>
|
||||
<Component Id="cmpBE3C1D05C7C90455322C9F819A57A07A" Guid="*">
|
||||
<File Id="filE7C602A91344AD969255F20A2CA7411A" KeyPath="yes" Source="$(var.HarvestPath)\Hardcodet.Wpf.TaskbarNotification.dll" />
|
||||
</Component>
|
||||
<Component Id="cmp1AB3F692680AD43D977D2B4893C60651" Guid="*">
|
||||
<File Id="fil8DCFE8E2064CED909E7B76E107F2D738" KeyPath="yes" Source="$(var.HarvestPath)\Hardcodet.Wpf.TaskbarNotification.xml" />
|
||||
</Component>
|
||||
<Component Id="cmp13D58469BCB864EB53214ED46E622188" Guid="*">
|
||||
<File Id="fil28F7A9478894C77C5F6C2A95DAA4B459" KeyPath="yes" Source="$(var.HarvestPath)\log4net.dll" />
|
||||
</Component>
|
||||
<Component Id="cmp742785C9A7B88BE6B2E81C2322E3D2EE" Guid="*">
|
||||
<File Id="filA307C00D897BECB908C510DE71A3AD29" KeyPath="yes" Source="$(var.HarvestPath)\log4net.xml" />
|
||||
</Component>
|
||||
<Component Id="cmp57FCE16B127552B85167E1625E9421BE" Guid="*">
|
||||
<File Id="filE9D90C01E678160833AE4A2F7E2CC468" KeyPath="yes" Source="$(var.HarvestPath)\LogitechLedEnginesWrapper.dll" />
|
||||
</Component>
|
||||
<Component Id="cmpC92D9566450D2381C819C291B41E2EE8" Guid="*">
|
||||
<File Id="fil3B7D3B0904598A6E39F49D385D9EF1F6" KeyPath="yes" Source="$(var.HarvestPath)\logo.ico" />
|
||||
</Component>
|
||||
<Component Id="cmp223D4754378C01052DA8253A843FD297" Guid="*">
|
||||
<File Id="filBC562C5B3D9848A2114F0AF7275FF1E6" KeyPath="yes" Source="$(var.HarvestPath)\MahApps.Metro.dll" />
|
||||
</Component>
|
||||
<Component Id="cmp43D899344ED173B0DAFCD84946D02788" Guid="*">
|
||||
<File Id="fil7FCB3B29476FFB610381CD77013296AD" KeyPath="yes" Source="$(var.HarvestPath)\MahApps.Metro.xml" />
|
||||
</Component>
|
||||
<Component Id="cmp2FCEBC7A99564B55654E85ED28E48600" Guid="*">
|
||||
<File Id="fil4EAD90E131DF96A66C4D6F6426CE480B" KeyPath="yes" Source="$(var.HarvestPath)\MoonSharp.Interpreter.dll" />
|
||||
</Component>
|
||||
<Component Id="cmpF3259CFFC7B5247438581E9B04AB35D8" Guid="*">
|
||||
<File Id="filD117DB2E80E33BDED00898D9DB2B086A" KeyPath="yes" Source="$(var.HarvestPath)\MoonSharp.Interpreter.xml" />
|
||||
</Component>
|
||||
<Component Id="cmpBC4FC00A26E7D32479D42D3411317FC5" Guid="*">
|
||||
<File Id="fil90A8AAD9FC612906D405476D61CEA3F4" KeyPath="yes" Source="$(var.HarvestPath)\Newtonsoft.Json.dll" />
|
||||
</Component>
|
||||
<Component Id="cmp125C379E185231EFADA4CB4301BD0A9E" Guid="*">
|
||||
<File Id="fil3A2F44A7730E98D18E0948B3261DFABD" KeyPath="yes" Source="$(var.HarvestPath)\Newtonsoft.Json.xml" />
|
||||
</Component>
|
||||
<Component Id="cmpDA60982F820038280380BE207B6E738E" Guid="*">
|
||||
<File Id="filFB25B5D44CA54D4D876DD0B5BC0DA0E0" KeyPath="yes" Source="$(var.HarvestPath)\Ninject.dll" />
|
||||
</Component>
|
||||
<Component Id="cmp115DB0C4CBA276D1E4BF73C7F0D12168" Guid="*">
|
||||
<File Id="fil9864AE07D5BAA41F302A315D151D206B" KeyPath="yes" Source="$(var.HarvestPath)\Ninject.Extensions.Conventions.dll" />
|
||||
</Component>
|
||||
<Component Id="cmp667EC93AB28DC800EC8C0C696B6252F3" Guid="*">
|
||||
<File Id="fil76EEFF8F12090D39F0CB70E63C967D5E" KeyPath="yes" Source="$(var.HarvestPath)\Ninject.Extensions.Conventions.xml" />
|
||||
</Component>
|
||||
<Component Id="cmpB163B8B3242EED7EB32E270810A5C294" Guid="*">
|
||||
<File Id="fil2829742BE68F0C1965B32144E97066A8" KeyPath="yes" Source="$(var.HarvestPath)\Ninject.Extensions.Logging.dll" />
|
||||
</Component>
|
||||
<Component Id="cmpD934BE4677B83286DC33948DD39DDFD0" Guid="*">
|
||||
<File Id="fil4B1AF407257D321CBF6C8E1AF5095607" KeyPath="yes" Source="$(var.HarvestPath)\Ninject.Extensions.Logging.NLog4.dll" />
|
||||
</Component>
|
||||
<Component Id="cmpD620842EF41724FF29FB815A4D4EAC9F" Guid="*">
|
||||
<File Id="filEC2E3811DEBAF7C1CF74FB14B4F6E606" KeyPath="yes" Source="$(var.HarvestPath)\Ninject.Extensions.Logging.NLog4.xml" />
|
||||
</Component>
|
||||
<Component Id="cmp00A9C690A734DF8DBF6B58522866EFB9" Guid="*">
|
||||
<File Id="filB9E89E8C208F3FBEA1C45079398FC62A" KeyPath="yes" Source="$(var.HarvestPath)\Ninject.Extensions.Logging.xml" />
|
||||
</Component>
|
||||
<Component Id="cmpB8D71C46885F3F849C4526BB4F6C303F" Guid="*">
|
||||
<File Id="filE3269A14F34C799370A12BE5D82002D0" KeyPath="yes" Source="$(var.HarvestPath)\Ninject.xml" />
|
||||
</Component>
|
||||
<Component Id="cmpB7F1EBE42DCB1051B92D42C1EF84E2F9" Guid="*">
|
||||
<File Id="filA09ADF42C6343B9B7C7780D266455CC4" KeyPath="yes" Source="$(var.HarvestPath)\NLog.dll" />
|
||||
</Component>
|
||||
<Component Id="cmpAF162B14FA6391E4D0D34D9485A3CBEB" Guid="*">
|
||||
<File Id="fil938BF1D1B479C73F0CECCBD51683AA0E" KeyPath="yes" Source="$(var.HarvestPath)\NLog.xml" />
|
||||
</Component>
|
||||
<Component Id="cmpC788DBAFBC9F98E69B6A163430726358" Guid="*">
|
||||
<File Id="fil90249C4571D1C5C77FEF83E6CD7C0486" KeyPath="yes" Source="$(var.HarvestPath)\PcapDotNet.Base.dll" />
|
||||
</Component>
|
||||
<Component Id="cmp34B431D779DBCB134781FB546E793672" Guid="*">
|
||||
<File Id="filF22891E372F5EE5250A214F03B209159" KeyPath="yes" Source="$(var.HarvestPath)\PcapDotNet.Base.xml" />
|
||||
</Component>
|
||||
<Component Id="cmpC306A22C66D6CF8D48E8AA6050A52C97" Guid="*">
|
||||
<File Id="fil582142C4134BD92594B8F90F7B4B5C1F" KeyPath="yes" Source="$(var.HarvestPath)\PcapDotNet.Core.dll" />
|
||||
</Component>
|
||||
<Component Id="cmp880114322C539610888B6FE5E0430EFD" Guid="*">
|
||||
<File Id="filA3DCFB0511C279CFF23D9027A6EF8034" KeyPath="yes" Source="$(var.HarvestPath)\PcapDotNet.Core.Extensions.dll" />
|
||||
</Component>
|
||||
<Component Id="cmp2BDA3BC9AACE855B92939FAC7E485D24" Guid="*">
|
||||
<File Id="fil74465812CD5B22E5E5E2DAACA2F84A09" KeyPath="yes" Source="$(var.HarvestPath)\PcapDotNet.Core.Extensions.xml" />
|
||||
</Component>
|
||||
<Component Id="cmp0DE0CF5F9F4EBB61B3E2366D5E01ACDA" Guid="*">
|
||||
<File Id="fil2B276F38ABE0890FD005BE1FD1450AC2" KeyPath="yes" Source="$(var.HarvestPath)\PcapDotNet.Core.xml" />
|
||||
</Component>
|
||||
<Component Id="cmp5B06590B9AB52A536B50EE73700F03B7" Guid="*">
|
||||
<File Id="filC3001B1F38283A14D605C01009EE5815" KeyPath="yes" Source="$(var.HarvestPath)\PcapDotNet.Packets.dll" />
|
||||
</Component>
|
||||
<Component Id="cmp4D8569518C357F8E84EFB1725283D60A" Guid="*">
|
||||
<File Id="fil160F2677CE3E20572D82BFFADCA3E0D4" KeyPath="yes" Source="$(var.HarvestPath)\PcapDotNet.Packets.xml" />
|
||||
</Component>
|
||||
<Component Id="cmp2DDF6D17BE1860B9D9659B9467BE29B2" Guid="*">
|
||||
<File Id="fil7DCA2F46028FF87F6BF1D93C796F2940" KeyPath="yes" Source="$(var.HarvestPath)\Process.NET.dll" />
|
||||
</Component>
|
||||
<Component Id="cmpC4421A56E3C93C93233BC144EDDD52DE" Guid="*">
|
||||
<File Id="fil094D2250A8E795A10D0384375675E336" KeyPath="yes" Source="$(var.HarvestPath)\Process.NET.xml" />
|
||||
</Component>
|
||||
<Component Id="cmp5628FD27631E522C3D67C498667BC8A5" Guid="*">
|
||||
<File Id="fil9AF927B04C176B9DDB9785FEBFB421F9" KeyPath="yes" Source="$(var.HarvestPath)\SharpDX.Direct3D9.dll" />
|
||||
</Component>
|
||||
<Component Id="cmp3145619F7A6A826AB72CAFCEF603B974" Guid="*">
|
||||
<File Id="fil00A86DFB8F8C65A40FEFAF17ED6E71A5" KeyPath="yes" Source="$(var.HarvestPath)\SharpDX.Direct3D9.xml" />
|
||||
</Component>
|
||||
<Component Id="cmp9607F152871CB9C2659ED14722E13E44" Guid="*">
|
||||
<File Id="filF5517F7734A13514A2CDF5F069816EE5" KeyPath="yes" Source="$(var.HarvestPath)\SharpDX.dll" />
|
||||
</Component>
|
||||
<Component Id="cmp3E773764A1181C634FC2FEFEB834376C" Guid="*">
|
||||
<File Id="fil7D1935BC55074319110C6493796D1131" KeyPath="yes" Source="$(var.HarvestPath)\SharpDX.xml" />
|
||||
</Component>
|
||||
<Component Id="cmp5483DB1210EFE289D9B08CDE6C4DF7D2" Guid="*">
|
||||
<File Id="filF8AFD1E6AB4CAF4A6E005DE4F98F25C8" KeyPath="yes" Source="$(var.HarvestPath)\SpotifyAPI.dll" />
|
||||
</Component>
|
||||
<Component Id="cmp4C89FD380B87BABF2C2EC0B905FC716A" Guid="*">
|
||||
<File Id="fil91FEC8591C752BE99EBB262282E480C7" KeyPath="yes" Source="$(var.HarvestPath)\SpotifyAPI.xml" />
|
||||
</Component>
|
||||
<Component Id="cmp017BFB3832A5B110A2B3A350E13F2A5C" Guid="*">
|
||||
<File Id="fil17E34524E8398461D615894C92558FE9" KeyPath="yes" Source="$(var.HarvestPath)\System.Windows.Interactivity.dll" />
|
||||
</Component>
|
||||
<Component Id="cmp8E352492AA4EFD741D361DB10D9CDE54" Guid="*">
|
||||
<File Id="fil4A56C6D02CE99309F98F2DC52BD44FB0" KeyPath="yes" Source="$(var.HarvestPath)\VioletTape.WpfExceptionViewer.dll" />
|
||||
</Component>
|
||||
<Directory Id="dir6D8C24E0E6B175D1F4DFF0EAC196DDF2" Name="lib">
|
||||
<Component Id="cmp97A41A22042DE905D0A5799554A3C4DB" Guid="*">
|
||||
<File Id="fil3BC1E3A3EF0D5982FD254F6A5A9D4549" KeyPath="yes" Source="$(var.HarvestPath)\lib\SDKDLL.dll" />
|
||||
</Component>
|
||||
</Directory>
|
||||
<Directory Id="dir43FCCFA109FBF584D9155DCE31E452EB" Name="x64">
|
||||
<Component Id="cmpECD409B8EBFA879EA008219F73249A40" Guid="*">
|
||||
<File Id="filA302F3B249F37DDA886F98B4984D0020" KeyPath="yes" Source="$(var.HarvestPath)\x64\CUESDK_2015.dll" />
|
||||
</Component>
|
||||
</Directory>
|
||||
<Directory Id="dir97F42FF68945B97AAE670945C4FDAE93" Name="x86">
|
||||
<Component Id="cmp0A1EF8C9603FD314A6357DDC62FAABEC" Guid="*">
|
||||
<File Id="fil51DCB5DC79C1956F92047AD679E8AB55" KeyPath="yes" Source="$(var.HarvestPath)\x86\CUESDK_2015.dll" />
|
||||
</Component>
|
||||
</Directory>
|
||||
</DirectoryRef>
|
||||
</Fragment>
|
||||
<Fragment>
|
||||
<ComponentGroup Id="HeatGenerated">
|
||||
<ComponentRef Id="cmp9B04FAC2BF56F13B71858D3F9539F8FE" />
|
||||
<ComponentRef Id="cmp84F8E8E529BEF2230424503D7A54F566" />
|
||||
<ComponentRef Id="cmp98E421B03991EBFA9D74DA1DE5FDCEB4" />
|
||||
<ComponentRef Id="cmp5978FBD119D600B675CF51F7CB5B1DB8" />
|
||||
<ComponentRef Id="cmp4688F61692F1E1A7C8A650F257BA3780" />
|
||||
<ComponentRef Id="cmpF6DB600EAE4F92B06118C49F01583429" />
|
||||
<ComponentRef Id="cmp3ADD63EC603C0189D3C536D6FE228F29" />
|
||||
<ComponentRef Id="cmp6E4F12F91C4B75E02675BB4C94196438" />
|
||||
<ComponentRef Id="cmp1C206319B53EA02514D73AF8086C62B4" />
|
||||
<ComponentRef Id="cmp3E3AA980BDCF05810907BC4EB3821194" />
|
||||
<ComponentRef Id="cmp17D9A8147FAEAB525E5B8101916313BA" />
|
||||
<ComponentRef Id="cmpA643245E2404309B3DABA70BB912DCCB" />
|
||||
<ComponentRef Id="cmpFBDA3E7CEA190733BF9F05003E25D5AF" />
|
||||
<ComponentRef Id="cmp0215030D177DFD73F427CC3D7CA19238" />
|
||||
<ComponentRef Id="cmpA1F7266A1B0ADDC69DE569177E196895" />
|
||||
<ComponentRef Id="cmp55AF7BD4F37A05E9BB3300FB06BC8083" />
|
||||
<ComponentRef Id="cmp8D9BC4E9081E35E49D1317948B71CF9E" />
|
||||
<ComponentRef Id="cmp6527C67EBA0A64B342B4DFD472F51344" />
|
||||
<ComponentRef Id="cmp51BF717902634148759143BD6AD539B0" />
|
||||
<ComponentRef Id="cmpF91C67D347AB218E39A848636AB895E3" />
|
||||
<ComponentRef Id="cmpFDA802159822E5F335299869D8F57A96" />
|
||||
<ComponentRef Id="cmp781EEA928029B571EC5B4E7090BD7946" />
|
||||
<ComponentRef Id="cmp349050BDBF99EA8BFA2BA8F9E31ED252" />
|
||||
<ComponentRef Id="cmpBE3C1D05C7C90455322C9F819A57A07A" />
|
||||
<ComponentRef Id="cmp1AB3F692680AD43D977D2B4893C60651" />
|
||||
<ComponentRef Id="cmp13D58469BCB864EB53214ED46E622188" />
|
||||
<ComponentRef Id="cmp742785C9A7B88BE6B2E81C2322E3D2EE" />
|
||||
<ComponentRef Id="cmp57FCE16B127552B85167E1625E9421BE" />
|
||||
<ComponentRef Id="cmpC92D9566450D2381C819C291B41E2EE8" />
|
||||
<ComponentRef Id="cmp223D4754378C01052DA8253A843FD297" />
|
||||
<ComponentRef Id="cmp43D899344ED173B0DAFCD84946D02788" />
|
||||
<ComponentRef Id="cmp2FCEBC7A99564B55654E85ED28E48600" />
|
||||
<ComponentRef Id="cmpF3259CFFC7B5247438581E9B04AB35D8" />
|
||||
<ComponentRef Id="cmpBC4FC00A26E7D32479D42D3411317FC5" />
|
||||
<ComponentRef Id="cmp125C379E185231EFADA4CB4301BD0A9E" />
|
||||
<ComponentRef Id="cmpDA60982F820038280380BE207B6E738E" />
|
||||
<ComponentRef Id="cmp115DB0C4CBA276D1E4BF73C7F0D12168" />
|
||||
<ComponentRef Id="cmp667EC93AB28DC800EC8C0C696B6252F3" />
|
||||
<ComponentRef Id="cmpB163B8B3242EED7EB32E270810A5C294" />
|
||||
<ComponentRef Id="cmpD934BE4677B83286DC33948DD39DDFD0" />
|
||||
<ComponentRef Id="cmpD620842EF41724FF29FB815A4D4EAC9F" />
|
||||
<ComponentRef Id="cmp00A9C690A734DF8DBF6B58522866EFB9" />
|
||||
<ComponentRef Id="cmpB8D71C46885F3F849C4526BB4F6C303F" />
|
||||
<ComponentRef Id="cmpB7F1EBE42DCB1051B92D42C1EF84E2F9" />
|
||||
<ComponentRef Id="cmpAF162B14FA6391E4D0D34D9485A3CBEB" />
|
||||
<ComponentRef Id="cmpC788DBAFBC9F98E69B6A163430726358" />
|
||||
<ComponentRef Id="cmp34B431D779DBCB134781FB546E793672" />
|
||||
<ComponentRef Id="cmpC306A22C66D6CF8D48E8AA6050A52C97" />
|
||||
<ComponentRef Id="cmp880114322C539610888B6FE5E0430EFD" />
|
||||
<ComponentRef Id="cmp2BDA3BC9AACE855B92939FAC7E485D24" />
|
||||
<ComponentRef Id="cmp0DE0CF5F9F4EBB61B3E2366D5E01ACDA" />
|
||||
<ComponentRef Id="cmp5B06590B9AB52A536B50EE73700F03B7" />
|
||||
<ComponentRef Id="cmp4D8569518C357F8E84EFB1725283D60A" />
|
||||
<ComponentRef Id="cmp2DDF6D17BE1860B9D9659B9467BE29B2" />
|
||||
<ComponentRef Id="cmpC4421A56E3C93C93233BC144EDDD52DE" />
|
||||
<ComponentRef Id="cmp5628FD27631E522C3D67C498667BC8A5" />
|
||||
<ComponentRef Id="cmp3145619F7A6A826AB72CAFCEF603B974" />
|
||||
<ComponentRef Id="cmp9607F152871CB9C2659ED14722E13E44" />
|
||||
<ComponentRef Id="cmp3E773764A1181C634FC2FEFEB834376C" />
|
||||
<ComponentRef Id="cmp5483DB1210EFE289D9B08CDE6C4DF7D2" />
|
||||
<ComponentRef Id="cmp4C89FD380B87BABF2C2EC0B905FC716A" />
|
||||
<ComponentRef Id="cmp017BFB3832A5B110A2B3A350E13F2A5C" />
|
||||
<ComponentRef Id="cmp8E352492AA4EFD741D361DB10D9CDE54" />
|
||||
<ComponentRef Id="cmp97A41A22042DE905D0A5799554A3C4DB" />
|
||||
<ComponentRef Id="cmpECD409B8EBFA879EA008219F73249A40" />
|
||||
<ComponentRef Id="cmp0A1EF8C9603FD314A6357DDC62FAABEC" />
|
||||
</ComponentGroup>
|
||||
</Fragment>
|
||||
</Wix>
|
||||
@ -1,84 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi" xmlns:util="http://schemas.microsoft.com/wix/UtilExtension">
|
||||
|
||||
<Product Id="*" Name="Artemis" Language="1033" Version="1.11.0.0" Manufacturer="SpoinkyNL" UpgradeCode="ebc7bc50-0473-4729-8de8-32ddb99bb986">
|
||||
<Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" />
|
||||
<MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
|
||||
<MediaTemplate EmbedCab="yes" />
|
||||
|
||||
<!-- Images -->
|
||||
<Icon Id="ProductIcon" SourceFile="logo.ico" />
|
||||
<WixVariable Id="WixUIBannerBmp" Value="banner.bmp" />
|
||||
<WixVariable Id="WixUIDialogBmp" Value="dialog.bmp" />
|
||||
|
||||
<Property Id="ARPPRODUCTICON" Value="ProductIcon" />
|
||||
<Property Id="ARPHELPLINK" Value="https://github.com/SpoinkyNL/Artemis/wiki" />
|
||||
<Property Id="ARPURLINFOABOUT" Value="https://github.com/SpoinkyNL/Artemis" />
|
||||
<Property Id="ARPNOREPAIR" Value="1" />
|
||||
<Property Id="INSTALLFOLDER">
|
||||
<RegistrySearch Id="ArtemisRegistry" Type="raw" Root="HKLM" Key="Software\[Manufacturer]\[ProductName]" Name="InstallDir" />
|
||||
</Property>
|
||||
<Property Id="WIXUI_INSTALLDIR" Value="INSTALLFOLDER" />
|
||||
|
||||
|
||||
<Feature Id="ProductFeature" Title="Artemis" Level="1">
|
||||
<ComponentGroupRef Id="HeatGenerated" />
|
||||
<ComponentRef Id="InstallDirRegistry"/>
|
||||
<ComponentRef Id="ApplicationShortcuts" />
|
||||
|
||||
</Feature>
|
||||
<UI Id='Mondo'>
|
||||
<Property Id="WIXUI_EXITDIALOGOPTIONALCHECKBOXTEXT" Value="Launch Artemis" />
|
||||
<UIRef Id="WixUI_InstallDir" />
|
||||
|
||||
<Publish Dialog="ExitDialog" Control="Finish" Event="DoAction" Value="LaunchApplication">
|
||||
WIXUI_EXITDIALOGOPTIONALCHECKBOX = 1 and NOT Installed
|
||||
</Publish>
|
||||
|
||||
<!-- Skip the license agreement don't have one anyway -->
|
||||
<Publish Dialog="WelcomeDlg" Control="Next" Event="NewDialog" Value="InstallDirDlg" Order="3">1</Publish>
|
||||
<Publish Dialog="InstallDirDlg" Control="Back" Event="NewDialog" Value="WelcomeDlg" Order="3">1</Publish>
|
||||
</UI>
|
||||
</Product>
|
||||
|
||||
<Fragment>
|
||||
<CustomAction Id="CloseApp" Return="ignore" Execute="deferred" Directory="TARGETDIR" Impersonate="no" ExeCommand="TASKKILL.EXE /F /IM Artemis.exe" />
|
||||
<CustomAction Id="TaskDelete" Return="ignore" Execute="deferred" Directory="TARGETDIR" Impersonate="no" ExeCommand="SCHTASKS.EXE /DELETE /TN Artemis /F" />
|
||||
<Directory Id="TARGETDIR" Name="SourceDir">
|
||||
<Directory Id="ProgramFiles64Folder">
|
||||
<Directory Id="INSTALLFOLDER" Name="Artemis" />
|
||||
<!-- Retrieve install dir from registry -->
|
||||
<Component Id="InstallDirRegistry">
|
||||
<RegistryValue Root="HKLM" Key="Software\[Manufacturer]\[ProductName]" Name="InstallDir" Type="string" Value="[INSTALLFOLDER]" KeyPath="yes" />
|
||||
</Component>
|
||||
|
||||
</Directory>
|
||||
<Directory Id="ProgramMenuFolder">
|
||||
<Directory Id="ProgramMenuSubfolder" Name="Artemis">
|
||||
<Component Id="ApplicationShortcuts" Guid="b7465bd9-c8d7-4999-9695-8bbfd9306986">
|
||||
<Shortcut Id="ApplicationShortcut1" Name="Artemis" Description="Artemis" Target="[INSTALLFOLDER]Artemis.exe" WorkingDirectory="INSTALLFOLDER" />
|
||||
<RegistryValue Root="HKCU" Key="Software\[Manufacturer]\[ProductName]" Name="installed" Type="integer" Value="1" KeyPath="yes" />
|
||||
<RemoveFolder Id="ProgramMenuSubfolder" On="uninstall" />
|
||||
</Component>
|
||||
</Directory>
|
||||
</Directory>
|
||||
</Directory>
|
||||
|
||||
<!-- Optionally run Artemis after intallation -->
|
||||
<Property Id="WixShellExecTarget" Value="[INSTALLFOLDER]Artemis.exe" />
|
||||
<CustomAction Id="LaunchApplication" BinaryKey="WixCA" DllEntry="WixShellExec" Impersonate="yes" />
|
||||
|
||||
<InstallExecuteSequence>
|
||||
<!-- Always close any running instances of Artemis -->
|
||||
<Custom Action="CloseApp" After="InstallInitialize" />
|
||||
<!--Remove task on Uninstall or Upgrade-->
|
||||
<Custom Action='TaskDelete' Before="InstallFinalize">REMOVE="ALL"</Custom>
|
||||
</InstallExecuteSequence>
|
||||
</Fragment>
|
||||
|
||||
<Fragment>
|
||||
<ComponentGroup Id="ProductComponents" Directory="INSTALLFOLDER">
|
||||
</ComponentGroup>
|
||||
</Fragment>
|
||||
</Wix>
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 84 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 451 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 361 KiB |
@ -1,246 +0,0 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 15
|
||||
VisualStudioVersion = 15.0.26730.12
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Artemis", "Artemis\Artemis.csproj", "{ED9997A2-E54C-4E9F-9350-62BE672C3ABE}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Razer2Artemis", "Razer2Artemis\Razer2Artemis.vcxproj", "{39711909-C1D5-46CE-A9EA-2D561692EA47}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ColorBox", "ColorBox\ColorBox.csproj", "{40085232-ACED-4CBE-945B-90BA8153C151}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "LogiLed2Artemis", "LogiLed2Artemis\LogiLed2Artemis.vcxproj", "{D2EDB8F3-F0CB-4670-B472-0B46D5800D2C}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Artemis86Wrapper", "Artemis86Wrapper\Artemis86Wrapper.csproj", "{47A9BBFD-4BEA-4D7D-8AB7-896E760B2CF2}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "LightFX2Artemis", "LightFX2Artemis\LightFX2Artemis.vcxproj", "{1A349CF5-2008-41E8-AC13-874CBBCDFA0A}"
|
||||
EndProject
|
||||
Project("{930C7802-8A8C-48F9-8165-68863BCCD9DD}") = "Artemis.Installer", "Artemis.Installer\Artemis.Installer.wixproj", "{A34F9047-8464-4423-89EF-A2F43E089E93}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
CD_ROM|Any CPU = CD_ROM|Any CPU
|
||||
CD_ROM|x64 = CD_ROM|x64
|
||||
CD_ROM|x86 = CD_ROM|x86
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Debug|x64 = Debug|x64
|
||||
Debug|x86 = Debug|x86
|
||||
DVD-5|Any CPU = DVD-5|Any CPU
|
||||
DVD-5|x64 = DVD-5|x64
|
||||
DVD-5|x86 = DVD-5|x86
|
||||
Release|Any CPU = Release|Any CPU
|
||||
Release|x64 = Release|x64
|
||||
Release|x86 = Release|x86
|
||||
SingleImage|Any CPU = SingleImage|Any CPU
|
||||
SingleImage|x64 = SingleImage|x64
|
||||
SingleImage|x86 = SingleImage|x86
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{ED9997A2-E54C-4E9F-9350-62BE672C3ABE}.CD_ROM|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{ED9997A2-E54C-4E9F-9350-62BE672C3ABE}.CD_ROM|Any CPU.Build.0 = Release|Any CPU
|
||||
{ED9997A2-E54C-4E9F-9350-62BE672C3ABE}.CD_ROM|x64.ActiveCfg = Release|x64
|
||||
{ED9997A2-E54C-4E9F-9350-62BE672C3ABE}.CD_ROM|x64.Build.0 = Release|x64
|
||||
{ED9997A2-E54C-4E9F-9350-62BE672C3ABE}.CD_ROM|x86.ActiveCfg = Release|x86
|
||||
{ED9997A2-E54C-4E9F-9350-62BE672C3ABE}.CD_ROM|x86.Build.0 = Release|x86
|
||||
{ED9997A2-E54C-4E9F-9350-62BE672C3ABE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{ED9997A2-E54C-4E9F-9350-62BE672C3ABE}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{ED9997A2-E54C-4E9F-9350-62BE672C3ABE}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{ED9997A2-E54C-4E9F-9350-62BE672C3ABE}.Debug|x64.Build.0 = Debug|x64
|
||||
{ED9997A2-E54C-4E9F-9350-62BE672C3ABE}.Debug|x86.ActiveCfg = Debug|x86
|
||||
{ED9997A2-E54C-4E9F-9350-62BE672C3ABE}.Debug|x86.Build.0 = Debug|x86
|
||||
{ED9997A2-E54C-4E9F-9350-62BE672C3ABE}.DVD-5|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{ED9997A2-E54C-4E9F-9350-62BE672C3ABE}.DVD-5|Any CPU.Build.0 = Debug|Any CPU
|
||||
{ED9997A2-E54C-4E9F-9350-62BE672C3ABE}.DVD-5|x64.ActiveCfg = Debug|x64
|
||||
{ED9997A2-E54C-4E9F-9350-62BE672C3ABE}.DVD-5|x64.Build.0 = Debug|x64
|
||||
{ED9997A2-E54C-4E9F-9350-62BE672C3ABE}.DVD-5|x86.ActiveCfg = Debug|x86
|
||||
{ED9997A2-E54C-4E9F-9350-62BE672C3ABE}.DVD-5|x86.Build.0 = Debug|x86
|
||||
{ED9997A2-E54C-4E9F-9350-62BE672C3ABE}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{ED9997A2-E54C-4E9F-9350-62BE672C3ABE}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{ED9997A2-E54C-4E9F-9350-62BE672C3ABE}.Release|x64.ActiveCfg = Release|x64
|
||||
{ED9997A2-E54C-4E9F-9350-62BE672C3ABE}.Release|x64.Build.0 = Release|x64
|
||||
{ED9997A2-E54C-4E9F-9350-62BE672C3ABE}.Release|x86.ActiveCfg = Release|x86
|
||||
{ED9997A2-E54C-4E9F-9350-62BE672C3ABE}.Release|x86.Build.0 = Release|x86
|
||||
{ED9997A2-E54C-4E9F-9350-62BE672C3ABE}.SingleImage|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{ED9997A2-E54C-4E9F-9350-62BE672C3ABE}.SingleImage|Any CPU.Build.0 = Release|Any CPU
|
||||
{ED9997A2-E54C-4E9F-9350-62BE672C3ABE}.SingleImage|x64.ActiveCfg = Release|x64
|
||||
{ED9997A2-E54C-4E9F-9350-62BE672C3ABE}.SingleImage|x64.Build.0 = Release|x64
|
||||
{ED9997A2-E54C-4E9F-9350-62BE672C3ABE}.SingleImage|x86.ActiveCfg = Release|x86
|
||||
{ED9997A2-E54C-4E9F-9350-62BE672C3ABE}.SingleImage|x86.Build.0 = Release|x86
|
||||
{39711909-C1D5-46CE-A9EA-2D561692EA47}.CD_ROM|Any CPU.ActiveCfg = Release|x64
|
||||
{39711909-C1D5-46CE-A9EA-2D561692EA47}.CD_ROM|Any CPU.Build.0 = Release|x64
|
||||
{39711909-C1D5-46CE-A9EA-2D561692EA47}.CD_ROM|x64.ActiveCfg = Release|x64
|
||||
{39711909-C1D5-46CE-A9EA-2D561692EA47}.CD_ROM|x64.Build.0 = Release|x64
|
||||
{39711909-C1D5-46CE-A9EA-2D561692EA47}.CD_ROM|x86.ActiveCfg = Release|Win32
|
||||
{39711909-C1D5-46CE-A9EA-2D561692EA47}.CD_ROM|x86.Build.0 = Release|Win32
|
||||
{39711909-C1D5-46CE-A9EA-2D561692EA47}.Debug|Any CPU.ActiveCfg = Debug|Win32
|
||||
{39711909-C1D5-46CE-A9EA-2D561692EA47}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{39711909-C1D5-46CE-A9EA-2D561692EA47}.Debug|x64.Build.0 = Debug|x64
|
||||
{39711909-C1D5-46CE-A9EA-2D561692EA47}.Debug|x86.ActiveCfg = Debug|Win32
|
||||
{39711909-C1D5-46CE-A9EA-2D561692EA47}.Debug|x86.Build.0 = Debug|Win32
|
||||
{39711909-C1D5-46CE-A9EA-2D561692EA47}.DVD-5|Any CPU.ActiveCfg = Release|x64
|
||||
{39711909-C1D5-46CE-A9EA-2D561692EA47}.DVD-5|Any CPU.Build.0 = Release|x64
|
||||
{39711909-C1D5-46CE-A9EA-2D561692EA47}.DVD-5|x64.ActiveCfg = Debug|x64
|
||||
{39711909-C1D5-46CE-A9EA-2D561692EA47}.DVD-5|x64.Build.0 = Debug|x64
|
||||
{39711909-C1D5-46CE-A9EA-2D561692EA47}.DVD-5|x86.ActiveCfg = Debug|Win32
|
||||
{39711909-C1D5-46CE-A9EA-2D561692EA47}.DVD-5|x86.Build.0 = Debug|Win32
|
||||
{39711909-C1D5-46CE-A9EA-2D561692EA47}.Release|Any CPU.ActiveCfg = Release|Win32
|
||||
{39711909-C1D5-46CE-A9EA-2D561692EA47}.Release|x64.ActiveCfg = Release|x64
|
||||
{39711909-C1D5-46CE-A9EA-2D561692EA47}.Release|x64.Build.0 = Release|x64
|
||||
{39711909-C1D5-46CE-A9EA-2D561692EA47}.Release|x86.ActiveCfg = Release|Win32
|
||||
{39711909-C1D5-46CE-A9EA-2D561692EA47}.Release|x86.Build.0 = Release|Win32
|
||||
{39711909-C1D5-46CE-A9EA-2D561692EA47}.SingleImage|Any CPU.ActiveCfg = Release|x64
|
||||
{39711909-C1D5-46CE-A9EA-2D561692EA47}.SingleImage|Any CPU.Build.0 = Release|x64
|
||||
{39711909-C1D5-46CE-A9EA-2D561692EA47}.SingleImage|x64.ActiveCfg = Release|x64
|
||||
{39711909-C1D5-46CE-A9EA-2D561692EA47}.SingleImage|x64.Build.0 = Release|x64
|
||||
{39711909-C1D5-46CE-A9EA-2D561692EA47}.SingleImage|x86.ActiveCfg = Release|Win32
|
||||
{39711909-C1D5-46CE-A9EA-2D561692EA47}.SingleImage|x86.Build.0 = Release|Win32
|
||||
{40085232-ACED-4CBE-945B-90BA8153C151}.CD_ROM|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{40085232-ACED-4CBE-945B-90BA8153C151}.CD_ROM|Any CPU.Build.0 = Release|Any CPU
|
||||
{40085232-ACED-4CBE-945B-90BA8153C151}.CD_ROM|x64.ActiveCfg = Release|Any CPU
|
||||
{40085232-ACED-4CBE-945B-90BA8153C151}.CD_ROM|x64.Build.0 = Release|Any CPU
|
||||
{40085232-ACED-4CBE-945B-90BA8153C151}.CD_ROM|x86.ActiveCfg = Release|Any CPU
|
||||
{40085232-ACED-4CBE-945B-90BA8153C151}.CD_ROM|x86.Build.0 = Release|Any CPU
|
||||
{40085232-ACED-4CBE-945B-90BA8153C151}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{40085232-ACED-4CBE-945B-90BA8153C151}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{40085232-ACED-4CBE-945B-90BA8153C151}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{40085232-ACED-4CBE-945B-90BA8153C151}.Debug|x64.Build.0 = Debug|Any CPU
|
||||
{40085232-ACED-4CBE-945B-90BA8153C151}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{40085232-ACED-4CBE-945B-90BA8153C151}.Debug|x86.Build.0 = Debug|Any CPU
|
||||
{40085232-ACED-4CBE-945B-90BA8153C151}.DVD-5|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{40085232-ACED-4CBE-945B-90BA8153C151}.DVD-5|Any CPU.Build.0 = Debug|Any CPU
|
||||
{40085232-ACED-4CBE-945B-90BA8153C151}.DVD-5|x64.ActiveCfg = Debug|Any CPU
|
||||
{40085232-ACED-4CBE-945B-90BA8153C151}.DVD-5|x64.Build.0 = Debug|Any CPU
|
||||
{40085232-ACED-4CBE-945B-90BA8153C151}.DVD-5|x86.ActiveCfg = Debug|Any CPU
|
||||
{40085232-ACED-4CBE-945B-90BA8153C151}.DVD-5|x86.Build.0 = Debug|Any CPU
|
||||
{40085232-ACED-4CBE-945B-90BA8153C151}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{40085232-ACED-4CBE-945B-90BA8153C151}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{40085232-ACED-4CBE-945B-90BA8153C151}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{40085232-ACED-4CBE-945B-90BA8153C151}.Release|x64.Build.0 = Release|Any CPU
|
||||
{40085232-ACED-4CBE-945B-90BA8153C151}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{40085232-ACED-4CBE-945B-90BA8153C151}.Release|x86.Build.0 = Release|Any CPU
|
||||
{40085232-ACED-4CBE-945B-90BA8153C151}.SingleImage|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{40085232-ACED-4CBE-945B-90BA8153C151}.SingleImage|Any CPU.Build.0 = Release|Any CPU
|
||||
{40085232-ACED-4CBE-945B-90BA8153C151}.SingleImage|x64.ActiveCfg = Release|Any CPU
|
||||
{40085232-ACED-4CBE-945B-90BA8153C151}.SingleImage|x64.Build.0 = Release|Any CPU
|
||||
{40085232-ACED-4CBE-945B-90BA8153C151}.SingleImage|x86.ActiveCfg = Release|Any CPU
|
||||
{40085232-ACED-4CBE-945B-90BA8153C151}.SingleImage|x86.Build.0 = Release|Any CPU
|
||||
{D2EDB8F3-F0CB-4670-B472-0B46D5800D2C}.CD_ROM|Any CPU.ActiveCfg = Release|x64
|
||||
{D2EDB8F3-F0CB-4670-B472-0B46D5800D2C}.CD_ROM|Any CPU.Build.0 = Release|x64
|
||||
{D2EDB8F3-F0CB-4670-B472-0B46D5800D2C}.CD_ROM|x64.ActiveCfg = Release|x64
|
||||
{D2EDB8F3-F0CB-4670-B472-0B46D5800D2C}.CD_ROM|x64.Build.0 = Release|x64
|
||||
{D2EDB8F3-F0CB-4670-B472-0B46D5800D2C}.CD_ROM|x86.ActiveCfg = Release|Win32
|
||||
{D2EDB8F3-F0CB-4670-B472-0B46D5800D2C}.CD_ROM|x86.Build.0 = Release|Win32
|
||||
{D2EDB8F3-F0CB-4670-B472-0B46D5800D2C}.Debug|Any CPU.ActiveCfg = Debug|Win32
|
||||
{D2EDB8F3-F0CB-4670-B472-0B46D5800D2C}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{D2EDB8F3-F0CB-4670-B472-0B46D5800D2C}.Debug|x64.Build.0 = Debug|x64
|
||||
{D2EDB8F3-F0CB-4670-B472-0B46D5800D2C}.Debug|x86.ActiveCfg = Debug|Win32
|
||||
{D2EDB8F3-F0CB-4670-B472-0B46D5800D2C}.Debug|x86.Build.0 = Debug|Win32
|
||||
{D2EDB8F3-F0CB-4670-B472-0B46D5800D2C}.DVD-5|Any CPU.ActiveCfg = Release|x64
|
||||
{D2EDB8F3-F0CB-4670-B472-0B46D5800D2C}.DVD-5|Any CPU.Build.0 = Release|x64
|
||||
{D2EDB8F3-F0CB-4670-B472-0B46D5800D2C}.DVD-5|x64.ActiveCfg = Debug|x64
|
||||
{D2EDB8F3-F0CB-4670-B472-0B46D5800D2C}.DVD-5|x64.Build.0 = Debug|x64
|
||||
{D2EDB8F3-F0CB-4670-B472-0B46D5800D2C}.DVD-5|x86.ActiveCfg = Debug|Win32
|
||||
{D2EDB8F3-F0CB-4670-B472-0B46D5800D2C}.DVD-5|x86.Build.0 = Debug|Win32
|
||||
{D2EDB8F3-F0CB-4670-B472-0B46D5800D2C}.Release|Any CPU.ActiveCfg = Release|Win32
|
||||
{D2EDB8F3-F0CB-4670-B472-0B46D5800D2C}.Release|x64.ActiveCfg = Release|x64
|
||||
{D2EDB8F3-F0CB-4670-B472-0B46D5800D2C}.Release|x64.Build.0 = Release|x64
|
||||
{D2EDB8F3-F0CB-4670-B472-0B46D5800D2C}.Release|x86.ActiveCfg = Release|Win32
|
||||
{D2EDB8F3-F0CB-4670-B472-0B46D5800D2C}.Release|x86.Build.0 = Release|Win32
|
||||
{D2EDB8F3-F0CB-4670-B472-0B46D5800D2C}.SingleImage|Any CPU.ActiveCfg = Release|x64
|
||||
{D2EDB8F3-F0CB-4670-B472-0B46D5800D2C}.SingleImage|Any CPU.Build.0 = Release|x64
|
||||
{D2EDB8F3-F0CB-4670-B472-0B46D5800D2C}.SingleImage|x64.ActiveCfg = Release|x64
|
||||
{D2EDB8F3-F0CB-4670-B472-0B46D5800D2C}.SingleImage|x64.Build.0 = Release|x64
|
||||
{D2EDB8F3-F0CB-4670-B472-0B46D5800D2C}.SingleImage|x86.ActiveCfg = Release|Win32
|
||||
{D2EDB8F3-F0CB-4670-B472-0B46D5800D2C}.SingleImage|x86.Build.0 = Release|Win32
|
||||
{47A9BBFD-4BEA-4D7D-8AB7-896E760B2CF2}.CD_ROM|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{47A9BBFD-4BEA-4D7D-8AB7-896E760B2CF2}.CD_ROM|Any CPU.Build.0 = Release|Any CPU
|
||||
{47A9BBFD-4BEA-4D7D-8AB7-896E760B2CF2}.CD_ROM|x64.ActiveCfg = Release|Any CPU
|
||||
{47A9BBFD-4BEA-4D7D-8AB7-896E760B2CF2}.CD_ROM|x64.Build.0 = Release|Any CPU
|
||||
{47A9BBFD-4BEA-4D7D-8AB7-896E760B2CF2}.CD_ROM|x86.ActiveCfg = Release|Any CPU
|
||||
{47A9BBFD-4BEA-4D7D-8AB7-896E760B2CF2}.CD_ROM|x86.Build.0 = Release|Any CPU
|
||||
{47A9BBFD-4BEA-4D7D-8AB7-896E760B2CF2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{47A9BBFD-4BEA-4D7D-8AB7-896E760B2CF2}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{47A9BBFD-4BEA-4D7D-8AB7-896E760B2CF2}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{47A9BBFD-4BEA-4D7D-8AB7-896E760B2CF2}.Debug|x64.Build.0 = Debug|Any CPU
|
||||
{47A9BBFD-4BEA-4D7D-8AB7-896E760B2CF2}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{47A9BBFD-4BEA-4D7D-8AB7-896E760B2CF2}.Debug|x86.Build.0 = Debug|Any CPU
|
||||
{47A9BBFD-4BEA-4D7D-8AB7-896E760B2CF2}.DVD-5|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{47A9BBFD-4BEA-4D7D-8AB7-896E760B2CF2}.DVD-5|Any CPU.Build.0 = Debug|Any CPU
|
||||
{47A9BBFD-4BEA-4D7D-8AB7-896E760B2CF2}.DVD-5|x64.ActiveCfg = Debug|Any CPU
|
||||
{47A9BBFD-4BEA-4D7D-8AB7-896E760B2CF2}.DVD-5|x64.Build.0 = Debug|Any CPU
|
||||
{47A9BBFD-4BEA-4D7D-8AB7-896E760B2CF2}.DVD-5|x86.ActiveCfg = Debug|Any CPU
|
||||
{47A9BBFD-4BEA-4D7D-8AB7-896E760B2CF2}.DVD-5|x86.Build.0 = Debug|Any CPU
|
||||
{47A9BBFD-4BEA-4D7D-8AB7-896E760B2CF2}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{47A9BBFD-4BEA-4D7D-8AB7-896E760B2CF2}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{47A9BBFD-4BEA-4D7D-8AB7-896E760B2CF2}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{47A9BBFD-4BEA-4D7D-8AB7-896E760B2CF2}.Release|x64.Build.0 = Release|Any CPU
|
||||
{47A9BBFD-4BEA-4D7D-8AB7-896E760B2CF2}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{47A9BBFD-4BEA-4D7D-8AB7-896E760B2CF2}.Release|x86.Build.0 = Release|Any CPU
|
||||
{47A9BBFD-4BEA-4D7D-8AB7-896E760B2CF2}.SingleImage|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{47A9BBFD-4BEA-4D7D-8AB7-896E760B2CF2}.SingleImage|Any CPU.Build.0 = Release|Any CPU
|
||||
{47A9BBFD-4BEA-4D7D-8AB7-896E760B2CF2}.SingleImage|x64.ActiveCfg = Release|Any CPU
|
||||
{47A9BBFD-4BEA-4D7D-8AB7-896E760B2CF2}.SingleImage|x64.Build.0 = Release|Any CPU
|
||||
{47A9BBFD-4BEA-4D7D-8AB7-896E760B2CF2}.SingleImage|x86.ActiveCfg = Release|Any CPU
|
||||
{47A9BBFD-4BEA-4D7D-8AB7-896E760B2CF2}.SingleImage|x86.Build.0 = Release|Any CPU
|
||||
{1A349CF5-2008-41E8-AC13-874CBBCDFA0A}.CD_ROM|Any CPU.ActiveCfg = Release|x64
|
||||
{1A349CF5-2008-41E8-AC13-874CBBCDFA0A}.CD_ROM|Any CPU.Build.0 = Release|x64
|
||||
{1A349CF5-2008-41E8-AC13-874CBBCDFA0A}.CD_ROM|x64.ActiveCfg = Release|x64
|
||||
{1A349CF5-2008-41E8-AC13-874CBBCDFA0A}.CD_ROM|x64.Build.0 = Release|x64
|
||||
{1A349CF5-2008-41E8-AC13-874CBBCDFA0A}.CD_ROM|x86.ActiveCfg = Release|Win32
|
||||
{1A349CF5-2008-41E8-AC13-874CBBCDFA0A}.CD_ROM|x86.Build.0 = Release|Win32
|
||||
{1A349CF5-2008-41E8-AC13-874CBBCDFA0A}.Debug|Any CPU.ActiveCfg = Debug|Win32
|
||||
{1A349CF5-2008-41E8-AC13-874CBBCDFA0A}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{1A349CF5-2008-41E8-AC13-874CBBCDFA0A}.Debug|x64.Build.0 = Debug|x64
|
||||
{1A349CF5-2008-41E8-AC13-874CBBCDFA0A}.Debug|x86.ActiveCfg = Debug|Win32
|
||||
{1A349CF5-2008-41E8-AC13-874CBBCDFA0A}.Debug|x86.Build.0 = Debug|Win32
|
||||
{1A349CF5-2008-41E8-AC13-874CBBCDFA0A}.DVD-5|Any CPU.ActiveCfg = Release|x64
|
||||
{1A349CF5-2008-41E8-AC13-874CBBCDFA0A}.DVD-5|Any CPU.Build.0 = Release|x64
|
||||
{1A349CF5-2008-41E8-AC13-874CBBCDFA0A}.DVD-5|x64.ActiveCfg = Debug|x64
|
||||
{1A349CF5-2008-41E8-AC13-874CBBCDFA0A}.DVD-5|x64.Build.0 = Debug|x64
|
||||
{1A349CF5-2008-41E8-AC13-874CBBCDFA0A}.DVD-5|x86.ActiveCfg = Debug|Win32
|
||||
{1A349CF5-2008-41E8-AC13-874CBBCDFA0A}.DVD-5|x86.Build.0 = Debug|Win32
|
||||
{1A349CF5-2008-41E8-AC13-874CBBCDFA0A}.Release|Any CPU.ActiveCfg = Release|Win32
|
||||
{1A349CF5-2008-41E8-AC13-874CBBCDFA0A}.Release|x64.ActiveCfg = Release|x64
|
||||
{1A349CF5-2008-41E8-AC13-874CBBCDFA0A}.Release|x64.Build.0 = Release|x64
|
||||
{1A349CF5-2008-41E8-AC13-874CBBCDFA0A}.Release|x86.ActiveCfg = Release|Win32
|
||||
{1A349CF5-2008-41E8-AC13-874CBBCDFA0A}.Release|x86.Build.0 = Release|Win32
|
||||
{1A349CF5-2008-41E8-AC13-874CBBCDFA0A}.SingleImage|Any CPU.ActiveCfg = Release|x64
|
||||
{1A349CF5-2008-41E8-AC13-874CBBCDFA0A}.SingleImage|Any CPU.Build.0 = Release|x64
|
||||
{1A349CF5-2008-41E8-AC13-874CBBCDFA0A}.SingleImage|x64.ActiveCfg = Release|x64
|
||||
{1A349CF5-2008-41E8-AC13-874CBBCDFA0A}.SingleImage|x64.Build.0 = Release|x64
|
||||
{1A349CF5-2008-41E8-AC13-874CBBCDFA0A}.SingleImage|x86.ActiveCfg = Release|Win32
|
||||
{1A349CF5-2008-41E8-AC13-874CBBCDFA0A}.SingleImage|x86.Build.0 = Release|Win32
|
||||
{A34F9047-8464-4423-89EF-A2F43E089E93}.CD_ROM|Any CPU.ActiveCfg = Release|x86
|
||||
{A34F9047-8464-4423-89EF-A2F43E089E93}.CD_ROM|Any CPU.Build.0 = Release|x86
|
||||
{A34F9047-8464-4423-89EF-A2F43E089E93}.CD_ROM|x64.ActiveCfg = Release|x86
|
||||
{A34F9047-8464-4423-89EF-A2F43E089E93}.CD_ROM|x64.Build.0 = Release|x86
|
||||
{A34F9047-8464-4423-89EF-A2F43E089E93}.CD_ROM|x86.ActiveCfg = Release|x86
|
||||
{A34F9047-8464-4423-89EF-A2F43E089E93}.CD_ROM|x86.Build.0 = Release|x86
|
||||
{A34F9047-8464-4423-89EF-A2F43E089E93}.Debug|Any CPU.ActiveCfg = Debug|x86
|
||||
{A34F9047-8464-4423-89EF-A2F43E089E93}.Debug|x64.ActiveCfg = Debug|x86
|
||||
{A34F9047-8464-4423-89EF-A2F43E089E93}.Debug|x86.ActiveCfg = Debug|x86
|
||||
{A34F9047-8464-4423-89EF-A2F43E089E93}.Debug|x86.Build.0 = Debug|x86
|
||||
{A34F9047-8464-4423-89EF-A2F43E089E93}.DVD-5|Any CPU.ActiveCfg = Release|x86
|
||||
{A34F9047-8464-4423-89EF-A2F43E089E93}.DVD-5|Any CPU.Build.0 = Release|x86
|
||||
{A34F9047-8464-4423-89EF-A2F43E089E93}.DVD-5|x64.ActiveCfg = Release|x86
|
||||
{A34F9047-8464-4423-89EF-A2F43E089E93}.DVD-5|x64.Build.0 = Release|x86
|
||||
{A34F9047-8464-4423-89EF-A2F43E089E93}.DVD-5|x86.ActiveCfg = Debug|x86
|
||||
{A34F9047-8464-4423-89EF-A2F43E089E93}.DVD-5|x86.Build.0 = Debug|x86
|
||||
{A34F9047-8464-4423-89EF-A2F43E089E93}.Release|Any CPU.ActiveCfg = Release|x86
|
||||
{A34F9047-8464-4423-89EF-A2F43E089E93}.Release|x64.ActiveCfg = Release|x86
|
||||
{A34F9047-8464-4423-89EF-A2F43E089E93}.Release|x86.ActiveCfg = Release|x86
|
||||
{A34F9047-8464-4423-89EF-A2F43E089E93}.Release|x86.Build.0 = Release|x86
|
||||
{A34F9047-8464-4423-89EF-A2F43E089E93}.SingleImage|Any CPU.ActiveCfg = Release|x86
|
||||
{A34F9047-8464-4423-89EF-A2F43E089E93}.SingleImage|Any CPU.Build.0 = Release|x86
|
||||
{A34F9047-8464-4423-89EF-A2F43E089E93}.SingleImage|x64.ActiveCfg = Release|x86
|
||||
{A34F9047-8464-4423-89EF-A2F43E089E93}.SingleImage|x64.Build.0 = Release|x86
|
||||
{A34F9047-8464-4423-89EF-A2F43E089E93}.SingleImage|x86.ActiveCfg = Release|x86
|
||||
{A34F9047-8464-4423-89EF-A2F43E089E93}.SingleImage|x86.Build.0 = Release|x86
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {7F70A235-016F-4E1A-85B7-B66102F15535}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
@ -1,53 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<configuration>
|
||||
<configSections />
|
||||
<connectionStrings />
|
||||
<startup>
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
|
||||
</startup>
|
||||
<runtime>
|
||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-10.0.0.0" newVersion="10.0.0.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="log4net" publicKeyToken="669e0ddf0bb1aa2a" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-1.2.15.0" newVersion="1.2.15.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Caliburn.Micro" publicKeyToken="8e5891231f2ed21f" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-2.0.2.0" newVersion="2.0.2.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Caliburn.Micro.Platform" publicKeyToken="8e5891231f2ed21f" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-2.0.2.0" newVersion="2.0.2.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Autofac" publicKeyToken="17863af14b0044da" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="SharpDX" publicKeyToken="b4dcf0f35e5521f1" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-4.0.1.0" newVersion="4.0.1.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Castle.Core" publicKeyToken="407dd0808d44fbdc" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-3.3.0.0" newVersion="3.3.0.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="NLog" publicKeyToken="5120e14c03d0593c" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="DeltaCompressionDotNet.MsDelta" publicKeyToken="46b2138a390abf55" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-1.1.0.0" newVersion="1.1.0.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="SharpCompress" publicKeyToken="afb0a02973931d96" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-0.18.1.0" newVersion="0.18.1.0" />
|
||||
</dependentAssembly>
|
||||
</assemblyBinding></runtime>
|
||||
|
||||
</configuration>
|
||||
@ -1,28 +0,0 @@
|
||||
<Application x:Class="Artemis.App"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:artemis="clr-namespace:Artemis"
|
||||
xmlns:converters="clr-namespace:Artemis.Utilities.Converters"
|
||||
DispatcherUnhandledException="Application_DispatcherUnhandledException"
|
||||
ShutdownMode="OnExplicitShutdown">
|
||||
<Application.Resources>
|
||||
<ResourceDictionary>
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<ResourceDictionary>
|
||||
<artemis:ArtemisBootstrapper x:Key="ArtemisBootstrapper" />
|
||||
</ResourceDictionary>
|
||||
<!-- MahApps.Metro resource dictionaries. Make sure that all file names are Case Sensitive! -->
|
||||
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.xaml" />
|
||||
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Fonts.xaml" />
|
||||
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Colors.xaml" />
|
||||
<!-- Accent and AppTheme setting -->
|
||||
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Accents/Teal.xaml" />
|
||||
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Accents/BaseDark.xaml" />
|
||||
<ResourceDictionary Source="/Resources/Icons.xaml" />
|
||||
<ResourceDictionary Source="Styles/ColorBox.xaml" />
|
||||
<ResourceDictionary Source="Styles/MarkdownStyles.xaml" />
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
<converters:MilliSecondTimespanConverter x:Key="MilliSecondTimespanConverter" />
|
||||
</ResourceDictionary>
|
||||
</Application.Resources>
|
||||
</Application>
|
||||
@ -1,57 +0,0 @@
|
||||
using System;
|
||||
using System.Windows;
|
||||
using System.Windows.Threading;
|
||||
using Artemis.Utilities;
|
||||
using NLog;
|
||||
using WpfExceptionViewer;
|
||||
|
||||
namespace Artemis
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for App.xaml
|
||||
/// </summary>
|
||||
public partial class App : Application
|
||||
{
|
||||
public App()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public bool DoHandle { get; set; }
|
||||
|
||||
protected override void OnExit(ExitEventArgs e)
|
||||
{
|
||||
base.OnExit(e);
|
||||
Environment.Exit(0);
|
||||
}
|
||||
|
||||
private void Application_DispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e)
|
||||
{
|
||||
// Get rid of the keyboard hook in case of a crash, otherwise input freezes up system wide until Artemis is gone
|
||||
InputHook.Stop();
|
||||
|
||||
if (DoHandle)
|
||||
{
|
||||
GetArtemisExceptionViewer(e.Exception).ShowDialog();
|
||||
e.Handled = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
GetArtemisExceptionViewer(e.Exception).ShowDialog();
|
||||
e.Handled = false;
|
||||
}
|
||||
}
|
||||
|
||||
public static ExceptionViewer GetArtemisExceptionViewer(Exception e)
|
||||
{
|
||||
var logger = LogManager.GetCurrentClassLogger();
|
||||
logger.Fatal(e, "Unhandled exception, showing dialog and shutting down.");
|
||||
return new ExceptionViewer("An unexpected error occurred in Artemis.", e)
|
||||
{
|
||||
Title = "Artemis - Exception :c",
|
||||
Height = 400,
|
||||
Width = 800
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@ -1,146 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Input;
|
||||
using Artemis.DAL;
|
||||
using Artemis.InjectionModules;
|
||||
using Artemis.Services;
|
||||
using Artemis.Settings;
|
||||
using Artemis.Utilities;
|
||||
using Artemis.Utilities.ActiveWindowDetection;
|
||||
using Artemis.Utilities.Converters;
|
||||
using Artemis.Utilities.DataReaders;
|
||||
using Artemis.ViewModels;
|
||||
using Caliburn.Micro;
|
||||
using Newtonsoft.Json;
|
||||
using Ninject;
|
||||
|
||||
namespace Artemis
|
||||
{
|
||||
public class ArtemisBootstrapper : BootstrapperBase
|
||||
{
|
||||
private IKernel _kernel;
|
||||
|
||||
public ArtemisBootstrapper()
|
||||
{
|
||||
// Make sure the data folder exists
|
||||
GeneralHelpers.SetupDataFolder();
|
||||
|
||||
// Start logging before anything else
|
||||
Logging.SetupLogging(SettingsProvider.Load<GeneralSettings>().LogLevel);
|
||||
// Restore DDLs before interacting with any SDKs
|
||||
DllManager.RestoreLogitechDll();
|
||||
// Check compatibility before trying to boot further
|
||||
CompatibilityService.CheckRivaTuner();
|
||||
Updater.CleanSquirrel();
|
||||
|
||||
Initialize();
|
||||
BindSpecialValues();
|
||||
|
||||
AppDomain.CurrentDomain.UnhandledException += CurrentDomainOnUnhandledException;
|
||||
}
|
||||
|
||||
private void CurrentDomainOnUnhandledException(object sender, UnhandledExceptionEventArgs unhandledExceptionEventArgs)
|
||||
{
|
||||
// Get rid of the keyboard hook in case of a crash, otherwise input freezes up system wide until Artemis is gone
|
||||
InputHook.Stop();
|
||||
}
|
||||
|
||||
private void BindSpecialValues()
|
||||
{
|
||||
MessageBinder.SpecialValues.Add("$scaledmousex", ctx =>
|
||||
{
|
||||
var img = ctx.Source as Image;
|
||||
var input = ctx.Source as IInputElement;
|
||||
var e = ctx.EventArgs as MouseEventArgs;
|
||||
|
||||
// If there is an image control, get the scaled position
|
||||
if (img != null && e != null)
|
||||
{
|
||||
var position = e.GetPosition(img);
|
||||
return (int) (img.Source.Width * (position.X / img.ActualWidth));
|
||||
}
|
||||
|
||||
// If there is another type of of IInputControl get the non-scaled position - or do some processing to get a scaled position, whatever needs to happen
|
||||
if (e != null && input != null)
|
||||
return e.GetPosition(input).X;
|
||||
|
||||
// Return 0 if no processing could be done
|
||||
return 0;
|
||||
});
|
||||
MessageBinder.SpecialValues.Add("$scaledmousey", ctx =>
|
||||
{
|
||||
var img = ctx.Source as Image;
|
||||
var input = ctx.Source as IInputElement;
|
||||
var e = ctx.EventArgs as MouseEventArgs;
|
||||
|
||||
// If there is an image control, get the scaled position
|
||||
if (img != null && e != null)
|
||||
{
|
||||
var position = e.GetPosition(img);
|
||||
return (int) (img.Source.Width * (position.Y / img.ActualWidth));
|
||||
}
|
||||
|
||||
// If there is another type of of IInputControl get the non-scaled position - or do some processing to get a scaled position, whatever needs to happen
|
||||
if (e != null && input != null)
|
||||
return e.GetPosition(input).Y;
|
||||
|
||||
// Return 0 if no processing could be done
|
||||
return 0;
|
||||
});
|
||||
}
|
||||
|
||||
protected override void Configure()
|
||||
{
|
||||
_kernel = new StandardKernel(new BaseModules(), new ManagerModules());
|
||||
|
||||
_kernel.Bind<IWindowManager>().To<WindowManager>().InSingletonScope();
|
||||
_kernel.Bind<IEventAggregator>().To<EventAggregator>().InSingletonScope();
|
||||
|
||||
// Configure JSON.NET
|
||||
var settings = new JsonSerializerSettings
|
||||
{
|
||||
TypeNameHandling = TypeNameHandling.Auto,
|
||||
ContractResolver = _kernel.Get<NinjectContractResolver>()
|
||||
};
|
||||
JsonConvert.DefaultSettings = () => settings;
|
||||
|
||||
//TODO DarthAffe 17.12.2016: Is this the right location for this?
|
||||
//TODO Move to Mainmanager and make disposable
|
||||
ActiveWindowHelper.SetActiveWindowDetectionType(SettingsProvider.Load<GeneralSettings>().ActiveWindowDetection);
|
||||
}
|
||||
|
||||
protected override void OnExit(object sender, EventArgs e)
|
||||
{
|
||||
_kernel.Dispose();
|
||||
ActiveWindowHelper.Dispose();
|
||||
base.OnExit(sender, e);
|
||||
}
|
||||
|
||||
protected override object GetInstance(Type service, string key)
|
||||
{
|
||||
if (service == null)
|
||||
throw new ArgumentNullException(nameof(service));
|
||||
|
||||
return _kernel.Get(service);
|
||||
}
|
||||
|
||||
protected override IEnumerable<object> GetAllInstances(Type service)
|
||||
{
|
||||
return _kernel.GetAll(service);
|
||||
}
|
||||
|
||||
protected override void BuildUp(object instance)
|
||||
{
|
||||
_kernel.Inject(instance);
|
||||
}
|
||||
|
||||
protected override void OnStartup(object sender, StartupEventArgs e)
|
||||
{
|
||||
DisplayRootViewFor<ShellViewModel>();
|
||||
InputHook.Start();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,27 +0,0 @@
|
||||
<UserControl x:Class="Artemis.Controls.Log.LoggingControl"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="300" d:DesignWidth="300"
|
||||
DataContext="{Binding RelativeSource={RelativeSource Self}}">
|
||||
|
||||
<Grid>
|
||||
<!--<TextBox IsReadOnly="True" AcceptsReturn="True" Height="Auto" HorizontalAlignment="Stretch" Name="dgLog" VerticalAlignment="Stretch" Width="Auto"/>-->
|
||||
<ListView ItemsSource="{Binding LogCollection}" Name="logView">
|
||||
<ListView.View>
|
||||
<GridView>
|
||||
<GridView.Columns>
|
||||
<!--<GridViewColumn DisplayMemberBinding="{Binding LoggerName}" Header="Logger"/>-->
|
||||
<GridViewColumn DisplayMemberBinding="{Binding Level}" Header="Level" />
|
||||
<GridViewColumn DisplayMemberBinding="{Binding TimeStamp, StringFormat=HH:mm:ss.ffffff}" Header="Time" />
|
||||
<GridViewColumn DisplayMemberBinding="{Binding FormattedMessage}" Width="500" Header="Message" />
|
||||
<GridViewColumn DisplayMemberBinding="{Binding Exception.Message}" Width="300" Header="Exception" />
|
||||
</GridView.Columns>
|
||||
</GridView>
|
||||
</ListView.View>
|
||||
</ListView>
|
||||
<!--<ListBox Height="Auto" HorizontalAlignment="Stretch" Name="dgLog" VerticalAlignment="Stretch" Width="Auto" />-->
|
||||
</Grid>
|
||||
</UserControl>
|
||||
@ -1,37 +0,0 @@
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Windows.Controls;
|
||||
using Artemis.Utilities;
|
||||
using NLog;
|
||||
|
||||
namespace Artemis.Controls.Log
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for LoggingControl.xaml
|
||||
/// </summary>
|
||||
public partial class LoggingControl : UserControl
|
||||
{
|
||||
public LoggingControl()
|
||||
{
|
||||
LogCollection = new ObservableCollection<LogEventInfo>();
|
||||
|
||||
InitializeComponent();
|
||||
|
||||
// init memory queue
|
||||
Logging.ClearLoggingEvent();
|
||||
Logging.MemoryEvent += EventReceived;
|
||||
}
|
||||
|
||||
public static ObservableCollection<LogEventInfo> LogCollection { get; set; }
|
||||
|
||||
private async void EventReceived(LogEventInfo message)
|
||||
{
|
||||
await Dispatcher.InvokeAsync(() =>
|
||||
{
|
||||
if (LogCollection.Count >= 50)
|
||||
LogCollection.RemoveAt(0);
|
||||
|
||||
LogCollection.Add(message);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,20 +0,0 @@
|
||||
using System;
|
||||
using NLog;
|
||||
using NLog.Targets;
|
||||
|
||||
namespace Artemis.Controls.Log
|
||||
{
|
||||
public class MemoryEventTarget : Target
|
||||
{
|
||||
public event Action<LogEventInfo> EventReceived;
|
||||
|
||||
/// <summary>
|
||||
/// Notifies listeners about new event
|
||||
/// </summary>
|
||||
/// <param name="logEvent">The logging event.</param>
|
||||
protected override void Write(LogEventInfo logEvent)
|
||||
{
|
||||
EventReceived?.Invoke(logEvent);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,254 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
using System.IO.Compression;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using Artemis.DeviceProviders;
|
||||
using Artemis.Modules.Abstract;
|
||||
using Artemis.Profiles;
|
||||
using Artemis.Profiles.Layers.Types.Keyboard;
|
||||
using Artemis.Properties;
|
||||
using Artemis.Utilities;
|
||||
using MoonSharp.Interpreter;
|
||||
using Newtonsoft.Json;
|
||||
using NLog;
|
||||
|
||||
namespace Artemis.DAL
|
||||
{
|
||||
public static class ProfileProvider
|
||||
{
|
||||
public static readonly string ProfileFolder = GeneralHelpers.DataFolder + "profiles\\";
|
||||
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
|
||||
private static bool _installedDefaults;
|
||||
|
||||
static ProfileProvider()
|
||||
{
|
||||
// Configure MoonSharp
|
||||
UserData.RegisterAssembly();
|
||||
CheckProfiles();
|
||||
InstallDefaults();
|
||||
}
|
||||
|
||||
public static List<string> GetProfileNames(KeyboardProvider keyboard, ModuleModel module)
|
||||
{
|
||||
if (keyboard == null || module == null)
|
||||
return null;
|
||||
return ReadProfiles(keyboard.Slug + "/" + module.Name).Select(p => p.Name).ToList();
|
||||
}
|
||||
|
||||
public static ProfileModel GetProfile(KeyboardProvider keyboard, ModuleModel module, string name)
|
||||
{
|
||||
if (keyboard == null || module == null)
|
||||
return null;
|
||||
return ReadProfiles(keyboard.Slug + "/" + module.Name).FirstOrDefault(p => p.Name == name);
|
||||
}
|
||||
|
||||
public static bool IsProfileUnique(ProfileModel profileModel)
|
||||
{
|
||||
var existing = ReadProfiles(profileModel.KeyboardSlug + "/" + profileModel.GameName);
|
||||
return !existing.Contains(profileModel);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds or update the given profile.
|
||||
/// Updates occur when a profile with the same name and game exist.
|
||||
/// </summary>
|
||||
/// <param name="prof">The profile to add or update</param>
|
||||
public static void AddOrUpdate(ProfileModel prof)
|
||||
{
|
||||
if (prof == null)
|
||||
throw new ArgumentNullException(nameof(prof));
|
||||
|
||||
lock (prof)
|
||||
{
|
||||
// Store the file
|
||||
if (!(prof.GameName?.Length > 1) || !(prof.KeyboardSlug?.Length > 1) || !(prof.Slug?.Length > 1))
|
||||
throw new ArgumentException("Profile is invalid. Name, GameName and KeyboardSlug are required");
|
||||
|
||||
var path = ProfileFolder + $"{prof.KeyboardSlug}\\{prof.GameName}";
|
||||
if (!Directory.Exists(path))
|
||||
Directory.CreateDirectory(path);
|
||||
|
||||
string json;
|
||||
|
||||
// Should saving fail for whatever reason, catch the exception and log it
|
||||
// But DON'T touch the profile file.
|
||||
try
|
||||
{
|
||||
json = JsonConvert.SerializeObject(prof, Formatting.Indented);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Logger.Error(e, "Couldn't save profile '{0}.json'", prof.Slug);
|
||||
return;
|
||||
}
|
||||
|
||||
File.WriteAllText(path + $"\\{prof.Slug}.json", json);
|
||||
Logger.Debug("Saved profile {0}/{1}/{2}", prof.KeyboardSlug, prof.GameName, prof.Name);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Renames the profile on the model and filesystem
|
||||
/// </summary>
|
||||
/// <param name="profile">The profile to rename</param>
|
||||
/// <param name="name">The new name</param>
|
||||
public static void RenameProfile(ProfileModel profile, string name)
|
||||
{
|
||||
if (string.IsNullOrEmpty(name))
|
||||
return;
|
||||
|
||||
// Store the profile path before it is renamed
|
||||
var oldPath = ProfileFolder + $"{profile.KeyboardSlug}\\{profile.GameName}\\{profile.Slug}.json";
|
||||
|
||||
// Update the profile, creating a new file
|
||||
profile.Name = name;
|
||||
AddOrUpdate(profile);
|
||||
|
||||
// Remove the file with the old name
|
||||
if (File.Exists(oldPath))
|
||||
File.Delete(oldPath);
|
||||
}
|
||||
|
||||
public static void DeleteProfile(ProfileModel prof)
|
||||
{
|
||||
// Remove the file
|
||||
var path = ProfileFolder + $"{prof.KeyboardSlug}\\{prof.GameName}\\{prof.Slug}.json";
|
||||
if (File.Exists(path))
|
||||
File.Delete(path);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Attempts to load a profile from a given path
|
||||
/// </summary>
|
||||
/// <param name="path">The absolute path to load the profile from</param>
|
||||
/// <returns>The loaded profile, or null if invalid</returns>
|
||||
public static ProfileModel LoadProfileIfValid(string path)
|
||||
{
|
||||
try
|
||||
{
|
||||
var prof = JsonConvert.DeserializeObject<ProfileModel>(File.ReadAllText(path));
|
||||
if (prof == null)
|
||||
return null;
|
||||
if (prof.GameName.Length < 1 || prof.KeyboardSlug.Length < 1 || prof.Name.Length < 1)
|
||||
return null;
|
||||
return prof;
|
||||
}
|
||||
catch (JsonException)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Exports the given profile to the provided path in JSON
|
||||
/// </summary>
|
||||
/// <param name="prof">The profile to export</param>
|
||||
/// <param name="path">The path to save the profile to</param>
|
||||
public static void ExportProfile(ProfileModel prof, string path)
|
||||
{
|
||||
var json = JsonConvert.SerializeObject(prof);
|
||||
File.WriteAllText(path, json);
|
||||
}
|
||||
|
||||
public static void InsertGif(string moduleName, string profileName, string layerName, Bitmap gifFile, string fileName)
|
||||
{
|
||||
var directories = new DirectoryInfo(ProfileFolder).GetDirectories();
|
||||
var profiles = new List<ProfileModel>();
|
||||
foreach (var directoryInfo in directories)
|
||||
profiles.AddRange(ReadProfiles(directoryInfo.Name + "\\" + moduleName).Where(d => d.Name == profileName));
|
||||
|
||||
// Extract the GIF file
|
||||
var gifDir = GeneralHelpers.DataFolder + "gifs";
|
||||
Directory.CreateDirectory(gifDir);
|
||||
var gifPath = gifDir + $"\\{fileName}.gif";
|
||||
if (!File.Exists(gifPath))
|
||||
gifFile.Save(gifPath);
|
||||
|
||||
foreach (var profile in profiles)
|
||||
{
|
||||
var gifLayer = profile.GetLayers().FirstOrDefault(l => l.Name == layerName);
|
||||
if (gifLayer == null)
|
||||
continue;
|
||||
|
||||
((KeyboardPropertiesModel) gifLayer.Properties).GifFile = gifPath;
|
||||
AddOrUpdate(profile);
|
||||
}
|
||||
}
|
||||
|
||||
public static List<ProfileModel> ReadProfiles(string subDirectory)
|
||||
{
|
||||
var profiles = new List<ProfileModel>();
|
||||
var directory = ProfileFolder + subDirectory;
|
||||
if (!Directory.Exists(directory))
|
||||
return profiles;
|
||||
|
||||
// Create the directory structure
|
||||
var profilePaths = Directory.GetFiles(directory, "*.json", SearchOption.AllDirectories);
|
||||
|
||||
// Parse the JSON files into objects and add them if they are valid
|
||||
foreach (var path in profilePaths)
|
||||
try
|
||||
{
|
||||
var prof = LoadProfileIfValid(path);
|
||||
if (prof == null)
|
||||
continue;
|
||||
|
||||
// Only add unique profiles
|
||||
if (profiles.Any(p => p.GameName == prof.GameName && p.Name == prof.Name && p.KeyboardSlug == prof.KeyboardSlug))
|
||||
Logger.Info("Didn't load duplicate profile: {0}", path);
|
||||
else
|
||||
profiles.Add(prof);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Logger.Error("Failed to load profile: {0} - {1}", path, e);
|
||||
}
|
||||
return profiles;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Unpacks the default profiles into the profile directory
|
||||
/// </summary>
|
||||
private static void InstallDefaults()
|
||||
{
|
||||
try
|
||||
{
|
||||
// Only install the defaults once per session
|
||||
if (_installedDefaults)
|
||||
return;
|
||||
_installedDefaults = true;
|
||||
|
||||
// Load the ZIP from resources
|
||||
var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("Artemis.Resources.Keyboards.default-profiles.zip");
|
||||
|
||||
// Extract it over the old defaults in case one was updated
|
||||
if (stream == null)
|
||||
return;
|
||||
var archive = new ZipArchive(stream);
|
||||
archive.ExtractToDirectory(ProfileFolder, true);
|
||||
|
||||
InsertGif("GeneralProfile", "Demo (duplicate to keep changes)", "GIF", Resources.demo_gif, "demo-gif");
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
Logger.Warn(e, "Failed to place default profiles, perhaps there are two instances of Artemis " +
|
||||
"starting at the same time?");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Makes sure the profile directory structure is in order and places default profiles
|
||||
/// </summary>
|
||||
private static void CheckProfiles()
|
||||
{
|
||||
// Create the directory structure
|
||||
if (Directory.Exists(ProfileFolder))
|
||||
return;
|
||||
|
||||
Directory.CreateDirectory(ProfileFolder);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,101 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using Artemis.Settings;
|
||||
using Artemis.Utilities;
|
||||
using Newtonsoft.Json;
|
||||
using NLog;
|
||||
|
||||
namespace Artemis.DAL
|
||||
{
|
||||
public static class SettingsProvider
|
||||
{
|
||||
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
|
||||
private static readonly string SettingsFolder = GeneralHelpers.DataFolder + "settings\\";
|
||||
private static readonly List<IArtemisSettings> Settings = new List<IArtemisSettings>();
|
||||
|
||||
/// <summary>
|
||||
/// Loads settings with the given name from the filesystem
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static T Load<T>() where T : new()
|
||||
{
|
||||
if (!AreSettings(typeof(T)))
|
||||
throw new ArgumentException("Type doesn't implement IArtemisSettings");
|
||||
|
||||
// Attempt to load from memory first
|
||||
var inMemory = Settings.FirstOrDefault(s => s.GetType() == typeof(T));
|
||||
if (inMemory != null)
|
||||
return (T) inMemory;
|
||||
|
||||
CheckSettings();
|
||||
|
||||
try
|
||||
{
|
||||
var loadSettings = (IArtemisSettings) JsonConvert.DeserializeObject<T>(File.ReadAllText(SettingsFolder + $"{typeof(T)}.json"));
|
||||
if (loadSettings == null)
|
||||
{
|
||||
loadSettings = (IArtemisSettings) new T();
|
||||
loadSettings.Reset(true);
|
||||
}
|
||||
|
||||
Settings.Add(loadSettings);
|
||||
return (T) loadSettings;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Logger.Error(e, "Couldn't load settings '{0}.json'", typeof(T));
|
||||
|
||||
// Not sure about this, I've seen prettier code
|
||||
var loadSettings = (IArtemisSettings) new T();
|
||||
loadSettings.Reset(true);
|
||||
Settings.Add(loadSettings);
|
||||
return (T) loadSettings;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Saves the settings object to the filesystem
|
||||
/// </summary>
|
||||
/// <param name="artemisSettings"></param>
|
||||
public static void Save(IArtemisSettings artemisSettings)
|
||||
{
|
||||
CheckSettings();
|
||||
|
||||
string json;
|
||||
// Should saving fail for whatever reason, catch the exception and log it
|
||||
// But DON'T touch the settings file.
|
||||
try
|
||||
{
|
||||
json = JsonConvert.SerializeObject(artemisSettings, Formatting.Indented);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Logger.Error(e, "Couldn't save settings '{0}.json'", artemisSettings.GetType());
|
||||
return;
|
||||
}
|
||||
|
||||
File.WriteAllText(SettingsFolder + $"{artemisSettings.GetType()}.json", json);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ensures the settings folder exists
|
||||
/// </summary>
|
||||
private static void CheckSettings()
|
||||
{
|
||||
if (!Directory.Exists(SettingsFolder))
|
||||
Directory.CreateDirectory(SettingsFolder);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks to see if the given type is a setting
|
||||
/// </summary>
|
||||
/// <param name="t"></param>
|
||||
/// <returns></returns>
|
||||
private static bool AreSettings(Type t)
|
||||
{
|
||||
return typeof(IArtemisSettings).IsAssignableFrom(t);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,42 +0,0 @@
|
||||
using System.Drawing;
|
||||
using System.Windows;
|
||||
using System.Windows.Forms;
|
||||
using Artemis.Properties;
|
||||
|
||||
namespace Artemis.DeviceProviders.Artemis
|
||||
{
|
||||
public class NoneKeyboard : KeyboardProvider
|
||||
{
|
||||
public NoneKeyboard()
|
||||
{
|
||||
Name = "None";
|
||||
Slug = "none";
|
||||
CantEnableText = "Waaaaah, this should not be happening!";
|
||||
Height = 1;
|
||||
Width = 1;
|
||||
PreviewSettings = new PreviewSettings(new Rect(), Resources.none);
|
||||
}
|
||||
|
||||
public override void Disable()
|
||||
{
|
||||
}
|
||||
|
||||
public override bool CanEnable()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public override void Enable()
|
||||
{
|
||||
}
|
||||
|
||||
public override void DrawBitmap(Bitmap bitmap)
|
||||
{
|
||||
}
|
||||
|
||||
public override KeyMatch? GetKeyPosition(Keys keyCode)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,96 +0,0 @@
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Windows;
|
||||
using System.Windows.Forms;
|
||||
using Artemis.DAL;
|
||||
using Artemis.DeviceProviders.CoolerMaster.Utilities;
|
||||
using Artemis.DeviceProviders.Logitech.Utilities;
|
||||
using Artemis.Properties;
|
||||
using Artemis.Settings;
|
||||
using Artemis.Utilities;
|
||||
|
||||
namespace Artemis.DeviceProviders.CoolerMaster
|
||||
{
|
||||
public class MasterkeysProL : KeyboardProvider
|
||||
{
|
||||
private GeneralSettings _generalSettings;
|
||||
|
||||
public MasterkeysProL()
|
||||
{
|
||||
Name = "CM Masterkeys Pro L";
|
||||
Slug = "cm-masterkeys-pro-l";
|
||||
|
||||
CantEnableText = "Couldn't connect to your CM Masterkeys Pro L.\n" +
|
||||
"Please check your cables and try updating your CM software.\n\n" +
|
||||
"If needed, you can select a different keyboard in Artemis under settings.";
|
||||
|
||||
Height = 6;
|
||||
Width = 22;
|
||||
|
||||
PreviewSettings = new PreviewSettings(new Rect(17, 13, 812, 219), Resources.masterkeys_pro_l);
|
||||
_generalSettings = SettingsProvider.Load<GeneralSettings>();
|
||||
}
|
||||
|
||||
public override void Disable()
|
||||
{
|
||||
CmSdk.SetControlDevice(DEVICE_INDEX.DEV_MKeys_L);
|
||||
CmSdk.EnableLedControl(false);
|
||||
Thread.Sleep(500);
|
||||
}
|
||||
|
||||
public override bool CanEnable()
|
||||
{
|
||||
CmSdk.SetControlDevice(DEVICE_INDEX.DEV_MKeys_L);
|
||||
|
||||
// Doesn't seem reliable but better than nothing I suppose
|
||||
return CmSdk.IsDevicePlug();
|
||||
}
|
||||
|
||||
public override void Enable()
|
||||
{
|
||||
CmSdk.SetControlDevice(DEVICE_INDEX.DEV_MKeys_L);
|
||||
CmSdk.EnableLedControl(true);
|
||||
}
|
||||
|
||||
public override void DrawBitmap(Bitmap bitmap)
|
||||
{
|
||||
// Resize the bitmap
|
||||
using (var b = ImageUtilities.ResizeImage(bitmap, Width, Height))
|
||||
{
|
||||
// Create an empty matrix
|
||||
var matrix = new COLOR_MATRIX {KeyColor = new KEY_COLOR[6, 22]};
|
||||
|
||||
// Map the bytes to the matix
|
||||
for (var x = 0; x < Width; x++)
|
||||
{
|
||||
for (var y = 0; y < Height; y++)
|
||||
{
|
||||
var c = b.GetPixel(x, y);
|
||||
if (c.R != 0)
|
||||
Console.WriteLine();
|
||||
matrix.KeyColor[y, x] = new KEY_COLOR(c.R, c.G, c.B);
|
||||
}
|
||||
}
|
||||
|
||||
// Send the matrix to the keyboard
|
||||
CmSdk.SetControlDevice(DEVICE_INDEX.DEV_MKeys_L);
|
||||
CmSdk.SetAllLedColor(matrix);
|
||||
}
|
||||
}
|
||||
|
||||
public override KeyMatch? GetKeyPosition(Keys keyCode)
|
||||
{
|
||||
switch (_generalSettings.Layout)
|
||||
{
|
||||
case "Qwerty":
|
||||
return KeyMap.QwertyLayout.FirstOrDefault(k => k.KeyCode == keyCode);
|
||||
case "Qwertz":
|
||||
return KeyMap.QwertzLayout.FirstOrDefault(k => k.KeyCode == keyCode);
|
||||
default:
|
||||
return KeyMap.AzertyLayout.FirstOrDefault(k => k.KeyCode == keyCode);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,96 +0,0 @@
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Windows;
|
||||
using System.Windows.Forms;
|
||||
using Artemis.DAL;
|
||||
using Artemis.DeviceProviders.CoolerMaster.Utilities;
|
||||
using Artemis.DeviceProviders.Logitech.Utilities;
|
||||
using Artemis.Properties;
|
||||
using Artemis.Settings;
|
||||
using Artemis.Utilities;
|
||||
|
||||
namespace Artemis.DeviceProviders.CoolerMaster
|
||||
{
|
||||
public class MasterkeysProM : KeyboardProvider
|
||||
{
|
||||
private GeneralSettings _generalSettings;
|
||||
|
||||
public MasterkeysProM()
|
||||
{
|
||||
Name = "CM Masterkeys Pro M";
|
||||
Slug = "cm-masterkeys-pro-m";
|
||||
|
||||
CantEnableText = "Couldn't connect to your CM Masterkeys Pro M.\n" +
|
||||
"Please check your cables and try updating your CM software.\n\n" +
|
||||
"If needed, you can select a different keyboard in Artemis under settings.";
|
||||
|
||||
Height = 6;
|
||||
Width = 19;
|
||||
|
||||
PreviewSettings = new PreviewSettings(new Rect(11, 10, 634, 215), Resources.masterkeys_pro_m);
|
||||
_generalSettings = SettingsProvider.Load<GeneralSettings>();
|
||||
}
|
||||
|
||||
public override void Disable()
|
||||
{
|
||||
CmSdk.SetControlDevice(DEVICE_INDEX.DEV_MKeys_M);
|
||||
CmSdk.EnableLedControl(false);
|
||||
Thread.Sleep(500);
|
||||
}
|
||||
|
||||
public override bool CanEnable()
|
||||
{
|
||||
CmSdk.SetControlDevice(DEVICE_INDEX.DEV_MKeys_M);
|
||||
|
||||
// Doesn't seem reliable but better than nothing I suppose
|
||||
return CmSdk.IsDevicePlug();
|
||||
}
|
||||
|
||||
public override void Enable()
|
||||
{
|
||||
CmSdk.SetControlDevice(DEVICE_INDEX.DEV_MKeys_M);
|
||||
CmSdk.EnableLedControl(true);
|
||||
}
|
||||
|
||||
public override void DrawBitmap(Bitmap bitmap)
|
||||
{
|
||||
// Resize the bitmap
|
||||
using (var b = ImageUtilities.ResizeImage(bitmap, Width, Height))
|
||||
{
|
||||
// Create an empty matrix
|
||||
var matrix = new COLOR_MATRIX {KeyColor = new KEY_COLOR[6, 22]};
|
||||
|
||||
// Map the bytes to the matix
|
||||
for (var x = 0; x < Width; x++)
|
||||
{
|
||||
for (var y = 0; y < Height; y++)
|
||||
{
|
||||
var c = b.GetPixel(x, y);
|
||||
if (c.R != 0)
|
||||
Console.WriteLine();
|
||||
matrix.KeyColor[y, x] = new KEY_COLOR(c.R, c.G, c.B);
|
||||
}
|
||||
}
|
||||
|
||||
// Send the matrix to the keyboard
|
||||
CmSdk.SetControlDevice(DEVICE_INDEX.DEV_MKeys_M);
|
||||
CmSdk.SetAllLedColor(matrix);
|
||||
}
|
||||
}
|
||||
|
||||
public override KeyMatch? GetKeyPosition(Keys keyCode)
|
||||
{
|
||||
switch (_generalSettings.Layout)
|
||||
{
|
||||
case "Qwerty":
|
||||
return KeyMap.QwertyLayout.FirstOrDefault(k => k.KeyCode == keyCode);
|
||||
case "Qwertz":
|
||||
return KeyMap.QwertzLayout.FirstOrDefault(k => k.KeyCode == keyCode);
|
||||
default:
|
||||
return KeyMap.AzertyLayout.FirstOrDefault(k => k.KeyCode == keyCode);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,93 +0,0 @@
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Windows;
|
||||
using System.Windows.Forms;
|
||||
using Artemis.DAL;
|
||||
using Artemis.DeviceProviders.CoolerMaster.Utilities;
|
||||
using Artemis.DeviceProviders.Logitech.Utilities;
|
||||
using Artemis.Properties;
|
||||
using Artemis.Settings;
|
||||
using Artemis.Utilities;
|
||||
|
||||
namespace Artemis.DeviceProviders.CoolerMaster
|
||||
{
|
||||
public class MasterkeysProS : KeyboardProvider
|
||||
{
|
||||
private GeneralSettings _generalSettings;
|
||||
|
||||
public MasterkeysProS()
|
||||
{
|
||||
Name = "CM Masterkeys Pro S";
|
||||
Slug = "cm-masterkeys-pro-s";
|
||||
|
||||
CantEnableText = "Couldn't connect to your CM Masterkeys Pro S.\n" +
|
||||
"Please check your cables and try updating your CM software.\n\n" +
|
||||
"If needed, you can select a different keyboard in Artemis under settings.";
|
||||
|
||||
Height = 6;
|
||||
Width = 18;
|
||||
|
||||
PreviewSettings = new PreviewSettings(new Rect(13, 12, 657, 219), Resources.masterkeys_pro_s);
|
||||
_generalSettings = SettingsProvider.Load<GeneralSettings>();
|
||||
}
|
||||
|
||||
public override void Disable()
|
||||
{
|
||||
CmSdk.SetControlDevice(DEVICE_INDEX.DEV_MKeys_S);
|
||||
CmSdk.EnableLedControl(false);
|
||||
Thread.Sleep(500);
|
||||
}
|
||||
|
||||
public override bool CanEnable()
|
||||
{
|
||||
CmSdk.SetControlDevice(DEVICE_INDEX.DEV_MKeys_S);
|
||||
|
||||
// Doesn't seem reliable but better than nothing I suppose
|
||||
return CmSdk.IsDevicePlug();
|
||||
}
|
||||
|
||||
public override void Enable()
|
||||
{
|
||||
CmSdk.SetControlDevice(DEVICE_INDEX.DEV_MKeys_S);
|
||||
CmSdk.EnableLedControl(true);
|
||||
}
|
||||
|
||||
public override void DrawBitmap(Bitmap bitmap)
|
||||
{
|
||||
// Resize the bitmap
|
||||
using (var b = ImageUtilities.ResizeImage(bitmap, Width, Height))
|
||||
{
|
||||
// Create an empty matrix
|
||||
var matrix = new COLOR_MATRIX {KeyColor = new KEY_COLOR[6, 22]};
|
||||
|
||||
// Map the bytes to the matix
|
||||
for (var x = 0; x < Width; x++)
|
||||
{
|
||||
for (var y = 0; y < Height; y++)
|
||||
{
|
||||
var c = b.GetPixel(x, y);
|
||||
matrix.KeyColor[y, x] = new KEY_COLOR(c.R, c.G, c.B);
|
||||
}
|
||||
}
|
||||
|
||||
// Send the matrix to the keyboard
|
||||
CmSdk.SetControlDevice(DEVICE_INDEX.DEV_MKeys_S);
|
||||
CmSdk.SetAllLedColor(matrix);
|
||||
}
|
||||
}
|
||||
|
||||
public override KeyMatch? GetKeyPosition(Keys keyCode)
|
||||
{
|
||||
switch (_generalSettings.Layout)
|
||||
{
|
||||
case "Qwerty":
|
||||
return KeyMap.QwertyLayout.FirstOrDefault(k => k.KeyCode == keyCode);
|
||||
case "Qwertz":
|
||||
return KeyMap.QwertzLayout.FirstOrDefault(k => k.KeyCode == keyCode);
|
||||
default:
|
||||
return KeyMap.AzertyLayout.FirstOrDefault(k => k.KeyCode == keyCode);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,65 +0,0 @@
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using Artemis.DeviceProviders.CoolerMaster.Utilities;
|
||||
using Ninject.Extensions.Logging;
|
||||
|
||||
namespace Artemis.DeviceProviders.CoolerMaster
|
||||
{
|
||||
public class MastermouseProL : DeviceProvider
|
||||
{
|
||||
public MastermouseProL(ILogger logger)
|
||||
{
|
||||
Logger = logger;
|
||||
Type = DeviceType.Mouse;
|
||||
}
|
||||
|
||||
public ILogger Logger { get; }
|
||||
|
||||
public override void UpdateDevice(Bitmap bitmap)
|
||||
{
|
||||
// Create an empty matrix
|
||||
var matrix = new COLOR_MATRIX { KeyColor = new KEY_COLOR[6, 22] };
|
||||
|
||||
// Get colors from the bitmap's center X and on 2/5th, 3/5th and 4/5th Y
|
||||
var x = bitmap.Width / 2;
|
||||
var y = bitmap.Width / 5;
|
||||
var led1Color = bitmap.GetPixel(x, y);
|
||||
var led2Color = bitmap.GetPixel(x, y * 2);
|
||||
var led3Color = bitmap.GetPixel(x, y * 3);
|
||||
var led4Color = bitmap.GetPixel(x, y * 4);
|
||||
matrix.KeyColor[0, 0] = new KEY_COLOR(led1Color.R, led1Color.G, led1Color.B);
|
||||
matrix.KeyColor[0, 1] = new KEY_COLOR(led2Color.R, led2Color.G, led2Color.B);
|
||||
matrix.KeyColor[0, 2] = new KEY_COLOR(led3Color.R, led3Color.G, led3Color.B);
|
||||
matrix.KeyColor[0, 3] = new KEY_COLOR(led4Color.R, led4Color.G, led4Color.B);
|
||||
|
||||
// Send the matrix to the mouse
|
||||
CmSdk.SetControlDevice(DEVICE_INDEX.DEV_MMouse_L);
|
||||
CmSdk.SetAllLedColor(matrix);
|
||||
}
|
||||
|
||||
public override bool TryEnable()
|
||||
{
|
||||
CmSdk.SetControlDevice(DEVICE_INDEX.DEV_MMouse_L);
|
||||
|
||||
// Doesn't seem reliable but better than nothing I suppose
|
||||
try
|
||||
{
|
||||
CanUse = CmSdk.IsDevicePlug();
|
||||
if (CanUse)
|
||||
CmSdk.EnableLedControl(true);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
CanUse = false;
|
||||
}
|
||||
|
||||
Logger.Debug("Attempted to enable Mastermouse Pro L. CanUse: {0}", CanUse);
|
||||
return CanUse;
|
||||
}
|
||||
|
||||
public override void Disable()
|
||||
{
|
||||
throw new NotSupportedException("Can only disable a keyboard");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,61 +0,0 @@
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using Artemis.DeviceProviders.CoolerMaster.Utilities;
|
||||
using Ninject.Extensions.Logging;
|
||||
|
||||
namespace Artemis.DeviceProviders.CoolerMaster
|
||||
{
|
||||
public class MastermouseProS : DeviceProvider
|
||||
{
|
||||
public MastermouseProS(ILogger logger)
|
||||
{
|
||||
Logger = logger;
|
||||
Type = DeviceType.Mouse;
|
||||
}
|
||||
|
||||
public ILogger Logger { get; }
|
||||
|
||||
public override void UpdateDevice(Bitmap bitmap)
|
||||
{
|
||||
// Create an empty matrix
|
||||
var matrix = new COLOR_MATRIX {KeyColor = new KEY_COLOR[6, 22]};
|
||||
|
||||
// Get colors from the bitmap's center X and on 1/3rd and 2/3rd Y
|
||||
var x = bitmap.Width / 2;
|
||||
var y = bitmap.Width / 3;
|
||||
var led1Color = bitmap.GetPixel(x, y);
|
||||
var led2Color = bitmap.GetPixel(x, y * 2);
|
||||
matrix.KeyColor[0, 0] = new KEY_COLOR(led1Color.R, led1Color.G, led1Color.B);
|
||||
matrix.KeyColor[0, 1] = new KEY_COLOR(led2Color.R, led2Color.G, led2Color.B);
|
||||
|
||||
// Send the matrix to the mouse
|
||||
CmSdk.SetControlDevice(DEVICE_INDEX.DEV_MMouse_S);
|
||||
CmSdk.SetAllLedColor(matrix);
|
||||
}
|
||||
|
||||
public override bool TryEnable()
|
||||
{
|
||||
CmSdk.SetControlDevice(DEVICE_INDEX.DEV_MMouse_S);
|
||||
|
||||
// Doesn't seem reliable but better than nothing I suppose
|
||||
try
|
||||
{
|
||||
CanUse = CmSdk.IsDevicePlug();
|
||||
if (CanUse)
|
||||
CmSdk.EnableLedControl(true);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
CanUse = false;
|
||||
}
|
||||
|
||||
Logger.Debug("Attempted to enable Mastermouse Pro S. CanUse: {0}", CanUse);
|
||||
return CanUse;
|
||||
}
|
||||
|
||||
public override void Disable()
|
||||
{
|
||||
throw new NotSupportedException("Can only disable a keyboard");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,101 +0,0 @@
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Artemis.DeviceProviders.CoolerMaster.Utilities
|
||||
{
|
||||
public struct KEY_COLOR
|
||||
{
|
||||
public byte r;
|
||||
public byte g;
|
||||
public byte b;
|
||||
|
||||
public KEY_COLOR(byte colR, byte colG, byte colB)
|
||||
{
|
||||
r = colR;
|
||||
g = colG;
|
||||
b = colB;
|
||||
}
|
||||
}
|
||||
|
||||
public struct COLOR_MATRIX
|
||||
{
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 132)] public KEY_COLOR[,] KeyColor;
|
||||
}
|
||||
|
||||
//Enumeration of device list
|
||||
public enum DEVICE_INDEX
|
||||
{
|
||||
DEV_MKeys_L = 0,
|
||||
DEV_MKeys_S = 1,
|
||||
DEV_MKeys_L_White = 2,
|
||||
DEV_MKeys_M_White = 3,
|
||||
DEV_MMouse_L = 4,
|
||||
DEV_MMouse_S = 5,
|
||||
DEV_MKeys_M = 6,
|
||||
DEV_MKeys_S_White = 7
|
||||
}
|
||||
|
||||
//Enumeration of device layout
|
||||
public enum LAYOUT_KEYBOARD
|
||||
{
|
||||
LAYOUT_UNINIT = 0,
|
||||
LAYOUT_US = 1,
|
||||
LAYOUT_EU = 2
|
||||
}
|
||||
|
||||
public static class CmSdk
|
||||
{
|
||||
/// <summary>
|
||||
/// Sets the control device which all following actions are targetted to
|
||||
/// </summary>
|
||||
/// <param name="devIndex"></param>
|
||||
[DllImport("lib\\SDKDLL ", CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void SetControlDevice(DEVICE_INDEX devIndex);
|
||||
|
||||
/// <summary>
|
||||
/// Obtain current device layout
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[DllImport("lib\\SDKDLL ", CallingConvention = CallingConvention.Cdecl)]
|
||||
[return: MarshalAs(UnmanagedType.I1)]
|
||||
public static extern LAYOUT_KEYBOARD GetDeviceLayout();
|
||||
|
||||
/// <summary>
|
||||
/// Verify if the currently conrolled device is plugged in
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[DllImport("lib\\SDKDLL ", CallingConvention = CallingConvention.Cdecl)]
|
||||
[return: MarshalAs(UnmanagedType.I1)]
|
||||
public static extern bool IsDevicePlug();
|
||||
|
||||
/// <summary>
|
||||
/// Enables led control on the currently controlled device
|
||||
/// </summary>
|
||||
/// <param name="bEnable"></param>
|
||||
/// <returns></returns>
|
||||
[DllImport("lib\\SDKDLL ", CallingConvention = CallingConvention.Cdecl)]
|
||||
[return: MarshalAs(UnmanagedType.I1)]
|
||||
public static extern bool EnableLedControl(bool bEnable);
|
||||
|
||||
/// <summary>
|
||||
/// Sets the LED of the currently controlled device
|
||||
/// </summary>
|
||||
/// <param name="iRow"></param>
|
||||
/// <param name="iColumn"></param>
|
||||
/// <param name="r"></param>
|
||||
/// <param name="g"></param>
|
||||
/// <param name="b"></param>
|
||||
/// <returns></returns>
|
||||
[DllImport("lib\\SDKDLL ", CallingConvention = CallingConvention.Cdecl)]
|
||||
[return: MarshalAs(UnmanagedType.I1)]
|
||||
public static extern bool SetLedColor(int iRow, int iColumn, byte r, byte g, byte b);
|
||||
|
||||
/// <summary>
|
||||
/// Sets all LEDS using the given color matrix
|
||||
/// </summary>
|
||||
/// <param name="colorMatrix"></param>
|
||||
/// <returns></returns>
|
||||
[DllImport("lib\\SDKDLL ", CallingConvention = CallingConvention.Cdecl)]
|
||||
[return: MarshalAs(UnmanagedType.I1)]
|
||||
public static extern bool SetAllLedColor(COLOR_MATRIX colorMatrix);
|
||||
}
|
||||
}
|
||||
@ -1,84 +0,0 @@
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Threading;
|
||||
using Artemis.DeviceProviders.Corsair.Utilities;
|
||||
using CUE.NET;
|
||||
using CUE.NET.Brushes;
|
||||
using CUE.NET.Devices.Generic.Enums;
|
||||
using Ninject.Extensions.Logging;
|
||||
|
||||
namespace Artemis.DeviceProviders.Corsair
|
||||
{
|
||||
public class CorsairHeadset : DeviceProvider
|
||||
{
|
||||
private readonly ImageBrush _headsetBrush;
|
||||
|
||||
public CorsairHeadset(ILogger logger)
|
||||
{
|
||||
Logger = logger;
|
||||
Type = DeviceType.Headset;
|
||||
_headsetBrush = new ImageBrush();
|
||||
}
|
||||
|
||||
public ILogger Logger { get; set; }
|
||||
|
||||
public override bool TryEnable()
|
||||
{
|
||||
try
|
||||
{
|
||||
lock (CorsairUtilities.SDKLock)
|
||||
{
|
||||
CanUse = CanInitializeSdk();
|
||||
if (CanUse && !CueSDK.IsInitialized)
|
||||
CueSDK.Initialize(true);
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
CanUse = false;
|
||||
}
|
||||
|
||||
Logger.Debug("Attempted to enable Corsair headset. CanUse: {0}", CanUse);
|
||||
|
||||
if (CanUse)
|
||||
{
|
||||
CueSDK.UpdateMode = UpdateMode.Manual;
|
||||
CueSDK.HeadsetSDK.Brush = _headsetBrush;
|
||||
}
|
||||
|
||||
return CanUse;
|
||||
}
|
||||
|
||||
public override void Disable()
|
||||
{
|
||||
throw new NotSupportedException("Can only disable a keyboard");
|
||||
}
|
||||
|
||||
public override void UpdateDevice(Bitmap bitmap)
|
||||
{
|
||||
if (!CanUse || bitmap == null)
|
||||
return;
|
||||
if (bitmap.Width != bitmap.Height)
|
||||
throw new ArgumentException("Bitmap must be a perfect square");
|
||||
|
||||
_headsetBrush.Image = bitmap;
|
||||
CueSDK.HeadsetSDK.Update();
|
||||
}
|
||||
|
||||
private static bool CanInitializeSdk()
|
||||
{
|
||||
// This will skip the check-loop if the SDK is initialized
|
||||
if (CueSDK.IsInitialized)
|
||||
return CueSDK.IsSDKAvailable(CorsairDeviceType.Headset);
|
||||
|
||||
for (var tries = 0; tries < 9; tries++)
|
||||
{
|
||||
if (CueSDK.IsSDKAvailable(CorsairDeviceType.Headset))
|
||||
return true;
|
||||
Thread.Sleep(2000);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,149 +0,0 @@
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Windows;
|
||||
using System.Windows.Forms;
|
||||
using Artemis.DeviceProviders.Corsair.Utilities;
|
||||
using Artemis.Properties;
|
||||
using Artemis.Utilities;
|
||||
using CUE.NET;
|
||||
using CUE.NET.Brushes;
|
||||
using CUE.NET.Devices.Generic;
|
||||
using CUE.NET.Devices.Generic.Enums;
|
||||
using CUE.NET.Exceptions;
|
||||
using CUE.NET.Helper;
|
||||
using Ninject.Extensions.Logging;
|
||||
using Point = System.Drawing.Point;
|
||||
|
||||
namespace Artemis.DeviceProviders.Corsair
|
||||
{
|
||||
public class CorsairKeyboard : KeyboardProvider
|
||||
{
|
||||
private CUE.NET.Devices.Keyboard.CorsairKeyboard _keyboard;
|
||||
private ImageBrush _keyboardBrush;
|
||||
|
||||
public CorsairKeyboard(ILogger logger)
|
||||
{
|
||||
Logger = logger;
|
||||
Name = "Corsair RGB Keyboard";
|
||||
CantEnableText = "Couldn't connect to your Corsair keyboard.\n" +
|
||||
"Please check your cables and/or drivers (could be outdated) and that Corsair Utility Engine is running.\n" +
|
||||
"In CUE, make sure \"Enable SDK\" is checked under Global Settings.\n\n" +
|
||||
"If needed, you can select a different keyboard in Artemis under settings.";
|
||||
}
|
||||
|
||||
public ILogger Logger { get; set; }
|
||||
|
||||
public override bool CanEnable()
|
||||
{
|
||||
return CueSDK.IsSDKAvailable(CorsairDeviceType.Keyboard);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Enables the SDK and sets updatemode to manual as well as the color of the background to black.
|
||||
/// </summary>
|
||||
public override void Enable()
|
||||
{
|
||||
lock (CorsairUtilities.SDKLock)
|
||||
{
|
||||
if (!CueSDK.IsInitialized)
|
||||
CueSDK.Initialize(true);
|
||||
}
|
||||
|
||||
CueSDK.UpdateMode = UpdateMode.Manual;
|
||||
_keyboard = CueSDK.KeyboardSDK;
|
||||
switch (_keyboard.DeviceInfo.Model)
|
||||
{
|
||||
case "K95 RGB":
|
||||
Height = 7;
|
||||
Width = 25;
|
||||
Slug = "corsair-k95-rgb";
|
||||
PreviewSettings = new PreviewSettings(new Rect(20, 26, 1066, 282), Resources.k95);
|
||||
break;
|
||||
case "K95 RGB PLATINUM":
|
||||
Height = 9;
|
||||
Width = 22;
|
||||
Slug = "corsair-k95-rgb-platinum";
|
||||
PreviewSettings = new PreviewSettings(new Rect(12, 1, 1075, 346), Resources.k95_platinum);
|
||||
break;
|
||||
case "K70 RGB":
|
||||
case "K70 RGB RAPIDFIRE":
|
||||
case "K70 LUX RGB":
|
||||
Height = 7;
|
||||
Width = 21;
|
||||
Slug = "corsair-k70-rgb";
|
||||
PreviewSettings = new PreviewSettings(new Rect(15, 26, 929, 282), Resources.k70);
|
||||
break;
|
||||
case "K65 RGB":
|
||||
case "CGK65 RGB":
|
||||
case "K65 LUX RGB":
|
||||
case "K65 RGB RAPIDFIRE":
|
||||
Height = 7;
|
||||
Width = 18;
|
||||
Slug = "corsair-k65-rgb";
|
||||
PreviewSettings = new PreviewSettings(new Rect(15, 30, 751, 284), Resources.k65);
|
||||
break;
|
||||
case "STRAFE RGB":
|
||||
Height = 8;
|
||||
Width = 22;
|
||||
Slug = "corsair-strafe-rgb";
|
||||
PreviewSettings = new PreviewSettings(new Rect(23, 12, 937, 324), Resources.strafe);
|
||||
break;
|
||||
}
|
||||
|
||||
Logger.Debug("Corsair SDK reported device as: {0}", _keyboard.DeviceInfo.Model);
|
||||
|
||||
_keyboard.Brush = _keyboardBrush ?? (_keyboardBrush = new ImageBrush());
|
||||
}
|
||||
|
||||
public override void Disable()
|
||||
{
|
||||
try
|
||||
{
|
||||
CueSDK.Reset();
|
||||
}
|
||||
catch (WrapperException e)
|
||||
{
|
||||
// This occurs when releasing the SDK after sleep, ignore it
|
||||
if (e.Message != "The previously loaded Keyboard got disconnected.")
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Properly resizes any size bitmap to the keyboard by creating a rectangle whose size is dependent on the bitmap
|
||||
/// size.
|
||||
/// </summary>
|
||||
/// <param name="bitmap"></param>
|
||||
public override void DrawBitmap(Bitmap bitmap)
|
||||
{
|
||||
_keyboardBrush.Image = bitmap;
|
||||
_keyboard.Update();
|
||||
}
|
||||
|
||||
public override KeyMatch? GetKeyPosition(Keys keyCode)
|
||||
{
|
||||
var widthMultiplier = Width / _keyboard.Brush.RenderedRectangle.Width;
|
||||
var heightMultiplier = Height / _keyboard.Brush.RenderedRectangle.Height;
|
||||
|
||||
CorsairLed cueLed = null;
|
||||
try
|
||||
{
|
||||
cueLed = _keyboard.Leds.FirstOrDefault(k => k.Id.ToString() == keyCode.ToString()) ??
|
||||
_keyboard.Leds.FirstOrDefault(k => k.Id == CorsairUtilities.FormsKeys[keyCode]);
|
||||
|
||||
Logger.Trace("Keycode: {0} resolved to CUE LED: {1}", keyCode, cueLed);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
// ignored
|
||||
}
|
||||
|
||||
if (cueLed == null)
|
||||
return null;
|
||||
|
||||
var center = cueLed.LedRectangle.GetCenter();
|
||||
return new KeyMatch(keyCode, (int) (center.X * widthMultiplier), (int) (center.Y * heightMultiplier));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,83 +0,0 @@
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Threading;
|
||||
using Artemis.DeviceProviders.Corsair.Utilities;
|
||||
using CUE.NET;
|
||||
using CUE.NET.Brushes;
|
||||
using CUE.NET.Devices.Generic.Enums;
|
||||
using Ninject.Extensions.Logging;
|
||||
|
||||
namespace Artemis.DeviceProviders.Corsair
|
||||
{
|
||||
public class CorsairMouse : DeviceProvider
|
||||
{
|
||||
private readonly ImageBrush _mouseBrush;
|
||||
|
||||
public CorsairMouse(ILogger logger)
|
||||
{
|
||||
Logger = logger;
|
||||
Type = DeviceType.Mouse;
|
||||
_mouseBrush = new ImageBrush();
|
||||
}
|
||||
|
||||
public ILogger Logger { get; set; }
|
||||
|
||||
public override bool TryEnable()
|
||||
{
|
||||
try
|
||||
{
|
||||
lock (CorsairUtilities.SDKLock)
|
||||
{
|
||||
CanUse = CanInitializeSdk();
|
||||
if (CanUse && !CueSDK.IsInitialized)
|
||||
CueSDK.Initialize(true);
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
CanUse = false;
|
||||
}
|
||||
|
||||
Logger.Debug("Attempted to enable Corsair mice. CanUse: {0}", CanUse);
|
||||
|
||||
if (CanUse)
|
||||
{
|
||||
CueSDK.UpdateMode = UpdateMode.Manual;
|
||||
CueSDK.MouseSDK.Brush = _mouseBrush;
|
||||
}
|
||||
|
||||
return CanUse;
|
||||
}
|
||||
|
||||
public override void Disable()
|
||||
{
|
||||
throw new NotSupportedException("Can only disable a keyboard");
|
||||
}
|
||||
|
||||
public override void UpdateDevice(Bitmap bitmap)
|
||||
{
|
||||
if (!CanUse || bitmap == null)
|
||||
return;
|
||||
if (bitmap.Width != bitmap.Height)
|
||||
throw new ArgumentException("Bitmap must be a perfect square");
|
||||
|
||||
_mouseBrush.Image = bitmap;
|
||||
CueSDK.MouseSDK.Update();
|
||||
}
|
||||
|
||||
private static bool CanInitializeSdk()
|
||||
{
|
||||
// This will skip the check-loop if the SDK is initialized
|
||||
if (CueSDK.IsInitialized)
|
||||
return CueSDK.IsSDKAvailable(CorsairDeviceType.Mouse);
|
||||
|
||||
for (var tries = 0; tries < 9; tries++)
|
||||
{
|
||||
if (CueSDK.IsSDKAvailable(CorsairDeviceType.Mouse))
|
||||
return true;
|
||||
Thread.Sleep(2000);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,83 +0,0 @@
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Threading;
|
||||
using Artemis.DeviceProviders.Corsair.Utilities;
|
||||
using CUE.NET;
|
||||
using CUE.NET.Brushes;
|
||||
using CUE.NET.Devices.Generic.Enums;
|
||||
using Ninject.Extensions.Logging;
|
||||
|
||||
namespace Artemis.DeviceProviders.Corsair
|
||||
{
|
||||
public class CorsairMousemat : DeviceProvider
|
||||
{
|
||||
private readonly ImageBrush _mousematBrush;
|
||||
|
||||
public CorsairMousemat(ILogger logger)
|
||||
{
|
||||
Logger = logger;
|
||||
Type = DeviceType.Mousemat;
|
||||
_mousematBrush = new ImageBrush();
|
||||
}
|
||||
|
||||
public ILogger Logger { get; set; }
|
||||
|
||||
public override bool TryEnable()
|
||||
{
|
||||
try
|
||||
{
|
||||
lock (CorsairUtilities.SDKLock)
|
||||
{
|
||||
CanUse = CanInitializeSdk();
|
||||
if (CanUse && !CueSDK.IsInitialized)
|
||||
CueSDK.Initialize(true);
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
CanUse = false;
|
||||
}
|
||||
|
||||
Logger.Debug("Attempted to enable Corsair mousemat. CanUse: {0}", CanUse);
|
||||
|
||||
if (CanUse)
|
||||
{
|
||||
CueSDK.UpdateMode = UpdateMode.Manual;
|
||||
CueSDK.MousematSDK.Brush = _mousematBrush;
|
||||
}
|
||||
|
||||
return CanUse;
|
||||
}
|
||||
|
||||
public override void Disable()
|
||||
{
|
||||
throw new NotSupportedException("Can only disable a keyboard");
|
||||
}
|
||||
|
||||
public override void UpdateDevice(Bitmap bitmap)
|
||||
{
|
||||
if (!CanUse || bitmap == null)
|
||||
return;
|
||||
if (bitmap.Width != bitmap.Height)
|
||||
throw new ArgumentException("Bitmap must be a perfect square");
|
||||
|
||||
_mousematBrush.Image = bitmap;
|
||||
CueSDK.MousematSDK.Update();
|
||||
}
|
||||
|
||||
private static bool CanInitializeSdk()
|
||||
{
|
||||
// This will skip the check-loop if the SDK is initialized
|
||||
if (CueSDK.IsInitialized)
|
||||
return CueSDK.IsSDKAvailable(CorsairDeviceType.Mousemat);
|
||||
|
||||
for (var tries = 0; tries < 9; tries++)
|
||||
{
|
||||
if (CueSDK.IsSDKAvailable(CorsairDeviceType.Mousemat))
|
||||
return true;
|
||||
Thread.Sleep(2000);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,72 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Windows.Forms;
|
||||
using CUE.NET.Devices.Generic.Enums;
|
||||
|
||||
namespace Artemis.DeviceProviders.Corsair.Utilities
|
||||
{
|
||||
public static class CorsairUtilities
|
||||
{
|
||||
static CorsairUtilities()
|
||||
{
|
||||
FormsKeys = new Dictionary<Keys, CorsairLedId>
|
||||
{
|
||||
{Keys.Scroll, CorsairLedId.ScrollLock},
|
||||
{Keys.Pause, CorsairLedId.PauseBreak},
|
||||
{Keys.Back, CorsairLedId.Backspace},
|
||||
{Keys.Oemtilde, CorsairLedId.GraveAccentAndTilde},
|
||||
{Keys.OemMinus, CorsairLedId.MinusAndUnderscore},
|
||||
{Keys.Oemplus, CorsairLedId.EqualsAndPlus},
|
||||
{Keys.OemOpenBrackets, CorsairLedId.BracketLeft},
|
||||
{Keys.Oem6, CorsairLedId.BracketRight},
|
||||
{Keys.Return, CorsairLedId.Enter},
|
||||
{Keys.Next, CorsairLedId.PageDown},
|
||||
{Keys.Capital, CorsairLedId.CapsLock},
|
||||
{Keys.Oem1, CorsairLedId.SemicolonAndColon},
|
||||
{Keys.Oem7, CorsairLedId.ApostropheAndDoubleQuote},
|
||||
{Keys.OemBackslash, CorsairLedId.NonUsBackslash},
|
||||
{Keys.LShiftKey, CorsairLedId.LeftShift},
|
||||
{Keys.Oem5, CorsairLedId.NonUsTilde},
|
||||
{Keys.Oemcomma, CorsairLedId.CommaAndLessThan},
|
||||
{Keys.OemPeriod, CorsairLedId.PeriodAndBiggerThan},
|
||||
{Keys.OemQuestion, CorsairLedId.SlashAndQuestionMark},
|
||||
{Keys.RShiftKey, CorsairLedId.RightShift},
|
||||
{Keys.LControlKey, CorsairLedId.LeftCtrl},
|
||||
{Keys.LWin, CorsairLedId.LeftGui},
|
||||
{Keys.LMenu, CorsairLedId.LeftAlt},
|
||||
{Keys.RMenu, CorsairLedId.RightAlt},
|
||||
{Keys.RWin, CorsairLedId.RightGui},
|
||||
{Keys.Apps, CorsairLedId.Application},
|
||||
{Keys.RControlKey, CorsairLedId.RightCtrl},
|
||||
{Keys.Left, CorsairLedId.LeftArrow},
|
||||
{Keys.Down, CorsairLedId.DownArrow},
|
||||
{Keys.Right, CorsairLedId.RightArrow},
|
||||
{Keys.Up, CorsairLedId.UpArrow},
|
||||
{Keys.NumPad0, CorsairLedId.Keypad0},
|
||||
{Keys.NumPad1, CorsairLedId.Keypad1},
|
||||
{Keys.NumPad2, CorsairLedId.Keypad2},
|
||||
{Keys.NumPad3, CorsairLedId.Keypad3},
|
||||
{Keys.NumPad4, CorsairLedId.Keypad4},
|
||||
{Keys.NumPad5, CorsairLedId.Keypad5},
|
||||
{Keys.NumPad6, CorsairLedId.Keypad6},
|
||||
{Keys.NumPad7, CorsairLedId.Keypad7},
|
||||
{Keys.NumPad8, CorsairLedId.Keypad8},
|
||||
{Keys.NumPad9, CorsairLedId.Keypad9},
|
||||
{Keys.Divide, CorsairLedId.KeypadSlash},
|
||||
{Keys.Multiply, CorsairLedId.KeypadAsterisk},
|
||||
{Keys.Subtract, CorsairLedId.KeypadMinus},
|
||||
{Keys.Add, CorsairLedId.KeypadPlus},
|
||||
{Keys.Decimal, CorsairLedId.KeypadPeriodAndDelete},
|
||||
{Keys.MediaStop, CorsairLedId.Stop},
|
||||
{Keys.MediaPreviousTrack, CorsairLedId.ScanPreviousTrack},
|
||||
{Keys.MediaNextTrack, CorsairLedId.ScanNextTrack},
|
||||
{Keys.MediaPlayPause, CorsairLedId.PlayPause},
|
||||
{Keys.VolumeMute, CorsairLedId.Mute},
|
||||
{Keys.VolumeUp, CorsairLedId.VolumeUp},
|
||||
{Keys.VolumeDown, CorsairLedId.VolumeDown}
|
||||
};
|
||||
}
|
||||
|
||||
public static Dictionary<Keys, CorsairLedId> FormsKeys { get; set; }
|
||||
public static object SDKLock { get; set; } = new object();
|
||||
}
|
||||
}
|
||||
@ -1,52 +0,0 @@
|
||||
using System.Drawing;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Artemis.DeviceProviders
|
||||
{
|
||||
public abstract class DeviceProvider
|
||||
{
|
||||
/// <summary>
|
||||
/// Indicates the device type
|
||||
/// </summary>
|
||||
public DeviceType Type { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Indicates whether or not the device can be updated
|
||||
/// </summary>
|
||||
public bool CanUse { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Updates a non-keyboard to take the colours found in the provided bitmap
|
||||
/// </summary>
|
||||
/// <param name="bitmap"></param>
|
||||
public abstract void UpdateDevice(Bitmap bitmap);
|
||||
|
||||
/// <summary>
|
||||
/// Tries to enable the device and updates CanUse accordingly
|
||||
/// </summary>
|
||||
public abstract bool TryEnable();
|
||||
|
||||
/// <summary>
|
||||
/// Disables the device
|
||||
/// </summary>
|
||||
public abstract void Disable();
|
||||
|
||||
/// <summary>
|
||||
/// Tries to enable the device and updates CanUse accordingly asynchronously
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public Task<bool> TryEnableAsync()
|
||||
{
|
||||
return Task.Run(() => TryEnable());
|
||||
}
|
||||
}
|
||||
|
||||
public enum DeviceType
|
||||
{
|
||||
Keyboard,
|
||||
Mouse,
|
||||
Headset,
|
||||
Generic,
|
||||
Mousemat
|
||||
}
|
||||
}
|
||||
@ -1,132 +0,0 @@
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Forms;
|
||||
using System.Windows.Media.Imaging;
|
||||
using Artemis.Utilities;
|
||||
using MahApps.Metro.Controls.Dialogs;
|
||||
using Size = System.Windows.Size;
|
||||
|
||||
namespace Artemis.DeviceProviders
|
||||
{
|
||||
public abstract class KeyboardProvider : DeviceProvider
|
||||
{
|
||||
protected KeyboardProvider()
|
||||
{
|
||||
Type = DeviceType.Keyboard;
|
||||
}
|
||||
|
||||
public string Name { get; set; }
|
||||
public string Slug { get; set; }
|
||||
public int Height { get; set; }
|
||||
public int Width { get; set; }
|
||||
public string CantEnableText { get; set; }
|
||||
public PreviewSettings PreviewSettings { get; set; }
|
||||
|
||||
public abstract bool CanEnable();
|
||||
public abstract void Enable();
|
||||
public abstract void DrawBitmap(Bitmap bitmap);
|
||||
|
||||
/// <summary>
|
||||
/// Returns a bitmap matching the keyboard's dimensions using the provided scale
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public Bitmap KeyboardBitmap(int scale = 4) => new Bitmap(Width * scale, Height * scale);
|
||||
|
||||
public Rect KeyboardRectangle(int scale = 4) => new Rect(new Size(Width * scale, Height * scale));
|
||||
|
||||
/// <summary>
|
||||
/// Runs CanEnable asynchronously multiple times until successful, cancelled or max tries reached
|
||||
/// </summary>
|
||||
/// <param name="dialog"></param>
|
||||
/// <returns></returns>
|
||||
public Task<bool> CanEnableAsync(ProgressDialogController dialog)
|
||||
{
|
||||
return Task.Run(() =>
|
||||
{
|
||||
for (var tries = 1; tries <= 10; tries++)
|
||||
{
|
||||
// Dialog interaction
|
||||
if (dialog != null)
|
||||
{
|
||||
// Stop if cancelled by user
|
||||
if (dialog.IsCanceled)
|
||||
{
|
||||
dialog.SetIndeterminate();
|
||||
return false;
|
||||
}
|
||||
// Updated progress to indicate how much tries are left
|
||||
dialog.SetProgress(0.1 * tries);
|
||||
}
|
||||
|
||||
if (CanEnable())
|
||||
{
|
||||
dialog?.SetIndeterminate();
|
||||
return true;
|
||||
}
|
||||
Thread.Sleep(2000);
|
||||
}
|
||||
dialog?.SetIndeterminate();
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Runs CanEnable asynchronously
|
||||
/// </summary>
|
||||
/// <param name="dialog"></param>
|
||||
/// <returns></returns>
|
||||
public Task EnableAsync(ProgressDialogController dialog)
|
||||
{
|
||||
return Task.Run(() => Enable());
|
||||
}
|
||||
|
||||
public override void UpdateDevice(Bitmap bitmap)
|
||||
{
|
||||
throw new NotSupportedException("KeyboardProvider doesn't implement UpdateDevice, use DrawBitmap instead.");
|
||||
}
|
||||
|
||||
public override bool TryEnable()
|
||||
{
|
||||
throw new NotSupportedException("KeyboardProvider doesn't implement TryEnable, use CanEnableAsync instead.");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the real life X and Y coordinates of the given key
|
||||
/// </summary>
|
||||
/// <param name="keyCode"></param>
|
||||
/// <returns></returns>
|
||||
public abstract KeyMatch? GetKeyPosition(Keys keyCode);
|
||||
}
|
||||
|
||||
public struct KeyMatch
|
||||
{
|
||||
public KeyMatch(Keys keyCode, int x, int y)
|
||||
{
|
||||
KeyCode = keyCode;
|
||||
X = x;
|
||||
Y = y;
|
||||
}
|
||||
|
||||
public Keys KeyCode { get; set; }
|
||||
public int X { get; set; }
|
||||
public int Y { get; set; }
|
||||
}
|
||||
|
||||
public struct PreviewSettings
|
||||
{
|
||||
public Rect OverlayRectangle { get; set; }
|
||||
public Rect BackgroundRectangle { get; set; }
|
||||
public BitmapImage Image { get; set; }
|
||||
|
||||
public PreviewSettings(Rect overlayRectangle, Bitmap bitmap)
|
||||
{
|
||||
OverlayRectangle = overlayRectangle;
|
||||
BackgroundRectangle = new Rect(0, 0, bitmap.Width, bitmap.Height);
|
||||
Image = ImageUtilities.BitmapToBitmapImage(bitmap);
|
||||
Image.Freeze();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,88 +0,0 @@
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Windows;
|
||||
using System.Windows.Forms;
|
||||
using Artemis.DAL;
|
||||
using Artemis.DeviceProviders.Logitech.Utilities;
|
||||
using Artemis.Properties;
|
||||
using Artemis.Settings;
|
||||
|
||||
namespace Artemis.DeviceProviders.Logitech
|
||||
{
|
||||
public class G810 : LogitechKeyboard
|
||||
{
|
||||
private GeneralSettings _generalSettings;
|
||||
|
||||
public G810()
|
||||
{
|
||||
Name = "Logitech G810 RGB";
|
||||
Slug = "logitech-g810";
|
||||
CantEnableText = "Couldn't connect to your Logitech G810.\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 = 7;
|
||||
Width = 21;
|
||||
PreviewSettings = new PreviewSettings(new Rect(19, 36, 1010, 304), Resources.g810);
|
||||
_generalSettings = SettingsProvider.Load<GeneralSettings>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The G910 also updates the G-logo, G-badge and G-keys
|
||||
/// </summary>
|
||||
/// <param name="bitmap"></param>
|
||||
public override void DrawBitmap(Bitmap bitmap)
|
||||
{
|
||||
using (var croppedBitmap = new Bitmap(21 * 4, 6 * 4))
|
||||
{
|
||||
// Deal with non-standard DPI
|
||||
croppedBitmap.SetResolution(96, 96);
|
||||
// Don't forget that the image is upscaled 4 times
|
||||
using (var g = Graphics.FromImage(croppedBitmap))
|
||||
{
|
||||
g.DrawImage(bitmap, new Rectangle(0, 0, 84, 24), new Rectangle(4, 4, 84, 24), GraphicsUnit.Pixel);
|
||||
}
|
||||
|
||||
LogitechGSDK.LogiLedSetTargetDevice(LogitechGSDK.LOGI_DEVICETYPE_PERKEY_RGB);
|
||||
// TODO: Remapping
|
||||
LogitechGSDK.LogiLedSetLightingFromBitmap(OrionUtilities.BitmapToByteArray(bitmap));
|
||||
}
|
||||
|
||||
using (var resized = OrionUtilities.ResizeImage(bitmap, 21, 7))
|
||||
{
|
||||
// Color G-logo, lets also try some other values to see what happens
|
||||
SetLogitechColorFromCoordinates(resized, KeyboardNames.G_LOGO, 0, 0);
|
||||
SetLogitechColorFromCoordinates(resized, KeyboardNames.G_BADGE, 0, 0);
|
||||
SetLogitechColorFromCoordinates(resized, KeyboardNames.G_1, 0, 0);
|
||||
SetLogitechColorFromCoordinates(resized, KeyboardNames.G_2, 0, 0);
|
||||
SetLogitechColorFromCoordinates(resized, KeyboardNames.G_3, 0, 0);
|
||||
SetLogitechColorFromCoordinates(resized, KeyboardNames.G_4, 0, 0);
|
||||
SetLogitechColorFromCoordinates(resized, KeyboardNames.G_5, 0, 0);
|
||||
SetLogitechColorFromCoordinates(resized, KeyboardNames.G_6, 0, 0);
|
||||
SetLogitechColorFromCoordinates(resized, KeyboardNames.G_7, 0, 0);
|
||||
SetLogitechColorFromCoordinates(resized, KeyboardNames.G_8, 0, 0);
|
||||
SetLogitechColorFromCoordinates(resized, KeyboardNames.G_9, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
public override KeyMatch? GetKeyPosition(Keys keyCode)
|
||||
{
|
||||
KeyMatch value;
|
||||
switch (_generalSettings.Layout)
|
||||
{
|
||||
case "Qwerty":
|
||||
value = KeyMap.QwertyLayout.FirstOrDefault(k => k.KeyCode == keyCode);
|
||||
break;
|
||||
case "Qwertz":
|
||||
value = KeyMap.QwertzLayout.FirstOrDefault(k => k.KeyCode == keyCode);
|
||||
break;
|
||||
default:
|
||||
value = KeyMap.AzertyLayout.FirstOrDefault(k => k.KeyCode == keyCode);
|
||||
break;
|
||||
}
|
||||
|
||||
// Adjust the distance by 1 on y for the G810
|
||||
return new KeyMatch(value.KeyCode, value.X, value.Y + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,235 +0,0 @@
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Windows;
|
||||
using System.Windows.Forms;
|
||||
using Artemis.DAL;
|
||||
using Artemis.DeviceProviders.Logitech.Utilities;
|
||||
using Artemis.Properties;
|
||||
using Artemis.Settings;
|
||||
|
||||
namespace Artemis.DeviceProviders.Logitech
|
||||
{
|
||||
public class G910 : LogitechKeyboard
|
||||
{
|
||||
private readonly GeneralSettings _generalSettings;
|
||||
|
||||
public G910()
|
||||
{
|
||||
Name = "Logitech G910 RGB";
|
||||
Slug = "logitech-g910";
|
||||
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 = 7;
|
||||
Width = 22;
|
||||
PreviewSettings = new PreviewSettings(new Rect(34, 18, 916, 272), Resources.g910);
|
||||
_generalSettings = SettingsProvider.Load<GeneralSettings>();
|
||||
}
|
||||
|
||||
public override KeyMatch? GetKeyPosition(Keys keyCode)
|
||||
{
|
||||
KeyMatch value;
|
||||
switch (_generalSettings.Layout)
|
||||
{
|
||||
case "Qwerty":
|
||||
value = KeyMap.QwertyLayout.FirstOrDefault(k => k.KeyCode == keyCode);
|
||||
break;
|
||||
case "Qwertz":
|
||||
value = KeyMap.QwertzLayout.FirstOrDefault(k => k.KeyCode == keyCode);
|
||||
break;
|
||||
default:
|
||||
value = KeyMap.AzertyLayout.FirstOrDefault(k => k.KeyCode == keyCode);
|
||||
break;
|
||||
}
|
||||
|
||||
// Adjust the distance by 1 on both x and y for the G910
|
||||
return new KeyMatch(value.KeyCode, value.X + 1, value.Y + 1);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The G910 also updates the G-logo, G-badge and G-keys
|
||||
/// </summary>
|
||||
/// <param name="bitmap"></param>
|
||||
public override void DrawBitmap(Bitmap bitmap)
|
||||
{
|
||||
using (var croppedBitmap = new Bitmap(21 * 4, 6 * 4))
|
||||
{
|
||||
// Deal with non-standard DPI
|
||||
croppedBitmap.SetResolution(96, 96);
|
||||
// Don't forget that the image is upscaled 4 times
|
||||
using (var g = Graphics.FromImage(croppedBitmap))
|
||||
{
|
||||
g.DrawImage(bitmap, new Rectangle(0, 0, 84, 24), new Rectangle(4, 4, 84, 24), GraphicsUnit.Pixel);
|
||||
}
|
||||
|
||||
LogitechGSDK.LogiLedSetTargetDevice(LogitechGSDK.LOGI_DEVICETYPE_PERKEY_RGB);
|
||||
LogitechGSDK.LogiLedSetLightingFromBitmap(OrionUtilities.BitmapToByteArray(bitmap, G910Keymappings));
|
||||
}
|
||||
|
||||
using (var resized = OrionUtilities.ResizeImage(bitmap, 22, 7))
|
||||
{
|
||||
// Color the extra keys on the left side of the keyboard
|
||||
SetLogitechColorFromCoordinates(resized, KeyboardNames.G_LOGO, 0, 1);
|
||||
SetLogitechColorFromCoordinates(resized, KeyboardNames.G_1, 0, 2);
|
||||
SetLogitechColorFromCoordinates(resized, KeyboardNames.G_2, 0, 3);
|
||||
SetLogitechColorFromCoordinates(resized, KeyboardNames.G_3, 0, 4);
|
||||
SetLogitechColorFromCoordinates(resized, KeyboardNames.G_4, 0, 5);
|
||||
SetLogitechColorFromCoordinates(resized, KeyboardNames.G_5, 0, 6);
|
||||
|
||||
// Color the extra keys on the top of the keyboard
|
||||
SetLogitechColorFromCoordinates(resized, KeyboardNames.G_6, 3, 0);
|
||||
SetLogitechColorFromCoordinates(resized, KeyboardNames.G_7, 4, 0);
|
||||
SetLogitechColorFromCoordinates(resized, KeyboardNames.G_8, 5, 0);
|
||||
SetLogitechColorFromCoordinates(resized, KeyboardNames.G_9, 6, 0);
|
||||
|
||||
// Color the G-badge
|
||||
SetLogitechColorFromCoordinates(resized, KeyboardNames.G_BADGE, 5, 6);
|
||||
}
|
||||
}
|
||||
|
||||
// These mappings are used by the G910 to fix alignments
|
||||
public static OrionUtilities.KeyMapping[] G910Keymappings =
|
||||
{
|
||||
// First row
|
||||
new OrionUtilities.KeyMapping(0, 0),
|
||||
new OrionUtilities.KeyMapping(1, 1),
|
||||
new OrionUtilities.KeyMapping(2, 1),
|
||||
new OrionUtilities.KeyMapping(3, 2),
|
||||
new OrionUtilities.KeyMapping(4, 3),
|
||||
new OrionUtilities.KeyMapping(5, 4),
|
||||
new OrionUtilities.KeyMapping(6, 5),
|
||||
new OrionUtilities.KeyMapping(7, 6),
|
||||
new OrionUtilities.KeyMapping(8, 7),
|
||||
new OrionUtilities.KeyMapping(9, 8),
|
||||
new OrionUtilities.KeyMapping(10, 9),
|
||||
new OrionUtilities.KeyMapping(11, 9),
|
||||
new OrionUtilities.KeyMapping(12, 10),
|
||||
new OrionUtilities.KeyMapping(13, 11),
|
||||
new OrionUtilities.KeyMapping(13, 12),
|
||||
new OrionUtilities.KeyMapping(14, 13),
|
||||
new OrionUtilities.KeyMapping(15, 14),
|
||||
new OrionUtilities.KeyMapping(16, 15),
|
||||
new OrionUtilities.KeyMapping(17, 16),
|
||||
new OrionUtilities.KeyMapping(18, 17),
|
||||
new OrionUtilities.KeyMapping(19, 18),
|
||||
|
||||
// Second row
|
||||
new OrionUtilities.KeyMapping(21, 21),
|
||||
new OrionUtilities.KeyMapping(22, 22),
|
||||
new OrionUtilities.KeyMapping(23, 23),
|
||||
new OrionUtilities.KeyMapping(24, 24),
|
||||
new OrionUtilities.KeyMapping(25, 25),
|
||||
new OrionUtilities.KeyMapping(26, 26),
|
||||
new OrionUtilities.KeyMapping(27, 27),
|
||||
new OrionUtilities.KeyMapping(28, 28),
|
||||
new OrionUtilities.KeyMapping(29, 29),
|
||||
new OrionUtilities.KeyMapping(30, 30),
|
||||
new OrionUtilities.KeyMapping(31, 31),
|
||||
new OrionUtilities.KeyMapping(32, 32),
|
||||
new OrionUtilities.KeyMapping(33, 33),
|
||||
new OrionUtilities.KeyMapping(34, 34),
|
||||
new OrionUtilities.KeyMapping(35, 35),
|
||||
new OrionUtilities.KeyMapping(36, 36),
|
||||
new OrionUtilities.KeyMapping(37, 37),
|
||||
new OrionUtilities.KeyMapping(38, 38),
|
||||
new OrionUtilities.KeyMapping(39, 39),
|
||||
new OrionUtilities.KeyMapping(40, 40),
|
||||
new OrionUtilities.KeyMapping(41, 41),
|
||||
|
||||
// Third row
|
||||
new OrionUtilities.KeyMapping(42, 42),
|
||||
new OrionUtilities.KeyMapping(43, 43),
|
||||
new OrionUtilities.KeyMapping(44, 44),
|
||||
new OrionUtilities.KeyMapping(45, 45),
|
||||
new OrionUtilities.KeyMapping(46, 46),
|
||||
new OrionUtilities.KeyMapping(47, 46),
|
||||
new OrionUtilities.KeyMapping(48, 47),
|
||||
new OrionUtilities.KeyMapping(49, 48),
|
||||
new OrionUtilities.KeyMapping(50, 49),
|
||||
new OrionUtilities.KeyMapping(51, 50),
|
||||
new OrionUtilities.KeyMapping(52, 51),
|
||||
new OrionUtilities.KeyMapping(53, 52),
|
||||
new OrionUtilities.KeyMapping(54, 53),
|
||||
new OrionUtilities.KeyMapping(54, 54),
|
||||
new OrionUtilities.KeyMapping(55, 55),
|
||||
new OrionUtilities.KeyMapping(56, 56),
|
||||
new OrionUtilities.KeyMapping(57, 57),
|
||||
new OrionUtilities.KeyMapping(58, 58),
|
||||
new OrionUtilities.KeyMapping(59, 59),
|
||||
new OrionUtilities.KeyMapping(60, 60),
|
||||
new OrionUtilities.KeyMapping(61, 61),
|
||||
new OrionUtilities.KeyMapping(62, 62),
|
||||
|
||||
// Fourth row
|
||||
new OrionUtilities.KeyMapping(63, 63),
|
||||
new OrionUtilities.KeyMapping(64, 64),
|
||||
new OrionUtilities.KeyMapping(65, 65),
|
||||
new OrionUtilities.KeyMapping(66, 65),
|
||||
new OrionUtilities.KeyMapping(67, 66),
|
||||
new OrionUtilities.KeyMapping(68, 67),
|
||||
new OrionUtilities.KeyMapping(69, 68),
|
||||
new OrionUtilities.KeyMapping(70, 69),
|
||||
new OrionUtilities.KeyMapping(71, 70),
|
||||
new OrionUtilities.KeyMapping(72, 71),
|
||||
new OrionUtilities.KeyMapping(73, 72),
|
||||
new OrionUtilities.KeyMapping(74, 73),
|
||||
new OrionUtilities.KeyMapping(75, 74),
|
||||
new OrionUtilities.KeyMapping(76, 75),
|
||||
new OrionUtilities.KeyMapping(76, 76),
|
||||
new OrionUtilities.KeyMapping(78, 77),
|
||||
new OrionUtilities.KeyMapping(79, 78),
|
||||
new OrionUtilities.KeyMapping(79, 79),
|
||||
new OrionUtilities.KeyMapping(80, 80),
|
||||
new OrionUtilities.KeyMapping(81, 81),
|
||||
new OrionUtilities.KeyMapping(82, 82),
|
||||
|
||||
// Fifth row
|
||||
new OrionUtilities.KeyMapping(84, 84),
|
||||
new OrionUtilities.KeyMapping(85, 85),
|
||||
new OrionUtilities.KeyMapping(86, 86),
|
||||
new OrionUtilities.KeyMapping(87, 87),
|
||||
new OrionUtilities.KeyMapping(88, 88),
|
||||
new OrionUtilities.KeyMapping(89, 89),
|
||||
new OrionUtilities.KeyMapping(90, 90),
|
||||
new OrionUtilities.KeyMapping(91, 91),
|
||||
new OrionUtilities.KeyMapping(92, 92),
|
||||
new OrionUtilities.KeyMapping(93, 93),
|
||||
new OrionUtilities.KeyMapping(94, 94),
|
||||
new OrionUtilities.KeyMapping(95, 95),
|
||||
new OrionUtilities.KeyMapping(96, 96),
|
||||
new OrionUtilities.KeyMapping(97, 97),
|
||||
new OrionUtilities.KeyMapping(98, 98),
|
||||
new OrionUtilities.KeyMapping(99, 99),
|
||||
new OrionUtilities.KeyMapping(100, 100),
|
||||
new OrionUtilities.KeyMapping(101, 101),
|
||||
new OrionUtilities.KeyMapping(102, 102),
|
||||
new OrionUtilities.KeyMapping(103, 103),
|
||||
new OrionUtilities.KeyMapping(104, 104),
|
||||
|
||||
// Sixth row
|
||||
new OrionUtilities.KeyMapping(105, 105),
|
||||
new OrionUtilities.KeyMapping(106, 106),
|
||||
new OrionUtilities.KeyMapping(107, 107),
|
||||
new OrionUtilities.KeyMapping(108, 107),
|
||||
new OrionUtilities.KeyMapping(109, 109),
|
||||
new OrionUtilities.KeyMapping(110, 110),
|
||||
new OrionUtilities.KeyMapping(111, 110),
|
||||
new OrionUtilities.KeyMapping(112, 111),
|
||||
new OrionUtilities.KeyMapping(113, 112),
|
||||
new OrionUtilities.KeyMapping(114, 113),
|
||||
new OrionUtilities.KeyMapping(115, 114),
|
||||
new OrionUtilities.KeyMapping(116, 115),
|
||||
new OrionUtilities.KeyMapping(115, 116), // ALTGR
|
||||
new OrionUtilities.KeyMapping(116, 117),
|
||||
new OrionUtilities.KeyMapping(117, 118),
|
||||
new OrionUtilities.KeyMapping(118, 119),
|
||||
new OrionUtilities.KeyMapping(119, 120),
|
||||
new OrionUtilities.KeyMapping(120, 121),
|
||||
new OrionUtilities.KeyMapping(121, 122),
|
||||
new OrionUtilities.KeyMapping(122, 123),
|
||||
new OrionUtilities.KeyMapping(124, 124)
|
||||
};
|
||||
}
|
||||
}
|
||||
@ -1,55 +0,0 @@
|
||||
//using System;
|
||||
//using System.Drawing;
|
||||
//using Artemis.DeviceProviders.Logitech.Utilities;
|
||||
//using Ninject.Extensions.Logging;
|
||||
//
|
||||
//namespace Artemis.DeviceProviders.Logitech
|
||||
//{
|
||||
// // TODO: Handle shutdown, maybe implement Disable() afterall?
|
||||
// public class LogitechGeneric : DeviceProvider
|
||||
// {
|
||||
// /// <summary>
|
||||
// /// A generic Logitech DeviceProvider. Because the Logitech SDK currently doesn't allow specific
|
||||
// /// device targeting (only very broad per-key-RGB and full RGB etc..)
|
||||
// /// </summary>
|
||||
// public LogitechGeneric(ILogger logger)
|
||||
// {
|
||||
// Logger = logger;
|
||||
// Type = DeviceType.Generic;
|
||||
// }
|
||||
//
|
||||
// public ILogger Logger { get; set; }
|
||||
//
|
||||
// public override void UpdateDevice(Bitmap bitmap)
|
||||
// {
|
||||
// if (!CanUse || bitmap == null)
|
||||
// return;
|
||||
//
|
||||
// var col = bitmap.GetPixel(bitmap.Width/2, bitmap.Height/2);
|
||||
// LogitechGSDK.LogiLedSetTargetDevice(LogitechGSDK.LOGI_DEVICETYPE_RGB);
|
||||
// LogitechGSDK.LogiLedSetLighting((int) (col.R/2.55), (int) (col.G/2.55), (int) (col.B/2.55));
|
||||
// }
|
||||
//
|
||||
// public override bool TryEnable()
|
||||
// {
|
||||
// var majorNum = 0;
|
||||
// var minorNum = 0;
|
||||
// var buildNum = 0;
|
||||
//
|
||||
// LogitechGSDK.LogiLedInit();
|
||||
// LogitechGSDK.LogiLedGetSdkVersion(ref majorNum, ref minorNum, ref buildNum);
|
||||
//
|
||||
// // Turn it into one long number...
|
||||
// var version = int.Parse($"{majorNum}{minorNum}{buildNum}");
|
||||
// CanUse = version >= 88115;
|
||||
// Logger.Debug("Attempted to enable Logitech generic device. CanUse: {0}", CanUse);
|
||||
//
|
||||
// return CanUse;
|
||||
// }
|
||||
//
|
||||
// public override void Disable()
|
||||
// {
|
||||
// throw new NotSupportedException("Can only disable a keyboard");
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
@ -1,61 +0,0 @@
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Threading;
|
||||
using Artemis.DeviceProviders.Logitech.Utilities;
|
||||
using Artemis.Utilities.DataReaders;
|
||||
using Microsoft.Win32;
|
||||
|
||||
namespace Artemis.DeviceProviders.Logitech
|
||||
{
|
||||
public abstract class LogitechKeyboard : KeyboardProvider
|
||||
{
|
||||
public override bool CanEnable()
|
||||
{
|
||||
// Just to be sure, restore the Logitech DLL registry key
|
||||
DllManager.RestoreLogitechDll();
|
||||
|
||||
int majorNum = 0, minorNum = 0, buildNum = 0;
|
||||
|
||||
LogitechGSDK.LogiLedInit();
|
||||
LogitechGSDK.LogiLedGetSdkVersion(ref majorNum, ref minorNum, ref buildNum);
|
||||
LogitechGSDK.LogiLedShutdown();
|
||||
|
||||
// Turn it into one long number...
|
||||
var version = int.Parse($"{majorNum}{minorNum}{buildNum}");
|
||||
CantEnableText = "Couldn't connect to your Logitech keyboard.\n" +
|
||||
"Please check your cables and updating the Logitech Gaming Software\n" +
|
||||
$"A minimum version of 8.81.15 is required (detected {majorNum}.{minorNum}.{buildNum}).\n\n" +
|
||||
"If the detected version differs from the version LGS is reporting, reinstall LGS or see the FAQ.\n\n" +
|
||||
"If needed, you can select a different keyboard in Artemis under settings.";
|
||||
|
||||
return version >= 88115;
|
||||
}
|
||||
|
||||
public override void Enable()
|
||||
{
|
||||
// Initialize the SDK
|
||||
LogitechGSDK.LogiLedInit();
|
||||
Thread.Sleep(200);
|
||||
|
||||
LogitechGSDK.LogiLedSaveCurrentLighting();
|
||||
LogitechGSDK.LogiLedSetTargetDevice(LogitechGSDK.LOGI_DEVICETYPE_PERKEY_RGB);
|
||||
}
|
||||
|
||||
public override void Disable()
|
||||
{
|
||||
// Shutdown the SDK
|
||||
LogitechGSDK.LogiLedRestoreLighting();
|
||||
LogitechGSDK.LogiLedShutdown();
|
||||
}
|
||||
|
||||
protected void SetLogitechColorFromCoordinates(Bitmap bitmap, KeyboardNames key, int x, int y)
|
||||
{
|
||||
var color = bitmap.GetPixel(x, y);
|
||||
var rPer = (int)Math.Round(color.R / 2.55);
|
||||
var gPer = (int)Math.Round(color.G / 2.55);
|
||||
var bPer = (int)Math.Round(color.B / 2.55);
|
||||
|
||||
LogitechGSDK.LogiLedSetLightingForKeyWithKeyName(key, rPer, gPer, bPer);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,392 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Artemis.DeviceProviders.Logitech.Utilities
|
||||
{
|
||||
public static class KeyMap
|
||||
{
|
||||
static KeyMap()
|
||||
{
|
||||
// There are several keyboard layouts
|
||||
|
||||
#region Qwerty
|
||||
|
||||
QwertyLayout = new List<KeyMatch>
|
||||
{
|
||||
// Row 1
|
||||
new KeyMatch(Keys.Escape, 0, 0),
|
||||
new KeyMatch(Keys.F1, 2, 0),
|
||||
new KeyMatch(Keys.F2, 3, 0),
|
||||
new KeyMatch(Keys.F3, 4, 0),
|
||||
new KeyMatch(Keys.F4, 5, 0),
|
||||
new KeyMatch(Keys.F5, 6, 0),
|
||||
new KeyMatch(Keys.F6, 7, 0),
|
||||
new KeyMatch(Keys.F7, 8, 0),
|
||||
new KeyMatch(Keys.F8, 9, 0),
|
||||
new KeyMatch(Keys.F9, 11, 0),
|
||||
new KeyMatch(Keys.F10, 12, 0),
|
||||
new KeyMatch(Keys.F11, 13, 0),
|
||||
new KeyMatch(Keys.F12, 14, 0),
|
||||
new KeyMatch(Keys.PrintScreen, 15, 0),
|
||||
new KeyMatch(Keys.Scroll, 16, 0),
|
||||
new KeyMatch(Keys.Pause, 17, 0),
|
||||
|
||||
// Row 2
|
||||
new KeyMatch(Keys.Oemtilde, 0, 1),
|
||||
new KeyMatch(Keys.D1, 1, 1),
|
||||
new KeyMatch(Keys.D2, 2, 1),
|
||||
new KeyMatch(Keys.D3, 3, 1),
|
||||
new KeyMatch(Keys.D4, 4, 1),
|
||||
new KeyMatch(Keys.D5, 5, 1),
|
||||
new KeyMatch(Keys.D6, 6, 1),
|
||||
new KeyMatch(Keys.D7, 7, 1),
|
||||
new KeyMatch(Keys.D8, 8, 1),
|
||||
new KeyMatch(Keys.D9, 9, 1),
|
||||
new KeyMatch(Keys.D0, 10, 1),
|
||||
new KeyMatch(Keys.OemMinus, 11, 1),
|
||||
new KeyMatch(Keys.Oemplus, 12, 1),
|
||||
new KeyMatch(Keys.Back, 13, 1),
|
||||
new KeyMatch(Keys.Insert, 14, 1),
|
||||
new KeyMatch(Keys.Home, 15, 1),
|
||||
new KeyMatch(Keys.PageUp, 16, 1),
|
||||
new KeyMatch(Keys.NumLock, 17, 1),
|
||||
new KeyMatch(Keys.Divide, 18, 1),
|
||||
new KeyMatch(Keys.Multiply, 19, 1),
|
||||
new KeyMatch(Keys.Subtract, 20, 1),
|
||||
|
||||
// Row 3
|
||||
new KeyMatch(Keys.Tab, 0, 2),
|
||||
new KeyMatch(Keys.Q, 1, 2),
|
||||
new KeyMatch(Keys.W, 2, 2),
|
||||
new KeyMatch(Keys.E, 3, 2),
|
||||
new KeyMatch(Keys.R, 5, 2),
|
||||
new KeyMatch(Keys.T, 6, 2),
|
||||
new KeyMatch(Keys.Y, 7, 2),
|
||||
new KeyMatch(Keys.U, 8, 2),
|
||||
new KeyMatch(Keys.I, 9, 2),
|
||||
new KeyMatch(Keys.O, 10, 2),
|
||||
new KeyMatch(Keys.P, 11, 2),
|
||||
new KeyMatch(Keys.OemOpenBrackets, 12, 2),
|
||||
new KeyMatch(Keys.Oem6, 13, 2),
|
||||
new KeyMatch(Keys.Delete, 14, 2),
|
||||
new KeyMatch(Keys.End, 15, 2),
|
||||
new KeyMatch(Keys.Next, 16, 2),
|
||||
new KeyMatch(Keys.NumPad7, 17, 2),
|
||||
new KeyMatch(Keys.NumPad8, 18, 2),
|
||||
new KeyMatch(Keys.NumPad9, 19, 2),
|
||||
new KeyMatch(Keys.Add, 20, 2),
|
||||
|
||||
// Row 4
|
||||
new KeyMatch(Keys.Capital, 0, 3),
|
||||
new KeyMatch(Keys.A, 1, 3),
|
||||
new KeyMatch(Keys.S, 3, 3),
|
||||
new KeyMatch(Keys.D, 4, 3),
|
||||
new KeyMatch(Keys.F, 5, 3),
|
||||
new KeyMatch(Keys.G, 6, 3),
|
||||
new KeyMatch(Keys.H, 7, 3),
|
||||
new KeyMatch(Keys.J, 8, 3),
|
||||
new KeyMatch(Keys.K, 9, 3),
|
||||
new KeyMatch(Keys.L, 10, 3),
|
||||
new KeyMatch(Keys.Oem1, 11, 3),
|
||||
new KeyMatch(Keys.Oem7, 12, 3),
|
||||
new KeyMatch(Keys.Oem5, 13, 3),
|
||||
new KeyMatch(Keys.Return, 14, 3),
|
||||
new KeyMatch(Keys.NumPad4, 17, 3),
|
||||
new KeyMatch(Keys.NumPad5, 18, 3),
|
||||
new KeyMatch(Keys.NumPad6, 19, 3),
|
||||
|
||||
// Row 5
|
||||
new KeyMatch(Keys.LShiftKey, 1, 4),
|
||||
new KeyMatch(Keys.OemBackslash, 2, 4),
|
||||
new KeyMatch(Keys.Z, 2, 4),
|
||||
new KeyMatch(Keys.X, 3, 4),
|
||||
new KeyMatch(Keys.C, 4, 4),
|
||||
new KeyMatch(Keys.V, 5, 4),
|
||||
new KeyMatch(Keys.B, 6, 4),
|
||||
new KeyMatch(Keys.N, 7, 4),
|
||||
new KeyMatch(Keys.M, 8, 4),
|
||||
new KeyMatch(Keys.Oemcomma, 9, 4),
|
||||
new KeyMatch(Keys.OemPeriod, 10, 4),
|
||||
new KeyMatch(Keys.OemQuestion, 11, 4),
|
||||
new KeyMatch(Keys.RShiftKey, 13, 4),
|
||||
new KeyMatch(Keys.Up, 15, 4),
|
||||
new KeyMatch(Keys.NumPad1, 17, 4),
|
||||
new KeyMatch(Keys.NumPad2, 18, 4),
|
||||
new KeyMatch(Keys.NumPad3, 19, 4),
|
||||
// Both returns return "Return" (Yes...)
|
||||
// new OrionKey(System.Windows.Forms.Keys.Return, 20, 4),
|
||||
|
||||
// Row 6
|
||||
new KeyMatch(Keys.LControlKey, 0, 5),
|
||||
new KeyMatch(Keys.LWin, 1, 5),
|
||||
new KeyMatch(Keys.LMenu, 3, 5),
|
||||
new KeyMatch(Keys.Space, 6, 5),
|
||||
new KeyMatch(Keys.RMenu, 11, 5),
|
||||
new KeyMatch(Keys.RWin, 12, 5),
|
||||
new KeyMatch(Keys.Apps, 13, 5),
|
||||
new KeyMatch(Keys.RControlKey, 14, 5),
|
||||
new KeyMatch(Keys.Left, 15, 5),
|
||||
new KeyMatch(Keys.Down, 16, 5),
|
||||
new KeyMatch(Keys.Right, 17, 5),
|
||||
new KeyMatch(Keys.NumPad0, 18, 5),
|
||||
new KeyMatch(Keys.Decimal, 19, 5)
|
||||
};
|
||||
|
||||
#endregion
|
||||
|
||||
#region Qwertz
|
||||
|
||||
QwertzLayout = new List<KeyMatch>
|
||||
{
|
||||
// Row 1
|
||||
new KeyMatch(Keys.Escape, 0, 0),
|
||||
new KeyMatch(Keys.F1, 2, 0),
|
||||
new KeyMatch(Keys.F2, 3, 0),
|
||||
new KeyMatch(Keys.F3, 4, 0),
|
||||
new KeyMatch(Keys.F4, 5, 0),
|
||||
new KeyMatch(Keys.F5, 6, 0),
|
||||
new KeyMatch(Keys.F6, 7, 0),
|
||||
new KeyMatch(Keys.F7, 8, 0),
|
||||
new KeyMatch(Keys.F8, 9, 0),
|
||||
new KeyMatch(Keys.F9, 11, 0),
|
||||
new KeyMatch(Keys.F10, 12, 0), // returns 'None'
|
||||
new KeyMatch(Keys.F11, 13, 0),
|
||||
new KeyMatch(Keys.F12, 14, 0),
|
||||
new KeyMatch(Keys.PrintScreen, 15, 0),
|
||||
new KeyMatch(Keys.Scroll, 16, 0),
|
||||
new KeyMatch(Keys.Pause, 17, 0),
|
||||
|
||||
// Row 2
|
||||
new KeyMatch(Keys.Oem5, 0, 1),
|
||||
new KeyMatch(Keys.D1, 1, 1),
|
||||
new KeyMatch(Keys.D2, 2, 1),
|
||||
new KeyMatch(Keys.D3, 3, 1),
|
||||
new KeyMatch(Keys.D4, 4, 1),
|
||||
new KeyMatch(Keys.D5, 5, 1),
|
||||
new KeyMatch(Keys.D6, 6, 1),
|
||||
new KeyMatch(Keys.D7, 7, 1),
|
||||
new KeyMatch(Keys.D8, 8, 1),
|
||||
new KeyMatch(Keys.D9, 9, 1),
|
||||
new KeyMatch(Keys.D0, 10, 1),
|
||||
new KeyMatch(Keys.OemOpenBrackets, 11, 1),
|
||||
new KeyMatch(Keys.Oem6, 12, 1),
|
||||
new KeyMatch(Keys.Back, 13, 1),
|
||||
new KeyMatch(Keys.Insert, 14, 1),
|
||||
new KeyMatch(Keys.Home, 15, 1),
|
||||
new KeyMatch(Keys.PageUp, 16, 1),
|
||||
new KeyMatch(Keys.NumLock, 17, 1),
|
||||
new KeyMatch(Keys.Divide, 18, 1),
|
||||
new KeyMatch(Keys.Multiply, 19, 1),
|
||||
new KeyMatch(Keys.Subtract, 20, 1),
|
||||
|
||||
// Row 3
|
||||
new KeyMatch(Keys.Tab, 0, 2),
|
||||
new KeyMatch(Keys.Q, 1, 2),
|
||||
new KeyMatch(Keys.W, 2, 2),
|
||||
new KeyMatch(Keys.E, 3, 2),
|
||||
new KeyMatch(Keys.R, 5, 2),
|
||||
new KeyMatch(Keys.T, 6, 2),
|
||||
new KeyMatch(Keys.Z, 7, 2),
|
||||
new KeyMatch(Keys.U, 8, 2),
|
||||
new KeyMatch(Keys.I, 9, 2),
|
||||
new KeyMatch(Keys.O, 10, 2),
|
||||
new KeyMatch(Keys.P, 11, 2),
|
||||
new KeyMatch(Keys.Oem1, 12, 2),
|
||||
new KeyMatch(Keys.Oemplus, 13, 2),
|
||||
new KeyMatch(Keys.Delete, 14, 2),
|
||||
new KeyMatch(Keys.End, 15, 2),
|
||||
new KeyMatch(Keys.Next, 16, 2),
|
||||
new KeyMatch(Keys.NumPad7, 17, 2),
|
||||
new KeyMatch(Keys.NumPad8, 18, 2),
|
||||
new KeyMatch(Keys.NumPad9, 19, 2),
|
||||
new KeyMatch(Keys.Add, 20, 2),
|
||||
|
||||
// Row 4
|
||||
new KeyMatch(Keys.Capital, 0, 3),
|
||||
new KeyMatch(Keys.A, 1, 3),
|
||||
new KeyMatch(Keys.S, 3, 3),
|
||||
new KeyMatch(Keys.D, 4, 3),
|
||||
new KeyMatch(Keys.F, 5, 3),
|
||||
new KeyMatch(Keys.G, 6, 3),
|
||||
new KeyMatch(Keys.H, 7, 3),
|
||||
new KeyMatch(Keys.J, 8, 3),
|
||||
new KeyMatch(Keys.K, 9, 3),
|
||||
new KeyMatch(Keys.L, 10, 3),
|
||||
new KeyMatch(Keys.Oemtilde, 11, 3),
|
||||
new KeyMatch(Keys.Oem7, 12, 3),
|
||||
new KeyMatch(Keys.OemQuestion, 13, 3),
|
||||
new KeyMatch(Keys.Return, 14, 3),
|
||||
new KeyMatch(Keys.NumPad4, 17, 3),
|
||||
new KeyMatch(Keys.NumPad5, 18, 3),
|
||||
new KeyMatch(Keys.NumPad6, 19, 3),
|
||||
|
||||
// Row 5
|
||||
new KeyMatch(Keys.LShiftKey, 1, 4),
|
||||
new KeyMatch(Keys.OemBackslash, 2, 4),
|
||||
new KeyMatch(Keys.Y, 2, 4),
|
||||
new KeyMatch(Keys.X, 3, 4),
|
||||
new KeyMatch(Keys.C, 4, 4),
|
||||
new KeyMatch(Keys.V, 5, 4),
|
||||
new KeyMatch(Keys.B, 6, 4),
|
||||
new KeyMatch(Keys.N, 7, 4),
|
||||
new KeyMatch(Keys.M, 8, 4),
|
||||
new KeyMatch(Keys.Oemcomma, 9, 4),
|
||||
new KeyMatch(Keys.OemPeriod, 10, 4),
|
||||
new KeyMatch(Keys.OemMinus, 11, 4),
|
||||
new KeyMatch(Keys.RShiftKey, 13, 4),
|
||||
new KeyMatch(Keys.Up, 15, 4),
|
||||
new KeyMatch(Keys.NumPad1, 17, 4),
|
||||
new KeyMatch(Keys.NumPad2, 18, 4),
|
||||
new KeyMatch(Keys.NumPad3, 19, 4),
|
||||
// Both returns return "Return" (Yes...)
|
||||
// new OrionKey(System.Windows.Forms.Keys.Return, 20, 4),
|
||||
|
||||
// Row 6
|
||||
new KeyMatch(Keys.LControlKey, 0, 5),
|
||||
new KeyMatch(Keys.LWin, 1, 5),
|
||||
new KeyMatch(Keys.Menu, 3, 5), // returns 'None'
|
||||
new KeyMatch(Keys.Space, 6, 5),
|
||||
new KeyMatch(Keys.RMenu, 11, 5),
|
||||
new KeyMatch(Keys.RWin, 12, 5),
|
||||
new KeyMatch(Keys.Apps, 13, 5),
|
||||
new KeyMatch(Keys.RControlKey, 14, 5),
|
||||
new KeyMatch(Keys.Left, 15, 5),
|
||||
new KeyMatch(Keys.Down, 16, 5),
|
||||
new KeyMatch(Keys.Right, 17, 5),
|
||||
new KeyMatch(Keys.NumPad0, 18, 5),
|
||||
new KeyMatch(Keys.Decimal, 19, 5)
|
||||
};
|
||||
|
||||
#endregion
|
||||
|
||||
#region Azerty
|
||||
|
||||
AzertyLayout = new List<KeyMatch>
|
||||
{
|
||||
// Row 1
|
||||
new KeyMatch(Keys.Escape, 0, 0),
|
||||
new KeyMatch(Keys.F1, 2, 0),
|
||||
new KeyMatch(Keys.F2, 3, 0),
|
||||
new KeyMatch(Keys.F3, 4, 0),
|
||||
new KeyMatch(Keys.F4, 5, 0),
|
||||
new KeyMatch(Keys.F5, 6, 0),
|
||||
new KeyMatch(Keys.F6, 7, 0),
|
||||
new KeyMatch(Keys.F7, 8, 0),
|
||||
new KeyMatch(Keys.F8, 9, 0),
|
||||
new KeyMatch(Keys.F9, 11, 0),
|
||||
new KeyMatch(Keys.F10, 12, 0),
|
||||
new KeyMatch(Keys.F11, 13, 0),
|
||||
new KeyMatch(Keys.F12, 14, 0),
|
||||
new KeyMatch(Keys.PrintScreen, 15, 0),
|
||||
new KeyMatch(Keys.Scroll, 16, 0),
|
||||
new KeyMatch(Keys.Pause, 17, 0),
|
||||
|
||||
// Row 2
|
||||
new KeyMatch(Keys.Oemtilde, 0, 1),
|
||||
new KeyMatch(Keys.D1, 1, 1),
|
||||
new KeyMatch(Keys.D2, 2, 1),
|
||||
new KeyMatch(Keys.D3, 3, 1),
|
||||
new KeyMatch(Keys.D4, 4, 1),
|
||||
new KeyMatch(Keys.D5, 5, 1),
|
||||
new KeyMatch(Keys.D6, 6, 1),
|
||||
new KeyMatch(Keys.D7, 7, 1),
|
||||
new KeyMatch(Keys.D8, 8, 1),
|
||||
new KeyMatch(Keys.D9, 9, 1),
|
||||
new KeyMatch(Keys.D0, 10, 1),
|
||||
new KeyMatch(Keys.OemMinus, 11, 1),
|
||||
new KeyMatch(Keys.Oemplus, 12, 1),
|
||||
new KeyMatch(Keys.Back, 13, 1),
|
||||
new KeyMatch(Keys.Insert, 14, 1),
|
||||
new KeyMatch(Keys.Home, 15, 1),
|
||||
new KeyMatch(Keys.PageUp, 16, 1),
|
||||
new KeyMatch(Keys.NumLock, 17, 1),
|
||||
new KeyMatch(Keys.Divide, 18, 1),
|
||||
new KeyMatch(Keys.Multiply, 19, 1),
|
||||
new KeyMatch(Keys.Subtract, 20, 1),
|
||||
|
||||
// Row 3
|
||||
new KeyMatch(Keys.Tab, 0, 2),
|
||||
new KeyMatch(Keys.A, 1, 2),
|
||||
new KeyMatch(Keys.Z, 2, 2),
|
||||
new KeyMatch(Keys.E, 3, 2),
|
||||
new KeyMatch(Keys.R, 5, 2),
|
||||
new KeyMatch(Keys.T, 6, 2),
|
||||
new KeyMatch(Keys.Y, 7, 2),
|
||||
new KeyMatch(Keys.U, 8, 2),
|
||||
new KeyMatch(Keys.I, 9, 2),
|
||||
new KeyMatch(Keys.O, 10, 2),
|
||||
new KeyMatch(Keys.P, 11, 2),
|
||||
new KeyMatch(Keys.OemQuotes, 12, 2),
|
||||
new KeyMatch(Keys.Oem6, 13, 2),
|
||||
new KeyMatch(Keys.Delete, 14, 2),
|
||||
new KeyMatch(Keys.End, 15, 2),
|
||||
new KeyMatch(Keys.Next, 16, 2),
|
||||
new KeyMatch(Keys.NumPad7, 17, 2),
|
||||
new KeyMatch(Keys.NumPad8, 18, 2),
|
||||
new KeyMatch(Keys.NumPad9, 19, 2),
|
||||
new KeyMatch(Keys.Add, 20, 2),
|
||||
|
||||
// Row 4
|
||||
new KeyMatch(Keys.Capital, 0, 3),
|
||||
new KeyMatch(Keys.Q, 1, 3),
|
||||
new KeyMatch(Keys.S, 3, 3),
|
||||
new KeyMatch(Keys.D, 4, 3),
|
||||
new KeyMatch(Keys.F, 5, 3),
|
||||
new KeyMatch(Keys.G, 6, 3),
|
||||
new KeyMatch(Keys.H, 7, 3),
|
||||
new KeyMatch(Keys.J, 8, 3),
|
||||
new KeyMatch(Keys.K, 9, 3),
|
||||
new KeyMatch(Keys.L, 10, 3),
|
||||
new KeyMatch(Keys.M, 11, 3),
|
||||
new KeyMatch(Keys.Oem7, 12, 3),
|
||||
new KeyMatch(Keys.Oem5, 13, 3),
|
||||
new KeyMatch(Keys.Return, 14, 3),
|
||||
new KeyMatch(Keys.NumPad4, 17, 3),
|
||||
new KeyMatch(Keys.NumPad5, 18, 3),
|
||||
new KeyMatch(Keys.NumPad6, 19, 3),
|
||||
|
||||
// Row 5
|
||||
new KeyMatch(Keys.LShiftKey, 1, 4),
|
||||
new KeyMatch(Keys.OemBackslash, 2, 4),
|
||||
new KeyMatch(Keys.W, 2, 4),
|
||||
new KeyMatch(Keys.X, 3, 4),
|
||||
new KeyMatch(Keys.C, 4, 4),
|
||||
new KeyMatch(Keys.V, 5, 4),
|
||||
new KeyMatch(Keys.B, 6, 4),
|
||||
new KeyMatch(Keys.N, 7, 4),
|
||||
new KeyMatch(Keys.OemQuestion, 8, 4),
|
||||
new KeyMatch(Keys.Oemcomma, 9, 4),
|
||||
new KeyMatch(Keys.OemPeriod, 10, 4),
|
||||
new KeyMatch(Keys.OemQuestion, 11, 4),
|
||||
new KeyMatch(Keys.RShiftKey, 13, 4),
|
||||
new KeyMatch(Keys.Up, 15, 4),
|
||||
new KeyMatch(Keys.NumPad1, 17, 4),
|
||||
new KeyMatch(Keys.NumPad2, 18, 4),
|
||||
new KeyMatch(Keys.NumPad3, 19, 4),
|
||||
// Both returns return "Return" (Yes...)
|
||||
// new OrionKey(System.Windows.Forms.Keys.Return, 20, 4),
|
||||
|
||||
// Row 6
|
||||
new KeyMatch(Keys.LControlKey, 0, 5),
|
||||
new KeyMatch(Keys.LWin, 1, 5),
|
||||
new KeyMatch(Keys.LMenu, 3, 5),
|
||||
new KeyMatch(Keys.Space, 6, 5),
|
||||
new KeyMatch(Keys.RMenu, 11, 5),
|
||||
new KeyMatch(Keys.RWin, 12, 5),
|
||||
new KeyMatch(Keys.Apps, 13, 5),
|
||||
new KeyMatch(Keys.RControlKey, 14, 5),
|
||||
new KeyMatch(Keys.Left, 15, 5),
|
||||
new KeyMatch(Keys.Down, 16, 5),
|
||||
new KeyMatch(Keys.Right, 17, 5),
|
||||
new KeyMatch(Keys.NumPad0, 18, 5),
|
||||
new KeyMatch(Keys.Decimal, 19, 5)
|
||||
};
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
public static List<KeyMatch> QwertyLayout { get; set; }
|
||||
public static List<KeyMatch> QwertzLayout { get; set; }
|
||||
public static List<KeyMatch> AzertyLayout { get; set; }
|
||||
}
|
||||
}
|
||||
@ -1,392 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Artemis.DeviceProviders.Logitech.Utilities
|
||||
{
|
||||
public static class KeyMapG810
|
||||
{
|
||||
static KeyMapG810()
|
||||
{
|
||||
// There are several keyboard layouts
|
||||
|
||||
#region Qwerty
|
||||
|
||||
QwertyLayout = new List<KeyMatch>
|
||||
{
|
||||
// Row 1
|
||||
new KeyMatch(Keys.Escape, 0, 0),
|
||||
new KeyMatch(Keys.F1, 2, 0),
|
||||
new KeyMatch(Keys.F2, 3, 0),
|
||||
new KeyMatch(Keys.F3, 4, 0),
|
||||
new KeyMatch(Keys.F4, 5, 0),
|
||||
new KeyMatch(Keys.F5, 6, 0),
|
||||
new KeyMatch(Keys.F6, 7, 0),
|
||||
new KeyMatch(Keys.F7, 8, 0),
|
||||
new KeyMatch(Keys.F8, 9, 0),
|
||||
new KeyMatch(Keys.F9, 11, 0),
|
||||
new KeyMatch(Keys.F10, 12, 0),
|
||||
new KeyMatch(Keys.F11, 13, 0),
|
||||
new KeyMatch(Keys.F12, 14, 0),
|
||||
new KeyMatch(Keys.PrintScreen, 15, 0),
|
||||
new KeyMatch(Keys.Scroll, 16, 0),
|
||||
new KeyMatch(Keys.Pause, 17, 0),
|
||||
|
||||
// Row 2
|
||||
new KeyMatch(Keys.Oemtilde, 0, 1),
|
||||
new KeyMatch(Keys.D1, 1, 1),
|
||||
new KeyMatch(Keys.D2, 2, 1),
|
||||
new KeyMatch(Keys.D3, 3, 1),
|
||||
new KeyMatch(Keys.D4, 4, 1),
|
||||
new KeyMatch(Keys.D5, 5, 1),
|
||||
new KeyMatch(Keys.D6, 6, 1),
|
||||
new KeyMatch(Keys.D7, 7, 1),
|
||||
new KeyMatch(Keys.D8, 8, 1),
|
||||
new KeyMatch(Keys.D9, 9, 1),
|
||||
new KeyMatch(Keys.D0, 10, 1),
|
||||
new KeyMatch(Keys.OemMinus, 11, 1),
|
||||
new KeyMatch(Keys.Oemplus, 12, 1),
|
||||
new KeyMatch(Keys.Back, 13, 1),
|
||||
new KeyMatch(Keys.Insert, 14, 1),
|
||||
new KeyMatch(Keys.Home, 15, 1),
|
||||
new KeyMatch(Keys.PageUp, 16, 1),
|
||||
new KeyMatch(Keys.NumLock, 17, 1),
|
||||
new KeyMatch(Keys.Divide, 18, 1),
|
||||
new KeyMatch(Keys.Multiply, 19, 1),
|
||||
new KeyMatch(Keys.Subtract, 20, 1),
|
||||
|
||||
// Row 3
|
||||
new KeyMatch(Keys.Tab, 0, 2),
|
||||
new KeyMatch(Keys.Q, 1, 2),
|
||||
new KeyMatch(Keys.W, 2, 2),
|
||||
new KeyMatch(Keys.E, 3, 2),
|
||||
new KeyMatch(Keys.R, 5, 2),
|
||||
new KeyMatch(Keys.T, 6, 2),
|
||||
new KeyMatch(Keys.Y, 7, 2),
|
||||
new KeyMatch(Keys.U, 8, 2),
|
||||
new KeyMatch(Keys.I, 9, 2),
|
||||
new KeyMatch(Keys.O, 10, 2),
|
||||
new KeyMatch(Keys.P, 11, 2),
|
||||
new KeyMatch(Keys.OemOpenBrackets, 12, 2),
|
||||
new KeyMatch(Keys.Oem6, 13, 2),
|
||||
new KeyMatch(Keys.Delete, 14, 2),
|
||||
new KeyMatch(Keys.End, 15, 2),
|
||||
new KeyMatch(Keys.Next, 16, 2),
|
||||
new KeyMatch(Keys.NumPad7, 17, 2),
|
||||
new KeyMatch(Keys.NumPad8, 18, 2),
|
||||
new KeyMatch(Keys.NumPad9, 19, 2),
|
||||
new KeyMatch(Keys.Add, 20, 2),
|
||||
|
||||
// Row 4
|
||||
new KeyMatch(Keys.Capital, 0, 3),
|
||||
new KeyMatch(Keys.A, 1, 3),
|
||||
new KeyMatch(Keys.S, 3, 3),
|
||||
new KeyMatch(Keys.D, 4, 3),
|
||||
new KeyMatch(Keys.F, 5, 3),
|
||||
new KeyMatch(Keys.G, 6, 3),
|
||||
new KeyMatch(Keys.H, 7, 3),
|
||||
new KeyMatch(Keys.J, 8, 3),
|
||||
new KeyMatch(Keys.K, 9, 3),
|
||||
new KeyMatch(Keys.L, 10, 3),
|
||||
new KeyMatch(Keys.Oem1, 11, 3),
|
||||
new KeyMatch(Keys.Oem7, 12, 3),
|
||||
new KeyMatch(Keys.Oem5, 13, 3),
|
||||
new KeyMatch(Keys.Return, 14, 3),
|
||||
new KeyMatch(Keys.NumPad4, 17, 3),
|
||||
new KeyMatch(Keys.NumPad5, 18, 3),
|
||||
new KeyMatch(Keys.NumPad6, 19, 3),
|
||||
|
||||
// Row 5
|
||||
new KeyMatch(Keys.LShiftKey, 1, 4),
|
||||
new KeyMatch(Keys.OemBackslash, 2, 4),
|
||||
new KeyMatch(Keys.Z, 2, 4),
|
||||
new KeyMatch(Keys.X, 3, 4),
|
||||
new KeyMatch(Keys.C, 4, 4),
|
||||
new KeyMatch(Keys.V, 5, 4),
|
||||
new KeyMatch(Keys.B, 6, 4),
|
||||
new KeyMatch(Keys.N, 7, 4),
|
||||
new KeyMatch(Keys.M, 8, 4),
|
||||
new KeyMatch(Keys.Oemcomma, 9, 4),
|
||||
new KeyMatch(Keys.OemPeriod, 10, 4),
|
||||
new KeyMatch(Keys.OemQuestion, 11, 4),
|
||||
new KeyMatch(Keys.RShiftKey, 13, 4),
|
||||
new KeyMatch(Keys.Up, 15, 4),
|
||||
new KeyMatch(Keys.NumPad1, 17, 4),
|
||||
new KeyMatch(Keys.NumPad2, 18, 4),
|
||||
new KeyMatch(Keys.NumPad3, 19, 4),
|
||||
// Both returns return "Return" (Yes...)
|
||||
// new OrionKey(System.Windows.Forms.Keys.Return, 20, 4),
|
||||
|
||||
// Row 6
|
||||
new KeyMatch(Keys.LControlKey, 0, 5),
|
||||
new KeyMatch(Keys.LWin, 1, 5),
|
||||
new KeyMatch(Keys.LMenu, 3, 5),
|
||||
new KeyMatch(Keys.Space, 6, 5),
|
||||
new KeyMatch(Keys.RMenu, 11, 5),
|
||||
new KeyMatch(Keys.RWin, 12, 5),
|
||||
new KeyMatch(Keys.Apps, 13, 5),
|
||||
new KeyMatch(Keys.RControlKey, 14, 5),
|
||||
new KeyMatch(Keys.Left, 15, 5),
|
||||
new KeyMatch(Keys.Down, 16, 5),
|
||||
new KeyMatch(Keys.Right, 17, 5),
|
||||
new KeyMatch(Keys.NumPad0, 18, 5),
|
||||
new KeyMatch(Keys.Decimal, 19, 5)
|
||||
};
|
||||
|
||||
#endregion
|
||||
|
||||
#region Qwertz
|
||||
|
||||
QwertzLayout = new List<KeyMatch>
|
||||
{
|
||||
// Row 1
|
||||
new KeyMatch(Keys.Escape, 0, 0),
|
||||
new KeyMatch(Keys.F1, 2, 0),
|
||||
new KeyMatch(Keys.F2, 3, 0),
|
||||
new KeyMatch(Keys.F3, 4, 0),
|
||||
new KeyMatch(Keys.F4, 5, 0),
|
||||
new KeyMatch(Keys.F5, 6, 0),
|
||||
new KeyMatch(Keys.F6, 7, 0),
|
||||
new KeyMatch(Keys.F7, 8, 0),
|
||||
new KeyMatch(Keys.F8, 9, 0),
|
||||
new KeyMatch(Keys.F9, 11, 0),
|
||||
new KeyMatch(Keys.F10, 12, 0), // returns 'None'
|
||||
new KeyMatch(Keys.F11, 13, 0),
|
||||
new KeyMatch(Keys.F12, 14, 0),
|
||||
new KeyMatch(Keys.PrintScreen, 15, 0),
|
||||
new KeyMatch(Keys.Scroll, 16, 0),
|
||||
new KeyMatch(Keys.Pause, 17, 0),
|
||||
|
||||
// Row 2
|
||||
new KeyMatch(Keys.Oem5, 0, 1),
|
||||
new KeyMatch(Keys.D1, 1, 1),
|
||||
new KeyMatch(Keys.D2, 2, 1),
|
||||
new KeyMatch(Keys.D3, 3, 1),
|
||||
new KeyMatch(Keys.D4, 4, 1),
|
||||
new KeyMatch(Keys.D5, 5, 1),
|
||||
new KeyMatch(Keys.D6, 6, 1),
|
||||
new KeyMatch(Keys.D7, 7, 1),
|
||||
new KeyMatch(Keys.D8, 8, 1),
|
||||
new KeyMatch(Keys.D9, 9, 1),
|
||||
new KeyMatch(Keys.D0, 10, 1),
|
||||
new KeyMatch(Keys.OemOpenBrackets, 11, 1),
|
||||
new KeyMatch(Keys.Oem6, 12, 1),
|
||||
new KeyMatch(Keys.Back, 13, 1),
|
||||
new KeyMatch(Keys.Insert, 14, 1),
|
||||
new KeyMatch(Keys.Home, 15, 1),
|
||||
new KeyMatch(Keys.PageUp, 16, 1),
|
||||
new KeyMatch(Keys.NumLock, 17, 1),
|
||||
new KeyMatch(Keys.Divide, 18, 1),
|
||||
new KeyMatch(Keys.Multiply, 19, 1),
|
||||
new KeyMatch(Keys.Subtract, 20, 1),
|
||||
|
||||
// Row 3
|
||||
new KeyMatch(Keys.Tab, 0, 2),
|
||||
new KeyMatch(Keys.Q, 1, 2),
|
||||
new KeyMatch(Keys.W, 2, 2),
|
||||
new KeyMatch(Keys.E, 3, 2),
|
||||
new KeyMatch(Keys.R, 5, 2),
|
||||
new KeyMatch(Keys.T, 6, 2),
|
||||
new KeyMatch(Keys.Z, 7, 2),
|
||||
new KeyMatch(Keys.U, 8, 2),
|
||||
new KeyMatch(Keys.I, 9, 2),
|
||||
new KeyMatch(Keys.O, 10, 2),
|
||||
new KeyMatch(Keys.P, 11, 2),
|
||||
new KeyMatch(Keys.Oem1, 12, 2),
|
||||
new KeyMatch(Keys.Oemplus, 13, 2),
|
||||
new KeyMatch(Keys.Delete, 14, 2),
|
||||
new KeyMatch(Keys.End, 15, 2),
|
||||
new KeyMatch(Keys.Next, 16, 2),
|
||||
new KeyMatch(Keys.NumPad7, 17, 2),
|
||||
new KeyMatch(Keys.NumPad8, 18, 2),
|
||||
new KeyMatch(Keys.NumPad9, 19, 2),
|
||||
new KeyMatch(Keys.Add, 20, 2),
|
||||
|
||||
// Row 4
|
||||
new KeyMatch(Keys.Capital, 0, 3),
|
||||
new KeyMatch(Keys.A, 1, 3),
|
||||
new KeyMatch(Keys.S, 3, 3),
|
||||
new KeyMatch(Keys.D, 4, 3),
|
||||
new KeyMatch(Keys.F, 5, 3),
|
||||
new KeyMatch(Keys.G, 6, 3),
|
||||
new KeyMatch(Keys.H, 7, 3),
|
||||
new KeyMatch(Keys.J, 8, 3),
|
||||
new KeyMatch(Keys.K, 9, 3),
|
||||
new KeyMatch(Keys.L, 10, 3),
|
||||
new KeyMatch(Keys.Oemtilde, 11, 3),
|
||||
new KeyMatch(Keys.Oem7, 12, 3),
|
||||
new KeyMatch(Keys.OemQuestion, 13, 3),
|
||||
new KeyMatch(Keys.Return, 14, 3),
|
||||
new KeyMatch(Keys.NumPad4, 17, 3),
|
||||
new KeyMatch(Keys.NumPad5, 18, 3),
|
||||
new KeyMatch(Keys.NumPad6, 19, 3),
|
||||
|
||||
// Row 5
|
||||
new KeyMatch(Keys.LShiftKey, 1, 4),
|
||||
new KeyMatch(Keys.OemBackslash, 2, 4),
|
||||
new KeyMatch(Keys.Y, 2, 4),
|
||||
new KeyMatch(Keys.X, 3, 4),
|
||||
new KeyMatch(Keys.C, 4, 4),
|
||||
new KeyMatch(Keys.V, 5, 4),
|
||||
new KeyMatch(Keys.B, 6, 4),
|
||||
new KeyMatch(Keys.N, 7, 4),
|
||||
new KeyMatch(Keys.M, 8, 4),
|
||||
new KeyMatch(Keys.Oemcomma, 9, 4),
|
||||
new KeyMatch(Keys.OemPeriod, 10, 4),
|
||||
new KeyMatch(Keys.OemMinus, 11, 4),
|
||||
new KeyMatch(Keys.RShiftKey, 13, 4),
|
||||
new KeyMatch(Keys.Up, 15, 4),
|
||||
new KeyMatch(Keys.NumPad1, 17, 4),
|
||||
new KeyMatch(Keys.NumPad2, 18, 4),
|
||||
new KeyMatch(Keys.NumPad3, 19, 4),
|
||||
// Both returns return "Return" (Yes...)
|
||||
// new OrionKey(System.Windows.Forms.Keys.Return, 20, 4),
|
||||
|
||||
// Row 6
|
||||
new KeyMatch(Keys.LControlKey, 0, 5),
|
||||
new KeyMatch(Keys.LWin, 1, 5),
|
||||
new KeyMatch(Keys.Menu, 3, 5), // returns 'None'
|
||||
new KeyMatch(Keys.Space, 6, 5),
|
||||
new KeyMatch(Keys.RMenu, 11, 5),
|
||||
new KeyMatch(Keys.RWin, 12, 5),
|
||||
new KeyMatch(Keys.Apps, 13, 5),
|
||||
new KeyMatch(Keys.RControlKey, 14, 5),
|
||||
new KeyMatch(Keys.Left, 15, 5),
|
||||
new KeyMatch(Keys.Down, 16, 5),
|
||||
new KeyMatch(Keys.Right, 17, 5),
|
||||
new KeyMatch(Keys.NumPad0, 18, 5),
|
||||
new KeyMatch(Keys.Decimal, 19, 5)
|
||||
};
|
||||
|
||||
#endregion
|
||||
|
||||
#region Azerty
|
||||
|
||||
AzertyLayout = new List<KeyMatch>
|
||||
{
|
||||
// Row 1
|
||||
new KeyMatch(Keys.Escape, 0, 0),
|
||||
new KeyMatch(Keys.F1, 2, 0),
|
||||
new KeyMatch(Keys.F2, 3, 0),
|
||||
new KeyMatch(Keys.F3, 4, 0),
|
||||
new KeyMatch(Keys.F4, 5, 0),
|
||||
new KeyMatch(Keys.F5, 6, 0),
|
||||
new KeyMatch(Keys.F6, 7, 0),
|
||||
new KeyMatch(Keys.F7, 8, 0),
|
||||
new KeyMatch(Keys.F8, 9, 0),
|
||||
new KeyMatch(Keys.F9, 11, 0),
|
||||
new KeyMatch(Keys.F10, 12, 0),
|
||||
new KeyMatch(Keys.F11, 13, 0),
|
||||
new KeyMatch(Keys.F12, 14, 0),
|
||||
new KeyMatch(Keys.PrintScreen, 15, 0),
|
||||
new KeyMatch(Keys.Scroll, 16, 0),
|
||||
new KeyMatch(Keys.Pause, 17, 0),
|
||||
|
||||
// Row 2
|
||||
new KeyMatch(Keys.Oemtilde, 0, 1),
|
||||
new KeyMatch(Keys.D1, 1, 1),
|
||||
new KeyMatch(Keys.D2, 2, 1),
|
||||
new KeyMatch(Keys.D3, 3, 1),
|
||||
new KeyMatch(Keys.D4, 4, 1),
|
||||
new KeyMatch(Keys.D5, 5, 1),
|
||||
new KeyMatch(Keys.D6, 6, 1),
|
||||
new KeyMatch(Keys.D7, 7, 1),
|
||||
new KeyMatch(Keys.D8, 8, 1),
|
||||
new KeyMatch(Keys.D9, 9, 1),
|
||||
new KeyMatch(Keys.D0, 10, 1),
|
||||
new KeyMatch(Keys.OemMinus, 11, 1),
|
||||
new KeyMatch(Keys.Oemplus, 12, 1),
|
||||
new KeyMatch(Keys.Back, 13, 1),
|
||||
new KeyMatch(Keys.Insert, 14, 1),
|
||||
new KeyMatch(Keys.Home, 15, 1),
|
||||
new KeyMatch(Keys.PageUp, 16, 1),
|
||||
new KeyMatch(Keys.NumLock, 17, 1),
|
||||
new KeyMatch(Keys.Divide, 18, 1),
|
||||
new KeyMatch(Keys.Multiply, 19, 1),
|
||||
new KeyMatch(Keys.Subtract, 20, 1),
|
||||
|
||||
// Row 3
|
||||
new KeyMatch(Keys.Tab, 0, 2),
|
||||
new KeyMatch(Keys.A, 1, 2),
|
||||
new KeyMatch(Keys.Z, 2, 2),
|
||||
new KeyMatch(Keys.E, 3, 2),
|
||||
new KeyMatch(Keys.R, 5, 2),
|
||||
new KeyMatch(Keys.T, 6, 2),
|
||||
new KeyMatch(Keys.Y, 7, 2),
|
||||
new KeyMatch(Keys.U, 8, 2),
|
||||
new KeyMatch(Keys.I, 9, 2),
|
||||
new KeyMatch(Keys.O, 10, 2),
|
||||
new KeyMatch(Keys.P, 11, 2),
|
||||
new KeyMatch(Keys.OemQuotes, 12, 2),
|
||||
new KeyMatch(Keys.Oem6, 13, 2),
|
||||
new KeyMatch(Keys.Delete, 14, 2),
|
||||
new KeyMatch(Keys.End, 15, 2),
|
||||
new KeyMatch(Keys.Next, 16, 2),
|
||||
new KeyMatch(Keys.NumPad7, 17, 2),
|
||||
new KeyMatch(Keys.NumPad8, 18, 2),
|
||||
new KeyMatch(Keys.NumPad9, 19, 2),
|
||||
new KeyMatch(Keys.Add, 20, 2),
|
||||
|
||||
// Row 4
|
||||
new KeyMatch(Keys.Capital, 0, 3),
|
||||
new KeyMatch(Keys.Q, 1, 3),
|
||||
new KeyMatch(Keys.S, 3, 3),
|
||||
new KeyMatch(Keys.D, 4, 3),
|
||||
new KeyMatch(Keys.F, 5, 3),
|
||||
new KeyMatch(Keys.G, 6, 3),
|
||||
new KeyMatch(Keys.H, 7, 3),
|
||||
new KeyMatch(Keys.J, 8, 3),
|
||||
new KeyMatch(Keys.K, 9, 3),
|
||||
new KeyMatch(Keys.L, 10, 3),
|
||||
new KeyMatch(Keys.M, 11, 3),
|
||||
new KeyMatch(Keys.Oem7, 12, 3),
|
||||
new KeyMatch(Keys.Oem5, 13, 3),
|
||||
new KeyMatch(Keys.Return, 14, 3),
|
||||
new KeyMatch(Keys.NumPad4, 17, 3),
|
||||
new KeyMatch(Keys.NumPad5, 18, 3),
|
||||
new KeyMatch(Keys.NumPad6, 19, 3),
|
||||
|
||||
// Row 5
|
||||
new KeyMatch(Keys.LShiftKey, 1, 4),
|
||||
new KeyMatch(Keys.OemBackslash, 2, 4),
|
||||
new KeyMatch(Keys.W, 2, 4),
|
||||
new KeyMatch(Keys.X, 3, 4),
|
||||
new KeyMatch(Keys.C, 4, 4),
|
||||
new KeyMatch(Keys.V, 5, 4),
|
||||
new KeyMatch(Keys.B, 6, 4),
|
||||
new KeyMatch(Keys.N, 7, 4),
|
||||
new KeyMatch(Keys.OemQuestion, 8, 4),
|
||||
new KeyMatch(Keys.Oemcomma, 9, 4),
|
||||
new KeyMatch(Keys.OemPeriod, 10, 4),
|
||||
new KeyMatch(Keys.OemQuestion, 11, 4),
|
||||
new KeyMatch(Keys.RShiftKey, 13, 4),
|
||||
new KeyMatch(Keys.Up, 15, 4),
|
||||
new KeyMatch(Keys.NumPad1, 17, 4),
|
||||
new KeyMatch(Keys.NumPad2, 18, 4),
|
||||
new KeyMatch(Keys.NumPad3, 19, 4),
|
||||
// Both returns return "Return" (Yes...)
|
||||
// new OrionKey(System.Windows.Forms.Keys.Return, 20, 4),
|
||||
|
||||
// Row 6
|
||||
new KeyMatch(Keys.LControlKey, 0, 5),
|
||||
new KeyMatch(Keys.LWin, 1, 5),
|
||||
new KeyMatch(Keys.LMenu, 3, 5),
|
||||
new KeyMatch(Keys.Space, 6, 5),
|
||||
new KeyMatch(Keys.RMenu, 11, 5),
|
||||
new KeyMatch(Keys.RWin, 12, 5),
|
||||
new KeyMatch(Keys.Apps, 13, 5),
|
||||
new KeyMatch(Keys.RControlKey, 14, 5),
|
||||
new KeyMatch(Keys.Left, 15, 5),
|
||||
new KeyMatch(Keys.Down, 16, 5),
|
||||
new KeyMatch(Keys.Right, 17, 5),
|
||||
new KeyMatch(Keys.NumPad0, 18, 5),
|
||||
new KeyMatch(Keys.Decimal, 19, 5)
|
||||
};
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
public static List<KeyMatch> QwertyLayout { get; set; }
|
||||
public static List<KeyMatch> QwertzLayout { get; set; }
|
||||
public static List<KeyMatch> AzertyLayout { get; set; }
|
||||
}
|
||||
}
|
||||
@ -1,121 +0,0 @@
|
||||
namespace Artemis.DeviceProviders.Logitech.Utilities
|
||||
{
|
||||
public enum KeyboardNames
|
||||
{
|
||||
ESC = 0x01,
|
||||
F1 = 0x3b,
|
||||
F2 = 0x3c,
|
||||
F3 = 0x3d,
|
||||
F4 = 0x3e,
|
||||
F5 = 0x3f,
|
||||
F6 = 0x40,
|
||||
F7 = 0x41,
|
||||
F8 = 0x42,
|
||||
F9 = 0x43,
|
||||
F10 = 0x44,
|
||||
F11 = 0x57,
|
||||
F12 = 0x58,
|
||||
PRINT_SCREEN = 0x137,
|
||||
SCROLL_LOCK = 0x46,
|
||||
PAUSE_BREAK = 0x45,
|
||||
TILDE = 0x29,
|
||||
ONE = 0x02,
|
||||
TWO = 0x03,
|
||||
THREE = 0x04,
|
||||
FOUR = 0x05,
|
||||
FIVE = 0x06,
|
||||
SIX = 0x07,
|
||||
SEVEN = 0x08,
|
||||
EIGHT = 0x09,
|
||||
NINE = 0x0A,
|
||||
ZERO = 0x0B,
|
||||
MINUS = 0x0C,
|
||||
EQUALS = 0x0D,
|
||||
BACKSPACE = 0x0E,
|
||||
INSERT = 0x152,
|
||||
HOME = 0x147,
|
||||
PAGE_UP = 0x149,
|
||||
NUM_LOCK = 0x145,
|
||||
NUM_SLASH = 0x135,
|
||||
NUM_ASTERISK = 0x37,
|
||||
NUM_MINUS = 0x4A,
|
||||
TAB = 0x0F,
|
||||
Q = 0x10,
|
||||
W = 0x11,
|
||||
E = 0x12,
|
||||
R = 0x13,
|
||||
T = 0x14,
|
||||
Y = 0x15,
|
||||
U = 0x16,
|
||||
I = 0x17,
|
||||
O = 0x18,
|
||||
P = 0x19,
|
||||
OPEN_BRACKET = 0x1A,
|
||||
CLOSE_BRACKET = 0x1B,
|
||||
BACKSLASH = 0x2B,
|
||||
KEYBOARD_DELETE = 0x153,
|
||||
END = 0x14F,
|
||||
PAGE_DOWN = 0x151,
|
||||
NUM_SEVEN = 0x47,
|
||||
NUM_EIGHT = 0x48,
|
||||
NUM_NINE = 0x49,
|
||||
NUM_PLUS = 0x4E,
|
||||
CAPS_LOCK = 0x3A,
|
||||
A = 0x1E,
|
||||
S = 0x1F,
|
||||
D = 0x20,
|
||||
F = 0x21,
|
||||
G = 0x22,
|
||||
H = 0x23,
|
||||
J = 0x24,
|
||||
K = 0x25,
|
||||
L = 0x26,
|
||||
SEMICOLON = 0x27,
|
||||
APOSTROPHE = 0x28,
|
||||
ENTER = 0x1C,
|
||||
NUM_FOUR = 0x4B,
|
||||
NUM_FIVE = 0x4C,
|
||||
NUM_SIX = 0x4D,
|
||||
LEFT_SHIFT = 0x2A,
|
||||
Z = 0x2C,
|
||||
X = 0x2D,
|
||||
C = 0x2E,
|
||||
V = 0x2F,
|
||||
B = 0x30,
|
||||
N = 0x31,
|
||||
M = 0x32,
|
||||
COMMA = 0x33,
|
||||
PERIOD = 0x34,
|
||||
FORWARD_SLASH = 0x35,
|
||||
RIGHT_SHIFT = 0x36,
|
||||
ARROW_UP = 0x148,
|
||||
NUM_ONE = 0x4F,
|
||||
NUM_TWO = 0x50,
|
||||
NUM_THREE = 0x51,
|
||||
NUM_ENTER = 0x11C,
|
||||
LEFT_CONTROL = 0x1D,
|
||||
LEFT_WINDOWS = 0x15B,
|
||||
LEFT_ALT = 0x38,
|
||||
SPACE = 0x39,
|
||||
RIGHT_ALT = 0x138,
|
||||
RIGHT_WINDOWS = 0x15C,
|
||||
APPLICATION_SELECT = 0x15D,
|
||||
RIGHT_CONTROL = 0x11D,
|
||||
ARROW_LEFT = 0x14B,
|
||||
ARROW_DOWN = 0x150,
|
||||
ARROW_RIGHT = 0x14D,
|
||||
NUM_ZERO = 0x52,
|
||||
NUM_PERIOD = 0x53,
|
||||
G_1 = 0xFFF1,
|
||||
G_2 = 0xFFF2,
|
||||
G_3 = 0xFFF3,
|
||||
G_4 = 0xFFF4,
|
||||
G_5 = 0xFFF5,
|
||||
G_6 = 0xFFF6,
|
||||
G_7 = 0xFFF7,
|
||||
G_8 = 0xFFF8,
|
||||
G_9 = 0xFFF9,
|
||||
G_LOGO = 0xFFFF1,
|
||||
G_BADGE = 0xFFFF2
|
||||
}
|
||||
}
|
||||
@ -1,116 +0,0 @@
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
|
||||
namespace Artemis.DeviceProviders.Logitech.Utilities
|
||||
{
|
||||
public class LogitechGSDK
|
||||
{
|
||||
//LED SDK
|
||||
private const int LOGI_DEVICETYPE_MONOCHROME_ORD = 0;
|
||||
private const int LOGI_DEVICETYPE_RGB_ORD = 1;
|
||||
private const int LOGI_DEVICETYPE_PERKEY_RGB_ORD = 2;
|
||||
|
||||
public const int LOGI_DEVICETYPE_MONOCHROME = 1 << LOGI_DEVICETYPE_MONOCHROME_ORD;
|
||||
public const int LOGI_DEVICETYPE_RGB = 1 << LOGI_DEVICETYPE_RGB_ORD;
|
||||
public const int LOGI_DEVICETYPE_PERKEY_RGB = 1 << LOGI_DEVICETYPE_PERKEY_RGB_ORD;
|
||||
public const int LOGI_LED_BITMAP_WIDTH = 21;
|
||||
public const int LOGI_LED_BITMAP_HEIGHT = 6;
|
||||
public const int LOGI_LED_BITMAP_BYTES_PER_KEY = 4;
|
||||
|
||||
public const int LOGI_LED_BITMAP_SIZE =
|
||||
LOGI_LED_BITMAP_WIDTH*LOGI_LED_BITMAP_HEIGHT*LOGI_LED_BITMAP_BYTES_PER_KEY;
|
||||
|
||||
public const int LOGI_LED_DURATION_INFINITE = 0;
|
||||
|
||||
[DllImport("LogitechLedEnginesWrapper ", CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern bool LogiLedInit();
|
||||
|
||||
//Config option functions
|
||||
[DllImport("LogitechLedEnginesWrapper ", CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern bool LogiLedGetConfigOptionNumber([MarshalAs(UnmanagedType.LPWStr)] string configPath,
|
||||
ref double defaultNumber);
|
||||
|
||||
[DllImport("LogitechLedEnginesWrapper ", CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern bool LogiLedGetConfigOptionBool([MarshalAs(UnmanagedType.LPWStr)] string configPath,
|
||||
ref bool defaultRed);
|
||||
|
||||
[DllImport("LogitechLedEnginesWrapper ", CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern bool LogiLedGetConfigOptionColor([MarshalAs(UnmanagedType.LPWStr)] string configPath,
|
||||
ref int defaultRed, ref int defaultGreen, ref int defaultBlue);
|
||||
|
||||
[DllImport("LogitechLedEnginesWrapper ", CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern bool LogiLedGetConfigOptionKeyInput([MarshalAs(UnmanagedType.LPWStr)] string configPath,
|
||||
StringBuilder buffer, int bufsize);
|
||||
|
||||
/////////////////////
|
||||
|
||||
[DllImport("LogitechLedEnginesWrapper ", CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern bool LogiLedSetTargetDevice(int targetDevice);
|
||||
|
||||
[DllImport("LogitechLedEnginesWrapper ", CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern bool LogiLedGetSdkVersion(ref int majorNum, ref int minorNum, ref int buildNum);
|
||||
|
||||
[DllImport("LogitechLedEnginesWrapper ", CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern bool LogiLedSaveCurrentLighting();
|
||||
|
||||
[DllImport("LogitechLedEnginesWrapper ", CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern bool LogiLedSetLighting(int redPercentage, int greenPercentage, int bluePercentage);
|
||||
|
||||
[DllImport("LogitechLedEnginesWrapper ", CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern bool LogiLedRestoreLighting();
|
||||
|
||||
[DllImport("LogitechLedEnginesWrapper ", CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern bool LogiLedFlashLighting(int redPercentage, int greenPercentage, int bluePercentage,
|
||||
int milliSecondsDuration, int milliSecondsInterval);
|
||||
|
||||
[DllImport("LogitechLedEnginesWrapper ", CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern bool LogiLedPulseLighting(int redPercentage, int greenPercentage, int bluePercentage,
|
||||
int milliSecondsDuration, int milliSecondsInterval);
|
||||
|
||||
[DllImport("LogitechLedEnginesWrapper ", CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern bool LogiLedStopEffects();
|
||||
|
||||
[DllImport("LogitechLedEnginesWrapper ", CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern bool LogiLedExcludeKeysFromBitmap(KeyboardNames[] keyList, int listCount);
|
||||
|
||||
[DllImport("LogitechLedEnginesWrapper ", CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern bool LogiLedSetLightingFromBitmap(byte[] bitmap);
|
||||
|
||||
[DllImport("LogitechLedEnginesWrapper ", CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern bool LogiLedSetLightingForKeyWithScanCode(int keyCode, int redPercentage,
|
||||
int greenPercentage, int bluePercentage);
|
||||
|
||||
[DllImport("LogitechLedEnginesWrapper ", CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern bool LogiLedSetLightingForKeyWithHidCode(int keyCode, int redPercentage,
|
||||
int greenPercentage, int bluePercentage);
|
||||
|
||||
[DllImport("LogitechLedEnginesWrapper ", CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern bool LogiLedSetLightingForKeyWithQuartzCode(int keyCode, int redPercentage,
|
||||
int greenPercentage, int bluePercentage);
|
||||
|
||||
[DllImport("LogitechLedEnginesWrapper ", CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern bool LogiLedSetLightingForKeyWithKeyName(KeyboardNames keyCode, int redPercentage,
|
||||
int greenPercentage, int bluePercentage);
|
||||
|
||||
[DllImport("LogitechLedEnginesWrapper ", CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern bool LogiLedSaveLightingForKey(KeyboardNames keyName);
|
||||
|
||||
[DllImport("LogitechLedEnginesWrapper ", CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern bool LogiLedRestoreLightingForKey(KeyboardNames keyName);
|
||||
|
||||
[DllImport("LogitechLedEnginesWrapper ", CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern bool LogiLedFlashSingleKey(KeyboardNames keyName, int redPercentage, int greenPercentage,
|
||||
int bluePercentage, int msDuration, int msInterval);
|
||||
|
||||
[DllImport("LogitechLedEnginesWrapper ", CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern bool LogiLedPulseSingleKey(KeyboardNames keyName, int startRedPercentage,
|
||||
int startGreenPercentage, int startBluePercentage, int finishRedPercentage, int finishGreenPercentage,
|
||||
int finishBluePercentage, int msDuration, bool isInfinite);
|
||||
|
||||
[DllImport("LogitechLedEnginesWrapper ", CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern bool LogiLedStopEffectsOnKey(KeyboardNames keyName);
|
||||
|
||||
[DllImport("LogitechLedEnginesWrapper ", CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void LogiLedShutdown();
|
||||
}
|
||||
}
|
||||
@ -1,95 +0,0 @@
|
||||
using System.Drawing;
|
||||
using System.Drawing.Drawing2D;
|
||||
using System.Drawing.Imaging;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Artemis.DeviceProviders.Logitech.Utilities
|
||||
{
|
||||
public static class OrionUtilities
|
||||
{
|
||||
public static byte[] BitmapToByteArray(Bitmap b, KeyMapping[] keymappings = null)
|
||||
{
|
||||
if (b.Width > 21 || b.Height > 6)
|
||||
b = ResizeImage(b, 21, 6);
|
||||
|
||||
var rect = new Rectangle(0, 0, b.Width, b.Height);
|
||||
var bitmapData = b.LockBits(rect, ImageLockMode.ReadWrite, b.PixelFormat);
|
||||
|
||||
var depth = Image.GetPixelFormatSize(b.PixelFormat);
|
||||
var step = depth / 8;
|
||||
var pixels = new byte[21 * 6 * step];
|
||||
var iptr = bitmapData.Scan0;
|
||||
|
||||
// Copy data from pointer to array
|
||||
Marshal.Copy(iptr, pixels, 0, pixels.Length);
|
||||
|
||||
if (keymappings == null)
|
||||
return pixels;
|
||||
|
||||
var remapped = new byte[pixels.Length];
|
||||
|
||||
// Every key is 4 bytes
|
||||
for (var i = 0; i <= pixels.Length / 4; i++)
|
||||
{
|
||||
var firstSByte = keymappings[i].Source * 4;
|
||||
var firstTByte = keymappings[i].Target * 4;
|
||||
|
||||
for (var j = 0; j < 4; j++)
|
||||
remapped[firstTByte + j] = pixels[firstSByte + j];
|
||||
}
|
||||
|
||||
b.Dispose();
|
||||
return remapped;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Resize the image to the specified width and height.
|
||||
/// </summary>
|
||||
/// <param name="image">The image to resize.</param>
|
||||
/// <param name="width">The width to resize to.</param>
|
||||
/// <param name="height">The height to resize to.</param>
|
||||
/// <returns>The resized image.</returns>
|
||||
public static Bitmap ResizeImage(Image image, int width, int height)
|
||||
{
|
||||
var destRect = new Rectangle(0, 0, width, height);
|
||||
var destImage = new Bitmap(width, height);
|
||||
|
||||
destImage.SetResolution(image.HorizontalResolution, image.VerticalResolution);
|
||||
|
||||
using (var graphics = Graphics.FromImage(destImage))
|
||||
{
|
||||
graphics.CompositingMode = CompositingMode.SourceCopy;
|
||||
graphics.CompositingQuality = CompositingQuality.HighQuality;
|
||||
|
||||
graphics.SmoothingMode = SmoothingMode.AntiAlias;
|
||||
graphics.PixelOffsetMode = PixelOffsetMode.HighQuality;
|
||||
|
||||
// TODO: Make configurable
|
||||
// Prevents light bleed
|
||||
graphics.InterpolationMode = InterpolationMode.NearestNeighbor;
|
||||
// Soft/semi-transparent keys
|
||||
//graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
|
||||
|
||||
using (var wrapMode = new ImageAttributes())
|
||||
{
|
||||
wrapMode.SetWrapMode(WrapMode.TileFlipXY);
|
||||
graphics.DrawImage(image, destRect, 0, 0, image.Width, image.Height, GraphicsUnit.Pixel, wrapMode);
|
||||
}
|
||||
}
|
||||
|
||||
return destImage;
|
||||
}
|
||||
|
||||
public struct KeyMapping
|
||||
{
|
||||
public KeyMapping(int source, int target)
|
||||
{
|
||||
Source = source;
|
||||
Target = target;
|
||||
}
|
||||
|
||||
public int Source { get; set; }
|
||||
public int Target { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,78 +0,0 @@
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Windows;
|
||||
using System.Windows.Forms;
|
||||
using Artemis.DAL;
|
||||
using Artemis.DeviceProviders.Logitech.Utilities;
|
||||
using Artemis.DeviceProviders.Razer.Utilities;
|
||||
using Artemis.Properties;
|
||||
using Artemis.Settings;
|
||||
using Corale.Colore.Core;
|
||||
using Corale.Colore.Razer;
|
||||
using Constants = Corale.Colore.Razer.Keyboard.Constants;
|
||||
|
||||
namespace Artemis.DeviceProviders.Razer
|
||||
{
|
||||
public class BlackWidow : KeyboardProvider
|
||||
{
|
||||
private GeneralSettings _generalSettings;
|
||||
|
||||
public BlackWidow()
|
||||
{
|
||||
Name = "Razer BlackWidow Chroma";
|
||||
Slug = "razer-blackwidow-chroma";
|
||||
CantEnableText = "Couldn't connect to your Razer BlackWidow Chroma.\n" +
|
||||
"Please check your cables and try updating Razer Synapse.\n\n" +
|
||||
"If needed, you can select a different keyboard in Artemis under settings.";
|
||||
|
||||
Height = Constants.MaxRows;
|
||||
Width = Constants.MaxColumns;
|
||||
PreviewSettings = new PreviewSettings(new Rect(26, 56, 906, 234), Resources.blackwidow);
|
||||
_generalSettings = SettingsProvider.Load<GeneralSettings>();
|
||||
}
|
||||
|
||||
public override bool CanEnable()
|
||||
{
|
||||
if (!Chroma.SdkAvailable)
|
||||
return false;
|
||||
|
||||
// Some people have Synapse installed, but not a Chroma keyboard, deal with this
|
||||
Chroma.Instance.Initialize();
|
||||
var blackWidowFound = Chroma.Instance.Query(Devices.Blackwidow).Connected;
|
||||
var blackWidowTeFound = Chroma.Instance.Query(Devices.BlackwidowTe).Connected;
|
||||
Chroma.Instance.Uninitialize();
|
||||
|
||||
return blackWidowFound || blackWidowTeFound;
|
||||
}
|
||||
|
||||
public override void Enable()
|
||||
{
|
||||
Chroma.Instance.Initialize();
|
||||
}
|
||||
|
||||
public override void Disable()
|
||||
{
|
||||
Chroma.Instance.Uninitialize();
|
||||
}
|
||||
|
||||
public override void DrawBitmap(Bitmap bitmap)
|
||||
{
|
||||
var razerArray = RazerUtilities.BitmaptoKeyboardEffect(bitmap, Height, Width);
|
||||
Chroma.Instance.Keyboard.SetCustom(razerArray);
|
||||
}
|
||||
|
||||
public override KeyMatch? GetKeyPosition(Keys keyCode)
|
||||
{
|
||||
// TODO: Needs it's own keymap or a way to get it from the Chroma SDK
|
||||
switch (_generalSettings.Layout)
|
||||
{
|
||||
case "Qwerty":
|
||||
return KeyMap.QwertyLayout.FirstOrDefault(k => k.KeyCode == keyCode);
|
||||
case "Qwertz":
|
||||
return KeyMap.QwertzLayout.FirstOrDefault(k => k.KeyCode == keyCode);
|
||||
default:
|
||||
return KeyMap.AzertyLayout.FirstOrDefault(k => k.KeyCode == keyCode);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,50 +0,0 @@
|
||||
using Artemis.Settings;
|
||||
using Artemis.DAL;
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using Corale.Colore.Core;
|
||||
using Corale.Colore.Razer;
|
||||
using Ninject.Extensions.Logging;
|
||||
using Artemis.DeviceProviders.Razer.Utilities;
|
||||
|
||||
namespace Artemis.DeviceProviders.Razer
|
||||
{
|
||||
public class Firefly : DeviceProvider
|
||||
{
|
||||
private GeneralSettings _generalSettings;
|
||||
public ILogger Logger { get; set; }
|
||||
public Firefly(ILogger logger)
|
||||
{
|
||||
Logger = logger;
|
||||
Type = DeviceType.Mousemat;
|
||||
_generalSettings = SettingsProvider.Load<GeneralSettings>();
|
||||
}
|
||||
|
||||
public override void Disable()
|
||||
{
|
||||
throw new NotSupportedException("Can only disable a keyboard");
|
||||
}
|
||||
|
||||
public override bool TryEnable()
|
||||
{
|
||||
if (!Chroma.SdkAvailable)
|
||||
return false;
|
||||
|
||||
|
||||
// Some people have Synapse installed, but not a Chroma keyboard, deal with this
|
||||
Chroma.Instance.Initialize();
|
||||
CanUse = Chroma.Instance.Query(Devices.Firefly).Connected;
|
||||
return CanUse;
|
||||
}
|
||||
|
||||
public override void UpdateDevice(Bitmap bitmap)
|
||||
{
|
||||
if (Chroma.SdkAvailable && Chroma.Instance.Initialized)
|
||||
{
|
||||
var razerArray = RazerUtilities.BitmaptoMousePadEffect(bitmap);
|
||||
Chroma.Instance.Mousepad.SetCustom(razerArray);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,50 +0,0 @@
|
||||
using Artemis.Settings;
|
||||
using Artemis.DAL;
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using Corale.Colore.Core;
|
||||
using Corale.Colore.Razer;
|
||||
using Ninject.Extensions.Logging;
|
||||
using Artemis.DeviceProviders.Razer.Utilities;
|
||||
|
||||
namespace Artemis.DeviceProviders.Razer
|
||||
{
|
||||
public class Mamba : DeviceProvider
|
||||
{
|
||||
private GeneralSettings _generalSettings;
|
||||
public ILogger Logger { get; set; }
|
||||
public Mamba(ILogger logger)
|
||||
{
|
||||
Logger = logger;
|
||||
Type = DeviceType.Mouse;
|
||||
_generalSettings = SettingsProvider.Load<GeneralSettings>();
|
||||
}
|
||||
|
||||
public override void Disable()
|
||||
{
|
||||
throw new NotSupportedException("Can only disable a keyboard");
|
||||
}
|
||||
|
||||
public override bool TryEnable()
|
||||
{
|
||||
if (!Chroma.SdkAvailable)
|
||||
return false;
|
||||
|
||||
|
||||
// Some people have Synapse installed, but not a Chroma keyboard, deal with this
|
||||
Chroma.Instance.Initialize();
|
||||
CanUse = Chroma.Instance.Query(Devices.Mamba).Connected || Chroma.Instance.Query(Devices.MambaTe).Connected;
|
||||
return CanUse;
|
||||
}
|
||||
|
||||
public override void UpdateDevice(Bitmap bitmap)
|
||||
{
|
||||
if (Chroma.SdkAvailable && Chroma.Instance.Initialized)
|
||||
{
|
||||
var razerArray = RazerUtilities.BitmaptoMouseEffect(bitmap);
|
||||
Chroma.Instance.Mouse.SetCustom(razerArray);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,86 +0,0 @@
|
||||
using System.Drawing;
|
||||
using Artemis.Utilities;
|
||||
using Color = Corale.Colore.Core.Color;
|
||||
using Corale.Colore;
|
||||
|
||||
namespace Artemis.DeviceProviders.Razer.Utilities
|
||||
{
|
||||
public static class RazerUtilities
|
||||
{
|
||||
public static Corale.Colore.Razer.Keyboard.Effects.Custom BitmaptoKeyboardEffect(Bitmap b, int height, int width)
|
||||
{
|
||||
|
||||
var keyboardGrid = Corale.Colore.Razer.Keyboard.Effects.Custom.Create();
|
||||
// Resize the bitmap
|
||||
using (b = ImageUtilities.ResizeImage(b, width, height))
|
||||
{
|
||||
// Map the bytes to the grid
|
||||
for (var x = 0; x < b.Width; x++)
|
||||
{
|
||||
for (var y = 0; y < b.Height; y++)
|
||||
{
|
||||
var c = b.GetPixel(x, y);
|
||||
keyboardGrid[y, x] = new Color(c.R, c.G, c.B);
|
||||
}
|
||||
}
|
||||
|
||||
return keyboardGrid;
|
||||
}
|
||||
}
|
||||
|
||||
public static Corale.Colore.Razer.Mousepad.Effects.Custom BitmaptoMousePadEffect(Bitmap b)
|
||||
{
|
||||
var mousePadGrid = Corale.Colore.Razer.Mousepad.Effects.Custom.Create();
|
||||
int pos = 0;
|
||||
using (b = ImageUtilities.ResizeImage(b, 5, 5))
|
||||
{
|
||||
b.RotateFlip(RotateFlipType.RotateNoneFlipX);
|
||||
for (var x = 0; x < 5; x++)
|
||||
{
|
||||
var c = b.GetPixel(4, x);
|
||||
mousePadGrid[pos++] = new Color(c.R, c.G, c.B);
|
||||
}
|
||||
for (var x = 0; x < 5; x++)
|
||||
{
|
||||
var c = b.GetPixel(x , 4);
|
||||
mousePadGrid[pos++] = new Color(c.R, c.G, c.B);
|
||||
}
|
||||
for (var x = 0; x < 5; x++)
|
||||
{
|
||||
var c = b.GetPixel(0, x);
|
||||
mousePadGrid[pos++] = new Color(c.R, c.G, c.B);
|
||||
}
|
||||
}
|
||||
|
||||
return mousePadGrid;
|
||||
}
|
||||
|
||||
public static Corale.Colore.Razer.Mouse.Effects.Custom BitmaptoMouseEffect(Bitmap b)
|
||||
{
|
||||
var mouseGrid = Corale.Colore.Razer.Mouse.Effects.Custom.Create();
|
||||
using (b = ImageUtilities.ResizeImage(b, 3, 7))
|
||||
{
|
||||
var c = b.GetPixel(1, 0);
|
||||
int pos = 0;
|
||||
mouseGrid[pos++] = new Color(c.R, c.G, c.B);
|
||||
mouseGrid[pos++] = new Color(c.R, c.G, c.B);
|
||||
mouseGrid[pos++] = new Color(c.R, c.G, c.B);
|
||||
mouseGrid[pos++] = new Color(c.R, c.G, c.B);
|
||||
|
||||
for (var x = 0; x < 7; x++)
|
||||
{
|
||||
c = b.GetPixel(0, x);
|
||||
mouseGrid[pos++] = new Color(c.R, c.G, c.B);
|
||||
}
|
||||
b.RotateFlip(RotateFlipType.RotateNoneFlipX);
|
||||
for (var x = 0; x < 7; x++)
|
||||
{
|
||||
c = b.GetPixel(2, x);
|
||||
mouseGrid[pos++] = new Color(c.R, c.G, c.B);
|
||||
}
|
||||
|
||||
}
|
||||
return mouseGrid;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,57 +0,0 @@
|
||||
<dialogs:CustomDialog x:Class="Artemis.Dialogs.MarkdownDialog"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:dialogs="clr-namespace:MahApps.Metro.Controls.Dialogs;assembly=MahApps.Metro"
|
||||
xmlns:dialogs1="clr-namespace:Artemis.Dialogs"
|
||||
xmlns:markdown="clr-namespace:Artemis.Utilities.Markdown"
|
||||
xmlns:system="clr-namespace:System;assembly=mscorlib"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="300" d:DesignWidth="300">
|
||||
<dialogs:CustomDialog.Resources>
|
||||
<markdown:Markdown x:Key="Markdown"
|
||||
DocumentStyle="{StaticResource DocumentStyle}"
|
||||
Heading1Style="{StaticResource H1Style}"
|
||||
Heading2Style="{StaticResource H2Style}"
|
||||
Heading3Style="{StaticResource H3Style}"
|
||||
Heading4Style="{StaticResource H4Style}"
|
||||
LinkStyle="{StaticResource LinkStyle}"
|
||||
ImageStyle="{StaticResource ImageStyle}"
|
||||
SeparatorStyle="{StaticResource SeparatorStyle}"
|
||||
AssetPathRoot="{x:Static system:Environment.CurrentDirectory}" />
|
||||
|
||||
<markdown:TextToFlowDocumentConverter x:Key="TextToFlowDocumentConverter"
|
||||
Markdown="{StaticResource Markdown}" />
|
||||
</dialogs:CustomDialog.Resources>
|
||||
<Grid Margin="0 10 0 0">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="*" />
|
||||
<RowDefinition Height="Auto" />
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<FlowDocumentScrollViewer
|
||||
HorizontalScrollBarVisibility="Disabled"
|
||||
VerticalScrollBarVisibility="Auto"
|
||||
Margin="-15 -15 0 0"
|
||||
FontSize="{Binding DialogMessageFontSize, RelativeSource={RelativeSource AncestorType=dialogs:MessageDialog, Mode=FindAncestor}, UpdateSourceTrigger=PropertyChanged}"
|
||||
Foreground="{Binding Foreground, RelativeSource={RelativeSource AncestorType=dialogs:MessageDialog, Mode=FindAncestor}, UpdateSourceTrigger=PropertyChanged}"
|
||||
Document="{Binding Markdown, RelativeSource={RelativeSource AncestorType=dialogs1:MarkdownDialog, Mode=FindAncestor}, Converter={StaticResource TextToFlowDocumentConverter}, UpdateSourceTrigger=PropertyChanged}" IsSelectionEnabled="False" />
|
||||
|
||||
<StackPanel Grid.Row="1"
|
||||
Height="85"
|
||||
HorizontalAlignment="Right"
|
||||
Orientation="Horizontal">
|
||||
<Button x:Name="PART_AffirmativeButton"
|
||||
Height="35"
|
||||
MinWidth="80"
|
||||
Margin="0 0 5 0"
|
||||
Content="{Binding AffirmativeButtonText, RelativeSource={RelativeSource AncestorType=dialogs1:MarkdownDialog, Mode=FindAncestor}, UpdateSourceTrigger=PropertyChanged}" />
|
||||
<Button x:Name="PART_NegativeButton"
|
||||
Height="35"
|
||||
MinWidth="80"
|
||||
Margin="5 0 5 0"
|
||||
Content="{Binding NegativeButtonText, RelativeSource={RelativeSource AncestorType=dialogs1:MarkdownDialog, Mode=FindAncestor}, UpdateSourceTrigger=PropertyChanged}" />
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</dialogs:CustomDialog>
|
||||
@ -1,54 +0,0 @@
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Input;
|
||||
using MahApps.Metro.Controls;
|
||||
using MahApps.Metro.Controls.Dialogs;
|
||||
|
||||
namespace Artemis.Dialogs
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for MarkdownDialog.xaml
|
||||
/// </summary>
|
||||
public partial class MarkdownDialog : CustomDialog
|
||||
{
|
||||
public static readonly DependencyProperty MarkdownProperty = DependencyProperty.Register("Markdown", typeof(string), typeof(MarkdownDialog), new PropertyMetadata(default(string)));
|
||||
public static readonly DependencyProperty AffirmativeButtonTextProperty = DependencyProperty.Register("AffirmativeButtonText", typeof(string), typeof(MarkdownDialog), new PropertyMetadata("OK"));
|
||||
public static readonly DependencyProperty NegativeButtonTextProperty = DependencyProperty.Register("NegativeButtonText", typeof(string), typeof(MarkdownDialog), new PropertyMetadata("Cancel"));
|
||||
|
||||
public MarkdownDialog(MetroWindow parentWindow, MetroDialogSettings settings = null) : base(parentWindow, settings)
|
||||
{
|
||||
ParentWindow = parentWindow;
|
||||
InitializeComponent();
|
||||
|
||||
CommandBindings.Add(new CommandBinding(NavigationCommands.GoToPage, (sender, e) => System.Diagnostics.Process.Start((string) e.Parameter)));
|
||||
|
||||
PART_AffirmativeButton.Click += (sender, args) => ParentWindow.HideMetroDialogAsync(this);
|
||||
PART_NegativeButton.Click += (sender, args) => ParentWindow.HideMetroDialogAsync(this);
|
||||
|
||||
if (settings == null)
|
||||
return;
|
||||
AffirmativeButtonText = settings.AffirmativeButtonText;
|
||||
NegativeButtonText = settings.NegativeButtonText;
|
||||
}
|
||||
|
||||
public MetroWindow ParentWindow { get; set; }
|
||||
|
||||
public string Markdown
|
||||
{
|
||||
get => (string) GetValue(MarkdownProperty);
|
||||
set => SetValue(MarkdownProperty, value);
|
||||
}
|
||||
|
||||
public string AffirmativeButtonText
|
||||
{
|
||||
get => (string) GetValue(AffirmativeButtonTextProperty);
|
||||
set => SetValue(AffirmativeButtonTextProperty, value);
|
||||
}
|
||||
|
||||
public string NegativeButtonText
|
||||
{
|
||||
get => (string) GetValue(NegativeButtonTextProperty);
|
||||
set => SetValue(NegativeButtonTextProperty, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,17 +0,0 @@
|
||||
using System;
|
||||
using CSCore.CoreAudioAPI;
|
||||
|
||||
namespace Artemis.Events
|
||||
{
|
||||
public class AudioDeviceChangedEventArgs : EventArgs
|
||||
{
|
||||
public AudioDeviceChangedEventArgs(MMDevice defaultPlayback, MMDevice defaultRecording)
|
||||
{
|
||||
DefaultPlayback = defaultPlayback;
|
||||
DefaultRecording = defaultRecording;
|
||||
}
|
||||
|
||||
public MMDevice DefaultPlayback { get; }
|
||||
public MMDevice DefaultRecording { get; }
|
||||
}
|
||||
}
|
||||
@ -1,14 +0,0 @@
|
||||
using System;
|
||||
|
||||
namespace Artemis.Events
|
||||
{
|
||||
public class EnabledChangedEventArgs : EventArgs
|
||||
{
|
||||
public EnabledChangedEventArgs(bool enabled)
|
||||
{
|
||||
Enabled = enabled;
|
||||
}
|
||||
|
||||
public bool Enabled { get; }
|
||||
}
|
||||
}
|
||||
@ -1,17 +0,0 @@
|
||||
using System;
|
||||
using Artemis.DeviceProviders;
|
||||
|
||||
namespace Artemis.Events
|
||||
{
|
||||
public class KeyboardChangedEventArgs : EventArgs
|
||||
{
|
||||
public KeyboardChangedEventArgs(KeyboardProvider oldKeyboard, KeyboardProvider newKeyboard)
|
||||
{
|
||||
OldKeyboard = oldKeyboard;
|
||||
NewKeyboard = newKeyboard;
|
||||
}
|
||||
|
||||
public KeyboardProvider OldKeyboard { get; }
|
||||
public KeyboardProvider NewKeyboard { get; }
|
||||
}
|
||||
}
|
||||
@ -1,15 +0,0 @@
|
||||
using System;
|
||||
using Artemis.Modules.Abstract;
|
||||
|
||||
namespace Artemis.Events
|
||||
{
|
||||
public class ModuleChangedEventArgs : EventArgs
|
||||
{
|
||||
public ModuleChangedEventArgs(ModuleModel module)
|
||||
{
|
||||
Module = module;
|
||||
}
|
||||
|
||||
public ModuleModel Module { get; }
|
||||
}
|
||||
}
|
||||
@ -1,15 +0,0 @@
|
||||
using System;
|
||||
using Artemis.Profiles;
|
||||
|
||||
namespace Artemis.Events
|
||||
{
|
||||
public class ProfileChangedEventArgs : EventArgs
|
||||
{
|
||||
public ProfileChangedEventArgs(ProfileModel profileModel)
|
||||
{
|
||||
ProfileModel = profileModel;
|
||||
}
|
||||
|
||||
public ProfileModel ProfileModel { get; }
|
||||
}
|
||||
}
|
||||
@ -1,23 +0,0 @@
|
||||
using System;
|
||||
using System.Windows.Media;
|
||||
using Artemis.Modules.Abstract;
|
||||
using Artemis.Profiles.Layers.Interfaces;
|
||||
|
||||
namespace Artemis.Events
|
||||
{
|
||||
public class ProfileDeviceEventsArg : EventArgs
|
||||
{
|
||||
public ProfileDeviceEventsArg(DrawType updateType, ModuleDataModel dataModel, bool preview, DrawingContext drawingContext)
|
||||
{
|
||||
UpdateType = updateType.ToString().ToLower();
|
||||
DataModel = dataModel;
|
||||
Preview = preview;
|
||||
DrawingContext = drawingContext;
|
||||
}
|
||||
|
||||
public string UpdateType { get; }
|
||||
public ModuleDataModel DataModel { get; }
|
||||
public bool Preview { get; }
|
||||
public DrawingContext DrawingContext { get; }
|
||||
}
|
||||
}
|
||||
@ -1,14 +0,0 @@
|
||||
using System.Windows.Media;
|
||||
|
||||
namespace Artemis.Events
|
||||
{
|
||||
public class RazerColorArrayChanged
|
||||
{
|
||||
public RazerColorArrayChanged(Color[,] colors)
|
||||
{
|
||||
Colors = colors;
|
||||
}
|
||||
|
||||
public Color[,] Colors { get; set; }
|
||||
}
|
||||
}
|
||||
@ -1,15 +0,0 @@
|
||||
using System;
|
||||
using System.Windows.Media;
|
||||
|
||||
namespace Artemis.Events
|
||||
{
|
||||
public class RazerColorsChangedEventArgs : EventArgs
|
||||
{
|
||||
public RazerColorsChangedEventArgs(Color[,] colors)
|
||||
{
|
||||
Colors = colors;
|
||||
}
|
||||
|
||||
public Color[,] Colors { get; }
|
||||
}
|
||||
}
|
||||
@ -1,127 +0,0 @@
|
||||
using Artemis.DeviceProviders;
|
||||
using Artemis.Managers;
|
||||
using Artemis.Models;
|
||||
using Artemis.Modules.Abstract;
|
||||
using Artemis.Modules.Games.WoW;
|
||||
using Artemis.Profiles.Layers.Abstract;
|
||||
using Artemis.Profiles.Layers.Interfaces;
|
||||
using Artemis.Profiles.Layers.Types.Audio.AudioCapturing;
|
||||
using Artemis.Profiles.Lua;
|
||||
using Artemis.Profiles.Lua.Modules.Gui;
|
||||
using Artemis.Services;
|
||||
using Artemis.Utilities.DataReaders;
|
||||
using Artemis.Utilities.GameState;
|
||||
using Artemis.ViewModels;
|
||||
using Artemis.ViewModels.Abstract;
|
||||
using Ninject.Extensions.Conventions;
|
||||
using Ninject.Modules;
|
||||
|
||||
namespace Artemis.InjectionModules
|
||||
{
|
||||
public class BaseModules : NinjectModule
|
||||
{
|
||||
public override void Load()
|
||||
{
|
||||
#region Models
|
||||
|
||||
Bind<ProfileEditorModel>().ToSelf();
|
||||
Bind<LayerEditorModel>().ToSelf();
|
||||
|
||||
#endregion
|
||||
|
||||
#region ViewModels
|
||||
|
||||
Bind<ShellViewModel>().ToSelf().InSingletonScope();
|
||||
Bind<ProfileEditorViewModel>().ToSelf();
|
||||
Bind<DebugViewModel>().ToSelf().InSingletonScope();
|
||||
Kernel.Bind(x =>
|
||||
x.FromThisAssembly()
|
||||
.SelectAllClasses()
|
||||
.InheritedFrom<BaseViewModel>()
|
||||
.BindAllBaseClasses());
|
||||
|
||||
#endregion
|
||||
|
||||
#region Services
|
||||
|
||||
Bind<MetroDialogService>().ToSelf().InSingletonScope();
|
||||
Bind<WindowService>().ToSelf().InSingletonScope();
|
||||
|
||||
#endregion
|
||||
|
||||
#region Servers
|
||||
|
||||
Bind<GameStateWebServer>().ToSelf().InSingletonScope();
|
||||
Bind<PipeServer>().ToSelf().InSingletonScope();
|
||||
|
||||
#endregion
|
||||
|
||||
#region Devices
|
||||
|
||||
Kernel.Bind(x =>
|
||||
x.FromThisAssembly()
|
||||
.SelectAllClasses()
|
||||
.InheritedFrom<DeviceProvider>()
|
||||
.BindAllBaseClasses());
|
||||
|
||||
#endregion
|
||||
|
||||
#region Modules
|
||||
|
||||
Kernel.Bind(x =>
|
||||
x.FromThisAssembly()
|
||||
.SelectAllClasses()
|
||||
.InheritedFrom<ModuleModel>()
|
||||
.BindAllBaseClasses()
|
||||
.Configure((b, c) => b.InSingletonScope().Named(c.Name))
|
||||
);
|
||||
Kernel.Bind(x =>
|
||||
x.FromThisAssembly()
|
||||
.SelectAllClasses()
|
||||
.InheritedFrom<ModuleViewModel>()
|
||||
.BindAllBaseClasses()
|
||||
.Configure(b => b.InSingletonScope())
|
||||
);
|
||||
Bind<WowPacketScanner>().ToSelf();
|
||||
|
||||
#endregion
|
||||
|
||||
#region Profiles
|
||||
|
||||
Kernel.Bind(x =>
|
||||
x.FromThisAssembly()
|
||||
.SelectAllClasses()
|
||||
.InheritedFrom<ILayerAnimation>()
|
||||
.BindAllInterfaces());
|
||||
Kernel.Bind(x =>
|
||||
x.FromThisAssembly()
|
||||
.SelectAllClasses()
|
||||
.InheritedFrom<ILayerCondition>()
|
||||
.BindAllInterfaces());
|
||||
Kernel.Bind(x =>
|
||||
x.FromThisAssembly()
|
||||
.SelectAllClasses()
|
||||
.InheritedFrom<ILayerType>()
|
||||
.BindAllInterfaces());
|
||||
Kernel.Bind(x =>
|
||||
x.FromThisAssembly()
|
||||
.SelectAllClasses()
|
||||
.InheritedFrom<ILayerType>()
|
||||
.BindToSelf());
|
||||
|
||||
#endregion
|
||||
|
||||
#region Lua
|
||||
|
||||
Kernel.Bind(x =>
|
||||
x.FromThisAssembly()
|
||||
.SelectAllClasses()
|
||||
.InheritedFrom<LuaModule>()
|
||||
.BindAllBaseClasses());
|
||||
|
||||
Bind<LuaWindowViewModel>().ToSelf();
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,20 +0,0 @@
|
||||
using Artemis.Managers;
|
||||
using Ninject.Modules;
|
||||
|
||||
namespace Artemis.InjectionModules
|
||||
{
|
||||
public class ManagerModules : NinjectModule
|
||||
{
|
||||
public override void Load()
|
||||
{
|
||||
Bind<MainManager>().ToSelf().InSingletonScope();
|
||||
Bind<LoopManager>().ToSelf().InSingletonScope();
|
||||
Bind<DeviceManager>().ToSelf().InSingletonScope();
|
||||
Bind<ModuleManager>().ToSelf().InSingletonScope();
|
||||
Bind<PreviewManager>().ToSelf().InSingletonScope();
|
||||
Bind<LuaManager>().ToSelf().InSingletonScope();
|
||||
Bind<AudioCaptureManager>().ToSelf().InSingletonScope();
|
||||
Bind<MigrationManager>().ToSelf().InSingletonScope();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,97 +0,0 @@
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Interactivity;
|
||||
|
||||
namespace Artemis.ItemBehaviours
|
||||
{
|
||||
/// <summary>
|
||||
/// Chaitanya Kadamati - http://stackoverflow.com/a/33233162/5015269
|
||||
/// </summary>
|
||||
public class BindableSelectedItemBehavior : Behavior<TreeView>
|
||||
{
|
||||
protected override void OnAttached()
|
||||
{
|
||||
base.OnAttached();
|
||||
AssociatedObject.SelectedItemChanged += OnTreeViewSelectedItemChanged;
|
||||
}
|
||||
|
||||
protected override void OnDetaching()
|
||||
{
|
||||
base.OnDetaching();
|
||||
if (AssociatedObject != null)
|
||||
AssociatedObject.SelectedItemChanged -= OnTreeViewSelectedItemChanged;
|
||||
}
|
||||
|
||||
private void OnTreeViewSelectedItemChanged(object sender, RoutedPropertyChangedEventArgs<object> e)
|
||||
{
|
||||
SelectedItem = e.NewValue;
|
||||
}
|
||||
|
||||
#region SelectedItem Property
|
||||
|
||||
public object SelectedItem
|
||||
{
|
||||
get { return GetValue(SelectedItemProperty); }
|
||||
set { SetValue(SelectedItemProperty, value); }
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty SelectedItemProperty =
|
||||
DependencyProperty.Register("SelectedItem", typeof(object), typeof(BindableSelectedItemBehavior),
|
||||
new UIPropertyMetadata(null, OnSelectedItemChanged));
|
||||
|
||||
private static void OnSelectedItemChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
var behavior = sender as BindableSelectedItemBehavior;
|
||||
var tree = behavior?.AssociatedObject;
|
||||
if (tree == null)
|
||||
return;
|
||||
|
||||
if (e.NewValue == null)
|
||||
{
|
||||
foreach (var item in tree.Items.OfType<TreeViewItem>())
|
||||
item.SetValue(TreeViewItem.IsSelectedProperty, false);
|
||||
}
|
||||
var treeViewItem = e.NewValue as TreeViewItem;
|
||||
if (treeViewItem != null)
|
||||
treeViewItem.SetValue(TreeViewItem.IsSelectedProperty, true);
|
||||
else
|
||||
{
|
||||
var itemsHostProperty = tree.GetType()
|
||||
.GetProperty("ItemsHost", BindingFlags.NonPublic | BindingFlags.Instance);
|
||||
var itemsHost = itemsHostProperty?.GetValue(tree, null) as Panel;
|
||||
if (itemsHost == null)
|
||||
return;
|
||||
|
||||
foreach (var item in itemsHost.Children.OfType<TreeViewItem>())
|
||||
{
|
||||
if (WalkTreeViewItem(item, e.NewValue))
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static bool WalkTreeViewItem(TreeViewItem treeViewItem, object selectedValue)
|
||||
{
|
||||
if (treeViewItem.DataContext == selectedValue)
|
||||
{
|
||||
treeViewItem.SetValue(TreeViewItem.IsSelectedProperty, true);
|
||||
treeViewItem.Focus();
|
||||
return true;
|
||||
}
|
||||
var itemsHostProperty = treeViewItem.GetType()
|
||||
.GetProperty("ItemsHost", BindingFlags.NonPublic | BindingFlags.Instance);
|
||||
var itemsHost = itemsHostProperty?.GetValue(treeViewItem, null) as Panel;
|
||||
if (itemsHost == null) return false;
|
||||
foreach (var item in itemsHost.Children.OfType<TreeViewItem>())
|
||||
{
|
||||
if (WalkTreeViewItem(item, selectedValue))
|
||||
break;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
Binary file not shown.
@ -1,67 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Timers;
|
||||
using Artemis.Events;
|
||||
using Artemis.Profiles.Layers.Types.Audio;
|
||||
using Artemis.Profiles.Layers.Types.Audio.AudioCapturing;
|
||||
using CSCore.CoreAudioAPI;
|
||||
using Ninject.Extensions.Logging;
|
||||
|
||||
namespace Artemis.Managers
|
||||
{
|
||||
public class AudioCaptureManager
|
||||
{
|
||||
private readonly List<AudioCapture> _audioCaptures;
|
||||
private MMDevice _lastDefaultPlayback;
|
||||
private MMDevice _lastDefaultRecording;
|
||||
|
||||
public AudioCaptureManager(ILogger logger)
|
||||
{
|
||||
Logger = logger;
|
||||
_audioCaptures = new List<AudioCapture>();
|
||||
_lastDefaultPlayback = MMDeviceEnumerator.TryGetDefaultAudioEndpoint(DataFlow.Render, Role.Multimedia);
|
||||
_lastDefaultRecording = MMDeviceEnumerator.TryGetDefaultAudioEndpoint(DataFlow.Capture, Role.Multimedia);
|
||||
|
||||
var defaultDeviceTimer = new Timer(1000);
|
||||
defaultDeviceTimer.Elapsed += DefaultDeviceTimerOnElapsed;
|
||||
defaultDeviceTimer.Start();
|
||||
}
|
||||
|
||||
public event EventHandler<AudioDeviceChangedEventArgs> AudioDeviceChanged;
|
||||
|
||||
private void DefaultDeviceTimerOnElapsed(object sender, ElapsedEventArgs e)
|
||||
{
|
||||
var defaultPlayback = MMDeviceEnumerator.TryGetDefaultAudioEndpoint(DataFlow.Render, Role.Multimedia);
|
||||
var defaultRecording = MMDeviceEnumerator.TryGetDefaultAudioEndpoint(DataFlow.Capture, Role.Multimedia);
|
||||
|
||||
if (defaultPlayback?.DeviceID == _lastDefaultPlayback?.DeviceID &&
|
||||
defaultRecording?.DeviceID == _lastDefaultRecording?.DeviceID)
|
||||
return;
|
||||
|
||||
_lastDefaultPlayback = defaultPlayback;
|
||||
_lastDefaultRecording = defaultRecording;
|
||||
OnAudioDeviceChanged(new AudioDeviceChangedEventArgs(_lastDefaultPlayback, _lastDefaultRecording));
|
||||
}
|
||||
|
||||
public AudioCapture GetAudioCapture(MMDevice device, MmDeviceType type)
|
||||
{
|
||||
// Return existing audio capture if found
|
||||
var audioCapture = _audioCaptures.FirstOrDefault(a => a.Device.DeviceID == device.DeviceID);
|
||||
if (audioCapture != null)
|
||||
return audioCapture;
|
||||
|
||||
// Else create a new one and return that
|
||||
var newAudioCapture = new AudioCapture(Logger, device, type);
|
||||
_audioCaptures.Add(newAudioCapture);
|
||||
return newAudioCapture;
|
||||
}
|
||||
|
||||
public ILogger Logger { get; set; }
|
||||
|
||||
protected virtual void OnAudioDeviceChanged(AudioDeviceChangedEventArgs e)
|
||||
{
|
||||
AudioDeviceChanged?.Invoke(this, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,185 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Artemis.DAL;
|
||||
using Artemis.DeviceProviders;
|
||||
using Artemis.Events;
|
||||
using Artemis.Services;
|
||||
using Artemis.Settings;
|
||||
using MahApps.Metro.Controls.Dialogs;
|
||||
using Ninject;
|
||||
using Ninject.Extensions.Logging;
|
||||
|
||||
namespace Artemis.Managers
|
||||
{
|
||||
/// <summary>
|
||||
/// Manages the keyboard providers
|
||||
/// </summary>
|
||||
public class DeviceManager
|
||||
{
|
||||
private readonly GeneralSettings _generalSettings;
|
||||
private readonly ILogger _logger;
|
||||
|
||||
public DeviceManager(ILogger logger, List<DeviceProvider> deviceProviders)
|
||||
{
|
||||
_logger = logger;
|
||||
_generalSettings = SettingsProvider.Load<GeneralSettings>();
|
||||
|
||||
KeyboardProviders = deviceProviders.Where(d => d.Type == DeviceType.Keyboard)
|
||||
.Cast<KeyboardProvider>().ToList();
|
||||
MiceProviders = deviceProviders.Where(d => d.Type == DeviceType.Mouse).ToList();
|
||||
HeadsetProviders = deviceProviders.Where(d => d.Type == DeviceType.Headset).ToList();
|
||||
GenericProviders = deviceProviders.Where(d => d.Type == DeviceType.Generic).ToList();
|
||||
MousematProviders = deviceProviders.Where(d => d.Type == DeviceType.Mousemat).ToList();
|
||||
|
||||
_logger.Info("Intialized DeviceManager with {0} device providers", deviceProviders.Count);
|
||||
}
|
||||
|
||||
public List<DeviceProvider> MiceProviders { get; set; }
|
||||
public List<DeviceProvider> HeadsetProviders { get; set; }
|
||||
public List<DeviceProvider> GenericProviders { get; set; }
|
||||
public List<DeviceProvider> MousematProviders { get; set; }
|
||||
|
||||
[Inject]
|
||||
public MetroDialogService DialogService { get; set; }
|
||||
|
||||
public List<KeyboardProvider> KeyboardProviders { get; set; }
|
||||
|
||||
public KeyboardProvider ActiveKeyboard { get; set; }
|
||||
|
||||
public bool ChangingKeyboard { get; private set; }
|
||||
|
||||
|
||||
public event EventHandler<KeyboardChangedEventArgs> OnKeyboardChanged;
|
||||
|
||||
/// <summary>
|
||||
/// Enables the last keyboard according to the settings file
|
||||
/// </summary>
|
||||
public void EnableLastKeyboard()
|
||||
{
|
||||
_logger.Debug("Getting last keyboard: {0}", _generalSettings.LastKeyboard);
|
||||
if (string.IsNullOrEmpty(_generalSettings.LastKeyboard))
|
||||
return;
|
||||
|
||||
var keyboard = KeyboardProviders.FirstOrDefault(k => k.Name == _generalSettings.LastKeyboard);
|
||||
EnableKeyboard(keyboard);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Enables the given keyboard
|
||||
/// </summary>
|
||||
/// <param name="keyboardProvider"></param>
|
||||
public async void EnableKeyboard(KeyboardProvider keyboardProvider)
|
||||
{
|
||||
if (keyboardProvider == null)
|
||||
return;
|
||||
|
||||
if (ChangingKeyboard || (ActiveKeyboard?.Name == keyboardProvider.Name))
|
||||
return;
|
||||
|
||||
_logger.Debug("Trying to enable keyboard: {0}", keyboardProvider.Name);
|
||||
ChangingKeyboard = true;
|
||||
|
||||
// Store the old keyboard so it can be used in the event we're raising later
|
||||
var oldKeyboard = ActiveKeyboard;
|
||||
|
||||
// Release the current keyboard
|
||||
ReleaseActiveKeyboard();
|
||||
|
||||
// Create a dialog to let the user know Artemis hasn't frozen
|
||||
ProgressDialogController dialog = null;
|
||||
if (DialogService.GetActiveWindow() != null)
|
||||
{
|
||||
dialog = await DialogService.ShowProgressDialog("Enabling keyboard",
|
||||
$"Checking if keyboard '{keyboardProvider.Name}' can be enabled...", true);
|
||||
|
||||
// May seem a bit cheesy, but it's tidier to have the animation finish
|
||||
await Task.Delay(500);
|
||||
}
|
||||
dialog?.SetIndeterminate();
|
||||
|
||||
var canEnable = await keyboardProvider.CanEnableAsync(dialog);
|
||||
if (!canEnable)
|
||||
{
|
||||
if (dialog != null)
|
||||
await dialog.CloseAsync();
|
||||
|
||||
DialogService.ShowErrorMessageBox(keyboardProvider.CantEnableText);
|
||||
ActiveKeyboard = null;
|
||||
_generalSettings.LastKeyboard = null;
|
||||
_generalSettings.Save();
|
||||
_logger.Warn("Failed enabling keyboard: {0}", keyboardProvider.Name);
|
||||
ChangingKeyboard = false;
|
||||
return;
|
||||
}
|
||||
|
||||
dialog?.SetMessage($"Enabling keyboard: {keyboardProvider.Name}...");
|
||||
|
||||
// Setup the new keyboard
|
||||
ActiveKeyboard = keyboardProvider;
|
||||
await ActiveKeyboard.EnableAsync(dialog);
|
||||
EnableUsableDevices();
|
||||
|
||||
_generalSettings.LastKeyboard = ActiveKeyboard.Name;
|
||||
_generalSettings.Save();
|
||||
|
||||
RaiseKeyboardChangedEvent(new KeyboardChangedEventArgs(oldKeyboard, ActiveKeyboard));
|
||||
_logger.Debug("Enabled keyboard: {0}", keyboardProvider.Name);
|
||||
|
||||
if (dialog != null)
|
||||
await dialog.CloseAsync();
|
||||
|
||||
ChangingKeyboard = false;
|
||||
}
|
||||
|
||||
private void EnableUsableDevices()
|
||||
{
|
||||
foreach (var mouseProvider in MiceProviders)
|
||||
mouseProvider.TryEnableAsync();
|
||||
foreach (var headsetProvider in HeadsetProviders)
|
||||
headsetProvider.TryEnableAsync();
|
||||
foreach (var genericProvider in GenericProviders)
|
||||
genericProvider.TryEnableAsync();
|
||||
foreach (var mousematProviders in MousematProviders)
|
||||
mousematProviders.TryEnableAsync();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Releases the active keyboard
|
||||
/// </summary>
|
||||
/// <param name="save">Whether to save the LastKeyboard (making it null)</param>
|
||||
public void ReleaseActiveKeyboard(bool save = false)
|
||||
{
|
||||
lock (this)
|
||||
{
|
||||
if (ActiveKeyboard == null)
|
||||
return;
|
||||
|
||||
// Store the old keyboard so it can be used in the event we're raising later
|
||||
var oldKeyboard = ActiveKeyboard;
|
||||
|
||||
var releaseName = ActiveKeyboard.Name;
|
||||
ActiveKeyboard.Disable();
|
||||
ActiveKeyboard = null;
|
||||
|
||||
if (save)
|
||||
{
|
||||
_generalSettings.LastKeyboard = null;
|
||||
_generalSettings.Save();
|
||||
}
|
||||
|
||||
RaiseKeyboardChangedEvent(new KeyboardChangedEventArgs(oldKeyboard, null));
|
||||
_logger.Debug("Released keyboard: {0}", releaseName);
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual void RaiseKeyboardChangedEvent(KeyboardChangedEventArgs e)
|
||||
{
|
||||
// I do this in all to avoid a possible race condition
|
||||
// https://msdn.microsoft.com/en-us/library/w369ty8x.aspx
|
||||
var handler = OnKeyboardChanged;
|
||||
handler?.Invoke(this, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,98 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Windows.Forms;
|
||||
using System.Windows.Input;
|
||||
using Artemis.Models;
|
||||
using Artemis.Utilities;
|
||||
using MahApps.Metro.Controls;
|
||||
using KeyEventArgs = System.Windows.Forms.KeyEventArgs;
|
||||
using MouseEventArgs = System.Windows.Forms.MouseEventArgs;
|
||||
|
||||
namespace Artemis.Managers
|
||||
{
|
||||
public static class KeybindManager
|
||||
{
|
||||
private static readonly List<KeybindModel> KeybindModels = new List<KeybindModel>();
|
||||
|
||||
static KeybindManager()
|
||||
{
|
||||
InputHook.KeyDownCallback += args => ProcessKey(args, PressType.Down);
|
||||
InputHook.KeyUpCallback += args => ProcessKey(args, PressType.Up);
|
||||
InputHook.MouseDownCallback += args => ProcessMouse(args, PressType.Down);
|
||||
InputHook.MouseUpCallback += args => ProcessMouse(args, PressType.Up);
|
||||
}
|
||||
|
||||
private static void ProcessKey(KeyEventArgs keyEventArgs, PressType pressType)
|
||||
{
|
||||
// Don't trigger if the key itself is a modifier
|
||||
if (keyEventArgs.KeyCode == Keys.LShiftKey || keyEventArgs.KeyCode == Keys.RShiftKey ||
|
||||
keyEventArgs.KeyCode == Keys.LControlKey || keyEventArgs.KeyCode == Keys.RControlKey ||
|
||||
keyEventArgs.KeyCode == Keys.LMenu || keyEventArgs.KeyCode == Keys.RMenu)
|
||||
return;
|
||||
|
||||
// Create a WPF ModifierKeys enum
|
||||
var modifiers = ModifierKeysFromBooleans(keyEventArgs.Alt, keyEventArgs.Control, keyEventArgs.Shift);
|
||||
|
||||
// Create a HotKey object for comparison
|
||||
var hotKey = new HotKey(KeyInterop.KeyFromVirtualKey(keyEventArgs.KeyValue), modifiers);
|
||||
|
||||
foreach (var keybindModel in KeybindModels)
|
||||
keybindModel.InvokeIfMatched(hotKey, pressType);
|
||||
}
|
||||
|
||||
private static void ProcessMouse(MouseEventArgs mouseEventArgs, PressType pressType)
|
||||
{
|
||||
foreach (var keybindModel in KeybindModels)
|
||||
keybindModel.InvokeIfMatched(mouseEventArgs.Button, pressType);
|
||||
}
|
||||
|
||||
public static void AddOrUpdate(KeybindModel keybindModel)
|
||||
{
|
||||
if (keybindModel == null)
|
||||
return;
|
||||
|
||||
var existing = KeybindModels.FirstOrDefault(k => k.Name == keybindModel.Name);
|
||||
if (existing != null)
|
||||
KeybindModels.Remove(existing);
|
||||
|
||||
KeybindModels.Add(keybindModel);
|
||||
}
|
||||
|
||||
public static void Remove(KeybindModel keybindModel)
|
||||
{
|
||||
if (KeybindModels.Contains(keybindModel))
|
||||
KeybindModels.Remove(keybindModel);
|
||||
}
|
||||
|
||||
public static void Remove(string name)
|
||||
{
|
||||
var existing = KeybindModels.FirstOrDefault(k => k.Name == name);
|
||||
if (existing != null)
|
||||
KeybindModels.Remove(existing);
|
||||
}
|
||||
|
||||
public static ModifierKeys ModifierKeysFromBooleans(bool alt, bool control, bool shift)
|
||||
{
|
||||
// Create a WPF ModifierKeys enum
|
||||
var modifiers = ModifierKeys.None;
|
||||
if (alt)
|
||||
modifiers = ModifierKeys.Alt;
|
||||
if (control)
|
||||
{
|
||||
if (modifiers == ModifierKeys.None)
|
||||
modifiers = ModifierKeys.Control;
|
||||
else
|
||||
modifiers |= ModifierKeys.Control;
|
||||
}
|
||||
if (shift)
|
||||
{
|
||||
if (modifiers == ModifierKeys.None)
|
||||
modifiers = ModifierKeys.Shift;
|
||||
else
|
||||
modifiers |= ModifierKeys.Shift;
|
||||
}
|
||||
|
||||
return modifiers;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,211 +0,0 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Artemis.Models;
|
||||
using Artemis.ViewModels;
|
||||
using Ninject.Extensions.Logging;
|
||||
|
||||
namespace Artemis.Managers
|
||||
{
|
||||
/// <summary>
|
||||
/// Manages the main programn loop
|
||||
/// </summary>
|
||||
public class LoopManager : IDisposable
|
||||
{
|
||||
private readonly DebugViewModel _debugViewModel;
|
||||
private readonly DeviceManager _deviceManager;
|
||||
|
||||
private readonly ILogger _logger;
|
||||
|
||||
//private readonly Timer _loopTimer;
|
||||
private readonly Task _loopTask;
|
||||
|
||||
private readonly ModuleManager _moduleManager;
|
||||
|
||||
public LoopManager(ILogger logger, ModuleManager moduleManager, DeviceManager deviceManager,
|
||||
DebugViewModel debugViewModel)
|
||||
{
|
||||
_logger = logger;
|
||||
_moduleManager = moduleManager;
|
||||
_deviceManager = deviceManager;
|
||||
_debugViewModel = debugViewModel;
|
||||
|
||||
// Setup timers
|
||||
_loopTask = Task.Factory.StartNew(ProcessLoop);
|
||||
_logger.Info("Intialized LoopManager");
|
||||
}
|
||||
|
||||
public DebugViewModel DebugViewModel { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether the loop is running
|
||||
/// </summary>
|
||||
public bool Running { get; private set; }
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
_loopTask.Dispose();
|
||||
}
|
||||
|
||||
private void ProcessLoop()
|
||||
{
|
||||
//TODO DarthAffe 14.01.2017: A stop-condition and a real cleanup instead of just aborting might be better
|
||||
while (true)
|
||||
{
|
||||
try
|
||||
{
|
||||
long preUpdateTicks = DateTime.Now.Ticks;
|
||||
|
||||
Render();
|
||||
|
||||
int sleep = (int) (40f - (DateTime.Now.Ticks - preUpdateTicks) / 10000f);
|
||||
if (sleep > 0)
|
||||
Thread.Sleep(sleep);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
if (Debugger.IsAttached)
|
||||
throw;
|
||||
|
||||
_logger.Warn(e, "Exception in render loop");
|
||||
}
|
||||
}
|
||||
// ReSharper disable once FunctionNeverReturns
|
||||
}
|
||||
|
||||
public Task StartAsync()
|
||||
{
|
||||
return Task.Run(() => Start());
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
if (Running)
|
||||
return;
|
||||
|
||||
_logger.Debug("Starting LoopManager");
|
||||
|
||||
if (_deviceManager.ActiveKeyboard == null)
|
||||
_deviceManager.EnableLastKeyboard();
|
||||
|
||||
while (_deviceManager.ChangingKeyboard)
|
||||
Thread.Sleep(200);
|
||||
|
||||
// If still null, no last keyboard, so stop.
|
||||
if (_deviceManager.ActiveKeyboard == null)
|
||||
{
|
||||
_logger.Debug("Cancel LoopManager start, no keyboard");
|
||||
return;
|
||||
}
|
||||
|
||||
if (_moduleManager.ActiveModule == null)
|
||||
{
|
||||
var lastModule = _moduleManager.GetLastModule();
|
||||
if (lastModule == null || !lastModule.Settings.IsEnabled)
|
||||
{
|
||||
_logger.Debug("Cancel LoopManager start, no module");
|
||||
return;
|
||||
}
|
||||
_moduleManager.ChangeActiveModule(lastModule);
|
||||
}
|
||||
|
||||
Running = true;
|
||||
}
|
||||
|
||||
public void Stop()
|
||||
{
|
||||
if (!Running)
|
||||
return;
|
||||
|
||||
_logger.Debug("Stopping LoopManager");
|
||||
Running = false;
|
||||
|
||||
_deviceManager.ReleaseActiveKeyboard();
|
||||
}
|
||||
|
||||
private void Render()
|
||||
{
|
||||
if (!Running || _deviceManager.ChangingKeyboard)
|
||||
return;
|
||||
|
||||
// Stop if no active module
|
||||
if (_moduleManager.ActiveModule == null)
|
||||
{
|
||||
_logger.Debug("No active module, stopping");
|
||||
Stop();
|
||||
return;
|
||||
}
|
||||
var renderModule = _moduleManager.ActiveModule;
|
||||
|
||||
// Stop if no active keyboard
|
||||
if (_deviceManager.ActiveKeyboard == null)
|
||||
{
|
||||
_logger.Debug("No active keyboard, stopping");
|
||||
Stop();
|
||||
return;
|
||||
}
|
||||
|
||||
lock (_deviceManager.ActiveKeyboard)
|
||||
{
|
||||
// Skip frame if module is still initializing
|
||||
if (renderModule.IsInitialized == false)
|
||||
return;
|
||||
|
||||
// ApplyProperties the current module
|
||||
if (renderModule.IsInitialized)
|
||||
renderModule.Update();
|
||||
|
||||
// Get the devices that must be rendered to
|
||||
var mice = _deviceManager.MiceProviders.Where(m => m.CanUse).ToList();
|
||||
var headsets = _deviceManager.HeadsetProviders.Where(m => m.CanUse).ToList();
|
||||
var generics = _deviceManager.GenericProviders.Where(m => m.CanUse).ToList();
|
||||
var mousemats = _deviceManager.MousematProviders.Where(m => m.CanUse).ToList();
|
||||
|
||||
var keyboardOnly = !mice.Any() && !headsets.Any() && !generics.Any() && !mousemats.Any();
|
||||
|
||||
// Setup the frame for this tick
|
||||
using (var frame = new FrameModel(_deviceManager.ActiveKeyboard, mice.Any(), headsets.Any(), generics.Any(), mousemats.Any()))
|
||||
{
|
||||
if (renderModule.IsInitialized)
|
||||
renderModule.Render(frame, keyboardOnly);
|
||||
|
||||
// Draw enabled overlays on top of the renderModule
|
||||
foreach (var overlayModel in _moduleManager.OverlayModules.Where(o => o.Settings.IsEnabled))
|
||||
{
|
||||
overlayModel.Update();
|
||||
overlayModel.Render(frame, keyboardOnly);
|
||||
}
|
||||
|
||||
// Render the frame's drawing context to bitmaps
|
||||
frame.RenderBitmaps();
|
||||
|
||||
// Update the keyboard
|
||||
_deviceManager.ActiveKeyboard?.DrawBitmap(frame.KeyboardBitmap);
|
||||
|
||||
// Update the other devices
|
||||
foreach (var mouse in mice)
|
||||
mouse.UpdateDevice(frame.MouseBitmap);
|
||||
foreach (var headset in headsets)
|
||||
headset.UpdateDevice(frame.HeadsetBitmap);
|
||||
foreach (var generic in generics)
|
||||
generic.UpdateDevice(frame.GenericBitmap);
|
||||
foreach (var mousemat in mousemats)
|
||||
mousemat.UpdateDevice(frame.MousematBitmap);
|
||||
|
||||
_debugViewModel.DrawFrame(frame);
|
||||
|
||||
OnRenderCompleted();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public event EventHandler RenderCompleted;
|
||||
|
||||
protected virtual void OnRenderCompleted()
|
||||
{
|
||||
RenderCompleted?.Invoke(this, EventArgs.Empty);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,181 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using Artemis.DeviceProviders;
|
||||
using Artemis.Profiles;
|
||||
using Artemis.Profiles.Lua;
|
||||
using Artemis.Profiles.Lua.Modules;
|
||||
using Artemis.Profiles.Lua.Modules.Gui;
|
||||
using MoonSharp.Interpreter;
|
||||
using Ninject;
|
||||
using Ninject.Extensions.Logging;
|
||||
|
||||
namespace Artemis.Managers
|
||||
{
|
||||
public class LuaManager
|
||||
{
|
||||
private readonly DeviceManager _deviceManager;
|
||||
private readonly IKernel _kernel;
|
||||
private readonly ILogger _logger;
|
||||
private List<LuaModule> _luaModules;
|
||||
|
||||
public LuaManager(IKernel kernel, ILogger logger, DeviceManager deviceManager)
|
||||
{
|
||||
_kernel = kernel;
|
||||
_logger = logger;
|
||||
_deviceManager = deviceManager;
|
||||
|
||||
EditorButtons = new ObservableCollection<EditorButton>();
|
||||
LuaScript = new Script(CoreModules.Preset_SoftSandbox);
|
||||
}
|
||||
|
||||
public ProfileModel ProfileModel { get; private set; }
|
||||
public KeyboardProvider KeyboardProvider { get; private set; }
|
||||
public LuaProfileModule ProfileModule { get; private set; }
|
||||
public LuaEventsModule EventsModule { get; private set; }
|
||||
public Script LuaScript { get; }
|
||||
public ObservableCollection<EditorButton> EditorButtons { get; set; }
|
||||
|
||||
public void SetupLua(ProfileModel profileModel)
|
||||
{
|
||||
_logger.Debug("Setting up LUA for profile '{0}', module '{1}'", profileModel?.Name, profileModel?.GameName);
|
||||
// Clear old state
|
||||
ClearLua();
|
||||
|
||||
// Stop after that if no model provided/there is no keyboard
|
||||
if (profileModel == null || _deviceManager.ActiveKeyboard == null)
|
||||
return;
|
||||
|
||||
ProfileModel = profileModel;
|
||||
KeyboardProvider = _deviceManager.ActiveKeyboard;
|
||||
|
||||
// Get new instances of all modules
|
||||
_luaModules = _kernel.Get<List<LuaModule>>();
|
||||
ProfileModule = (LuaProfileModule) _luaModules.First(m => m.ModuleName == "Profile");
|
||||
EventsModule = (LuaEventsModule) _luaModules.First(m => m.ModuleName == "Events");
|
||||
|
||||
// Setup new state
|
||||
LuaScript.Options.DebugPrint = LuaPrint;
|
||||
|
||||
// Insert each module with a ModuleName into the script's globals
|
||||
foreach (var luaModule in _luaModules.Where(m => m.ModuleName != null))
|
||||
LuaScript.Globals[luaModule.ModuleName] = luaModule;
|
||||
|
||||
// If there is no LUA script, don't bother executing the string
|
||||
if (string.IsNullOrEmpty(ProfileModel.LuaScript))
|
||||
return;
|
||||
|
||||
try
|
||||
{
|
||||
lock (EventsModule.InvokeLock)
|
||||
{
|
||||
lock (LuaScript)
|
||||
{
|
||||
LuaScript.DoString(ProfileModel.LuaScript);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (InternalErrorException e)
|
||||
{
|
||||
_logger.Error("[{0}-LUA]: Error: {1}", ProfileModel.Name, e.DecoratedMessage);
|
||||
}
|
||||
catch (SyntaxErrorException e)
|
||||
{
|
||||
_logger.Error("[{0}-LUA]: Error: {1}", ProfileModel.Name, e.DecoratedMessage);
|
||||
}
|
||||
catch (ScriptRuntimeException e)
|
||||
{
|
||||
_logger.Error("[{0}-LUA]: Error: {1}", ProfileModel.Name, e.DecoratedMessage);
|
||||
}
|
||||
}
|
||||
|
||||
public void ClearLua()
|
||||
{
|
||||
if (_luaModules != null)
|
||||
{
|
||||
foreach (var luaModule in _luaModules)
|
||||
luaModule.Dispose();
|
||||
_luaModules.Clear();
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
LuaScript.Globals.Clear();
|
||||
LuaScript.Registry.Clear();
|
||||
LuaScript.Registry.RegisterConstants();
|
||||
LuaScript.Registry.RegisterCoreModules(CoreModules.Preset_SoftSandbox);
|
||||
LuaScript.Globals.RegisterConstants();
|
||||
LuaScript.Globals.RegisterCoreModules(CoreModules.Preset_SoftSandbox);
|
||||
}
|
||||
catch (NullReferenceException)
|
||||
{
|
||||
// TODO: Ask MoonSharp folks why this is happening
|
||||
}
|
||||
|
||||
if (EventsModule != null)
|
||||
lock (EventsModule.InvokeLock)
|
||||
{
|
||||
lock (LuaScript)
|
||||
{
|
||||
LuaScript.DoString("");
|
||||
}
|
||||
}
|
||||
else
|
||||
lock (LuaScript)
|
||||
{
|
||||
LuaScript.DoString("");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Safely call a function on the active script
|
||||
/// </summary>
|
||||
/// <param name="function"></param>
|
||||
/// <param name="args"></param>
|
||||
public void Call(DynValue function, DynValue[] args = null)
|
||||
{
|
||||
if (EventsModule == null)
|
||||
return;
|
||||
|
||||
try
|
||||
{
|
||||
lock (EventsModule.InvokeLock)
|
||||
{
|
||||
lock (LuaScript)
|
||||
{
|
||||
if (args != null)
|
||||
LuaScript.Call(function, args);
|
||||
else
|
||||
LuaScript.Call(function);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (ArgumentException e)
|
||||
{
|
||||
_logger.Error("[{0}-LUA]: Error: {1}", ProfileModel.Name, e.Message);
|
||||
}
|
||||
catch (InternalErrorException e)
|
||||
{
|
||||
_logger.Error("[{0}-LUA]: Error: {1}", ProfileModel.Name, e.DecoratedMessage);
|
||||
}
|
||||
catch (SyntaxErrorException e)
|
||||
{
|
||||
_logger.Error("[{0}-LUA]: Error: {1}", ProfileModel.Name, e.DecoratedMessage);
|
||||
}
|
||||
catch (ScriptRuntimeException e)
|
||||
{
|
||||
_logger.Error("[{0}-LUA]: Error: {1}", ProfileModel.Name, e.DecoratedMessage);
|
||||
}
|
||||
}
|
||||
|
||||
#region Private lua functions
|
||||
|
||||
private void LuaPrint(string s)
|
||||
{
|
||||
_logger.Info("[{0}-LUA]: {1}", ProfileModel?.Name, s);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@ -1,181 +0,0 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Threading.Tasks;
|
||||
using System.Timers;
|
||||
using Artemis.Events;
|
||||
using Artemis.Utilities;
|
||||
using Artemis.Utilities.DataReaders;
|
||||
using Artemis.Utilities.GameState;
|
||||
using Artemis.ViewModels;
|
||||
using Microsoft.Win32;
|
||||
using Ninject;
|
||||
using Ninject.Extensions.Logging;
|
||||
|
||||
namespace Artemis.Managers
|
||||
{
|
||||
/// <summary>
|
||||
/// Contains all the other managers and non-loop related components
|
||||
/// </summary>
|
||||
public class MainManager : IDisposable
|
||||
{
|
||||
private readonly MigrationManager _migrationManager;
|
||||
private readonly Timer _processTimer;
|
||||
|
||||
public MainManager(ILogger logger, LoopManager loopManager, DeviceManager deviceManager,
|
||||
ModuleManager moduleManager, PreviewManager previewManager, MigrationManager migrationManager,
|
||||
PipeServer pipeServer, GameStateWebServer gameStateWebServer)
|
||||
{
|
||||
_migrationManager = migrationManager;
|
||||
Logger = logger;
|
||||
LoopManager = loopManager;
|
||||
DeviceManager = deviceManager;
|
||||
ModuleManager = moduleManager;
|
||||
PreviewManager = previewManager;
|
||||
PipeServer = pipeServer;
|
||||
|
||||
_processTimer = new Timer(1000);
|
||||
_processTimer.Elapsed += ScanProcesses;
|
||||
_processTimer.Start();
|
||||
|
||||
ProgramEnabled = false;
|
||||
|
||||
// Create and start the web server
|
||||
GameStateWebServer = gameStateWebServer;
|
||||
GameStateWebServer.Start();
|
||||
|
||||
// Start the named pipe
|
||||
PipeServer.Start("artemis");
|
||||
|
||||
// Listen for power mode changes
|
||||
SystemEvents.PowerModeChanged += OnPowerChange;
|
||||
|
||||
Logger.Info("Intialized MainManager");
|
||||
Logger.Info($"Artemis version {Assembly.GetExecutingAssembly().GetName().Version} is ready!");
|
||||
}
|
||||
|
||||
[Inject]
|
||||
public Lazy<ShellViewModel> ShellViewModel { get; set; }
|
||||
|
||||
public ILogger Logger { get; set; }
|
||||
public LoopManager LoopManager { get; }
|
||||
public DeviceManager DeviceManager { get; set; }
|
||||
public ModuleManager ModuleManager { get; set; }
|
||||
public PreviewManager PreviewManager { get; set; }
|
||||
|
||||
public PipeServer PipeServer { get; set; }
|
||||
public GameStateWebServer GameStateWebServer { get; set; }
|
||||
public bool ProgramEnabled { get; private set; }
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Logger.Debug("Shutting down MainManager");
|
||||
|
||||
_processTimer?.Stop();
|
||||
_processTimer?.Dispose();
|
||||
LoopManager?.Stop();
|
||||
ModuleManager?.ActiveModule?.Dispose();
|
||||
GameStateWebServer?.Stop();
|
||||
PipeServer?.Stop();
|
||||
}
|
||||
|
||||
public event EventHandler<EnabledChangedEventArgs> EnabledChanged;
|
||||
|
||||
/// <summary>
|
||||
/// Restarts the loop manager when the system resumes
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private async void OnPowerChange(object sender, PowerModeChangedEventArgs e)
|
||||
{
|
||||
if (e.Mode != PowerModes.Resume)
|
||||
return;
|
||||
|
||||
Logger.Debug("Restarting for OnPowerChange");
|
||||
DisableProgram();
|
||||
// Wait an extra while for device providers to be fully ready
|
||||
await Task.Delay(2000);
|
||||
EnableProgram();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Loads the last active effect and starts the program
|
||||
/// </summary>
|
||||
public async void EnableProgram()
|
||||
{
|
||||
Logger.Debug("Enabling program");
|
||||
|
||||
ProgramEnabled = true;
|
||||
await LoopManager.StartAsync();
|
||||
|
||||
_migrationManager.MigrateProfiles();
|
||||
RaiseEnabledChangedEvent(new EnabledChangedEventArgs(ProgramEnabled));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Stops the program
|
||||
/// </summary>
|
||||
public void DisableProgram()
|
||||
{
|
||||
Logger.Debug("Disabling program");
|
||||
|
||||
foreach (var overlayModule in ModuleManager.OverlayModules)
|
||||
{
|
||||
if (overlayModule.Settings.IsEnabled)
|
||||
overlayModule.Dispose();
|
||||
}
|
||||
LoopManager.Stop();
|
||||
ProgramEnabled = false;
|
||||
RaiseEnabledChangedEvent(new EnabledChangedEventArgs(ProgramEnabled));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Manages active process bound modules by keeping an eye on their processes
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void ScanProcesses(object sender, ElapsedEventArgs e)
|
||||
{
|
||||
if (!ProgramEnabled)
|
||||
return;
|
||||
|
||||
var processes = System.Diagnostics.Process.GetProcesses();
|
||||
var module = ModuleManager.ActiveModule;
|
||||
|
||||
// If the current active module is in preview-mode, leave it alone
|
||||
if (module?.PreviewLayers != null)
|
||||
return;
|
||||
|
||||
// If the active module is a process bound module, make sure it should still be enabled
|
||||
if (module != null && module.IsBoundToProcess)
|
||||
{
|
||||
if (!module.Settings.IsEnabled)
|
||||
ModuleManager.DisableProcessBoundModule();
|
||||
|
||||
// If the currently active effect is a no longer running game, get rid of it.
|
||||
if (!processes.Any(p => module.ProcessNames.Contains(p.ProcessName) && !p.HasExited))
|
||||
{
|
||||
Logger.Info("Disabling process bound module because process stopped: {0}", module.Name);
|
||||
ModuleManager.DisableProcessBoundModule();
|
||||
}
|
||||
}
|
||||
|
||||
// Look for running games, stopping on the first one that's found.
|
||||
var newModule = ModuleManager.ProcessModules.Where(g => g.Settings.IsEnabled && g.Settings.IsEnabled)
|
||||
.FirstOrDefault(g => processes.Any(p => g.ProcessNames.Contains(p.ProcessName) && !p.HasExited));
|
||||
|
||||
if (newModule == null || module == newModule)
|
||||
return;
|
||||
|
||||
// If it's not already enabled, do so.
|
||||
Logger.Info("Detected and enabling process bound module: {0}", newModule.Name);
|
||||
ModuleManager.ChangeActiveModule(newModule, LoopManager);
|
||||
}
|
||||
|
||||
protected virtual void RaiseEnabledChangedEvent(EnabledChangedEventArgs e)
|
||||
{
|
||||
var handler = EnabledChanged;
|
||||
handler?.Invoke(this, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,40 +0,0 @@
|
||||
using System.IO;
|
||||
using Artemis.DAL;
|
||||
|
||||
namespace Artemis.Managers
|
||||
{
|
||||
public class MigrationManager
|
||||
{
|
||||
private readonly DeviceManager _deviceManager;
|
||||
|
||||
public MigrationManager(DeviceManager deviceManager)
|
||||
{
|
||||
_deviceManager = deviceManager;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Migrates old versions of profiles to new versions
|
||||
/// </summary>
|
||||
public void MigrateProfiles()
|
||||
{
|
||||
// 1.8.0.0 - Rename WindowsProfile to GeneralProfile
|
||||
foreach (var keyboardProvider in _deviceManager.KeyboardProviders)
|
||||
{
|
||||
var folder = ProfileProvider.ProfileFolder + "/" + keyboardProvider.Slug + "/WindowsProfile";
|
||||
if (!Directory.Exists(folder))
|
||||
continue;
|
||||
|
||||
// Get all the profiles
|
||||
var profiles = ProfileProvider.ReadProfiles(keyboardProvider.Slug + "/WindowsProfile");
|
||||
foreach (var profile in profiles)
|
||||
{
|
||||
// Change their GameName and save, effectively moving them to the new folder
|
||||
profile.GameName = "GeneralProfile";
|
||||
ProfileProvider.AddOrUpdate(profile);
|
||||
}
|
||||
// Delete the old profiles
|
||||
Directory.Delete(folder, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,191 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Artemis.Events;
|
||||
using Artemis.Modules.Abstract;
|
||||
using Artemis.Settings;
|
||||
using Ninject.Extensions.Logging;
|
||||
|
||||
namespace Artemis.Managers
|
||||
{
|
||||
public class ModuleManager
|
||||
{
|
||||
private readonly DeviceManager _deviceManager;
|
||||
private readonly ILogger _logger;
|
||||
private LoopManager _waitLoopManager;
|
||||
private ModuleModel _waitEffect;
|
||||
private readonly GeneralSettings _generalSettings;
|
||||
|
||||
public ModuleManager(ILogger logger, DeviceManager deviceManager, List<ModuleModel> moduleModels)
|
||||
{
|
||||
_generalSettings = DAL.SettingsProvider.Load<GeneralSettings>();
|
||||
_logger = logger;
|
||||
_deviceManager = deviceManager;
|
||||
|
||||
Modules = new List<ModuleModel>(moduleModels.Where(m => !m.IsOverlay && !m.IsBoundToProcess));
|
||||
OverlayModules = new List<ModuleModel>(moduleModels.Where(m => m.IsOverlay));
|
||||
ProcessModules = new List<ModuleModel>(moduleModels.Where(m => m.IsBoundToProcess));
|
||||
|
||||
_logger.Info("Intialized ModuleManager");
|
||||
}
|
||||
|
||||
public List<ModuleModel> Modules { get; set; }
|
||||
public List<ModuleModel> ProcessModules { get; set; }
|
||||
public List<ModuleModel> OverlayModules { get; set; }
|
||||
public ModuleModel ActiveModule { get; private set; }
|
||||
|
||||
public event EventHandler<ModuleChangedEventArgs> EffectChanged;
|
||||
|
||||
/// <summary>
|
||||
/// Loads the last active module from settings and enables it.
|
||||
/// </summary>
|
||||
public ModuleModel GetLastModule()
|
||||
{
|
||||
_logger.Debug("Getting last module: {0}", _generalSettings.LastModule);
|
||||
|
||||
if (_generalSettings.LastModule != null)
|
||||
{
|
||||
var lastModule = Modules.FirstOrDefault(e => e.Name == _generalSettings.LastModule);
|
||||
if (lastModule != null)
|
||||
return lastModule;
|
||||
}
|
||||
|
||||
_logger.Debug("Getting last module not found, defaulting to GeneralProfile");
|
||||
return Modules.First(e => e.Name == "GeneralProfile");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Disables the current module and changes it to the provided module.
|
||||
/// </summary>
|
||||
/// <param name="moduleModel">The module to activate</param>
|
||||
/// <param name="loopManager">Optionally pass the LoopManager to automatically start it, if it's not running.</param>
|
||||
/// <param name="storeAsLast">Whether or not to store this effect as the last effect</param>
|
||||
public void ChangeActiveModule(ModuleModel moduleModel, LoopManager loopManager = null, bool storeAsLast = true)
|
||||
{
|
||||
if (_waitEffect != null)
|
||||
{
|
||||
_logger.Debug("Stopping module change because a change is already queued");
|
||||
return;
|
||||
}
|
||||
|
||||
if (moduleModel == null)
|
||||
throw new ArgumentNullException(nameof(moduleModel));
|
||||
|
||||
if (_deviceManager.ActiveKeyboard == null)
|
||||
{
|
||||
_logger.Debug("Stopping module change until keyboard is enabled");
|
||||
_waitEffect = moduleModel;
|
||||
_waitLoopManager = loopManager;
|
||||
_deviceManager.OnKeyboardChanged += DeviceManagerOnOnKeyboardChanged;
|
||||
_deviceManager.EnableLastKeyboard();
|
||||
return;
|
||||
}
|
||||
|
||||
// Process bound modules are only used if they are enabled
|
||||
if (moduleModel.Settings != null && !moduleModel.Settings.IsEnabled && moduleModel.IsBoundToProcess)
|
||||
{
|
||||
_logger.Debug("Cancelling module change, provided module is process bound and not enabled");
|
||||
return;
|
||||
}
|
||||
|
||||
var wasNull = false;
|
||||
if (ActiveModule == null)
|
||||
{
|
||||
wasNull = true;
|
||||
ActiveModule = moduleModel;
|
||||
}
|
||||
|
||||
lock (ActiveModule)
|
||||
{
|
||||
if (!wasNull)
|
||||
ActiveModule.Dispose();
|
||||
lock (moduleModel)
|
||||
{
|
||||
ActiveModule = moduleModel;
|
||||
ActiveModule.Enable();
|
||||
if (!ActiveModule.IsInitialized)
|
||||
{
|
||||
_logger.Debug("Cancelling module change, couldn't initialize the module ({0})", moduleModel.Name);
|
||||
ActiveModule = null;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (loopManager != null && !loopManager.Running)
|
||||
{
|
||||
_logger.Debug("Starting LoopManager for module change");
|
||||
loopManager.StartAsync();
|
||||
}
|
||||
|
||||
if (!ActiveModule.IsBoundToProcess && !ActiveModule.IsOverlay && storeAsLast)
|
||||
{
|
||||
_generalSettings.LastModule = ActiveModule?.Name;
|
||||
_generalSettings.Save();
|
||||
}
|
||||
|
||||
_logger.Debug("Changed active module to: {0}", moduleModel.Name);
|
||||
RaiseEffectChangedEvent(new ModuleChangedEventArgs(moduleModel));
|
||||
}
|
||||
|
||||
private void DeviceManagerOnOnKeyboardChanged(object sender, KeyboardChangedEventArgs e)
|
||||
{
|
||||
_deviceManager.OnKeyboardChanged -= DeviceManagerOnOnKeyboardChanged;
|
||||
_logger.Debug("Resuming module change");
|
||||
|
||||
var module = _waitEffect;
|
||||
_waitEffect = null;
|
||||
var loopManager = _waitLoopManager;
|
||||
_waitLoopManager = null;
|
||||
|
||||
ChangeActiveModule(module, loopManager);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Clears the current module
|
||||
/// </summary>
|
||||
public void ClearActiveModule()
|
||||
{
|
||||
if (ActiveModule == null)
|
||||
return;
|
||||
|
||||
lock (ActiveModule)
|
||||
{
|
||||
ActiveModule.Dispose();
|
||||
ActiveModule = null;
|
||||
|
||||
_generalSettings.LastModule = null;
|
||||
_generalSettings.Save();
|
||||
}
|
||||
|
||||
_logger.Debug("Cleared active module");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Disables the currently active process bound module
|
||||
/// </summary>
|
||||
public void DisableProcessBoundModule()
|
||||
{
|
||||
if (ActiveModule == null)
|
||||
return;
|
||||
if (!ActiveModule.IsBoundToProcess)
|
||||
{
|
||||
_logger.Warn("Active module {0} is not process bound but is being disabled as if it is.",
|
||||
ActiveModule.Name);
|
||||
return;
|
||||
}
|
||||
|
||||
var lastModule = GetLastModule();
|
||||
if (lastModule == null || !lastModule.Settings.IsEnabled)
|
||||
ClearActiveModule();
|
||||
else
|
||||
ChangeActiveModule(lastModule);
|
||||
}
|
||||
|
||||
protected virtual void RaiseEffectChangedEvent(ModuleChangedEventArgs e)
|
||||
{
|
||||
var handler = EffectChanged;
|
||||
handler?.Invoke(this, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,91 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Timers;
|
||||
using Artemis.DAL;
|
||||
using Artemis.Modules.Abstract;
|
||||
using Artemis.Settings;
|
||||
using Artemis.Utilities;
|
||||
using Artemis.Utilities.ActiveWindowDetection;
|
||||
using Ninject.Extensions.Logging;
|
||||
|
||||
namespace Artemis.Managers
|
||||
{
|
||||
public class PreviewManager
|
||||
{
|
||||
private readonly DeviceManager _deviceManager;
|
||||
private readonly GeneralSettings _generalSettings;
|
||||
private readonly ILogger _logger;
|
||||
private readonly LoopManager _loopManager;
|
||||
private readonly ModuleManager _moduleManager;
|
||||
|
||||
public PreviewManager(ILogger logger, ModuleManager moduleManager, DeviceManager deviceManager,
|
||||
LoopManager loopManager)
|
||||
{
|
||||
_logger = logger;
|
||||
_moduleManager = moduleManager;
|
||||
_deviceManager = deviceManager;
|
||||
_loopManager = loopManager;
|
||||
_generalSettings = SettingsProvider.Load<GeneralSettings>();
|
||||
|
||||
PreviewViewModules = new List<ModuleViewModel>();
|
||||
|
||||
var profilePreviewTimer = new Timer(500);
|
||||
profilePreviewTimer.Elapsed += SetupProfilePreview;
|
||||
profilePreviewTimer.Start();
|
||||
|
||||
_logger.Info("Intialized PreviewManager");
|
||||
}
|
||||
|
||||
public List<ModuleViewModel> PreviewViewModules { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Keeps track of profiles being previewed and sets up the active efffect accordingly
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void SetupProfilePreview(object sender, ElapsedEventArgs e)
|
||||
{
|
||||
if (string.IsNullOrEmpty(_generalSettings.LastKeyboard) || _deviceManager.ChangingKeyboard)
|
||||
return;
|
||||
|
||||
// If Artemis doesn't have focus, don't preview unless overwritten by KeepActive
|
||||
var activePreview = PreviewViewModules.FirstOrDefault(vm => (vm.IsActive || vm.ProfileEditor.KeepActive) && vm.UsesProfileEditor && vm.ModuleModel.Settings.IsEnabled);
|
||||
if (activePreview != null && (activePreview.ProfileEditor.KeepActive || ActiveWindowHelper.MainWindowActive))
|
||||
EnsurePreviewActive(activePreview);
|
||||
else
|
||||
EnsurePreviewInactive();
|
||||
}
|
||||
|
||||
private void EnsurePreviewActive(ModuleViewModel toBeActive)
|
||||
{
|
||||
// If the current module is the same as what should be active, don't do anything
|
||||
if (_moduleManager.ActiveModule != null && _moduleManager.ActiveModule == toBeActive.ModuleModel)
|
||||
return;
|
||||
|
||||
_logger.Debug("Activate profile preview");
|
||||
_moduleManager.ChangeActiveModule(toBeActive.ModuleModel, null, false);
|
||||
|
||||
// LoopManager might be running, this method won't do any harm in that case.
|
||||
_loopManager.StartAsync();
|
||||
}
|
||||
|
||||
private void EnsurePreviewInactive()
|
||||
{
|
||||
// Check if the active module is being previewed, if so, that should no longer be happening
|
||||
if (_moduleManager.ActiveModule?.PreviewLayers == null)
|
||||
return;
|
||||
|
||||
_logger.Debug("Deactivate profile preview");
|
||||
|
||||
// Save the profile the editor was using
|
||||
var activePreview = PreviewViewModules.FirstOrDefault(p => p.IsModuleActive);
|
||||
activePreview?.ProfileEditor?.SaveSelectedProfile();
|
||||
|
||||
var lastModule = _moduleManager.GetLastModule();
|
||||
if (lastModule != null && lastModule.Settings.IsEnabled)
|
||||
_moduleManager.ChangeActiveModule(lastModule);
|
||||
else
|
||||
_moduleManager.ClearActiveModule();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,74 +0,0 @@
|
||||
using System.Drawing;
|
||||
using System.Windows;
|
||||
using System.Windows.Media;
|
||||
using Artemis.DeviceProviders;
|
||||
using Artemis.Profiles.Layers.Interfaces;
|
||||
using Color = System.Drawing.Color;
|
||||
|
||||
namespace Artemis.Models
|
||||
{
|
||||
public class DeviceVisualModel : DrawingVisual
|
||||
{
|
||||
private readonly int _x;
|
||||
private readonly KeyboardProvider _keyboard;
|
||||
private DrawingContext _ctx;
|
||||
|
||||
public DeviceVisualModel(DrawType drawType, int x)
|
||||
{
|
||||
_x = x;
|
||||
|
||||
DrawType = drawType;
|
||||
VisualBitmapScalingMode = BitmapScalingMode.LowQuality;
|
||||
}
|
||||
|
||||
public DeviceVisualModel(KeyboardProvider keyboard, int x)
|
||||
{
|
||||
_x = x;
|
||||
_keyboard = keyboard;
|
||||
|
||||
DrawType = DrawType.Keyboard;
|
||||
VisualBitmapScalingMode = BitmapScalingMode.LowQuality;
|
||||
}
|
||||
|
||||
public DrawType DrawType { get; }
|
||||
|
||||
public Rect RelativeRect => DrawType == DrawType.Keyboard
|
||||
? new Rect(_x, 0, _keyboard.Width * 4, _keyboard.Height * 4)
|
||||
: new Rect(_x, 0, 20, 20);
|
||||
|
||||
public Rect Rect => DrawType == DrawType.Keyboard
|
||||
? new Rect(0, 0, _keyboard.Width * 4, _keyboard.Height * 4)
|
||||
: new Rect(0, 0, 20, 20);
|
||||
|
||||
public Rectangle RelativeRectangle => DrawType == DrawType.Keyboard
|
||||
? new Rectangle(_x, 0, _keyboard.Width * 4, _keyboard.Height * 4)
|
||||
: new Rectangle(_x, 0, 20, 20);
|
||||
|
||||
public Bitmap GetBitmapFromFrame(Bitmap frame)
|
||||
{
|
||||
var bitmap = DrawType == DrawType.Keyboard
|
||||
? new Bitmap(_keyboard.Width * 4, _keyboard.Height * 4)
|
||||
: new Bitmap(20, 20);
|
||||
bitmap.SetResolution(96, 96);
|
||||
|
||||
using (var g = Graphics.FromImage(bitmap))
|
||||
{
|
||||
g.Clear(Color.Black);
|
||||
g.DrawImage(frame, new Rectangle(0, 0, bitmap.Width, bitmap.Height), RelativeRectangle, GraphicsUnit.Pixel);
|
||||
}
|
||||
|
||||
return bitmap;
|
||||
}
|
||||
|
||||
public DrawingContext GetDrawingContext()
|
||||
{
|
||||
return _ctx ?? (_ctx = RenderOpen());
|
||||
}
|
||||
|
||||
public void CloseDrawingContext()
|
||||
{
|
||||
_ctx?.Close();
|
||||
_ctx = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,122 +0,0 @@
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Windows;
|
||||
using System.Windows.Media;
|
||||
using Artemis.DeviceProviders;
|
||||
using Artemis.Profiles.Layers.Interfaces;
|
||||
using Artemis.Utilities;
|
||||
using Color = System.Windows.Media.Color;
|
||||
using Pen = System.Windows.Media.Pen;
|
||||
|
||||
namespace Artemis.Models
|
||||
{
|
||||
public class FrameModel : IDisposable
|
||||
{
|
||||
private readonly Rect _rect;
|
||||
|
||||
public FrameModel(KeyboardProvider keyboard, bool renderMice, bool renderHeadsets, bool renderGenerics,
|
||||
bool renderMousemats)
|
||||
{
|
||||
if (keyboard == null)
|
||||
return;
|
||||
|
||||
// Setup bitmaps
|
||||
var x = 0;
|
||||
if (renderMice)
|
||||
{
|
||||
MouseModel = new DeviceVisualModel(DrawType.Mouse, x);
|
||||
x += 20;
|
||||
}
|
||||
if (renderHeadsets)
|
||||
{
|
||||
HeadsetModel = new DeviceVisualModel(DrawType.Headset, x);
|
||||
x += 20;
|
||||
}
|
||||
if (renderGenerics)
|
||||
{
|
||||
GenericModel = new DeviceVisualModel(DrawType.Generic, x);
|
||||
x += 20;
|
||||
}
|
||||
if (renderMousemats)
|
||||
{
|
||||
MousematModel = new DeviceVisualModel(DrawType.Mousemat, x);
|
||||
x += 20;
|
||||
}
|
||||
|
||||
KeyboardModel = new DeviceVisualModel(keyboard, x);
|
||||
|
||||
// If not rendering anything but keyboard, use keyboard height, else default to 40
|
||||
var height = 20;
|
||||
if (keyboard.Height * 4 > height)
|
||||
height = keyboard.Height * 4;
|
||||
_rect = new Rect(0, 0, x + keyboard.Width * 4, height);
|
||||
}
|
||||
|
||||
public DeviceVisualModel MouseModel { get; }
|
||||
public DeviceVisualModel HeadsetModel { get; }
|
||||
public DeviceVisualModel GenericModel { get; }
|
||||
public DeviceVisualModel MousematModel { get; }
|
||||
public DeviceVisualModel KeyboardModel { get; }
|
||||
|
||||
public Bitmap KeyboardBitmap { get; private set; }
|
||||
public Bitmap MouseBitmap { get; private set; }
|
||||
public Bitmap HeadsetBitmap { get; private set; }
|
||||
public Bitmap GenericBitmap { get; private set; }
|
||||
public Bitmap MousematBitmap { get; private set; }
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
KeyboardBitmap?.Dispose();
|
||||
MouseBitmap?.Dispose();
|
||||
HeadsetBitmap?.Dispose();
|
||||
GenericBitmap?.Dispose();
|
||||
MousematBitmap?.Dispose();
|
||||
}
|
||||
|
||||
public void RenderBitmaps()
|
||||
{
|
||||
var visual = new DrawingVisual();
|
||||
using (var c = visual.RenderOpen())
|
||||
{
|
||||
c.PushClip(new RectangleGeometry(_rect));
|
||||
c.DrawRectangle(new SolidColorBrush(Color.FromArgb(0, 0, 0, 0)), null, _rect);
|
||||
|
||||
if (MouseModel != null)
|
||||
{
|
||||
MouseModel.CloseDrawingContext();
|
||||
c.DrawRectangle(new VisualBrush(MouseModel), new Pen(), MouseModel.RelativeRect);
|
||||
}
|
||||
if (HeadsetModel != null)
|
||||
{
|
||||
HeadsetModel.CloseDrawingContext();
|
||||
c.DrawRectangle(new VisualBrush(HeadsetModel), new Pen(), HeadsetModel.RelativeRect);
|
||||
}
|
||||
if (GenericModel != null)
|
||||
{
|
||||
GenericModel.CloseDrawingContext();
|
||||
c.DrawRectangle(new VisualBrush(GenericModel), new Pen(), GenericModel.RelativeRect);
|
||||
}
|
||||
if (MousematModel != null)
|
||||
{
|
||||
MousematModel.CloseDrawingContext();
|
||||
c.DrawRectangle(new VisualBrush(MousematModel), new Pen(), MousematModel.RelativeRect);
|
||||
}
|
||||
KeyboardModel.CloseDrawingContext();
|
||||
c.DrawRectangle(new VisualBrush(KeyboardModel), new Pen(), KeyboardModel.RelativeRect);
|
||||
|
||||
c.Pop();
|
||||
}
|
||||
|
||||
var frameBitmap = ImageUtilities.DrawingVisualToBitmap(visual, _rect);
|
||||
if (MouseModel != null)
|
||||
MouseBitmap = MouseModel.GetBitmapFromFrame(frameBitmap);
|
||||
if (HeadsetModel != null)
|
||||
HeadsetBitmap = HeadsetModel.GetBitmapFromFrame(frameBitmap);
|
||||
if (GenericModel != null)
|
||||
GenericBitmap = GenericModel.GetBitmapFromFrame(frameBitmap);
|
||||
if (MousematModel != null)
|
||||
MousematBitmap = MousematModel.GetBitmapFromFrame(frameBitmap);
|
||||
KeyboardBitmap = KeyboardModel.GetBitmapFromFrame(frameBitmap);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,55 +0,0 @@
|
||||
using System;
|
||||
using System.Windows.Forms;
|
||||
using MahApps.Metro.Controls;
|
||||
|
||||
namespace Artemis.Models
|
||||
{
|
||||
public class KeybindModel
|
||||
{
|
||||
public KeybindModel(string name, HotKey hotKey, PressType pressType, Action action)
|
||||
{
|
||||
Name = name;
|
||||
HotKey = hotKey;
|
||||
PressType = pressType;
|
||||
Action = action;
|
||||
}
|
||||
|
||||
public KeybindModel(string name, MouseButtons mouseButtons, PressType pressType, Action action)
|
||||
{
|
||||
Name = name;
|
||||
MouseButtons = mouseButtons;
|
||||
PressType = pressType;
|
||||
Action = action;
|
||||
}
|
||||
|
||||
public string Name { get; set; }
|
||||
public HotKey HotKey { get; set; }
|
||||
public MouseButtons? MouseButtons { get; }
|
||||
public PressType PressType { get; set; }
|
||||
public Action Action { get; set; }
|
||||
|
||||
public void InvokeIfMatched(HotKey hotKey, PressType pressType)
|
||||
{
|
||||
if (HotKey == null || hotKey == null || PressType != pressType)
|
||||
return;
|
||||
|
||||
if (hotKey.Equals(HotKey))
|
||||
Action?.Invoke();
|
||||
}
|
||||
|
||||
public void InvokeIfMatched(MouseButtons mouseButtons, PressType pressType)
|
||||
{
|
||||
if (PressType != pressType)
|
||||
return;
|
||||
|
||||
if (mouseButtons.Equals(MouseButtons))
|
||||
Action?.Invoke();
|
||||
}
|
||||
}
|
||||
|
||||
public enum PressType
|
||||
{
|
||||
Down,
|
||||
Up
|
||||
}
|
||||
}
|
||||
@ -1,12 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Artemis.Models
|
||||
{
|
||||
public class LayerEditorModel
|
||||
{
|
||||
}
|
||||
}
|
||||
@ -1,370 +0,0 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using Artemis.DAL;
|
||||
using Artemis.Managers;
|
||||
using Artemis.Modules.Abstract;
|
||||
using Artemis.Profiles;
|
||||
using Artemis.Profiles.Layers.Models;
|
||||
using Artemis.Profiles.Layers.Types.Folder;
|
||||
using Artemis.Properties;
|
||||
using Artemis.Services;
|
||||
using Artemis.Utilities;
|
||||
using Artemis.ViewModels;
|
||||
using Ninject.Parameters;
|
||||
|
||||
namespace Artemis.Models
|
||||
{
|
||||
public class ProfileEditorModel : IDisposable
|
||||
{
|
||||
private readonly DeviceManager _deviceManager;
|
||||
private readonly LuaManager _luaManager;
|
||||
private readonly DialogService _dialogService;
|
||||
private readonly WindowService _windowService;
|
||||
private FileSystemWatcher _watcher;
|
||||
private ModuleModel _luaModule;
|
||||
private ProfileModel _luaEditorProfile;
|
||||
|
||||
public ProfileEditorModel(WindowService windowService, MetroDialogService dialogService, DeviceManager deviceManager, LuaManager luaManager)
|
||||
{
|
||||
_windowService = windowService;
|
||||
_dialogService = dialogService;
|
||||
_deviceManager = deviceManager;
|
||||
_luaManager = luaManager;
|
||||
}
|
||||
|
||||
#region Layers
|
||||
|
||||
/// <summary>
|
||||
/// Opens a new LayerEditorView for the given layer
|
||||
/// </summary>
|
||||
/// <param name="layer">The layer to open the view for</param>
|
||||
/// <param name="dataModel">The datamodel to bind the editor to</param>
|
||||
public void EditLayer(LayerModel layer, ModuleDataModel dataModel)
|
||||
{
|
||||
IParameter[] args =
|
||||
{
|
||||
new ConstructorArgument("dataModel", dataModel),
|
||||
new ConstructorArgument("layer", layer)
|
||||
};
|
||||
_windowService.ShowDialog<LayerEditorViewModel>("Artemis | Edit layer", null, args);
|
||||
|
||||
// If the layer was a folder, but isn't anymore, assign it's children to it's parent.
|
||||
if (layer.LayerType is FolderType || !layer.Children.Any())
|
||||
return;
|
||||
|
||||
while (layer.Children.Any())
|
||||
{
|
||||
var child = layer.Children[0];
|
||||
layer.Children.Remove(child);
|
||||
if (layer.Parent != null)
|
||||
{
|
||||
layer.Parent.Children.Add(child);
|
||||
layer.Parent.FixOrder();
|
||||
}
|
||||
else
|
||||
{
|
||||
layer.Profile.Layers.Add(child);
|
||||
layer.Profile.FixOrder();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes the given layer from the profile
|
||||
/// </summary>
|
||||
/// <param name="layer">The layer to remove</param>
|
||||
/// <param name="profileModel">The profile to remove it from</param>
|
||||
public void RemoveLayer(LayerModel layer, ProfileModel profileModel)
|
||||
{
|
||||
if (layer == null)
|
||||
return;
|
||||
|
||||
if (layer.Parent != null)
|
||||
{
|
||||
var parent = layer.Parent;
|
||||
layer.Parent.Children.Remove(layer);
|
||||
parent.FixOrder();
|
||||
}
|
||||
else if (layer.Profile != null)
|
||||
{
|
||||
var profile = layer.Profile;
|
||||
layer.Profile.Layers.Remove(layer);
|
||||
profile.FixOrder();
|
||||
}
|
||||
|
||||
// Extra cleanup in case of a wonky layer that has no parent
|
||||
if (profileModel.Layers.Contains(layer))
|
||||
profileModel.Layers.Remove(layer);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Profiles
|
||||
|
||||
public async Task<ProfileModel> AddProfile(ModuleModel moduleModel)
|
||||
{
|
||||
if (_deviceManager.ActiveKeyboard == null)
|
||||
{
|
||||
_dialogService.ShowMessageBox("Cannot add profile.",
|
||||
"To add a profile, please select a keyboard in the options menu first.");
|
||||
return null;
|
||||
}
|
||||
|
||||
var name = await GetValidProfileName("Name profile", "Please enter a unique name for your new profile");
|
||||
// User cancelled
|
||||
if (name == null)
|
||||
return null;
|
||||
|
||||
var profile = new ProfileModel
|
||||
{
|
||||
Name = name,
|
||||
KeyboardSlug = _deviceManager.ActiveKeyboard.Slug,
|
||||
Width = _deviceManager.ActiveKeyboard.Width,
|
||||
Height = _deviceManager.ActiveKeyboard.Height,
|
||||
GameName = moduleModel.Name
|
||||
};
|
||||
|
||||
if (!ProfileProvider.IsProfileUnique(profile))
|
||||
{
|
||||
var overwrite = await _dialogService.ShowQuestionMessageBox("Overwrite existing profile",
|
||||
"A profile with this name already exists for this game. Would you like to overwrite it?");
|
||||
if (!overwrite.Value)
|
||||
return null;
|
||||
}
|
||||
|
||||
ProfileProvider.AddOrUpdate(profile);
|
||||
return profile;
|
||||
}
|
||||
|
||||
public async Task RenameProfile(ProfileModel profileModel)
|
||||
{
|
||||
// Store the old name
|
||||
var oldName = profileModel.Name;
|
||||
var name = await GetValidProfileName("Rename profile", "Please enter a unique new profile name");
|
||||
// User cancelled
|
||||
if (name == null)
|
||||
return;
|
||||
|
||||
// MakeProfileUnique does a check but also modifies the profile, set the old name back
|
||||
var doRename = await MakeProfileUnique(profileModel, name, profileModel.Name);
|
||||
var newName = profileModel.Name;
|
||||
profileModel.Name = oldName;
|
||||
|
||||
if (!doRename)
|
||||
return;
|
||||
|
||||
ProfileProvider.RenameProfile(profileModel, newName);
|
||||
}
|
||||
|
||||
public async Task<ProfileModel> DuplicateProfile(ProfileModel selectedProfile)
|
||||
{
|
||||
var newProfile = GeneralHelpers.Clone(selectedProfile);
|
||||
var name = await GetValidProfileName("Duplicate profile", "Please enter a unique new profile name");
|
||||
// User cancelled
|
||||
if (name == null)
|
||||
return null;
|
||||
var doRename = await MakeProfileUnique(newProfile, name, newProfile.Name);
|
||||
if (!doRename)
|
||||
return null;
|
||||
|
||||
// Make sure it's not default, in case of copying a default profile
|
||||
newProfile.IsDefault = false;
|
||||
ProfileProvider.AddOrUpdate(newProfile);
|
||||
|
||||
return newProfile;
|
||||
}
|
||||
|
||||
public async Task<bool> ConfirmDeleteProfile(ProfileModel selectedProfile, ModuleModel moduleModel)
|
||||
{
|
||||
var confirm = await _dialogService.ShowQuestionMessageBox("Delete profile",
|
||||
$"Are you sure you want to delete the profile named: {selectedProfile.Name}?\n\n" +
|
||||
"This cannot be undone.");
|
||||
|
||||
return confirm.Value;
|
||||
}
|
||||
|
||||
public async Task<ProfileModel> ImportProfile(ModuleModel moduleModel)
|
||||
{
|
||||
var dialog = new OpenFileDialog {Filter = "Artemis profile (*.json)|*.json"};
|
||||
var result = dialog.ShowDialog();
|
||||
if (result != DialogResult.OK)
|
||||
return null;
|
||||
|
||||
var profileModel = ProfileProvider.LoadProfileIfValid(dialog.FileName);
|
||||
if (profileModel == null)
|
||||
{
|
||||
_dialogService.ShowErrorMessageBox("Oh noes, the profile you provided is invalid. " +
|
||||
"If this keeps happening, please make an issue on GitHub and provide the profile.");
|
||||
return null;
|
||||
}
|
||||
|
||||
// Verify the game
|
||||
if (profileModel.GameName != moduleModel.Name)
|
||||
{
|
||||
_dialogService.ShowErrorMessageBox(
|
||||
$"Oh oops! This profile is ment for {profileModel.GameName}, not {moduleModel.Name} :c");
|
||||
return null;
|
||||
}
|
||||
|
||||
// Verify the keyboard
|
||||
var deviceManager = _deviceManager;
|
||||
if (profileModel.KeyboardSlug != deviceManager.ActiveKeyboard.Slug)
|
||||
{
|
||||
var adjustKeyboard = await _dialogService.ShowQuestionMessageBox("Profile not made for this keyboard",
|
||||
$"Watch out, this profile wasn't ment for this keyboard, but for the {profileModel.KeyboardSlug}. " +
|
||||
"You can still import it but you'll probably have to do some adjusting\n\n" +
|
||||
"Continue?");
|
||||
if (!adjustKeyboard.Value)
|
||||
return null;
|
||||
|
||||
// Resize layers that are on the full keyboard width
|
||||
profileModel.ResizeLayers(deviceManager.ActiveKeyboard);
|
||||
// Put layers back into the canvas if they fell outside it
|
||||
profileModel.FixBoundaries(deviceManager.ActiveKeyboard.KeyboardRectangle(1));
|
||||
|
||||
// Setup profile metadata to match the new keyboard
|
||||
profileModel.KeyboardSlug = deviceManager.ActiveKeyboard.Slug;
|
||||
profileModel.Width = deviceManager.ActiveKeyboard.Width;
|
||||
profileModel.Height = deviceManager.ActiveKeyboard.Height;
|
||||
}
|
||||
|
||||
var name = await GetValidProfileName("Rename profile", "Please enter a unique new profile name");
|
||||
// User cancelled
|
||||
if (name == null)
|
||||
return null;
|
||||
var doRename = await MakeProfileUnique(profileModel, name, profileModel.Name);
|
||||
if (!doRename)
|
||||
return null;
|
||||
|
||||
profileModel.IsDefault = false;
|
||||
ProfileProvider.AddOrUpdate(profileModel);
|
||||
return profileModel;
|
||||
}
|
||||
|
||||
public void ChangeProfileByName(ModuleModel moduleModel, string profileName)
|
||||
{
|
||||
if (string.IsNullOrEmpty(profileName))
|
||||
profileName = "Default";
|
||||
|
||||
moduleModel.ChangeProfile(ProfileProvider.GetProfile(_deviceManager.ActiveKeyboard, moduleModel, profileName));
|
||||
}
|
||||
|
||||
private async Task<string> GetValidProfileName(string title, string text)
|
||||
{
|
||||
var name = await _dialogService.ShowInputDialog(title, text);
|
||||
|
||||
// Null when the user cancelled
|
||||
if (name == null)
|
||||
return null;
|
||||
|
||||
if (name.Length >= 2)
|
||||
return name;
|
||||
|
||||
_dialogService.ShowMessageBox("Invalid profile name",
|
||||
"Please provide a valid profile name that's longer than 2 symbols");
|
||||
|
||||
return await GetValidProfileName(title, text);
|
||||
}
|
||||
|
||||
private async Task<bool> MakeProfileUnique(ProfileModel profileModel, string name, string oldName)
|
||||
{
|
||||
profileModel.Name = name;
|
||||
if (ProfileProvider.IsProfileUnique(profileModel))
|
||||
return true;
|
||||
|
||||
name = await GetValidProfileName("Rename profile", "Please enter a unique new profile name");
|
||||
if (name != null)
|
||||
return await MakeProfileUnique(profileModel, name, oldName);
|
||||
|
||||
// If cancelled, restore old name and stop
|
||||
profileModel.Name = oldName;
|
||||
return false;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region LUA
|
||||
|
||||
public void OpenLuaEditor(ModuleModel moduleModel)
|
||||
{
|
||||
if (moduleModel.ProfileModel == null)
|
||||
return;
|
||||
|
||||
// Clean up old environment
|
||||
DisposeLuaWatcher();
|
||||
|
||||
// Create a temp file
|
||||
var fileName = Guid.NewGuid() + ".lua";
|
||||
var file = File.Create(Path.GetTempPath() + fileName);
|
||||
file.Dispose();
|
||||
|
||||
// Add instructions to LUA script if it's a new file
|
||||
if (string.IsNullOrEmpty(moduleModel.ProfileModel.LuaScript))
|
||||
moduleModel.ProfileModel.LuaScript = Encoding.UTF8.GetString(Resources.lua_placeholder);
|
||||
File.WriteAllText(Path.GetTempPath() + fileName, moduleModel.ProfileModel.LuaScript);
|
||||
|
||||
// Watch the file for changes
|
||||
_luaModule = moduleModel;
|
||||
_luaEditorProfile = moduleModel.ProfileModel;
|
||||
_watcher = new FileSystemWatcher(Path.GetTempPath(), fileName);
|
||||
_watcher.Changed += LuaFileChanged;
|
||||
_watcher.EnableRaisingEvents = true;
|
||||
_watcher.Path = Path.GetTempPath();
|
||||
_watcher.Filter = fileName;
|
||||
|
||||
// Open the temp file with the default editor
|
||||
System.Diagnostics.Process.Start(Path.GetTempPath() + fileName);
|
||||
}
|
||||
|
||||
private void LuaFileChanged(object sender, FileSystemEventArgs args)
|
||||
{
|
||||
if (_luaModule == null)
|
||||
{
|
||||
DisposeLuaWatcher();
|
||||
return;
|
||||
}
|
||||
|
||||
if (args.ChangeType != WatcherChangeTypes.Changed)
|
||||
return;
|
||||
|
||||
lock (_luaModule)
|
||||
{
|
||||
using (var fs = new FileStream(args.FullPath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
|
||||
{
|
||||
using (var sr = new StreamReader(fs))
|
||||
{
|
||||
_luaEditorProfile.LuaScript = sr.ReadToEnd();
|
||||
}
|
||||
}
|
||||
|
||||
ProfileProvider.AddOrUpdate(_luaEditorProfile);
|
||||
if (_luaManager.ProfileModel == _luaEditorProfile)
|
||||
_luaManager.SetupLua(_luaModule.ProfileModel);
|
||||
}
|
||||
}
|
||||
|
||||
private void DisposeLuaWatcher()
|
||||
{
|
||||
if (_watcher == null)
|
||||
return;
|
||||
_watcher.Changed -= LuaFileChanged;
|
||||
_watcher.Dispose();
|
||||
_watcher = null;
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
DisposeLuaWatcher();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Rendering
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@ -1,6 +0,0 @@
|
||||
namespace Artemis.Modules.Abstract
|
||||
{
|
||||
public abstract class ModuleDataModel
|
||||
{
|
||||
}
|
||||
}
|
||||
@ -1,206 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Artemis.DAL;
|
||||
using Artemis.Events;
|
||||
using Artemis.Managers;
|
||||
using Artemis.Models;
|
||||
using Artemis.Profiles;
|
||||
using Artemis.Profiles.Layers.Models;
|
||||
using Newtonsoft.Json;
|
||||
using Ninject;
|
||||
using Ninject.Extensions.Logging;
|
||||
|
||||
namespace Artemis.Modules.Abstract
|
||||
{
|
||||
public abstract class ModuleModel : IDisposable
|
||||
{
|
||||
private readonly LuaManager _luaManager;
|
||||
protected readonly DeviceManager DeviceManager;
|
||||
private DateTime _lastTrace;
|
||||
|
||||
public ModuleModel(DeviceManager deviceManager, LuaManager luaManager)
|
||||
{
|
||||
_luaManager = luaManager;
|
||||
DeviceManager = deviceManager;
|
||||
|
||||
DeviceManager.OnKeyboardChanged += OnKeyboardChanged;
|
||||
}
|
||||
|
||||
#region Events
|
||||
|
||||
public event EventHandler<ProfileChangedEventArgs> ProfileChanged;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Abstract properties
|
||||
|
||||
/// <summary>
|
||||
/// The module's name, used in setting files and logging
|
||||
/// </summary>
|
||||
public abstract string Name { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Whether or not the module should be rendered as an overlay
|
||||
/// </summary>
|
||||
public abstract bool IsOverlay { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Whether or not the module is enabled by a certain process
|
||||
/// </summary>
|
||||
public abstract bool IsBoundToProcess { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The module's settings
|
||||
/// </summary>
|
||||
public ModuleSettings Settings { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The module's data model
|
||||
/// </summary>
|
||||
public ModuleDataModel DataModel { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
#region Base properties
|
||||
|
||||
[Inject]
|
||||
public ILogger Logger { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Whether or not the module is initialized and ready to be updated/rendered
|
||||
/// </summary>
|
||||
public bool IsInitialized { get; protected set; }
|
||||
|
||||
/// <summary>
|
||||
/// If this collection contains any layers they will be drawn instead of the regular profile
|
||||
/// </summary>
|
||||
public List<LayerModel> PreviewLayers { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The processes the module is bound to
|
||||
/// </summary>
|
||||
public List<string> ProcessNames { get; protected set; } = new List<string>();
|
||||
|
||||
/// <summary>
|
||||
/// The currently active profile of the module
|
||||
/// </summary>
|
||||
public ProfileModel ProfileModel { get; protected set; }
|
||||
|
||||
public bool IsGeneral => !IsOverlay && !IsBoundToProcess;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Base methods
|
||||
|
||||
public void ChangeProfile(ProfileModel profileModel)
|
||||
{
|
||||
if (!IsInitialized || Equals(ProfileModel, profileModel))
|
||||
return;
|
||||
|
||||
ProfileModel?.Deactivate(_luaManager);
|
||||
ProfileModel = profileModel;
|
||||
|
||||
if (!IsOverlay)
|
||||
ProfileModel?.Activate(_luaManager);
|
||||
if (ProfileModel != null)
|
||||
{
|
||||
Settings.LastProfile = ProfileModel.Name;
|
||||
Settings.Save();
|
||||
}
|
||||
|
||||
RaiseProfileChangedEvent(new ProfileChangedEventArgs(ProfileModel));
|
||||
}
|
||||
|
||||
public virtual void Enable()
|
||||
{
|
||||
IsInitialized = true;
|
||||
ChangeToLastProfile();
|
||||
}
|
||||
|
||||
public virtual void Dispose()
|
||||
{
|
||||
IsInitialized = false;
|
||||
|
||||
PreviewLayers = null;
|
||||
ProfileModel?.Deactivate(_luaManager);
|
||||
ProfileModel = null;
|
||||
}
|
||||
|
||||
private void OnKeyboardChanged(object sender, KeyboardChangedEventArgs e)
|
||||
{
|
||||
ChangeToLastProfile();
|
||||
}
|
||||
|
||||
public void ChangeToLastProfile()
|
||||
{
|
||||
var profileName = !string.IsNullOrEmpty(Settings?.LastProfile) ? Settings.LastProfile : "Default";
|
||||
|
||||
var profile = ProfileProvider.GetProfile(DeviceManager.ActiveKeyboard, this, profileName);
|
||||
if (profile == null)
|
||||
profile = ProfileProvider.GetProfile(DeviceManager.ActiveKeyboard, this, "Default");
|
||||
|
||||
ChangeProfile(profile);
|
||||
}
|
||||
|
||||
protected virtual void RaiseProfileChangedEvent(ProfileChangedEventArgs e)
|
||||
{
|
||||
var handler = ProfileChanged;
|
||||
handler?.Invoke(this, e);
|
||||
}
|
||||
|
||||
public abstract void Update();
|
||||
|
||||
public virtual void Render(FrameModel frameModel, bool keyboardOnly)
|
||||
{
|
||||
if (ProfileModel == null || DataModel == null || DeviceManager.ActiveKeyboard == null)
|
||||
return;
|
||||
|
||||
lock (DataModel)
|
||||
{
|
||||
lock (ProfileModel)
|
||||
{
|
||||
// Use the preview layers if they are present, else get all layers who's conditions are met
|
||||
var layers = PreviewLayers ?? GetRenderLayers(keyboardOnly);
|
||||
var preview = PreviewLayers != null;
|
||||
|
||||
// Render the keyboard layer-by-layer
|
||||
ProfileModel?.DrawLayers(frameModel.KeyboardModel, layers, DataModel, preview);
|
||||
// Render mice layer-by-layer
|
||||
if (frameModel.MouseModel != null)
|
||||
ProfileModel?.DrawLayers(frameModel.MouseModel, layers, DataModel, preview);
|
||||
// Render headsets layer-by-layer
|
||||
if (frameModel.HeadsetModel != null)
|
||||
ProfileModel?.DrawLayers(frameModel.HeadsetModel, layers, DataModel, preview);
|
||||
// Render generic devices layer-by-layer
|
||||
if (frameModel.GenericModel != null)
|
||||
ProfileModel?.DrawLayers(frameModel.GenericModel, layers, DataModel, preview);
|
||||
// Render mousemats layer-by-layer
|
||||
if (frameModel.MousematModel != null)
|
||||
ProfileModel?.DrawLayers(frameModel.MousematModel, layers, DataModel, preview);
|
||||
|
||||
// Trace debugging
|
||||
if (DateTime.Now.AddSeconds(-2) <= _lastTrace || Logger == null)
|
||||
return;
|
||||
|
||||
_lastTrace = DateTime.Now;
|
||||
var dmJson = JsonConvert.SerializeObject(DataModel, Formatting.Indented);
|
||||
Logger.Trace("Effect datamodel as JSON: \r\n{0}", dmJson);
|
||||
|
||||
if (layers == null)
|
||||
return;
|
||||
|
||||
Logger.Trace("Effect {0} has to render {1} layers", Name, layers.Count);
|
||||
foreach (var renderLayer in layers)
|
||||
Logger.Trace("- Layer name: {0}, layer type: {1}", renderLayer.Name, renderLayer.LayerType);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public virtual List<LayerModel> GetRenderLayers(bool keyboardOnly)
|
||||
{
|
||||
return ProfileModel?.GetRenderLayers(DataModel, keyboardOnly);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@ -1,34 +0,0 @@
|
||||
using System.ComponentModel;
|
||||
using Artemis.DAL;
|
||||
using Artemis.Settings;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Artemis.Modules.Abstract
|
||||
{
|
||||
public abstract class ModuleSettings : IArtemisSettings
|
||||
{
|
||||
[DefaultValue(true)]
|
||||
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Populate)]
|
||||
public bool IsEnabled { get; set; }
|
||||
|
||||
[DefaultValue("Default")]
|
||||
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Populate)]
|
||||
public string LastProfile { get; set; }
|
||||
|
||||
public void Save()
|
||||
{
|
||||
SettingsProvider.Save(this);
|
||||
}
|
||||
|
||||
public void Reset(bool save = false)
|
||||
{
|
||||
JsonConvert.PopulateObject("{}", this, new JsonSerializerSettings
|
||||
{
|
||||
ObjectCreationHandling = ObjectCreationHandling.Reuse
|
||||
});
|
||||
|
||||
if (save)
|
||||
SettingsProvider.Save(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,168 +0,0 @@
|
||||
using Artemis.DAL;
|
||||
using Artemis.Events;
|
||||
using Artemis.Managers;
|
||||
using Artemis.Services;
|
||||
using Artemis.Settings;
|
||||
using Artemis.ViewModels;
|
||||
using Caliburn.Micro;
|
||||
using Ninject;
|
||||
using Ninject.Extensions.Logging;
|
||||
using Ninject.Parameters;
|
||||
|
||||
namespace Artemis.Modules.Abstract
|
||||
{
|
||||
public abstract class ModuleViewModel : Screen
|
||||
{
|
||||
private readonly GeneralSettings _generalSettings;
|
||||
private readonly MainManager _mainManager;
|
||||
private readonly ModuleManager _moduleManager;
|
||||
private ModuleSettings _settings;
|
||||
|
||||
public ModuleViewModel(MainManager mainManager, ModuleModel moduleModel, IKernel kernel)
|
||||
{
|
||||
_mainManager = mainManager;
|
||||
_moduleManager = mainManager.ModuleManager;
|
||||
_generalSettings = SettingsProvider.Load<GeneralSettings>();
|
||||
ModuleModel = moduleModel;
|
||||
Settings = moduleModel.Settings;
|
||||
|
||||
_mainManager.EnabledChanged += MainManagerOnEnabledChanged;
|
||||
_moduleManager.EffectChanged += ModuleManagerOnModuleChanged;
|
||||
|
||||
// ReSharper disable once VirtualMemberCallInConstructor
|
||||
if (!UsesProfileEditor)
|
||||
return;
|
||||
|
||||
IParameter[] args =
|
||||
{
|
||||
new ConstructorArgument("mainManager", _mainManager),
|
||||
new ConstructorArgument("moduleModel", ModuleModel),
|
||||
new ConstructorArgument("lastProfile", Settings.LastProfile)
|
||||
};
|
||||
ProfileEditor = kernel.Get<ProfileEditorViewModel>(args);
|
||||
}
|
||||
|
||||
public ProfileEditorViewModel ProfileEditor { get; set; }
|
||||
public ModuleModel ModuleModel { get; }
|
||||
|
||||
[Inject]
|
||||
public ILogger Logger { get; set; }
|
||||
|
||||
[Inject]
|
||||
public MetroDialogService DialogService { get; set; }
|
||||
|
||||
public ModuleSettings Settings
|
||||
{
|
||||
get { return _settings; }
|
||||
set
|
||||
{
|
||||
if (Equals(value, _settings))
|
||||
return;
|
||||
_settings = value;
|
||||
NotifyOfPropertyChange(() => Settings);
|
||||
}
|
||||
}
|
||||
|
||||
public virtual bool IsModuleActive => _moduleManager.ActiveModule == ModuleModel;
|
||||
|
||||
public virtual bool IsModuleEnabled
|
||||
{
|
||||
get
|
||||
{
|
||||
if (!ModuleModel.IsGeneral)
|
||||
return Settings.IsEnabled;
|
||||
return _generalSettings.LastModule == ModuleModel.Name;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Indicates whether or not this module uses the profile editor
|
||||
/// </summary>
|
||||
public abstract bool UsesProfileEditor { get; }
|
||||
|
||||
private void MainManagerOnEnabledChanged(object sender, EnabledChangedEventArgs e)
|
||||
{
|
||||
UpdatedEnabledSetting();
|
||||
NotifyOfPropertyChange(() => IsModuleActive);
|
||||
}
|
||||
|
||||
private void ModuleManagerOnModuleChanged(object sender, ModuleChangedEventArgs e)
|
||||
{
|
||||
UpdatedEnabledSetting();
|
||||
NotifyOfPropertyChange(() => IsModuleActive);
|
||||
NotifyOfPropertyChange(() => IsModuleEnabled);
|
||||
}
|
||||
|
||||
private void UpdatedEnabledSetting()
|
||||
{
|
||||
if (!ModuleModel.IsGeneral || _moduleManager.ActiveModule != null && !_moduleManager.ActiveModule.IsGeneral || Settings.IsEnabled == IsModuleActive)
|
||||
return;
|
||||
|
||||
Settings.IsEnabled = IsModuleActive;
|
||||
Settings.Save();
|
||||
NotifyOfPropertyChange(() => Settings);
|
||||
}
|
||||
|
||||
public virtual void ToggleModule()
|
||||
{
|
||||
Settings.IsEnabled = !Settings.IsEnabled;
|
||||
Settings.Save();
|
||||
NotifyOfPropertyChange(() => Settings);
|
||||
|
||||
// On process-bound modules, only set the module model
|
||||
if (!ModuleModel.IsGeneral)
|
||||
{
|
||||
NotifyOfPropertyChange(() => IsModuleActive);
|
||||
NotifyOfPropertyChange(() => IsModuleEnabled);
|
||||
return;
|
||||
}
|
||||
|
||||
// On other modules, activate them if necessary
|
||||
if (IsModuleActive && !Settings.IsEnabled)
|
||||
_moduleManager.ClearActiveModule();
|
||||
else if (!IsModuleActive && Settings.IsEnabled)
|
||||
_moduleManager.ChangeActiveModule(ModuleModel, _mainManager.LoopManager);
|
||||
|
||||
NotifyOfPropertyChange(() => IsModuleActive);
|
||||
NotifyOfPropertyChange(() => IsModuleEnabled);
|
||||
}
|
||||
|
||||
public virtual void SaveSettings()
|
||||
{
|
||||
Settings?.Save();
|
||||
if (UsesProfileEditor)
|
||||
ProfileEditor.SaveSelectedProfile();
|
||||
if (!IsModuleActive)
|
||||
return;
|
||||
|
||||
// Restart the module if it's currently running to apply settings.
|
||||
_moduleManager.ChangeActiveModule(ModuleModel);
|
||||
}
|
||||
|
||||
public virtual async void ResetSettings()
|
||||
{
|
||||
var resetConfirm = await DialogService.ShowQuestionMessageBox("Reset module settings",
|
||||
"Are you sure you wish to reset this module's settings? \nAny changes you made will be lost.");
|
||||
|
||||
if (!resetConfirm.Value)
|
||||
return;
|
||||
|
||||
Settings.Reset(true);
|
||||
NotifyOfPropertyChange(() => Settings);
|
||||
|
||||
SaveSettings();
|
||||
}
|
||||
|
||||
protected override void OnActivate()
|
||||
{
|
||||
base.OnActivate();
|
||||
ProfileEditor?.OnActivate();
|
||||
}
|
||||
|
||||
protected override void OnDeactivate(bool close)
|
||||
{
|
||||
base.OnDeactivate(close);
|
||||
ProfileEditor?.OnDeactivate(close);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,164 +0,0 @@
|
||||
using Artemis.Modules.Abstract;
|
||||
using AssettoCorsaSharedMemory;
|
||||
using MoonSharp.Interpreter;
|
||||
|
||||
namespace Artemis.Modules.Games.AssettoCorsa
|
||||
{
|
||||
[MoonSharpUserData]
|
||||
public class AssettoCorsaDataModel : ModuleDataModel
|
||||
{
|
||||
public AssettoCorsaDataModel()
|
||||
{
|
||||
Physics = new Physics();
|
||||
Interface = new Graphics();
|
||||
StaticInfo = new StaticInfo();
|
||||
}
|
||||
|
||||
public Physics Physics { get; set; }
|
||||
public Graphics Interface { get; set; }
|
||||
public StaticInfo StaticInfo { get; set; }
|
||||
}
|
||||
|
||||
[MoonSharpUserData]
|
||||
public class Physics
|
||||
{
|
||||
public float Abs { get; set; }
|
||||
public float Gas { get; set; }
|
||||
public float Brake { get; set; }
|
||||
public float Fuel { get; set; }
|
||||
public int Gear { get; set; }
|
||||
public int Rpms { get; set; }
|
||||
public float SteerAngle { get; set; }
|
||||
public float SpeedKmh { get; set; }
|
||||
public float[] Velocity { get; set; }
|
||||
public float[] AccG { get; set; }
|
||||
public float[] WheelSlip { get; set; }
|
||||
public float[] WheelLoad { get; set; }
|
||||
public float[] WheelsPressure { get; set; }
|
||||
public float[] WheelAngularSpeed { get; set; }
|
||||
public float[] TyreWear { get; set; }
|
||||
public float[] TyreDirtyLevel { get; set; }
|
||||
public float[] TyreCoreTemperature { get; set; }
|
||||
public float[] CamberRad { get; set; }
|
||||
public float[] SuspensionTravel { get; set; }
|
||||
public float Drs { get; set; }
|
||||
public float TC { get; set; }
|
||||
public float Heading { get; set; }
|
||||
public float Pitch { get; set; }
|
||||
public float Roll { get; set; }
|
||||
public float CgHeight { get; set; }
|
||||
public float[] CarDamage { get; set; }
|
||||
public int NumberOfTyresOut { get; set; }
|
||||
public int PitLimiterOn { get; set; }
|
||||
public float KersCharge { get; set; }
|
||||
public float KersInput { get; set; }
|
||||
public int AutoShifterOn { get; set; }
|
||||
public float[] RideHeight { get; set; }
|
||||
public float TurboBoost { get; set; }
|
||||
public float Ballast { get; set; }
|
||||
public float AirDensity { get; set; }
|
||||
public float AirTemp { get; set; }
|
||||
public float RoadTemp { get; set; }
|
||||
public float[] LocalAngularVelocity { get; set; }
|
||||
public float FinalFF { get; set; }
|
||||
public float PerformanceMeter { get; set; }
|
||||
public int EngineBrake { get; set; }
|
||||
public int ErsRecoveryLevel { get; set; }
|
||||
public int ErsPowerLevel { get; set; }
|
||||
public int ErsHeatCharging { get; set; }
|
||||
public int ErsisCharging { get; set; }
|
||||
public float KersCurrentKJ { get; set; }
|
||||
public int DrsAvailable { get; set; }
|
||||
public int DrsEnabled { get; set; }
|
||||
public float[] BrakeTemp { get; set; }
|
||||
public float Clutch { get; set; }
|
||||
public float[] TyreTempI { get; set; }
|
||||
public float[] TyreTempM { get; set; }
|
||||
public float[] TyreTempO { get; set; }
|
||||
public int IsAIControlled { get; set; }
|
||||
public Coordinates[] TyreContactPoint { get; set; }
|
||||
public Coordinates[] TyreContactNormal { get; set; }
|
||||
public Coordinates[] TyreContactHeading { get; set; }
|
||||
public float BrakeBias { get; set; }
|
||||
}
|
||||
|
||||
[MoonSharpUserData]
|
||||
public class Graphics
|
||||
{
|
||||
public AC_STATUS Status { get; set; }
|
||||
public AC_SESSION_TYPE Session { get; set; }
|
||||
public string CurrentTime { get; set; }
|
||||
public string LastTime { get; set; }
|
||||
public string BestTime { get; set; }
|
||||
public string Split { get; set; }
|
||||
public int Position { get; set; }
|
||||
public int iCurrentTime { get; set; }
|
||||
public int iBestTime { get; set; }
|
||||
public int iLastTime { get; set; }
|
||||
public float SessionTimeLeft { get; set; }
|
||||
public float DistanceTraveled { get; set; }
|
||||
public int IsInPit { get; set; }
|
||||
public int CurrentSectorIndex { get; set; }
|
||||
public int LastSectorTime { get; set; }
|
||||
public int NumberOfLaps { get; set; }
|
||||
public string TyreCompound { get; set; }
|
||||
public float ReplayTimeMultiplier { get; set; }
|
||||
public float NormalizedCarPosition { get; set; }
|
||||
}
|
||||
|
||||
[MoonSharpUserData]
|
||||
public class StaticInfo
|
||||
{
|
||||
public StaticInfo()
|
||||
{
|
||||
Session = new Session();
|
||||
Car = new Car();
|
||||
}
|
||||
|
||||
public string SMVersion { get; set; }
|
||||
public string ACVersion { get; set; }
|
||||
public Session Session { get; set; }
|
||||
public Car Car { get; set; }
|
||||
}
|
||||
|
||||
[MoonSharpUserData]
|
||||
public class Session
|
||||
{
|
||||
public int NumberOfSessions { get; set; }
|
||||
public int NumCars { get; set; }
|
||||
public string Track { get; set; }
|
||||
public string TrackConfiguration { get; set; }
|
||||
public float TrackSPlineLength { get; set; }
|
||||
public string PlayerName { get; set; }
|
||||
public string PlayerSurname { get; set; }
|
||||
public string PlayerNick { get; set; }
|
||||
public int SectorCount { get; set; }
|
||||
public int PenaltiesEnabled { get; set; }
|
||||
}
|
||||
|
||||
[MoonSharpUserData]
|
||||
public class Car
|
||||
{
|
||||
public string CarModel { get; set; }
|
||||
public float MaxTorque { get; set; }
|
||||
public float MaxPower { get; set; }
|
||||
public int MaxRpm { get; set; }
|
||||
public float MaxFuel { get; set; }
|
||||
public float[] SuspensionMaxTravel { get; set; }
|
||||
public float[] TyreRadius { get; set; }
|
||||
public float MaxTurboBoost { get; set; }
|
||||
public float AidFuelRate { get; set; }
|
||||
public float AidTireRate { get; set; }
|
||||
public float AidMechanicalDamage { get; set; }
|
||||
public int AidAllowTyreBlankets { get; set; }
|
||||
public float AidStability { get; set; }
|
||||
public int AidAutoClutch { get; set; }
|
||||
public int AidAutoBlip { get; set; }
|
||||
public int HasDRS { get; set; }
|
||||
public int HasERS { get; set; }
|
||||
public int HasKERS { get; set; }
|
||||
public float KersMaxJoules { get; set; }
|
||||
public int EngineBrakeSettingsCount { get; set; }
|
||||
public int ErsPowerControllerCount { get; set; }
|
||||
}
|
||||
}
|
||||
@ -1,173 +0,0 @@
|
||||
using System;
|
||||
using Artemis.DAL;
|
||||
using Artemis.Managers;
|
||||
using Artemis.Modules.Abstract;
|
||||
using AssettoCorsaSharedMemory;
|
||||
|
||||
namespace Artemis.Modules.Games.AssettoCorsa
|
||||
{
|
||||
public class AssettoCorsaModel : ModuleModel
|
||||
{
|
||||
private AssettoCorsaSharedMemory.AssettoCorsa _ac;
|
||||
|
||||
public AssettoCorsaModel(DeviceManager deviceManager, LuaManager luaManager) : base(deviceManager, luaManager)
|
||||
{
|
||||
Settings = SettingsProvider.Load<AssettoCorsaSettings>();
|
||||
DataModel = new AssettoCorsaDataModel();
|
||||
ProcessNames.Add("AssettoCorsa");
|
||||
}
|
||||
|
||||
public override string Name => "AssettoCorsa";
|
||||
public override bool IsOverlay => false;
|
||||
public override bool IsBoundToProcess => true;
|
||||
|
||||
public override void Enable()
|
||||
{
|
||||
_ac = new AssettoCorsaSharedMemory.AssettoCorsa {PhysicsInterval = 40};
|
||||
// The event handlers map their respecive enums to the datamodel, not pretty but fastest way possible
|
||||
_ac.StaticInfoUpdated += AcOnStaticInfoUpdated;
|
||||
_ac.GraphicsUpdated += AcOnGraphicsUpdated;
|
||||
_ac.PhysicsUpdated += AcOnPhysicsUpdated;
|
||||
_ac.Start();
|
||||
|
||||
base.Enable();
|
||||
}
|
||||
|
||||
public override void Dispose()
|
||||
{
|
||||
base.Dispose();
|
||||
_ac.Stop();
|
||||
_ac = null;
|
||||
}
|
||||
|
||||
private void AcOnStaticInfoUpdated(object sender, StaticInfoEventArgs e)
|
||||
{
|
||||
var dataModel = (AssettoCorsaDataModel)DataModel;
|
||||
dataModel.StaticInfo.SMVersion = e.StaticInfo.SMVersion;
|
||||
dataModel.StaticInfo.ACVersion = e.StaticInfo.ACVersion;
|
||||
dataModel.StaticInfo.Session.NumberOfSessions = e.StaticInfo.NumberOfSessions;
|
||||
dataModel.StaticInfo.Session.NumCars = e.StaticInfo.NumCars;
|
||||
dataModel.StaticInfo.Session.Track = e.StaticInfo.Track;
|
||||
dataModel.StaticInfo.Session.TrackConfiguration = e.StaticInfo.TrackConfiguration;
|
||||
dataModel.StaticInfo.Session.TrackSPlineLength = e.StaticInfo.TrackSPlineLength;
|
||||
dataModel.StaticInfo.Session.PlayerName = e.StaticInfo.PlayerName;
|
||||
dataModel.StaticInfo.Session.PlayerSurname = e.StaticInfo.PlayerSurname;
|
||||
dataModel.StaticInfo.Session.PlayerNick = e.StaticInfo.PlayerNick;
|
||||
dataModel.StaticInfo.Session.SectorCount = e.StaticInfo.SectorCount;
|
||||
dataModel.StaticInfo.Session.PenaltiesEnabled = e.StaticInfo.PenaltiesEnabled;
|
||||
dataModel.StaticInfo.Car.CarModel = e.StaticInfo.CarModel;
|
||||
dataModel.StaticInfo.Car.MaxTorque = e.StaticInfo.MaxTorque;
|
||||
dataModel.StaticInfo.Car.MaxPower = e.StaticInfo.MaxPower;
|
||||
dataModel.StaticInfo.Car.MaxRpm = e.StaticInfo.MaxRpm;
|
||||
dataModel.StaticInfo.Car.MaxFuel = e.StaticInfo.MaxFuel;
|
||||
dataModel.StaticInfo.Car.SuspensionMaxTravel = e.StaticInfo.SuspensionMaxTravel;
|
||||
dataModel.StaticInfo.Car.TyreRadius = e.StaticInfo.TyreRadius;
|
||||
dataModel.StaticInfo.Car.MaxTurboBoost = e.StaticInfo.MaxTurboBoost;
|
||||
dataModel.StaticInfo.Car.AidFuelRate = e.StaticInfo.AidFuelRate;
|
||||
dataModel.StaticInfo.Car.AidTireRate = e.StaticInfo.AidTireRate;
|
||||
dataModel.StaticInfo.Car.AidMechanicalDamage = e.StaticInfo.AidMechanicalDamage;
|
||||
dataModel.StaticInfo.Car.AidAllowTyreBlankets = e.StaticInfo.AidAllowTyreBlankets;
|
||||
dataModel.StaticInfo.Car.AidStability = e.StaticInfo.AidStability;
|
||||
dataModel.StaticInfo.Car.AidAutoClutch = e.StaticInfo.AidAutoClutch;
|
||||
dataModel.StaticInfo.Car.AidAutoBlip = e.StaticInfo.AidAutoBlip;
|
||||
dataModel.StaticInfo.Car.HasDRS = e.StaticInfo.HasDRS;
|
||||
dataModel.StaticInfo.Car.HasERS = e.StaticInfo.HasERS;
|
||||
dataModel.StaticInfo.Car.HasKERS = e.StaticInfo.HasKERS;
|
||||
dataModel.StaticInfo.Car.KersMaxJoules = e.StaticInfo.KersMaxJoules;
|
||||
dataModel.StaticInfo.Car.EngineBrakeSettingsCount = e.StaticInfo.EngineBrakeSettingsCount;
|
||||
dataModel.StaticInfo.Car.ErsPowerControllerCount = e.StaticInfo.ErsPowerControllerCount;
|
||||
}
|
||||
|
||||
private void AcOnGraphicsUpdated(object sender, GraphicsEventArgs e)
|
||||
{
|
||||
var dataModel = (AssettoCorsaDataModel)DataModel;
|
||||
dataModel.Interface.Status = e.Graphics.Status;
|
||||
dataModel.Interface.Session = e.Graphics.Session;
|
||||
dataModel.Interface.CurrentTime = e.Graphics.CurrentTime;
|
||||
dataModel.Interface.LastTime = e.Graphics.LastTime;
|
||||
dataModel.Interface.BestTime = e.Graphics.BestTime;
|
||||
dataModel.Interface.Split = e.Graphics.Split;
|
||||
dataModel.Interface.Position = e.Graphics.Position;
|
||||
dataModel.Interface.iCurrentTime = e.Graphics.iCurrentTime;
|
||||
dataModel.Interface.iLastTime = e.Graphics.iLastTime;
|
||||
dataModel.Interface.iBestTime = e.Graphics.iBestTime;
|
||||
dataModel.Interface.SessionTimeLeft = e.Graphics.SessionTimeLeft;
|
||||
dataModel.Interface.DistanceTraveled = e.Graphics.DistanceTraveled;
|
||||
dataModel.Interface.IsInPit = e.Graphics.IsInPit;
|
||||
dataModel.Interface.CurrentSectorIndex = e.Graphics.CurrentSectorIndex;
|
||||
dataModel.Interface.LastSectorTime = e.Graphics.LastSectorTime;
|
||||
dataModel.Interface.NumberOfLaps = e.Graphics.NumberOfLaps;
|
||||
dataModel.Interface.TyreCompound = e.Graphics.TyreCompound;
|
||||
dataModel.Interface.ReplayTimeMultiplier = e.Graphics.ReplayTimeMultiplier;
|
||||
dataModel.Interface.NormalizedCarPosition = e.Graphics.NormalizedCarPosition;
|
||||
}
|
||||
|
||||
private void AcOnPhysicsUpdated(object sender, PhysicsEventArgs e)
|
||||
{
|
||||
var dataModel = (AssettoCorsaDataModel)DataModel;
|
||||
dataModel.Physics.Abs = e.Physics.Abs;
|
||||
dataModel.Physics.Gas = e.Physics.Gas;
|
||||
dataModel.Physics.Brake = e.Physics.Brake;
|
||||
dataModel.Physics.Fuel = e.Physics.Fuel;
|
||||
dataModel.Physics.Gear = e.Physics.Gear;
|
||||
dataModel.Physics.Rpms = e.Physics.Rpms;
|
||||
dataModel.Physics.SteerAngle = e.Physics.SteerAngle;
|
||||
dataModel.Physics.SpeedKmh = e.Physics.SpeedKmh;
|
||||
dataModel.Physics.Velocity = e.Physics.Velocity;
|
||||
dataModel.Physics.AccG = e.Physics.AccG;
|
||||
dataModel.Physics.WheelSlip = e.Physics.WheelSlip;
|
||||
dataModel.Physics.WheelLoad = e.Physics.WheelLoad;
|
||||
dataModel.Physics.WheelsPressure = e.Physics.WheelsPressure;
|
||||
dataModel.Physics.WheelAngularSpeed = e.Physics.WheelAngularSpeed;
|
||||
dataModel.Physics.TyreWear = e.Physics.TyreWear;
|
||||
dataModel.Physics.TyreDirtyLevel = e.Physics.TyreDirtyLevel;
|
||||
dataModel.Physics.TyreCoreTemperature = e.Physics.TyreCoreTemperature;
|
||||
dataModel.Physics.CamberRad = e.Physics.CamberRad;
|
||||
dataModel.Physics.SuspensionTravel = e.Physics.SuspensionTravel;
|
||||
dataModel.Physics.Drs = e.Physics.Drs;
|
||||
dataModel.Physics.TC = e.Physics.TC;
|
||||
dataModel.Physics.Heading = e.Physics.Heading;
|
||||
dataModel.Physics.Pitch = e.Physics.Pitch;
|
||||
dataModel.Physics.Roll = e.Physics.Roll;
|
||||
dataModel.Physics.CgHeight = e.Physics.CgHeight;
|
||||
dataModel.Physics.CarDamage = e.Physics.CarDamage;
|
||||
dataModel.Physics.NumberOfTyresOut = e.Physics.NumberOfTyresOut;
|
||||
dataModel.Physics.PitLimiterOn = e.Physics.PitLimiterOn;
|
||||
dataModel.Physics.KersCharge = e.Physics.KersCharge;
|
||||
dataModel.Physics.KersInput = e.Physics.KersInput;
|
||||
dataModel.Physics.AutoShifterOn = e.Physics.AutoShifterOn;
|
||||
dataModel.Physics.RideHeight = e.Physics.RideHeight;
|
||||
dataModel.Physics.TurboBoost = e.Physics.TurboBoost;
|
||||
dataModel.Physics.Ballast = e.Physics.Ballast;
|
||||
dataModel.Physics.AirDensity = e.Physics.AirDensity;
|
||||
dataModel.Physics.AirTemp = e.Physics.AirTemp;
|
||||
dataModel.Physics.RoadTemp = e.Physics.RoadTemp;
|
||||
dataModel.Physics.LocalAngularVelocity = e.Physics.LocalAngularVelocity;
|
||||
dataModel.Physics.FinalFF = e.Physics.FinalFF;
|
||||
dataModel.Physics.PerformanceMeter = e.Physics.PerformanceMeter;
|
||||
dataModel.Physics.EngineBrake = e.Physics.EngineBrake;
|
||||
dataModel.Physics.ErsRecoveryLevel = e.Physics.ErsRecoveryLevel;
|
||||
dataModel.Physics.ErsPowerLevel = e.Physics.ErsPowerLevel;
|
||||
dataModel.Physics.ErsHeatCharging = e.Physics.ErsHeatCharging;
|
||||
dataModel.Physics.ErsisCharging = e.Physics.ErsisCharging;
|
||||
dataModel.Physics.KersCurrentKJ = e.Physics.KersCurrentKJ;
|
||||
dataModel.Physics.DrsAvailable = e.Physics.DrsAvailable;
|
||||
dataModel.Physics.DrsEnabled = e.Physics.DrsEnabled;
|
||||
dataModel.Physics.BrakeTemp = e.Physics.BrakeTemp;
|
||||
dataModel.Physics.Clutch = e.Physics.Clutch;
|
||||
dataModel.Physics.TyreTempI = e.Physics.TyreTempI;
|
||||
dataModel.Physics.TyreTempM = e.Physics.TyreTempM;
|
||||
dataModel.Physics.TyreTempO = e.Physics.TyreTempO;
|
||||
dataModel.Physics.IsAIControlled = e.Physics.IsAIControlled;
|
||||
dataModel.Physics.TyreContactPoint = e.Physics.TyreContactPoint;
|
||||
dataModel.Physics.TyreContactNormal = e.Physics.TyreContactNormal;
|
||||
dataModel.Physics.TyreContactHeading = e.Physics.TyreContactHeading;
|
||||
dataModel.Physics.BrakeBias = e.Physics.BrakeBias;
|
||||
}
|
||||
|
||||
public override void Update()
|
||||
{
|
||||
// Updating is done by the events
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,8 +0,0 @@
|
||||
using Artemis.Modules.Abstract;
|
||||
|
||||
namespace Artemis.Modules.Games.AssettoCorsa
|
||||
{
|
||||
public class AssettoCorsaSettings : ModuleSettings
|
||||
{
|
||||
}
|
||||
}
|
||||
@ -1,50 +0,0 @@
|
||||
<UserControl x:Class="Artemis.Modules.Games.AssettoCorsa.AssettoCorsaView"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:cal="http://www.caliburnproject.org"
|
||||
xmlns:controls="http://metro.mahapps.com/winfx/xaml/controls"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="600" d:DesignWidth="900">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="*" />
|
||||
<RowDefinition Height="30" />
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<!-- Header -->
|
||||
<Label Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="2" FontSize="20" HorizontalAlignment="Left">
|
||||
<Label.Content>
|
||||
<AccessText TextWrapping="Wrap" Text="By default shows RPM on bottom half of the keyboard, engine stats on the top half and DRS on the numpad" />
|
||||
</Label.Content>
|
||||
</Label>
|
||||
|
||||
<!-- Sub header -->
|
||||
<TextBlock Grid.Row="1" Grid.Column="0" VerticalAlignment="Bottom" TextWrapping="Wrap" HorizontalAlignment="Left" FontFamily="Segoe UI Semibold" TextAlignment="Justify" Margin="5,0,0,10">
|
||||
The Assetto Corsa module uses the <Hyperlink RequestNavigate="Hyperlink_RequestNavigate" NavigateUri="https://github.com/mdjarv/assettocorsasharedmemory">Assetto Corsa Shared Memory Library</Hyperlink> project by mdjarv.
|
||||
</TextBlock>
|
||||
|
||||
<!-- Enable -->
|
||||
<StackPanel Grid.Row="1" Grid.Column="1" HorizontalAlignment="Right" Orientation="Horizontal">
|
||||
<Label Content="Enable module" HorizontalAlignment="Right" Margin="0,0,0,3" />
|
||||
<controls:ToggleSwitchButton IsChecked="{Binding Path=IsModuleEnabled, Mode=OneWay}" cal:Message.Attach="[Event Click] = [Action ToggleModule]"
|
||||
Style="{StaticResource MahApps.Metro.Styles.ToggleSwitchButton.Win10}" ToolTip="Note: You can't enable an module when Artemis is disabled" />
|
||||
</StackPanel>
|
||||
|
||||
<!-- Profile editor -->
|
||||
<ContentControl Grid.Row="2" Grid.Column="0" Grid.ColumnSpan="2" x:Name="ProfileEditor" />
|
||||
|
||||
<!-- Buttons -->
|
||||
<StackPanel Grid.Column="0" Grid.Row="3" Orientation="Horizontal" VerticalAlignment="Bottom">
|
||||
<Button x:Name="ResetSettings" Content="Reset effect" VerticalAlignment="Top" Width="100" Style="{DynamicResource SquareButtonStyle}" />
|
||||
<Button x:Name="SaveSettings" Content="Save changes" VerticalAlignment="Top" Width="100" Margin="10,0,0,0" Style="{DynamicResource SquareButtonStyle}" />
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
@ -1,18 +0,0 @@
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Navigation;
|
||||
|
||||
namespace Artemis.Modules.Games.AssettoCorsa
|
||||
{
|
||||
public partial class AssettoCorsaView : UserControl
|
||||
{
|
||||
public AssettoCorsaView()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void Hyperlink_RequestNavigate(object sender, RequestNavigateEventArgs e)
|
||||
{
|
||||
System.Diagnostics.Process.Start(e.Uri.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,17 +0,0 @@
|
||||
using Artemis.Managers;
|
||||
using Artemis.Modules.Abstract;
|
||||
using Ninject;
|
||||
|
||||
namespace Artemis.Modules.Games.AssettoCorsa
|
||||
{
|
||||
public sealed class AssettoCorsaViewModel : ModuleViewModel
|
||||
{
|
||||
public AssettoCorsaViewModel(MainManager mainManager, [Named(nameof(AssettoCorsaModel))] ModuleModel moduleModel,
|
||||
IKernel kernel) : base(mainManager, moduleModel, kernel)
|
||||
{
|
||||
DisplayName = "Assetto Corsa";
|
||||
}
|
||||
|
||||
public override bool UsesProfileEditor => true;
|
||||
}
|
||||
}
|
||||
@ -1,130 +0,0 @@
|
||||
using Artemis.Modules.Abstract;
|
||||
using MoonSharp.Interpreter;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Artemis.Modules.Games.CounterStrike
|
||||
{
|
||||
[MoonSharpUserData]
|
||||
public class CounterStrikeDataModel : ModuleDataModel
|
||||
{
|
||||
public Provider provider { get; set; }
|
||||
public Map map { get; set; }
|
||||
public Round round { get; set; }
|
||||
public Player player { get; set; }
|
||||
public Previously previously { get; set; }
|
||||
}
|
||||
|
||||
[MoonSharpUserData]
|
||||
public class Provider
|
||||
{
|
||||
public string name { get; set; }
|
||||
public int appid { get; set; }
|
||||
public int version { get; set; }
|
||||
public string steamid { get; set; }
|
||||
public int timestamp { get; set; }
|
||||
}
|
||||
|
||||
[MoonSharpUserData]
|
||||
public class TeamCt
|
||||
{
|
||||
public int score { get; set; }
|
||||
}
|
||||
|
||||
[MoonSharpUserData]
|
||||
public class TeamT
|
||||
{
|
||||
public int score { get; set; }
|
||||
}
|
||||
|
||||
[MoonSharpUserData]
|
||||
public class Map
|
||||
{
|
||||
public string mode { get; set; }
|
||||
public string name { get; set; }
|
||||
public string phase { get; set; }
|
||||
public int round { get; set; }
|
||||
public TeamCt team_ct { get; set; }
|
||||
public TeamT team_t { get; set; }
|
||||
}
|
||||
|
||||
[MoonSharpUserData]
|
||||
public class Round
|
||||
{
|
||||
public string phase { get; set; }
|
||||
public string bomb { get; set; }
|
||||
public string win_team { get; set; }
|
||||
}
|
||||
|
||||
[MoonSharpUserData]
|
||||
public class State
|
||||
{
|
||||
[JsonIgnore]
|
||||
public bool made_kill { get; set; }
|
||||
[JsonIgnore]
|
||||
public bool made_headshot { get; set; }
|
||||
public int health { get; set; }
|
||||
public int armor { get; set; }
|
||||
public bool helmet { get; set; }
|
||||
public int flashed { get; set; }
|
||||
public int smoked { get; set; }
|
||||
public int burning { get; set; }
|
||||
public int money { get; set; }
|
||||
public int round_kills { get; set; }
|
||||
public int round_killhs { get; set; }
|
||||
}
|
||||
|
||||
[MoonSharpUserData]
|
||||
public class Weapon
|
||||
{
|
||||
public string name { get; set; }
|
||||
public string paintkit { get; set; }
|
||||
public string type { get; set; }
|
||||
public int ammo_clip { get; set; }
|
||||
public int ammo_clip_max { get; set; }
|
||||
public int ammo_reserve { get; set; }
|
||||
public string state { get; set; }
|
||||
}
|
||||
|
||||
[MoonSharpUserData]
|
||||
public class Weapons
|
||||
{
|
||||
public Weapon active_weapon { get; set; }
|
||||
public Weapon weapon_0 { get; set; }
|
||||
public Weapon weapon_1 { get; set; }
|
||||
public Weapon weapon_2 { get; set; }
|
||||
}
|
||||
|
||||
[MoonSharpUserData]
|
||||
public class MatchStats
|
||||
{
|
||||
public int kills { get; set; }
|
||||
public int assists { get; set; }
|
||||
public int deaths { get; set; }
|
||||
public int mvps { get; set; }
|
||||
public int score { get; set; }
|
||||
}
|
||||
|
||||
[MoonSharpUserData]
|
||||
public class Player
|
||||
{
|
||||
public string steamid { get; set; }
|
||||
public string name { get; set; }
|
||||
public string team { get; set; }
|
||||
public string activity { get; set; }
|
||||
public State state { get; set; }
|
||||
public Weapons weapons { get; set; }
|
||||
public MatchStats match_stats { get; set; }
|
||||
}
|
||||
|
||||
[MoonSharpUserData]
|
||||
public class Round2
|
||||
{
|
||||
public string phase { get; set; }
|
||||
}
|
||||
|
||||
[MoonSharpUserData]
|
||||
public class Previously
|
||||
{
|
||||
public Round2 round { get; set; }
|
||||
}
|
||||
}
|
||||
@ -1,166 +0,0 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using Artemis.DAL;
|
||||
using Artemis.Managers;
|
||||
using Artemis.Modules.Abstract;
|
||||
using Artemis.Properties;
|
||||
using Artemis.Services;
|
||||
using Artemis.Utilities;
|
||||
using Artemis.Utilities.GameState;
|
||||
using Newtonsoft.Json;
|
||||
using ErrorEventArgs = Newtonsoft.Json.Serialization.ErrorEventArgs;
|
||||
|
||||
namespace Artemis.Modules.Games.CounterStrike
|
||||
{
|
||||
public class CounterStrikeModel : ModuleModel
|
||||
{
|
||||
private readonly MetroDialogService _dialogService;
|
||||
private readonly GameStateWebServer _gameStateWebServer;
|
||||
private DateTime _lastHeadshot;
|
||||
private int _lastHeadshots;
|
||||
private DateTime _lastKill;
|
||||
private int _lastKills;
|
||||
|
||||
public CounterStrikeModel(DeviceManager deviceManager, LuaManager luaManager, MetroDialogService dialogService,
|
||||
GameStateWebServer gameStateWebServer) : base(deviceManager, luaManager)
|
||||
{
|
||||
_gameStateWebServer = gameStateWebServer;
|
||||
_dialogService = dialogService;
|
||||
|
||||
Settings = SettingsProvider.Load<CounterStrikeSettings>();
|
||||
DataModel = new CounterStrikeDataModel();
|
||||
ProcessNames.Add("csgo");
|
||||
|
||||
FindGameDir();
|
||||
PlaceConfigFile();
|
||||
}
|
||||
|
||||
public override string Name => "CounterStrike";
|
||||
public override bool IsOverlay => false;
|
||||
public override bool IsBoundToProcess => true;
|
||||
|
||||
public override void Dispose()
|
||||
{
|
||||
base.Dispose();
|
||||
_gameStateWebServer.GameDataReceived -= HandleGameData;
|
||||
}
|
||||
|
||||
public override void Enable()
|
||||
{
|
||||
_gameStateWebServer.GameDataReceived += HandleGameData;
|
||||
base.Enable();
|
||||
}
|
||||
|
||||
public override void Update()
|
||||
{
|
||||
if (DataModel == null)
|
||||
return;
|
||||
|
||||
var dm = (CounterStrikeDataModel) DataModel;
|
||||
if (dm.player != null && dm.player.weapons != null)
|
||||
{
|
||||
// Detect active weapon
|
||||
if (dm.player.weapons.weapon_0?.state == "active")
|
||||
dm.player.weapons.active_weapon = dm.player.weapons.weapon_0;
|
||||
else if (dm.player.weapons.weapon_1?.state == "active")
|
||||
dm.player.weapons.active_weapon = dm.player.weapons.weapon_1;
|
||||
else if (dm.player.weapons.weapon_2?.state == "active")
|
||||
dm.player.weapons.active_weapon = dm.player.weapons.weapon_2;
|
||||
|
||||
// Detect a kill
|
||||
if (dm.player.state.round_kills > _lastKills)
|
||||
{
|
||||
dm.player.state.made_kill = true;
|
||||
_lastKill = DateTime.Now;
|
||||
}
|
||||
else if (dm.player.state.made_kill && DateTime.Now - _lastKill > TimeSpan.FromMilliseconds(500))
|
||||
{
|
||||
dm.player.state.made_kill = false;
|
||||
}
|
||||
_lastKills = dm.player.state.round_kills;
|
||||
|
||||
// Detect a headshot
|
||||
if (dm.player.state.round_killhs > _lastHeadshots)
|
||||
{
|
||||
dm.player.state.made_headshot = true;
|
||||
_lastHeadshot = DateTime.Now;
|
||||
}
|
||||
else if (dm.player.state.made_headshot && DateTime.Now - _lastHeadshot > TimeSpan.FromMilliseconds(500))
|
||||
{
|
||||
dm.player.state.made_headshot = false;
|
||||
}
|
||||
_lastHeadshots = dm.player.state.round_killhs;
|
||||
|
||||
// Detect a round win
|
||||
|
||||
// Detect a round loss
|
||||
}
|
||||
|
||||
DataModel = dm;
|
||||
}
|
||||
|
||||
public void FindGameDir()
|
||||
{
|
||||
var gameSettings = (CounterStrikeSettings) Settings;
|
||||
// If already propertly set up, don't do anything
|
||||
if (gameSettings.GameDirectory != null && File.Exists(gameSettings.GameDirectory + "csgo.exe") &&
|
||||
File.Exists(gameSettings.GameDirectory + "/csgo/cfg/gamestate_integration_artemis.cfg"))
|
||||
return;
|
||||
|
||||
var dir = GeneralHelpers.FindSteamGame(@"\Counter-Strike Global Offensive\csgo.exe");
|
||||
gameSettings.GameDirectory = dir ?? string.Empty;
|
||||
gameSettings.Save();
|
||||
}
|
||||
|
||||
public void PlaceConfigFile()
|
||||
{
|
||||
var gameSettings = (CounterStrikeSettings) Settings;
|
||||
if (gameSettings.GameDirectory == string.Empty)
|
||||
return;
|
||||
|
||||
var path = gameSettings.GameDirectory;
|
||||
if (Directory.Exists(path + "/csgo/cfg"))
|
||||
{
|
||||
var cfgFile = Resources.csgoGamestateConfiguration.Replace("{{port}}",
|
||||
_gameStateWebServer.Port.ToString());
|
||||
File.WriteAllText(path + "/csgo/cfg/gamestate_integration_artemis.cfg", cfgFile);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
_dialogService.ShowErrorMessageBox("Please select a valid CS:GO directory\n\n" +
|
||||
@"By default CS:GO is in \SteamApps\common\Counter-Strike Global Offensive");
|
||||
|
||||
gameSettings.GameDirectory = string.Empty;
|
||||
gameSettings.Save();
|
||||
}
|
||||
|
||||
public void HandleGameData(object sender, GameDataReceivedEventArgs e)
|
||||
{
|
||||
var jsonString = e.Json.ToString();
|
||||
|
||||
// Ensure it's CS:GO JSON
|
||||
if (!jsonString.Contains("Counter-Strike: Global Offensive"))
|
||||
return;
|
||||
|
||||
// Parse the JSON
|
||||
try
|
||||
{
|
||||
if (DataModel == null)
|
||||
DataModel = new CounterStrikeDataModel();
|
||||
JsonConvert.PopulateObject(jsonString, DataModel, new JsonSerializerSettings {Error = HandleGameDataError});
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger?.Error(ex, "Failed to deserialize CS:GO JSON");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
private void HandleGameDataError(object sender, ErrorEventArgs e)
|
||||
{
|
||||
// Ignore errors and leave them null
|
||||
e.ErrorContext.Handled = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,10 +0,0 @@
|
||||
using Artemis.Modules.Abstract;
|
||||
using Artemis.Settings;
|
||||
|
||||
namespace Artemis.Modules.Games.CounterStrike
|
||||
{
|
||||
public class CounterStrikeSettings : ModuleSettings
|
||||
{
|
||||
public string GameDirectory { get; set; }
|
||||
}
|
||||
}
|
||||
@ -1,55 +0,0 @@
|
||||
<UserControl x:Class="Artemis.Modules.Games.CounterStrike.CounterStrikeView"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:cal="http://www.caliburnproject.org"
|
||||
xmlns:controls="http://metro.mahapps.com/winfx/xaml/controls"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="476.986" d:DesignWidth="538.772">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="*" />
|
||||
<RowDefinition Height="30" />
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<!-- Header -->
|
||||
<Label Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="2" FontSize="20" HorizontalAlignment="Left">
|
||||
<Label.Content>
|
||||
<AccessText TextWrapping="Wrap" Text="By default shows team, HP, ammo and money on the keyboard and shows team colors on mouse and headset." />
|
||||
</Label.Content>
|
||||
</Label>
|
||||
|
||||
<!-- Enable -->
|
||||
<StackPanel Grid.Row="1" Grid.Column="1" HorizontalAlignment="Right" Orientation="Horizontal">
|
||||
<Label Content="Enable module" HorizontalAlignment="Right" Margin="0,0,0,3" />
|
||||
<controls:ToggleSwitchButton IsChecked="{Binding Path=IsModuleEnabled, Mode=OneWay}" cal:Message.Attach="[Event Click] = [Action ToggleModule]"
|
||||
Style="{StaticResource MahApps.Metro.Styles.ToggleSwitchButton.Win10}" ToolTip="Note: You can't enable an module when Artemis is disabled" />
|
||||
</StackPanel>
|
||||
|
||||
<!-- Directory -->
|
||||
<StackPanel Grid.Row="2" Grid.Column="0" Grid.ColumnSpan="2" Margin="0,0,1,0">
|
||||
<Label FontSize="20" HorizontalAlignment="Left" Content="Counter-Strike Global Offensive directory" />
|
||||
<Grid>
|
||||
<TextBox x:Name="GameDirectory" Height="23" TextWrapping="Wrap" Margin="0,0,30,0" Text="{Binding Path=Settings.GameDirectory, Mode=TwoWay}" cal:Message.Attach="[Event LostFocus] = [Action PlaceConfigFile]" />
|
||||
<Button x:Name="BrowseDirectory" Content="..." RenderTransformOrigin="-0.039,-0.944" HorizontalAlignment="Right" Width="25" Style="{DynamicResource SquareButtonStyle}" Height="26" />
|
||||
</Grid>
|
||||
</StackPanel>
|
||||
|
||||
<!-- Profile editor -->
|
||||
<ContentControl Grid.Row="3" Grid.Column="0" Grid.ColumnSpan="2" x:Name="ProfileEditor" />
|
||||
|
||||
<!-- Buttons -->
|
||||
<StackPanel Grid.Column="0" Grid.Row="4" Orientation="Horizontal" VerticalAlignment="Bottom">
|
||||
<Button x:Name="ResetSettings" Content="Reset effect" VerticalAlignment="Top" Width="100" Style="{DynamicResource SquareButtonStyle}" />
|
||||
<Button x:Name="SaveSettings" Content="Save changes" VerticalAlignment="Top" Width="100" Margin="10,0,0,0" Style="{DynamicResource SquareButtonStyle}" />
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
@ -1,15 +0,0 @@
|
||||
using System.Windows.Controls;
|
||||
|
||||
namespace Artemis.Modules.Games.CounterStrike
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for CounterStrikeView.xaml
|
||||
/// </summary>
|
||||
public partial class CounterStrikeView : UserControl
|
||||
{
|
||||
public CounterStrikeView()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,37 +0,0 @@
|
||||
using System.Windows.Forms;
|
||||
using Artemis.Managers;
|
||||
using Artemis.Modules.Abstract;
|
||||
using Ninject;
|
||||
|
||||
namespace Artemis.Modules.Games.CounterStrike
|
||||
{
|
||||
public sealed class CounterStrikeViewModel : ModuleViewModel
|
||||
{
|
||||
public CounterStrikeViewModel(MainManager mainManager, [Named(nameof(CounterStrikeModel))] ModuleModel moduleModel, IKernel kernel)
|
||||
: base(mainManager, moduleModel, kernel)
|
||||
{
|
||||
DisplayName = "CS:GO";
|
||||
}
|
||||
|
||||
public override bool UsesProfileEditor => true;
|
||||
|
||||
public void PlaceConfigFile()
|
||||
{
|
||||
((CounterStrikeModel) ModuleModel).PlaceConfigFile();
|
||||
NotifyOfPropertyChange(() => Settings);
|
||||
}
|
||||
|
||||
public void BrowseDirectory()
|
||||
{
|
||||
var dialog = new FolderBrowserDialog { SelectedPath = ((CounterStrikeSettings)Settings).GameDirectory };
|
||||
var result = dialog.ShowDialog();
|
||||
if (result != DialogResult.OK)
|
||||
return;
|
||||
|
||||
((CounterStrikeSettings)Settings).GameDirectory = dialog.SelectedPath;
|
||||
((CounterStrikeModel)ModuleModel).PlaceConfigFile();
|
||||
Settings.Save();
|
||||
NotifyOfPropertyChange(() => Settings);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,256 +0,0 @@
|
||||
using Artemis.Modules.Abstract;
|
||||
using Artemis.Modules.General.GeneralProfile;
|
||||
using MoonSharp.Interpreter;
|
||||
|
||||
namespace Artemis.Modules.Games.Dota2
|
||||
{
|
||||
[MoonSharpUserData]
|
||||
public class Dota2DataModel : ModuleDataModel
|
||||
{
|
||||
public Provider provider { get; set; }
|
||||
public Map map { get; set; }
|
||||
public Player player { get; set; }
|
||||
public Hero hero { get; set; }
|
||||
public Abilities abilities { get; set; }
|
||||
public Items items { get; set; }
|
||||
public Previously previously { get; set; }
|
||||
}
|
||||
|
||||
[MoonSharpUserData]
|
||||
public class Provider
|
||||
{
|
||||
public string name { get; set; }
|
||||
public int appid { get; set; }
|
||||
public int version { get; set; }
|
||||
public int timestamp { get; set; }
|
||||
}
|
||||
|
||||
[MoonSharpUserData]
|
||||
public class Map
|
||||
{
|
||||
public int dayCyclePercentage;
|
||||
public string name { get; set; }
|
||||
public long matchid { get; set; }
|
||||
public int game_time { get; set; }
|
||||
public int clock_time { get; set; }
|
||||
public bool daytime { get; set; }
|
||||
public bool nightstalker_night { get; set; }
|
||||
public string game_state { get; set; }
|
||||
public string win_team { get; set; }
|
||||
public string customgamename { get; set; }
|
||||
public int ward_purchase_cooldown { get; set; }
|
||||
}
|
||||
|
||||
[MoonSharpUserData]
|
||||
public class Player
|
||||
{
|
||||
public string steamid { get; set; }
|
||||
public string name { get; set; }
|
||||
public string activity { get; set; }
|
||||
public int kills { get; set; }
|
||||
public int deaths { get; set; }
|
||||
public int assists { get; set; }
|
||||
public int last_hits { get; set; }
|
||||
public int denies { get; set; }
|
||||
public int kill_streak { get; set; }
|
||||
public string team_name { get; set; }
|
||||
public int gold { get; set; }
|
||||
public int gold_reliable { get; set; }
|
||||
public int gold_unreliable { get; set; }
|
||||
public int gpm { get; set; }
|
||||
public int xpm { get; set; }
|
||||
}
|
||||
|
||||
[MoonSharpUserData]
|
||||
public class Hero
|
||||
{
|
||||
public int id { get; set; }
|
||||
public string name { get; set; }
|
||||
public int level { get; set; }
|
||||
public bool alive { get; set; }
|
||||
public int respawn_seconds { get; set; }
|
||||
public int buyback_cost { get; set; }
|
||||
public int buyback_cooldown { get; set; }
|
||||
public int health { get; set; }
|
||||
public int max_health { get; set; }
|
||||
public int health_percent { get; set; }
|
||||
public int mana { get; set; }
|
||||
public int max_mana { get; set; }
|
||||
public int mana_percent { get; set; }
|
||||
public bool silenced { get; set; }
|
||||
public bool stunned { get; set; }
|
||||
public bool disarmed { get; set; }
|
||||
public bool magicimmune { get; set; }
|
||||
public bool hexed { get; set; }
|
||||
public bool muted { get; set; }
|
||||
public bool _break { get; set; }
|
||||
public bool has_debuff { get; set; }
|
||||
}
|
||||
|
||||
[MoonSharpUserData]
|
||||
public class Abilities
|
||||
{
|
||||
public Ability0 ability0 { get; set; }
|
||||
public Ability1 ability1 { get; set; }
|
||||
public Ability2 ability2 { get; set; }
|
||||
public Ability3 ability3 { get; set; }
|
||||
|
||||
public Attributes attributes { get; set; }
|
||||
}
|
||||
|
||||
[MoonSharpUserData]
|
||||
public class Ability0
|
||||
{
|
||||
public string name { get; set; }
|
||||
public int level { get; set; }
|
||||
public bool can_cast { get; set; }
|
||||
public bool passive { get; set; }
|
||||
public bool ability_active { get; set; }
|
||||
public int cooldown { get; set; }
|
||||
public bool ultimate { get; set; }
|
||||
}
|
||||
|
||||
[MoonSharpUserData]
|
||||
public class Ability1
|
||||
{
|
||||
public string name { get; set; }
|
||||
public int level { get; set; }
|
||||
public bool can_cast { get; set; }
|
||||
public bool passive { get; set; }
|
||||
public bool ability_active { get; set; }
|
||||
public int cooldown { get; set; }
|
||||
public bool ultimate { get; set; }
|
||||
}
|
||||
|
||||
[MoonSharpUserData]
|
||||
public class Ability2
|
||||
{
|
||||
public string name { get; set; }
|
||||
public int level { get; set; }
|
||||
public bool can_cast { get; set; }
|
||||
public bool passive { get; set; }
|
||||
public bool ability_active { get; set; }
|
||||
public int cooldown { get; set; }
|
||||
public bool ultimate { get; set; }
|
||||
}
|
||||
|
||||
[MoonSharpUserData]
|
||||
public class Ability3
|
||||
{
|
||||
public string name { get; set; }
|
||||
public int level { get; set; }
|
||||
public bool can_cast { get; set; }
|
||||
public bool passive { get; set; }
|
||||
public bool ability_active { get; set; }
|
||||
public int cooldown { get; set; }
|
||||
public bool ultimate { get; set; }
|
||||
}
|
||||
|
||||
[MoonSharpUserData]
|
||||
public class Attributes
|
||||
{
|
||||
public int level { get; set; }
|
||||
}
|
||||
|
||||
[MoonSharpUserData]
|
||||
public class Items
|
||||
{
|
||||
public Slot0 slot0 { get; set; }
|
||||
public Slot1 slot1 { get; set; }
|
||||
public Slot2 slot2 { get; set; }
|
||||
public Slot3 slot3 { get; set; }
|
||||
public Slot4 slot4 { get; set; }
|
||||
public Slot5 slot5 { get; set; }
|
||||
public Stash0 stash0 { get; set; }
|
||||
public Stash1 stash1 { get; set; }
|
||||
public Stash2 stash2 { get; set; }
|
||||
public Stash3 stash3 { get; set; }
|
||||
public Stash4 stash4 { get; set; }
|
||||
public Stash5 stash5 { get; set; }
|
||||
}
|
||||
|
||||
[MoonSharpUserData]
|
||||
public class Slot0
|
||||
{
|
||||
public string name { get; set; }
|
||||
}
|
||||
|
||||
[MoonSharpUserData]
|
||||
public class Slot1
|
||||
{
|
||||
public string name { get; set; }
|
||||
}
|
||||
|
||||
[MoonSharpUserData]
|
||||
public class Slot2
|
||||
{
|
||||
public string name { get; set; }
|
||||
}
|
||||
|
||||
[MoonSharpUserData]
|
||||
public class Slot3
|
||||
{
|
||||
public string name { get; set; }
|
||||
}
|
||||
|
||||
[MoonSharpUserData]
|
||||
public class Slot4
|
||||
{
|
||||
public string name { get; set; }
|
||||
}
|
||||
|
||||
[MoonSharpUserData]
|
||||
public class Slot5
|
||||
{
|
||||
public string name { get; set; }
|
||||
}
|
||||
|
||||
[MoonSharpUserData]
|
||||
public class Stash0
|
||||
{
|
||||
public string name { get; set; }
|
||||
}
|
||||
|
||||
[MoonSharpUserData]
|
||||
public class Stash1
|
||||
{
|
||||
public string name { get; set; }
|
||||
}
|
||||
|
||||
[MoonSharpUserData]
|
||||
public class Stash2
|
||||
{
|
||||
public string name { get; set; }
|
||||
}
|
||||
|
||||
[MoonSharpUserData]
|
||||
public class Stash3
|
||||
{
|
||||
public string name { get; set; }
|
||||
}
|
||||
|
||||
[MoonSharpUserData]
|
||||
public class Stash4
|
||||
{
|
||||
public string name { get; set; }
|
||||
}
|
||||
|
||||
[MoonSharpUserData]
|
||||
public class Stash5
|
||||
{
|
||||
public string name { get; set; }
|
||||
}
|
||||
|
||||
[MoonSharpUserData]
|
||||
public class Previously
|
||||
{
|
||||
public Player1 player { get; set; }
|
||||
}
|
||||
|
||||
[MoonSharpUserData]
|
||||
public class Player1
|
||||
{
|
||||
public int gold { get; set; }
|
||||
public int gold_unreliable { get; set; }
|
||||
}
|
||||
}
|
||||
@ -1,123 +0,0 @@
|
||||
using System.IO;
|
||||
using Artemis.DAL;
|
||||
using Artemis.Managers;
|
||||
using Artemis.Modules.Abstract;
|
||||
using Artemis.Properties;
|
||||
using Artemis.Services;
|
||||
using Artemis.Utilities;
|
||||
using Artemis.Utilities.GameState;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Artemis.Modules.Games.Dota2
|
||||
{
|
||||
public class Dota2Model : ModuleModel
|
||||
{
|
||||
private readonly MetroDialogService _dialogService;
|
||||
private readonly GameStateWebServer _gameStateWebServer;
|
||||
|
||||
|
||||
public Dota2Model(DeviceManager deviceManager, LuaManager luaManager, MetroDialogService dialogService,
|
||||
GameStateWebServer gameStateWebServer) : base(deviceManager, luaManager)
|
||||
{
|
||||
_gameStateWebServer = gameStateWebServer;
|
||||
_dialogService = dialogService;
|
||||
|
||||
Settings = SettingsProvider.Load<Dota2Settings>();
|
||||
DataModel = new Dota2DataModel();
|
||||
ProcessNames.Add("dota2");
|
||||
|
||||
FindGameDir();
|
||||
PlaceConfigFile();
|
||||
}
|
||||
|
||||
public override string Name => "Dota2";
|
||||
public override bool IsOverlay => false;
|
||||
public override bool IsBoundToProcess => true;
|
||||
|
||||
public override void Dispose()
|
||||
{
|
||||
base.Dispose();
|
||||
_gameStateWebServer.GameDataReceived -= HandleGameData;
|
||||
}
|
||||
|
||||
public override void Enable()
|
||||
{
|
||||
_gameStateWebServer.GameDataReceived += HandleGameData;
|
||||
base.Enable();
|
||||
}
|
||||
|
||||
public override void Update()
|
||||
{
|
||||
UpdateDay();
|
||||
}
|
||||
|
||||
public void FindGameDir()
|
||||
{
|
||||
var gameSettings = (Dota2Settings) Settings;
|
||||
// If already propertly set up, don't do anything
|
||||
if ((gameSettings.GameDirectory != null) && File.Exists(gameSettings.GameDirectory + "csgo.exe") &&
|
||||
File.Exists(gameSettings.GameDirectory + "/csgo/cfg/gamestate_integration_artemis.cfg"))
|
||||
return;
|
||||
|
||||
var dir = GeneralHelpers.FindSteamGame(@"\dota 2 beta\game\bin\win32\dota2.exe");
|
||||
// Remove subdirectories where they stuck the executable
|
||||
dir = dir?.Substring(0, dir.Length - 15);
|
||||
|
||||
gameSettings.GameDirectory = dir ?? string.Empty;
|
||||
gameSettings.Save();
|
||||
}
|
||||
|
||||
public void PlaceConfigFile()
|
||||
{
|
||||
var gameSettings = (Dota2Settings) Settings;
|
||||
if (gameSettings.GameDirectory == string.Empty)
|
||||
return;
|
||||
if (Directory.Exists(gameSettings.GameDirectory + "/game/dota/cfg"))
|
||||
{
|
||||
var cfgFile = Resources.dotaGamestateConfiguration.Replace("{{port}}",
|
||||
_gameStateWebServer.Port.ToString());
|
||||
try
|
||||
{
|
||||
File.WriteAllText(gameSettings.GameDirectory +
|
||||
"/game/dota/cfg/gamestate_integration/gamestate_integration_artemis.cfg", cfgFile);
|
||||
}
|
||||
catch (DirectoryNotFoundException)
|
||||
{
|
||||
Directory.CreateDirectory(gameSettings.GameDirectory + "/game/dota/cfg/gamestate_integration/");
|
||||
File.WriteAllText(gameSettings.GameDirectory +
|
||||
"/game/dota/cfg/gamestate_integration/gamestate_integration_artemis.cfg",
|
||||
cfgFile);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
_dialogService.ShowErrorMessageBox("Please select a valid Dota 2 directory\n\n" +
|
||||
@"By default Dota 2 is in \SteamApps\common\dota 2 beta");
|
||||
gameSettings.GameDirectory = string.Empty;
|
||||
gameSettings.Save();
|
||||
}
|
||||
|
||||
private void UpdateDay()
|
||||
{
|
||||
var dataModel = DataModel as Dota2DataModel;
|
||||
if (dataModel?.map?.daytime == null)
|
||||
return;
|
||||
|
||||
var timeLeft = 240 - dataModel.map.clock_time % 240;
|
||||
dataModel.map.dayCyclePercentage = (int) (100.00 / 240 * timeLeft);
|
||||
}
|
||||
|
||||
public void HandleGameData(object sender, GameDataReceivedEventArgs e)
|
||||
{
|
||||
var jsonString = e.Json.ToString();
|
||||
|
||||
// Ensure it's Dota 2 JSON
|
||||
if (!jsonString.Contains("Dota 2"))
|
||||
return;
|
||||
|
||||
// Parse the JSON
|
||||
DataModel = JsonConvert.DeserializeObject<Dota2DataModel>(jsonString);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,9 +0,0 @@
|
||||
using Artemis.Modules.Abstract;
|
||||
|
||||
namespace Artemis.Modules.Games.Dota2
|
||||
{
|
||||
public class Dota2Settings : ModuleSettings
|
||||
{
|
||||
public string GameDirectory { get; set; }
|
||||
}
|
||||
}
|
||||
@ -1,55 +0,0 @@
|
||||
<UserControl x:Class="Artemis.Modules.Games.Dota2.Dota2View"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:cal="http://www.caliburnproject.org"
|
||||
xmlns:controls="http://metro.mahapps.com/winfx/xaml/controls"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="476.986" d:DesignWidth="538.772">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="*" />
|
||||
<RowDefinition Height="30" />
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<!-- Header -->
|
||||
<Label Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="2" FontSize="20" HorizontalAlignment="Left">
|
||||
<Label.Content>
|
||||
<AccessText TextWrapping="Wrap" Text="By default shows mana, HP, character state on the keyboard and colors headset and mouse according to HP." />
|
||||
</Label.Content>
|
||||
</Label>
|
||||
|
||||
<!-- Enable -->
|
||||
<StackPanel Grid.Row="1" Grid.Column="1" HorizontalAlignment="Right" Orientation="Horizontal">
|
||||
<Label Content="Enable module" HorizontalAlignment="Right" Margin="0,0,0,3" />
|
||||
<controls:ToggleSwitchButton IsChecked="{Binding Path=IsModuleEnabled, Mode=OneWay}" cal:Message.Attach="[Event Click] = [Action ToggleModule]"
|
||||
Style="{StaticResource MahApps.Metro.Styles.ToggleSwitchButton.Win10}" ToolTip="Note: You can't enable an module when Artemis is disabled" />
|
||||
</StackPanel>
|
||||
|
||||
<!-- Directory -->
|
||||
<StackPanel Grid.Row="2" Grid.Column="0" Grid.ColumnSpan="2" Margin="0,0,1,0">
|
||||
<Label FontSize="20" HorizontalAlignment="Left" Content="Dota 2 directory" />
|
||||
<Grid>
|
||||
<TextBox x:Name="GameDirectory" Height="23" TextWrapping="Wrap" Margin="0,0,30,0" Text="{Binding Path=Settings.GameDirectory, Mode=TwoWay}" cal:Message.Attach="[Event LostFocus] = [Action PlaceConfigFile]" />
|
||||
<Button x:Name="BrowseDirectory" Content="..." RenderTransformOrigin="-0.039,-0.944" HorizontalAlignment="Right" Width="25" Style="{DynamicResource SquareButtonStyle}" Height="26" />
|
||||
</Grid>
|
||||
</StackPanel>
|
||||
|
||||
<!-- Profile editor -->
|
||||
<ContentControl Grid.Row="3" Grid.Column="0" Grid.ColumnSpan="2" x:Name="ProfileEditor" />
|
||||
|
||||
<!-- Buttons -->
|
||||
<StackPanel Grid.Column="0" Grid.Row="4" Orientation="Horizontal" VerticalAlignment="Bottom">
|
||||
<Button x:Name="ResetSettings" Content="Reset effect" VerticalAlignment="Top" Width="100" Style="{DynamicResource SquareButtonStyle}" />
|
||||
<Button x:Name="SaveSettings" Content="Save changes" VerticalAlignment="Top" Width="100" Margin="10,0,0,0" Style="{DynamicResource SquareButtonStyle}" />
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
@ -1,15 +0,0 @@
|
||||
using System.Windows.Controls;
|
||||
|
||||
namespace Artemis.Modules.Games.Dota2
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for Dota2View.xaml
|
||||
/// </summary>
|
||||
public partial class Dota2View : UserControl
|
||||
{
|
||||
public Dota2View()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,37 +0,0 @@
|
||||
using System.Windows.Forms;
|
||||
using Artemis.Managers;
|
||||
using Artemis.Modules.Abstract;
|
||||
using Ninject;
|
||||
|
||||
namespace Artemis.Modules.Games.Dota2
|
||||
{
|
||||
public sealed class Dota2ViewModel : ModuleViewModel
|
||||
{
|
||||
public Dota2ViewModel(MainManager mainManager, [Named(nameof(Dota2Model))] ModuleModel moduleModel, IKernel kernel)
|
||||
: base(mainManager, moduleModel, kernel)
|
||||
{
|
||||
DisplayName = "Dota 2";
|
||||
}
|
||||
|
||||
public override bool UsesProfileEditor => true;
|
||||
|
||||
public void PlaceConfigFile()
|
||||
{
|
||||
((Dota2Model) ModuleModel).PlaceConfigFile();
|
||||
NotifyOfPropertyChange(() => Settings);
|
||||
}
|
||||
|
||||
public void BrowseDirectory()
|
||||
{
|
||||
var dialog = new FolderBrowserDialog { SelectedPath = ((Dota2Settings)Settings).GameDirectory };
|
||||
var result = dialog.ShowDialog();
|
||||
if (result != DialogResult.OK)
|
||||
return;
|
||||
|
||||
((Dota2Settings)Settings).GameDirectory = dialog.SelectedPath;
|
||||
((Dota2Model)ModuleModel).PlaceConfigFile();
|
||||
Settings.Save();
|
||||
NotifyOfPropertyChange(() => Settings);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,367 +0,0 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
using Artemis.Modules.Games.EurotruckSimulator2.Data.Reader;
|
||||
|
||||
namespace Artemis.Modules.Games.EurotruckSimulator2.Data
|
||||
{
|
||||
public class Ets2TelemetryData : IEts2TelemetryData
|
||||
{
|
||||
private Box<Ets2TelemetryStructure> _rawData;
|
||||
|
||||
public IEts2Game Game => new Ets2Game(_rawData);
|
||||
public IEts2Truck Truck => new Ets2Truck(_rawData);
|
||||
public IEts2Trailer Trailer => new Ets2Trailer(_rawData);
|
||||
public IEts2Job Job => new Ets2Job(_rawData);
|
||||
public IEts2Navigation Navigation => new Ets2Navigation(_rawData);
|
||||
|
||||
public void Update(Ets2TelemetryStructure rawData)
|
||||
{
|
||||
_rawData = new Box<Ets2TelemetryStructure>(rawData);
|
||||
}
|
||||
|
||||
internal static DateTime SecondsToDate(int seconds)
|
||||
{
|
||||
if (seconds < 0) seconds = 0;
|
||||
return new DateTime((long) seconds*10000000, DateTimeKind.Utc);
|
||||
}
|
||||
|
||||
internal static DateTime MinutesToDate(int minutes)
|
||||
{
|
||||
return SecondsToDate(minutes*60);
|
||||
}
|
||||
|
||||
internal static string BytesToString(byte[] bytes)
|
||||
{
|
||||
if (bytes == null)
|
||||
return string.Empty;
|
||||
return Encoding.UTF8.GetString(bytes, 0, Array.FindIndex(bytes, b => b == 0));
|
||||
}
|
||||
}
|
||||
|
||||
public class Ets2Game : IEts2Game
|
||||
{
|
||||
private readonly Box<Ets2TelemetryStructure> _rawData;
|
||||
|
||||
public Ets2Game(Box<Ets2TelemetryStructure> rawData)
|
||||
{
|
||||
_rawData = rawData;
|
||||
}
|
||||
|
||||
public bool Paused => _rawData.Struct.paused != 0;
|
||||
public DateTime Time => Ets2TelemetryData.MinutesToDate(_rawData.Struct.timeAbsolute);
|
||||
public float TimeScale => _rawData.Struct.localScale;
|
||||
public DateTime NextRestStopTime => Ets2TelemetryData.MinutesToDate(_rawData.Struct.nextRestStop);
|
||||
public string Version => $"{_rawData.Struct.ets2_version_major}.{_rawData.Struct.ets2_version_minor}";
|
||||
public string TelemetryPluginVersion => _rawData.Struct.ets2_telemetry_plugin_revision.ToString();
|
||||
}
|
||||
|
||||
public class Ets2Vector : IEts2Vector
|
||||
{
|
||||
public Ets2Vector(float x, float y, float z)
|
||||
{
|
||||
X = x;
|
||||
Y = y;
|
||||
Z = z;
|
||||
}
|
||||
|
||||
public float X { get; }
|
||||
public float Y { get; }
|
||||
public float Z { get; }
|
||||
}
|
||||
|
||||
public class Ets2Placement : IEts2Placement
|
||||
{
|
||||
public Ets2Placement(float x, float y, float z,
|
||||
float heading, float pitch, float roll)
|
||||
{
|
||||
X = x;
|
||||
Y = y;
|
||||
Z = z;
|
||||
Heading = heading;
|
||||
Pitch = pitch;
|
||||
Roll = roll;
|
||||
}
|
||||
|
||||
public float X { get; }
|
||||
public float Y { get; }
|
||||
public float Z { get; }
|
||||
public float Heading { get; }
|
||||
public float Pitch { get; }
|
||||
public float Roll { get; }
|
||||
}
|
||||
|
||||
public class Ets2Truck : IEts2Truck
|
||||
{
|
||||
private readonly Box<Ets2TelemetryStructure> _rawData;
|
||||
|
||||
public Ets2Truck(Box<Ets2TelemetryStructure> rawData)
|
||||
{
|
||||
_rawData = rawData;
|
||||
}
|
||||
|
||||
public string Id => Ets2TelemetryData.BytesToString(_rawData.Struct.truckMakeId);
|
||||
public string Make => Ets2TelemetryData.BytesToString(_rawData.Struct.truckMake);
|
||||
public string Model => Ets2TelemetryData.BytesToString(_rawData.Struct.truckModel);
|
||||
|
||||
/// <summary>
|
||||
/// Truck speed in km/h.
|
||||
/// </summary>
|
||||
public float Speed => _rawData.Struct.speed*3.6f;
|
||||
|
||||
/// <summary>
|
||||
/// Cruise control speed in km/h.
|
||||
/// </summary>
|
||||
public float CruiseControlSpeed => _rawData.Struct.cruiseControlSpeed*3.6f;
|
||||
|
||||
public bool CruiseControlOn => _rawData.Struct.cruiseControl != 0;
|
||||
public float Odometer => _rawData.Struct.truckOdometer;
|
||||
public int Gear => _rawData.Struct.gear;
|
||||
public int DisplayedGear => _rawData.Struct.displayedGear;
|
||||
public int ForwardGears => _rawData.Struct.gearsForward;
|
||||
public int ReverseGears => _rawData.Struct.gearsReverse;
|
||||
public string ShifterType => Ets2TelemetryData.BytesToString(_rawData.Struct.shifterType);
|
||||
public float EngineRpm => _rawData.Struct.engineRpm;
|
||||
public float EngineRpmMax => _rawData.Struct.engineRpmMax;
|
||||
public float Fuel => _rawData.Struct.fuel;
|
||||
public float FuelCapacity => _rawData.Struct.fuelCapacity;
|
||||
public float FuelAverageConsumption => _rawData.Struct.fuelAvgConsumption;
|
||||
public float FuelWarningFactor => _rawData.Struct.fuelWarningFactor;
|
||||
public bool FuelWarningOn => _rawData.Struct.fuelWarning != 0;
|
||||
public float WearEngine => _rawData.Struct.wearEngine;
|
||||
public float WearTransmission => _rawData.Struct.wearTransmission;
|
||||
public float WearCabin => _rawData.Struct.wearCabin;
|
||||
public float WearChassis => _rawData.Struct.wearChassis;
|
||||
public float WearWheels => _rawData.Struct.wearWheels;
|
||||
public float UserSteer => _rawData.Struct.userSteer;
|
||||
public float UserThrottle => _rawData.Struct.userThrottle;
|
||||
public float UserBrake => _rawData.Struct.userBrake;
|
||||
public float UserClutch => _rawData.Struct.userClutch;
|
||||
public float GameSteer => _rawData.Struct.gameSteer;
|
||||
public float GameThrottle => _rawData.Struct.gameThrottle;
|
||||
public float GameBrake => _rawData.Struct.gameBrake;
|
||||
public float GameClutch => _rawData.Struct.gameClutch;
|
||||
public int ShifterSlot => _rawData.Struct.shifterSlot;
|
||||
|
||||
//public int ShifterToggle
|
||||
//{
|
||||
// get { return _rawData.Struct.shifterToggle; }
|
||||
//}
|
||||
|
||||
public bool EngineOn => _rawData.Struct.engineEnabled != 0;
|
||||
public bool ElectricOn => _rawData.Struct.electricEnabled != 0;
|
||||
public bool WipersOn => _rawData.Struct.wipers != 0;
|
||||
public int RetarderBrake => _rawData.Struct.retarderBrake;
|
||||
public int RetarderStepCount => (int) _rawData.Struct.retarderStepCount;
|
||||
public bool ParkBrakeOn => _rawData.Struct.parkBrake != 0;
|
||||
public bool MotorBrakeOn => _rawData.Struct.motorBrake != 0;
|
||||
public float BrakeTemperature => _rawData.Struct.brakeTemperature;
|
||||
public float Adblue => _rawData.Struct.adblue;
|
||||
public float AdblueCapacity => _rawData.Struct.adblueCapacity;
|
||||
public float AdblueAverageConsumption => _rawData.Struct.adblueConsumption;
|
||||
public bool AdblueWarningOn => _rawData.Struct.adblueWarning != 0;
|
||||
public float AirPressure => _rawData.Struct.airPressure;
|
||||
public bool AirPressureWarningOn => _rawData.Struct.airPressureWarning != 0;
|
||||
public float AirPressureWarningValue => _rawData.Struct.airPressureWarningValue;
|
||||
public bool AirPressureEmergencyOn => _rawData.Struct.airPressureEmergency != 0;
|
||||
public float AirPressureEmergencyValue => _rawData.Struct.airPressureEmergencyValue;
|
||||
public float OilTemperature => _rawData.Struct.oilTemperature;
|
||||
public float OilPressure => _rawData.Struct.oilPressure;
|
||||
public bool OilPressureWarningOn => _rawData.Struct.oilPressureWarning != 0;
|
||||
public float OilPressureWarningValue => _rawData.Struct.oilPressureWarningValue;
|
||||
public float WaterTemperature => _rawData.Struct.waterTemperature;
|
||||
public bool WaterTemperatureWarningOn => _rawData.Struct.waterTemperatureWarning != 0;
|
||||
public float WaterTemperatureWarningValue => _rawData.Struct.waterTemperatureWarningValue;
|
||||
public float BatteryVoltage => _rawData.Struct.batteryVoltage;
|
||||
public bool BatteryVoltageWarningOn => _rawData.Struct.batteryVoltageWarning != 0;
|
||||
public float BatteryVoltageWarningValue => _rawData.Struct.batteryVoltageWarningValue;
|
||||
public float LightsDashboardValue => _rawData.Struct.lightsDashboard;
|
||||
public bool LightsDashboardOn => _rawData.Struct.lightsDashboard > 0;
|
||||
public bool BlinkerLeftActive => _rawData.Struct.blinkerLeftActive != 0;
|
||||
public bool BlinkerRightActive => _rawData.Struct.blinkerRightActive != 0;
|
||||
public bool BlinkerLeftOn => _rawData.Struct.blinkerLeftOn != 0;
|
||||
public bool BlinkerRightOn => _rawData.Struct.blinkerRightOn != 0;
|
||||
public bool LightsParkingOn => _rawData.Struct.lightsParking != 0;
|
||||
public bool LightsBeamLowOn => _rawData.Struct.lightsBeamLow != 0;
|
||||
public bool LightsBeamHighOn => _rawData.Struct.lightsBeamHigh != 0;
|
||||
public bool LightsAuxFrontOn => _rawData.Struct.lightsAuxFront != 0;
|
||||
public bool LightsAuxRoofOn => _rawData.Struct.lightsAuxRoof != 0;
|
||||
public bool LightsBeaconOn => _rawData.Struct.lightsBeacon != 0;
|
||||
public bool LightsBrakeOn => _rawData.Struct.lightsBrake != 0;
|
||||
public bool LightsReverseOn => _rawData.Struct.lightsReverse != 0;
|
||||
|
||||
public IEts2Placement Placement => new Ets2Placement(
|
||||
_rawData.Struct.coordinateX,
|
||||
_rawData.Struct.coordinateY,
|
||||
_rawData.Struct.coordinateZ,
|
||||
_rawData.Struct.rotationX,
|
||||
_rawData.Struct.rotationY,
|
||||
_rawData.Struct.rotationZ);
|
||||
|
||||
public IEts2Vector Acceleration => new Ets2Vector(
|
||||
_rawData.Struct.accelerationX,
|
||||
_rawData.Struct.accelerationY,
|
||||
_rawData.Struct.accelerationZ);
|
||||
|
||||
public IEts2Vector Head => new Ets2Vector(
|
||||
_rawData.Struct.headPositionX,
|
||||
_rawData.Struct.headPositionY,
|
||||
_rawData.Struct.headPositionZ);
|
||||
|
||||
public IEts2Vector Cabin => new Ets2Vector(
|
||||
_rawData.Struct.cabinPositionX,
|
||||
_rawData.Struct.cabinPositionY,
|
||||
_rawData.Struct.cabinPositionZ);
|
||||
|
||||
public IEts2Vector Hook => new Ets2Vector(
|
||||
_rawData.Struct.hookPositionX,
|
||||
_rawData.Struct.hookPositionY,
|
||||
_rawData.Struct.hookPositionZ);
|
||||
|
||||
/*
|
||||
public IEts2GearSlot[] GearSlots
|
||||
{
|
||||
get
|
||||
{
|
||||
var array = new IEts2GearSlot[_rawData.Struct.selectorCount];
|
||||
for (int i = 0; i < array.Length; i++)
|
||||
array[i] = new Ets2GearSlot(_rawData, i);
|
||||
return array;
|
||||
}
|
||||
}
|
||||
|
||||
public IEts2Wheel[] Wheels
|
||||
{
|
||||
get
|
||||
{
|
||||
var array = new IEts2Wheel[_rawData.Struct.wheelCount];
|
||||
for (int i = 0; i < array.Length; i++)
|
||||
array[i] = new Ets2Wheel(_rawData, i);
|
||||
return array;
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
public class Ets2Trailer : IEts2Trailer
|
||||
{
|
||||
private readonly Box<Ets2TelemetryStructure> _rawData;
|
||||
|
||||
public Ets2Trailer(Box<Ets2TelemetryStructure> rawData)
|
||||
{
|
||||
_rawData = rawData;
|
||||
}
|
||||
|
||||
public bool Attached => _rawData.Struct.trailer_attached != 0;
|
||||
public string Id => Ets2TelemetryData.BytesToString(_rawData.Struct.trailerId);
|
||||
public string Name => Ets2TelemetryData.BytesToString(_rawData.Struct.trailerName);
|
||||
|
||||
/// <summary>
|
||||
/// Trailer mass in kilograms.
|
||||
/// </summary>
|
||||
public float Mass => _rawData.Struct.trailerMass;
|
||||
|
||||
public float Wear => _rawData.Struct.wearTrailer;
|
||||
|
||||
public IEts2Placement Placement => new Ets2Placement(
|
||||
_rawData.Struct.trailerCoordinateX,
|
||||
_rawData.Struct.trailerCoordinateY,
|
||||
_rawData.Struct.trailerCoordinateZ,
|
||||
_rawData.Struct.trailerRotationX,
|
||||
_rawData.Struct.trailerRotationY,
|
||||
_rawData.Struct.trailerRotationZ);
|
||||
}
|
||||
|
||||
public class Ets2Navigation : IEts2Navigation
|
||||
{
|
||||
private readonly Box<Ets2TelemetryStructure> _rawData;
|
||||
|
||||
public Ets2Navigation(Box<Ets2TelemetryStructure> rawData)
|
||||
{
|
||||
_rawData = rawData;
|
||||
}
|
||||
|
||||
public DateTime EstimatedTime => Ets2TelemetryData.SecondsToDate((int) _rawData.Struct.navigationTime);
|
||||
public int EstimatedDistance => (int) _rawData.Struct.navigationDistance;
|
||||
|
||||
public int SpeedLimit
|
||||
=>
|
||||
_rawData.Struct.navigationSpeedLimit > 0 ? (int) Math.Round(_rawData.Struct.navigationSpeedLimit*3.6f) : 0;
|
||||
}
|
||||
|
||||
public class Ets2Job : IEts2Job
|
||||
{
|
||||
private readonly Box<Ets2TelemetryStructure> _rawData;
|
||||
|
||||
public Ets2Job(Box<Ets2TelemetryStructure> rawData)
|
||||
{
|
||||
_rawData = rawData;
|
||||
}
|
||||
|
||||
public int Income => _rawData.Struct.jobIncome;
|
||||
public DateTime DeadlineTime => Ets2TelemetryData.MinutesToDate(_rawData.Struct.jobDeadline);
|
||||
|
||||
public DateTime RemainingTime
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_rawData.Struct.jobDeadline > 0)
|
||||
return Ets2TelemetryData.MinutesToDate(_rawData.Struct.jobDeadline - _rawData.Struct.timeAbsolute);
|
||||
return Ets2TelemetryData.MinutesToDate(0);
|
||||
}
|
||||
}
|
||||
|
||||
public string SourceCity => Ets2TelemetryData.BytesToString(_rawData.Struct.jobCitySource);
|
||||
public string SourceCompany => Ets2TelemetryData.BytesToString(_rawData.Struct.jobCompanySource);
|
||||
public string DestinationCity => Ets2TelemetryData.BytesToString(_rawData.Struct.jobCityDestination);
|
||||
public string DestinationCompany => Ets2TelemetryData.BytesToString(_rawData.Struct.jobCompanyDestination);
|
||||
}
|
||||
|
||||
/*
|
||||
class Ets2Wheel : IEts2Wheel
|
||||
{
|
||||
public Ets2Wheel(Box<Ets2TelemetryStructure> rawData, int wheelIndex)
|
||||
{
|
||||
Simulated = rawData.Struct.wheelSimulated[wheelIndex] != 0;
|
||||
Steerable = rawData.Struct.wheelSteerable[wheelIndex] != 0;
|
||||
Radius = rawData.Struct.wheelRadius[wheelIndex];
|
||||
Position = new Ets2Vector(
|
||||
rawData.Struct.wheelPositionX[wheelIndex],
|
||||
rawData.Struct.wheelPositionY[wheelIndex],
|
||||
rawData.Struct.wheelPositionZ[wheelIndex]);
|
||||
Powered = rawData.Struct.wheelPowered[wheelIndex] != 0;
|
||||
Liftable = rawData.Struct.wheelLiftable[wheelIndex] != 0;
|
||||
}
|
||||
|
||||
public bool Simulated { get; private set; }
|
||||
public bool Steerable { get; private set; }
|
||||
public bool Powered { get; private set; }
|
||||
public bool Liftable { get; private set; }
|
||||
public float Radius { get; private set; }
|
||||
public IEts2Vector Position { get; private set; }
|
||||
}
|
||||
|
||||
class Ets2GearSlot : IEts2GearSlot
|
||||
{
|
||||
public Ets2GearSlot(Box<Ets2TelemetryStructure> rawData, int slotIndex)
|
||||
{
|
||||
Gear = rawData.Struct.slotGear[slotIndex];
|
||||
HandlePosition = (int)rawData.Struct.slotHandlePosition[slotIndex];
|
||||
SlotSelectors = (int)rawData.Struct.slotSelectors[slotIndex];
|
||||
}
|
||||
|
||||
public int Gear { get; private set; }
|
||||
public int HandlePosition { get; private set; }
|
||||
public int SlotSelectors { get; private set; }
|
||||
}
|
||||
*/
|
||||
|
||||
public class Box<T> where T : struct
|
||||
{
|
||||
public Box(T @struct)
|
||||
{
|
||||
Struct = @struct;
|
||||
}
|
||||
|
||||
public T Struct { get; set; }
|
||||
}
|
||||
}
|
||||
@ -1,44 +0,0 @@
|
||||
using System;
|
||||
using Artemis.Modules.Games.EurotruckSimulator2.Data.Reader;
|
||||
|
||||
namespace Artemis.Modules.Games.EurotruckSimulator2.Data
|
||||
{
|
||||
public class Ets2TelemetryDataReader : IDisposable
|
||||
{
|
||||
/// <summary>
|
||||
/// ETS2 telemetry plugin maps the data to this mapped file name.
|
||||
/// </summary>
|
||||
private const string Ets2TelemetryMappedFileName = "Local\\Ets2TelemetryServer";
|
||||
|
||||
// ReSharper disable once InconsistentNaming
|
||||
private static readonly Lazy<Ets2TelemetryDataReader> instance = new Lazy<Ets2TelemetryDataReader>(
|
||||
() => new Ets2TelemetryDataReader());
|
||||
|
||||
private readonly Ets2TelemetryData _data = new Ets2TelemetryData();
|
||||
|
||||
private readonly object _lock = new object();
|
||||
|
||||
private readonly SharedProcessMemory<Ets2TelemetryStructure> _sharedMemory =
|
||||
new SharedProcessMemory<Ets2TelemetryStructure>(Ets2TelemetryMappedFileName);
|
||||
|
||||
public static Ets2TelemetryDataReader Instance => instance.Value;
|
||||
|
||||
public bool IsConnected => _sharedMemory.IsConnected;
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
_sharedMemory?.Dispose();
|
||||
}
|
||||
|
||||
public IEts2TelemetryData Read()
|
||||
{
|
||||
lock (_lock)
|
||||
{
|
||||
_sharedMemory.Data = default(Ets2TelemetryStructure);
|
||||
_sharedMemory.Read();
|
||||
_data.Update(_sharedMemory.Data);
|
||||
return _data;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,763 +0,0 @@
|
||||
using System;
|
||||
|
||||
namespace Artemis.Modules.Games.EurotruckSimulator2.Data
|
||||
{
|
||||
public interface IEts2TelemetryData
|
||||
{
|
||||
/// <summary>
|
||||
/// Game information.
|
||||
/// </summary>
|
||||
IEts2Game Game { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Truck information.
|
||||
/// </summary>
|
||||
IEts2Truck Truck { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Trailer information.
|
||||
/// </summary>
|
||||
IEts2Trailer Trailer { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Job information.
|
||||
/// </summary>
|
||||
IEts2Job Job { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Navigation information.
|
||||
/// </summary>
|
||||
IEts2Navigation Navigation { get; }
|
||||
}
|
||||
|
||||
public interface IEts2Game
|
||||
{
|
||||
/// <summary>
|
||||
/// Current game time.
|
||||
/// Serializes to ISO 8601 string in JSON.
|
||||
/// Example: "0001-01-05T05:11:00Z"
|
||||
/// </summary>
|
||||
DateTime Time { get; }
|
||||
|
||||
/// <summary>
|
||||
/// True if game is currently paused, false otherwise.
|
||||
/// </summary>
|
||||
bool Paused { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Current version of the telemetry plugin DLL file.
|
||||
/// Example: "4"
|
||||
/// </summary>
|
||||
string TelemetryPluginVersion { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Current version of the game.
|
||||
/// Example: "1.10"
|
||||
/// </summary>
|
||||
string Version { get; }
|
||||
|
||||
/// <summary>
|
||||
/// When the fatigue simulation is disabled, the behavior of this channel
|
||||
/// is implementation dependent. The game might provide the value which would
|
||||
/// apply if it was enabled or provide no value at all.
|
||||
/// Example: "0001-01-01T10:52:00Z"
|
||||
/// </summary>
|
||||
DateTime NextRestStopTime { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Scale applied to distance and time to compensate
|
||||
/// for the scale of the map (e.g. 1s of real time corresponds
|
||||
/// to local_scale seconds of simulated game time).
|
||||
/// Example: 3
|
||||
/// </summary>
|
||||
float TimeScale { get; }
|
||||
}
|
||||
|
||||
public interface IEts2Vector
|
||||
{
|
||||
float X { get; }
|
||||
float Y { get; }
|
||||
float Z { get; }
|
||||
}
|
||||
|
||||
public interface IEts2Placement
|
||||
{
|
||||
/// <summary>
|
||||
/// X coordinate of the placement.
|
||||
/// Example: 13723.7881
|
||||
/// </summary>
|
||||
float X { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Y coordinate of the placement.
|
||||
/// Example: 65.22377
|
||||
/// </summary>
|
||||
float Y { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Z coordinate of the placement.
|
||||
/// Example: 13738.8018
|
||||
/// </summary>
|
||||
float Z { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The angle is measured counterclockwise in horizontal plane when looking
|
||||
/// from top where 0 corresponds to forward (north), 0.25 to left (west),
|
||||
/// 0.5 to backward (south) and 0.75 to right (east).
|
||||
/// Stored in unit range where (0,1) corresponds to (0,360).
|
||||
/// Example: 0.13688866
|
||||
/// </summary>
|
||||
float Heading { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The pitch angle is zero when in horizontal direction,
|
||||
/// with positive values pointing up (0.25 directly to zenith),
|
||||
/// and negative values pointing down (-0.25 directly to nadir).
|
||||
/// Stored in unit range where (-0.25,0.25) corresponds to (-90,90).
|
||||
/// Example: 0.00005
|
||||
/// </summary>
|
||||
float Pitch { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The angle is measured in counterclockwise when looking in direction of the roll axis.
|
||||
/// Stored in unit range where (-0.5,0.5) corresponds to (-180,180).
|
||||
/// Example: -0.00009
|
||||
/// </summary>
|
||||
float Roll { get; }
|
||||
}
|
||||
|
||||
public interface IEts2Truck
|
||||
{
|
||||
/// <summary>
|
||||
/// Current truck speed in km/h.
|
||||
/// Example: 50.411231
|
||||
/// </summary>
|
||||
float Speed { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Represents vehicle space linear acceleration of
|
||||
/// the truck measured in meters per second^2.
|
||||
/// Example: { "x": 0.046569, "y": -0.00116, "z": -1.03676 }
|
||||
/// </summary>
|
||||
IEts2Vector Acceleration { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Current truck placement in the game world.
|
||||
/// </summary>
|
||||
IEts2Placement Placement { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The value of the odometer in km.
|
||||
/// Example: 105809.25
|
||||
/// </summary>
|
||||
float Odometer { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Speed selected for the cruise control in km/h.
|
||||
/// Example: 75
|
||||
/// </summary>
|
||||
float CruiseControlSpeed { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Brand Id of the current truck.
|
||||
/// Example: "man".
|
||||
/// </summary>
|
||||
string Id { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Localized brand name of the current truck for display purposes.
|
||||
/// Example: "MAN".
|
||||
/// </summary>
|
||||
string Make { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Localized model name of the current truck.
|
||||
/// Example: "TGX".
|
||||
/// </summary>
|
||||
string Model { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gear that is currently selected in the engine.
|
||||
/// Positive values reflect forward gears, negative - reverse.
|
||||
/// Example: 9
|
||||
/// </summary>
|
||||
int Gear { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gear that is currently displayed on the main dashboard.
|
||||
/// Positive values reflect forward gears, negative - reverse.
|
||||
/// Example: 4
|
||||
/// </summary>
|
||||
int DisplayedGear { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Number of forward gears on undamaged truck.
|
||||
/// Example: 12
|
||||
/// </summary>
|
||||
int ForwardGears { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Number of reverse gears on undamaged truck.
|
||||
/// Example: 2
|
||||
/// </summary>
|
||||
int ReverseGears { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Current RPM value of the truck's engine (rotates per minute).
|
||||
/// Example: 1372.3175
|
||||
/// </summary>
|
||||
float EngineRpm { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Maximal RPM value of the truck's engine.
|
||||
/// Example: 2500
|
||||
/// </summary>
|
||||
float EngineRpmMax { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Current amount of fuel in liters.
|
||||
/// Example: 696.7544
|
||||
/// </summary>
|
||||
float Fuel { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Fuel tank capacity in litres.
|
||||
/// Example: 700
|
||||
/// </summary>
|
||||
float FuelCapacity { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Average consumption of the fuel in liters/km.
|
||||
/// Example: 0.4923077
|
||||
/// </summary>
|
||||
float FuelAverageConsumption { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Steering received from input (-1;1).
|
||||
/// Note that it is interpreted counterclockwise.
|
||||
/// If the user presses the steer right button on digital input
|
||||
/// (e.g. keyboard) this value goes immediatelly to -1.0
|
||||
/// Example: -1.0
|
||||
/// </summary>
|
||||
float UserSteer { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Throttle received from input (-1;1).
|
||||
/// If the user presses the forward button on digital input
|
||||
/// (e.g. keyboard) this value goes immediatelly to 1.0
|
||||
/// Example: 0
|
||||
/// </summary>
|
||||
float UserThrottle { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Brake received from input (-1;1)
|
||||
/// If the user presses the brake button on digital input
|
||||
/// (e.g. keyboard) this value goes immediatelly to 1.0
|
||||
/// Example: 0
|
||||
/// </summary>
|
||||
float UserBrake { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Clutch received from input (-1;1)
|
||||
/// If the user presses the clutch button on digital input
|
||||
/// (e.g. keyboard) this value goes immediatelly to 1.0
|
||||
/// Example: 0
|
||||
/// </summary>
|
||||
float UserClutch { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Steering as used by the simulation (-1;1)
|
||||
/// Note that it is interpreted counterclockwise.
|
||||
/// Accounts for interpolation speeds and simulated
|
||||
/// counterfoces for digital inputs.
|
||||
/// Example: -0.423521
|
||||
/// </summary>
|
||||
float GameSteer { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Throttle pedal input as used by the simulation (0;1)
|
||||
/// Accounts for the press attack curve for digital inputs
|
||||
/// or cruise-control input.
|
||||
/// Example: 0.17161
|
||||
/// </summary>
|
||||
float GameThrottle { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Brake pedal input as used by the simulation (0;1)
|
||||
/// Accounts for the press attack curve for digital inputs.
|
||||
/// Does not contain retarder, parking or motor brake.
|
||||
/// Example: 0
|
||||
/// </summary>
|
||||
float GameBrake { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Clutch pedal input as used by the simulation (0;1)
|
||||
/// Accounts for the automatic shifting or interpolation of
|
||||
/// player input.
|
||||
/// Example: 0
|
||||
/// </summary>
|
||||
float GameClutch { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Current level of the retarder brake.
|
||||
/// Ranges from 0 to RetarderStepCount.
|
||||
/// Example: 0
|
||||
/// </summary>
|
||||
int RetarderBrake { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Number of steps in the retarder.
|
||||
/// Set to zero if retarder is not mounted to the truck.
|
||||
/// Example: 3
|
||||
/// </summary>
|
||||
int RetarderStepCount { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gearbox slot the h-shifter handle is currently in.
|
||||
/// 0 means that no slot is selected.
|
||||
/// Example: 0
|
||||
/// </summary>
|
||||
int ShifterSlot { get; }
|
||||
|
||||
/// <summary>
|
||||
/// TODO: need to fix.
|
||||
/// </summary>
|
||||
/// <summary>
|
||||
/// Pressure in the brake air tank in psi.
|
||||
/// Example: 133.043961
|
||||
/// </summary>
|
||||
float AirPressure { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Temperature of the brakes in degrees celsius.
|
||||
/// Example: 15.9377184
|
||||
/// </summary>
|
||||
float BrakeTemperature { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Amount of AdBlue in liters.
|
||||
/// Example: 0
|
||||
/// </summary>
|
||||
float Adblue { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Average consumption of the adblue in liters/km.
|
||||
/// Example: 0
|
||||
/// </summary>
|
||||
float AdblueAverageConsumption { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Pressure of the oil in psi.
|
||||
/// Example: 36.4550362
|
||||
/// </summary>
|
||||
float OilPressure { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Temperature of the oil in degrees celsius.
|
||||
/// Example: 16.2580566
|
||||
/// </summary>
|
||||
float OilTemperature { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Temperature of the water in degrees celsius.
|
||||
/// Example: 16.1623955
|
||||
/// </summary>
|
||||
float WaterTemperature { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Voltage of the battery in volts.
|
||||
/// Example: 23.4985161
|
||||
/// </summary>
|
||||
float BatteryVoltage { get; }
|
||||
|
||||
/// <summary>
|
||||
/// AdBlue tank capacity in litres.
|
||||
/// Example: 0
|
||||
/// </summary>
|
||||
float AdblueCapacity { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Current level of truck's engine wear/damage between 0 (min) and 1 (max).
|
||||
/// Example: 0.00675457
|
||||
/// </summary>
|
||||
float WearEngine { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Current level of truck's transmission wear/damage between 0 (min) and 1 (max).
|
||||
/// </summary>
|
||||
float WearTransmission { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Current level of truck's cabin wear/damage between 0 (min) and 1 (max).
|
||||
/// </summary>
|
||||
float WearCabin { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Current level of truck's chassis wear/damage between 0 (min) and 1 (max).
|
||||
/// </summary>
|
||||
float WearChassis { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Current level of truck's wheel wear/damage between 0 (min) and 1 (max).
|
||||
/// </summary>
|
||||
float WearWheels { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Default position of the head in the cabin space.
|
||||
/// Example: { "x": -0.795116067, "y": 1.43522251, "z": -0.08483863 }
|
||||
/// </summary>
|
||||
IEts2Vector Head { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Position of the cabin in the vehicle space.
|
||||
/// This is position of the joint around which the cabin rotates.
|
||||
/// This attribute might be not present if the vehicle does not have a separate cabin.
|
||||
/// Example: { "x": 0, "y": 1.36506855, "z": -1.70362806 }
|
||||
/// </summary>
|
||||
IEts2Vector Cabin { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Position of the trailer connection hook in vehicle space.
|
||||
/// Example: { "x": 0, "y": 0.939669, "z": -6.17736959 }
|
||||
/// </summary>
|
||||
IEts2Vector Hook { get; }
|
||||
|
||||
/// <summary>
|
||||
/// All available selectors (e.g. range/splitter toggles). TODO: need to fix.
|
||||
/// </summary>
|
||||
/// <summary>
|
||||
/// Type of the shifter.
|
||||
/// One of the following values: "arcade", "automatic", "manual", "hshifter".
|
||||
/// </summary>
|
||||
string ShifterType { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Indicates whether cruise control is turned on or off.
|
||||
/// </summary>
|
||||
bool CruiseControlOn { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Indicates whether wipers are currently turned on or off.
|
||||
/// </summary>
|
||||
bool WipersOn { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Is the parking brake enabled or not.
|
||||
/// </summary>
|
||||
bool ParkBrakeOn { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Is the motor brake enabled or not.
|
||||
/// </summary>
|
||||
bool MotorBrakeOn { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Is the engine enabled or not.
|
||||
/// </summary>
|
||||
bool EngineOn { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Is the electric enabled or not.
|
||||
/// </summary>
|
||||
bool ElectricOn { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Is left blinker currently emits light or not.
|
||||
/// </summary>
|
||||
bool BlinkerLeftActive { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Is right blinker currently emits light or not.
|
||||
/// </summary>
|
||||
bool BlinkerRightActive { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Is left blinker currently turned on or off.
|
||||
/// </summary>
|
||||
bool BlinkerLeftOn { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Is right blinker currently turned on or off.
|
||||
/// </summary>
|
||||
bool BlinkerRightOn { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Are the parking lights enabled or not.
|
||||
/// </summary>
|
||||
bool LightsParkingOn { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Are the low beam lights enabled or not.
|
||||
/// </summary>
|
||||
bool LightsBeamLowOn { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Are the high beam lights enabled or not.
|
||||
/// </summary>
|
||||
bool LightsBeamHighOn { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Are the auxiliary front lights active or not.
|
||||
/// </summary>
|
||||
bool LightsAuxFrontOn { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Are the auxiliary roof lights active or not.
|
||||
/// </summary>
|
||||
bool LightsAuxRoofOn { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Are the beacon lights enabled or not.
|
||||
/// </summary>
|
||||
bool LightsBeaconOn { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Is the brake light active or not.
|
||||
/// </summary>
|
||||
bool LightsBrakeOn { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Is the reverse light active or not.
|
||||
/// </summary>
|
||||
bool LightsReverseOn { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Is the battery voltage/not charging warning active or not.
|
||||
/// </summary>
|
||||
bool BatteryVoltageWarningOn { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Is the air pressure warning active or not.
|
||||
/// </summary>
|
||||
bool AirPressureWarningOn { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Are the emergency brakes active as result of low air pressure or not.
|
||||
/// </summary>
|
||||
bool AirPressureEmergencyOn { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Is the low adblue warning active or not.
|
||||
/// </summary>
|
||||
bool AdblueWarningOn { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Is the oil pressure warning active or not.
|
||||
/// </summary>
|
||||
bool OilPressureWarningOn { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Is the water temperature warning active or not.
|
||||
/// </summary>
|
||||
bool WaterTemperatureWarningOn { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Intensity of the dashboard backlight between 0 (off) and 1 (max).
|
||||
/// </summary>
|
||||
float LightsDashboardValue { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Is the dashboard backlight currently turned on or off.
|
||||
/// </summary>
|
||||
bool LightsDashboardOn { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Is the low fuel warning active or not.
|
||||
/// </summary>
|
||||
bool FuelWarningOn { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Fraction of the fuel capacity bellow which is activated the fuel warning.
|
||||
/// Example: 0.15
|
||||
/// </summary>
|
||||
float FuelWarningFactor { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Pressure of the air in the tank bellow which the warning activates.
|
||||
/// Example: 65
|
||||
/// </summary>
|
||||
float AirPressureWarningValue { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Pressure of the air in the tank bellow which the emergency brakes activate.
|
||||
/// Example: 30
|
||||
/// </summary>
|
||||
float AirPressureEmergencyValue { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Pressure of the oil bellow which the warning activates.
|
||||
/// Example: 10
|
||||
/// </summary>
|
||||
float OilPressureWarningValue { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Temperature of the water above which the warning activates.
|
||||
/// Example: 105
|
||||
/// </summary>
|
||||
float WaterTemperatureWarningValue { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Voltage of the battery bellow which the warning activates.
|
||||
/// Example: 22
|
||||
/// </summary>
|
||||
float BatteryVoltageWarningValue { get; }
|
||||
}
|
||||
|
||||
public interface IEts2Navigation
|
||||
{
|
||||
/// <summary>
|
||||
/// Relative estimated time of arrival.
|
||||
/// Example: "0001-01-01T02:05:00Z"
|
||||
/// </summary>
|
||||
DateTime EstimatedTime { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Estimated distance to the destination in meters.
|
||||
/// Example: 1224
|
||||
/// </summary>
|
||||
int EstimatedDistance { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Current value of the "Route Advisor speed limit" in km/h.
|
||||
/// Example: 50
|
||||
/// </summary>
|
||||
int SpeedLimit { get; }
|
||||
}
|
||||
|
||||
public interface IEts2Job
|
||||
{
|
||||
/// <summary>
|
||||
/// Reward in internal game-specific currency.
|
||||
/// Example: 2316
|
||||
/// </summary>
|
||||
int Income { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Absolute in-game time of end of job delivery window.
|
||||
/// Delivering the job after this time will cause it be late.
|
||||
/// Example: "0001-01-09T03:34:00Z"
|
||||
/// </summary>
|
||||
DateTime DeadlineTime { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Relative remaining in-game time left before deadline.
|
||||
/// Example: "0001-01-01T07:06:00Z"
|
||||
/// </summary>
|
||||
DateTime RemainingTime { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Localized name of the source city for display purposes.
|
||||
/// Example: "Linz"
|
||||
/// </summary>
|
||||
string SourceCity { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Localized name of the destination city for display purposes.
|
||||
/// Example: "Salzburg"
|
||||
/// </summary>
|
||||
string DestinationCity { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Localized name of the source company for display purposes.
|
||||
/// Example: "DHL"
|
||||
/// </summary>
|
||||
string SourceCompany { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Localized name of the destination company for display purposes.
|
||||
/// Example: "JCB"
|
||||
/// </summary>
|
||||
string DestinationCompany { get; }
|
||||
}
|
||||
|
||||
public interface IEts2Trailer
|
||||
{
|
||||
/// <summary>
|
||||
/// Id of the cargo for internal use by code.
|
||||
/// Example: "derrick"
|
||||
/// </summary>
|
||||
string Id { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Localized name of the current trailer for display purposes.
|
||||
/// Example: "Derrick"
|
||||
/// </summary>
|
||||
string Name { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Is the trailer attached to the truck or not.
|
||||
/// </summary>
|
||||
bool Attached { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Mass of the cargo in kilograms.
|
||||
/// Example: 22000
|
||||
/// </summary>
|
||||
float Mass { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Current trailer placement in the game world.
|
||||
/// </summary>
|
||||
IEts2Placement Placement { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Current level of trailer wear/damage between 0 (min) and 1 (max).
|
||||
/// Example: 0.0314717
|
||||
/// </summary>
|
||||
float Wear { get; }
|
||||
}
|
||||
|
||||
/*
|
||||
public interface IEts2Wheel
|
||||
{
|
||||
/// <summary>
|
||||
/// Is the wheel physically simulated or not.
|
||||
/// </summary>
|
||||
bool Simulated { get; }
|
||||
/// <summary>
|
||||
/// Is the wheel steerable or not.
|
||||
/// </summary>
|
||||
bool Steerable { get; }
|
||||
/// <summary>
|
||||
/// Radius of the wheel.
|
||||
/// Example: 0.5120504
|
||||
/// </summary>
|
||||
float Radius { get; }
|
||||
/// <summary>
|
||||
/// Position of respective wheels in the vehicle space.
|
||||
/// Example: { "x": -0.9, "y": 0.506898463, "z": 6.25029 }
|
||||
/// </summary>
|
||||
IEts2Vector Position { get; }
|
||||
/// <summary>
|
||||
/// Is the wheel powered or not.
|
||||
/// </summary>
|
||||
bool Powered { get; }
|
||||
/// <summary>
|
||||
/// Is the wheel liftable or not.
|
||||
/// </summary>
|
||||
bool Liftable { get; }
|
||||
}
|
||||
|
||||
public interface IEts2GearSlot
|
||||
{
|
||||
/// <summary>
|
||||
/// Gear selected when requirements for this h-shifter slot are meet.
|
||||
/// Example: 0
|
||||
/// </summary>
|
||||
int Gear { get; }
|
||||
/// <summary>
|
||||
/// Position of h-shifter handle.
|
||||
/// Zero corresponds to neutral position.
|
||||
/// Mapping to physical position of the handle depends on input setup.
|
||||
/// Example: 0
|
||||
/// </summary>
|
||||
int HandlePosition { get; }
|
||||
/// <summary>
|
||||
/// Bitmask of required on/off state of selectors.
|
||||
/// Only first N number of bits are relevant (where N is the number of IEts2GearSlot objects).
|
||||
/// Example: 0
|
||||
/// </summary>
|
||||
int SlotSelectors { get; }
|
||||
}
|
||||
*/
|
||||
}
|
||||
@ -1,214 +0,0 @@
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Artemis.Modules.Games.EurotruckSimulator2.Data.Reader
|
||||
{
|
||||
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
|
||||
public struct Ets2TelemetryStructure
|
||||
{
|
||||
private const int GeneralStringSize = 64;
|
||||
|
||||
public uint time;
|
||||
public uint paused;
|
||||
|
||||
public uint ets2_telemetry_plugin_revision;
|
||||
public uint ets2_version_major;
|
||||
public uint ets2_version_minor;
|
||||
|
||||
// ***** REVISION 1 ****** //
|
||||
|
||||
private readonly byte padding1;
|
||||
public byte trailer_attached;
|
||||
public byte padding2;
|
||||
public byte padding3;
|
||||
|
||||
public float speed;
|
||||
public float accelerationX;
|
||||
public float accelerationY;
|
||||
public float accelerationZ;
|
||||
|
||||
public float coordinateX;
|
||||
public float coordinateY;
|
||||
public float coordinateZ;
|
||||
|
||||
public float rotationX;
|
||||
public float rotationY;
|
||||
public float rotationZ;
|
||||
|
||||
public int gear;
|
||||
public int gearsForward;
|
||||
public int gearRanges;
|
||||
public int gearRangeActive;
|
||||
|
||||
public float engineRpm;
|
||||
public float engineRpmMax;
|
||||
|
||||
public float fuel;
|
||||
public float fuelCapacity;
|
||||
public float fuelRate;
|
||||
public float fuelAvgConsumption;
|
||||
|
||||
public float userSteer;
|
||||
public float userThrottle;
|
||||
public float userBrake;
|
||||
public float userClutch;
|
||||
|
||||
public float gameSteer;
|
||||
public float gameThrottle;
|
||||
public float gameBrake;
|
||||
public float gameClutch;
|
||||
|
||||
public float truckWeight;
|
||||
public float trailerWeight;
|
||||
|
||||
public int modelOffset;
|
||||
public int modelLength;
|
||||
|
||||
public int trailerOffset;
|
||||
public int trailerLength;
|
||||
|
||||
public int timeAbsolute;
|
||||
public int gearsReverse;
|
||||
|
||||
public float trailerMass;
|
||||
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = GeneralStringSize)] public byte[] trailerId;
|
||||
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = GeneralStringSize)] public byte[] trailerName;
|
||||
|
||||
public int jobIncome;
|
||||
public int jobDeadline;
|
||||
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = GeneralStringSize)] public byte[] jobCitySource;
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = GeneralStringSize)] public byte[] jobCityDestination;
|
||||
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = GeneralStringSize)] public byte[] jobCompanySource;
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = GeneralStringSize)] public byte[] jobCompanyDestination;
|
||||
|
||||
// ***** REVISION 3 ****** //
|
||||
|
||||
public int retarderBrake;
|
||||
public int shifterSlot;
|
||||
public int shifterToggle;
|
||||
public int padding4;
|
||||
|
||||
public byte cruiseControl;
|
||||
public byte wipers;
|
||||
|
||||
public byte parkBrake;
|
||||
public byte motorBrake;
|
||||
|
||||
public byte electricEnabled;
|
||||
public byte engineEnabled;
|
||||
|
||||
public byte blinkerLeftActive;
|
||||
public byte blinkerRightActive;
|
||||
public byte blinkerLeftOn;
|
||||
public byte blinkerRightOn;
|
||||
|
||||
public byte lightsParking;
|
||||
public byte lightsBeamLow;
|
||||
public byte lightsBeamHigh;
|
||||
public uint lightsAuxFront;
|
||||
public uint lightsAuxRoof;
|
||||
public byte lightsBeacon;
|
||||
public byte lightsBrake;
|
||||
public byte lightsReverse;
|
||||
|
||||
public byte batteryVoltageWarning;
|
||||
public byte airPressureWarning;
|
||||
public byte airPressureEmergency;
|
||||
public byte adblueWarning;
|
||||
public byte oilPressureWarning;
|
||||
public byte waterTemperatureWarning;
|
||||
|
||||
public float airPressure;
|
||||
public float brakeTemperature;
|
||||
public int fuelWarning;
|
||||
public float adblue;
|
||||
public float adblueConsumption;
|
||||
public float oilPressure;
|
||||
public float oilTemperature;
|
||||
public float waterTemperature;
|
||||
public float batteryVoltage;
|
||||
public float lightsDashboard;
|
||||
public float wearEngine;
|
||||
public float wearTransmission;
|
||||
public float wearCabin;
|
||||
public float wearChassis;
|
||||
public float wearWheels;
|
||||
public float wearTrailer;
|
||||
public float truckOdometer;
|
||||
public float cruiseControlSpeed;
|
||||
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = GeneralStringSize)] public byte[] truckMake;
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = GeneralStringSize)] public byte[] truckMakeId;
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = GeneralStringSize)] public byte[] truckModel;
|
||||
|
||||
// ***** REVISION 4 ****** //
|
||||
|
||||
public float fuelWarningFactor;
|
||||
public float adblueCapacity;
|
||||
public float airPressureWarningValue;
|
||||
public float airPressureEmergencyValue;
|
||||
public float oilPressureWarningValue;
|
||||
public float waterTemperatureWarningValue;
|
||||
public float batteryVoltageWarningValue;
|
||||
|
||||
public uint retarderStepCount;
|
||||
|
||||
public float cabinPositionX;
|
||||
public float cabinPositionY;
|
||||
public float cabinPositionZ;
|
||||
public float headPositionX;
|
||||
public float headPositionY;
|
||||
public float headPositionZ;
|
||||
public float hookPositionX;
|
||||
public float hookPositionY;
|
||||
public float hookPositionZ;
|
||||
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)] public byte[] shifterType;
|
||||
|
||||
public float localScale;
|
||||
public int nextRestStop;
|
||||
public float trailerCoordinateX;
|
||||
public float trailerCoordinateY;
|
||||
public float trailerCoordinateZ;
|
||||
public float trailerRotationX;
|
||||
public float trailerRotationY;
|
||||
public float trailerRotationZ;
|
||||
|
||||
public int displayedGear;
|
||||
public float navigationDistance;
|
||||
public float navigationTime;
|
||||
public float navigationSpeedLimit;
|
||||
|
||||
/*
|
||||
const int MaxSlotCount = 32; // TODO: need to fix.
|
||||
const int MaxWheelCount = 20;
|
||||
public uint wheelCount;
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = MaxWheelCount)]
|
||||
public float[] wheelPositionX;
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = MaxWheelCount)]
|
||||
public float[] wheelPositionY;
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = MaxWheelCount)]
|
||||
public float[] wheelPositionZ;
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = MaxWheelCount)]
|
||||
public byte[] wheelSteerable;
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = MaxWheelCount)]
|
||||
public byte[] wheelSimulated;
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = MaxWheelCount)]
|
||||
public float[] wheelRadius;
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = MaxWheelCount)]
|
||||
public byte[] wheelPowered;
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = MaxWheelCount)]
|
||||
public byte[] wheelLiftable;
|
||||
public uint selectorCount;
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = MaxSlotCount)]
|
||||
public int[] slotGear;
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = MaxSlotCount)]
|
||||
public uint[] slotHandlePosition;
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = MaxSlotCount)]
|
||||
public uint[] slotSelectors;
|
||||
*/
|
||||
}
|
||||
}
|
||||
@ -1,84 +0,0 @@
|
||||
using System;
|
||||
using System.IO.MemoryMappedFiles;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Artemis.Modules.Games.EurotruckSimulator2.Data.Reader
|
||||
{
|
||||
public class SharedProcessMemory<T> : IDisposable
|
||||
{
|
||||
private readonly string _mapName;
|
||||
private MemoryMappedViewAccessor _memoryMappedAccessor;
|
||||
|
||||
private MemoryMappedFile _memoryMappedFile;
|
||||
|
||||
public SharedProcessMemory(string mapName)
|
||||
{
|
||||
_mapName = mapName;
|
||||
Data = default(T);
|
||||
}
|
||||
|
||||
public T Data { get; set; }
|
||||
|
||||
public bool IsConnected
|
||||
{
|
||||
get
|
||||
{
|
||||
InitializeViewAccessor();
|
||||
return _memoryMappedAccessor != null;
|
||||
}
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
if (_memoryMappedAccessor != null)
|
||||
{
|
||||
_memoryMappedAccessor.Dispose();
|
||||
_memoryMappedFile.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
private void InitializeViewAccessor()
|
||||
{
|
||||
if (_memoryMappedAccessor == null)
|
||||
try
|
||||
{
|
||||
_memoryMappedFile = MemoryMappedFile.OpenExisting(_mapName, MemoryMappedFileRights.ReadWrite);
|
||||
_memoryMappedAccessor = _memoryMappedFile.CreateViewAccessor(0, Marshal.SizeOf(typeof(T)),
|
||||
MemoryMappedFileAccess.Read);
|
||||
}
|
||||
// ReSharper disable once EmptyGeneralCatchClause
|
||||
catch
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public void Read()
|
||||
{
|
||||
InitializeViewAccessor();
|
||||
|
||||
if (_memoryMappedAccessor == null)
|
||||
return;
|
||||
|
||||
var rawData = new byte[Marshal.SizeOf(typeof(T))];
|
||||
|
||||
_memoryMappedAccessor.ReadArray(0, rawData, 0, rawData.Length);
|
||||
|
||||
T createdObject;
|
||||
|
||||
var reservedMemPtr = IntPtr.Zero;
|
||||
try
|
||||
{
|
||||
reservedMemPtr = Marshal.AllocHGlobal(rawData.Length);
|
||||
Marshal.Copy(rawData, 0, reservedMemPtr, rawData.Length);
|
||||
createdObject = (T) Marshal.PtrToStructure(reservedMemPtr, typeof(T));
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (reservedMemPtr != IntPtr.Zero)
|
||||
Marshal.FreeHGlobal(reservedMemPtr);
|
||||
}
|
||||
|
||||
Data = createdObject;
|
||||
}
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user