forked from miyu/MiniSynapse
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
89d502e
commit 0b76f99
Showing
5 changed files
with
127 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,25 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio 14 | ||
VisualStudioVersion = 14.0.22823.1 | ||
# Visual Studio Version 16 | ||
VisualStudioVersion = 16.0.30128.74 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ItzWarty.MiniSynapse", "ItzWarty.MiniSynapse\ItzWarty.MiniSynapse.csproj", "{69ACE22E-8599-4DD8-A53C-C0D320015F7A}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
Debug|x86 = Debug|x86 | ||
Release|x86 = Release|x86 | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{69ACE22E-8599-4DD8-A53C-C0D320015F7A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{69ACE22E-8599-4DD8-A53C-C0D320015F7A}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{69ACE22E-8599-4DD8-A53C-C0D320015F7A}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{69ACE22E-8599-4DD8-A53C-C0D320015F7A}.Release|Any CPU.Build.0 = Release|Any CPU | ||
{69ACE22E-8599-4DD8-A53C-C0D320015F7A}.Debug|x86.ActiveCfg = Debug|x86 | ||
{69ACE22E-8599-4DD8-A53C-C0D320015F7A}.Debug|x86.Build.0 = Debug|x86 | ||
{69ACE22E-8599-4DD8-A53C-C0D320015F7A}.Release|x86.ActiveCfg = Release|x86 | ||
{69ACE22E-8599-4DD8-A53C-C0D320015F7A}.Release|x86.Build.0 = Release|x86 | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
GlobalSection(ExtensibilityGlobals) = postSolution | ||
SolutionGuid = {117F73F5-1EA4-485C-B6F5-EDBD9C44D4CA} | ||
EndGlobalSection | ||
EndGlobal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<configuration> | ||
<startup> | ||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" /> | ||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2"/> | ||
</startup> | ||
</configuration> | ||
</configuration> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,86 @@ | ||
using System; | ||
using System.Windows.Forms; | ||
using Razer.Emily.Common; | ||
using Razer.Emily.UI; | ||
using Razer.Storage; | ||
|
||
namespace ItzWarty.MiniSynapse { | ||
class Program { | ||
[STAThread] | ||
static void Main() { | ||
var mainStorage = Singleton<MainStorage>.Instance; | ||
mainStorage.Initialize(Storage_Project.Emily); | ||
|
||
var isLoggedIn = mainStorage.TryLastLogin(); | ||
if (isLoggedIn != LoginStatus.Success) { | ||
MessageBox.Show("Cannot configure your Razer devices - you need to login through Razer Synapse first."); | ||
} else { | ||
var deviceManager = new RzDeviceManager(); | ||
deviceManager.Enumerate(); | ||
|
||
var commonConfigLoader = Singleton<CommonConfigLoader>.Instance; | ||
commonConfigLoader.StartConfig(); | ||
|
||
var devices = deviceManager.ActiveDevices.ToArray(); | ||
foreach (var device in devices) { | ||
device.RefreshData(); | ||
commonConfigLoader.DeviceAdded(device.VID, device.PID); | ||
|
||
// The following code is unnecessary for the program's functioning: | ||
var pluginDevice = commonConfigLoader.FindDevice(device.PID); | ||
Console.WriteLine("Configured device: " + pluginDevice.Name); | ||
using System; | ||
using System.Runtime.CompilerServices; | ||
using System.Runtime.InteropServices; | ||
using System.Windows.Forms; | ||
using Razer.Emily.Common; | ||
using Razer.Emily.UI; | ||
using Razer.Storage; | ||
|
||
namespace ItzWarty.MiniSynapse | ||
{ | ||
class Program | ||
{ | ||
// ↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓ | ||
// NEEDED FOR SYNAPSE 2.x+ | ||
// ↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓ | ||
|
||
const uint SPI_GETMOUSE = 0x0003; | ||
const uint SPI_SETMOUSE = 0x0004; | ||
|
||
public enum SPIF | ||
{ | ||
SPIF_NULL = 0x00, | ||
SPIF_UPDATEINIFILE = 0x01, | ||
SPIF_SENDCHANGE = 0x02, | ||
SPIF_SENDWININICHANGE = 0x02 | ||
} | ||
|
||
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)] | ||
[return: MarshalAs(UnmanagedType.Bool)] | ||
static extern bool SystemParametersInfo(uint uiAction, uint uiParam, IntPtr pvParam, SPIF fWinIni); | ||
|
||
// ↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑ | ||
// NEEDED FOR SYNAPSE 2.x+ | ||
// ↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑ | ||
|
||
[STAThread] | ||
private unsafe static void Main() | ||
{ | ||
// Values | ||
int[] MouseAccelParams = new int[3] { 0, 0, 0 }; | ||
GCHandle PArray = GCHandle.Alloc(MouseAccelParams, GCHandleType.Pinned); | ||
IntPtr Pointer = PArray.AddrOfPinnedObject(); | ||
|
||
// Store the current Windows mouse pointer settings, such as speed and acceleration status | ||
if (!SystemParametersInfo(SPI_GETMOUSE, 0, Pointer, 0)) | ||
MessageBox.Show("SPI_GETMOUSE failed!", "MiniSynapse - ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); | ||
|
||
// Log into Razer Synapse by using the last login data | ||
MainStorage I1 = Singleton<MainStorage>.Instance; | ||
I1.Initialize(Storage_Project.Emily); | ||
if (I1.TryLastLogin() != LoginStatus.Success) | ||
{ | ||
// Something went wrong and we were unable to login | ||
MessageBox.Show("Cannot configure your Razer devices - you need to login through Razer Synapse first."); | ||
PArray.Free(); | ||
|
||
return; | ||
} | ||
|
||
MessageBox.Show("Razer Devices Loaded.\t\t","Mini Synapse", MessageBoxButtons.OK, MessageBoxIcon.Information); | ||
} | ||
} | ||
} | ||
} | ||
// Enumerate all the installed Razer Synapse 2.x devices | ||
RzDeviceManager RazerDM = new RzDeviceManager(); | ||
RazerDM.Enumerate(); | ||
|
||
// Initialize the settings loader | ||
CommonConfigLoader I2 = Singleton<CommonConfigLoader>.Instance; | ||
I2.StartConfig(); | ||
|
||
// Apply the Razer Synapse settings to the device | ||
foreach (RzDevice RazerDevice in RazerDM.ActiveDevices.ToArray()) | ||
{ | ||
RazerDevice.RefreshData(); | ||
I2.DeviceAdded(RazerDevice.VID, RazerDevice.PID); | ||
Console.WriteLine("Configured device: " + I2.FindDevice(RazerDevice.PID).Name); | ||
} | ||
|
||
// Restore the mouse settings back, since Synapse 2.10+ seem to reset them | ||
if (!SystemParametersInfo(SPI_SETMOUSE, 0, Pointer, SPIF.SPIF_SENDCHANGE)) | ||
MessageBox.Show("SPI_SETMOUSE failed!", "MiniSynapse - ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); | ||
|
||
// Free the GCHandle since we don't need it anymore | ||
PArray.Free(); | ||
|
||
return; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters