mirror of
https://github.com/DarthAffe/CUE.NET.git
synced 2025-12-13 09:08:34 +00:00
Fixed use before initialize
This commit is contained in:
parent
1eba5c66be
commit
072f0c24ed
12
CueSDK.cs
12
CueSDK.cs
@ -171,19 +171,20 @@ namespace CUE.NET
|
|||||||
if (!info.CapsMask.HasFlag(CorsairDeviceCaps.Lighting))
|
if (!info.CapsMask.HasFlag(CorsairDeviceCaps.Lighting))
|
||||||
continue; // Everything that doesn't support lighting control is useless
|
continue; // Everything that doesn't support lighting control is useless
|
||||||
|
|
||||||
|
ICueDevice device;
|
||||||
switch (info.Type)
|
switch (info.Type)
|
||||||
{
|
{
|
||||||
case CorsairDeviceType.Keyboard:
|
case CorsairDeviceType.Keyboard:
|
||||||
devices.Add(KeyboardSDK = new CorsairKeyboard(new CorsairKeyboardDeviceInfo(nativeDeviceInfo)));
|
device = KeyboardSDK = new CorsairKeyboard(new CorsairKeyboardDeviceInfo(nativeDeviceInfo));
|
||||||
break;
|
break;
|
||||||
case CorsairDeviceType.Mouse:
|
case CorsairDeviceType.Mouse:
|
||||||
devices.Add(MouseSDK = new CorsairMouse(new CorsairMouseDeviceInfo(nativeDeviceInfo)));
|
device = MouseSDK = new CorsairMouse(new CorsairMouseDeviceInfo(nativeDeviceInfo));
|
||||||
break;
|
break;
|
||||||
case CorsairDeviceType.Headset:
|
case CorsairDeviceType.Headset:
|
||||||
devices.Add(HeadsetSDK = new CorsairHeadset(new CorsairHeadsetDeviceInfo(nativeDeviceInfo)));
|
device = HeadsetSDK = new CorsairHeadset(new CorsairHeadsetDeviceInfo(nativeDeviceInfo));
|
||||||
break;
|
break;
|
||||||
case CorsairDeviceType.Mousemat:
|
case CorsairDeviceType.Mousemat:
|
||||||
devices.Add(MousematSDK = new CorsairMousemat(new CorsairMousematDeviceInfo(nativeDeviceInfo)));
|
device = MousematSDK = new CorsairMousemat(new CorsairMousematDeviceInfo(nativeDeviceInfo));
|
||||||
break;
|
break;
|
||||||
// ReSharper disable once RedundantCaseLabel
|
// ReSharper disable once RedundantCaseLabel
|
||||||
case CorsairDeviceType.Unknown:
|
case CorsairDeviceType.Unknown:
|
||||||
@ -191,6 +192,9 @@ namespace CUE.NET
|
|||||||
throw new WrapperException("Unknown Device-Type");
|
throw new WrapperException("Unknown Device-Type");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
device.Initialize();
|
||||||
|
devices.Add(device);
|
||||||
|
|
||||||
error = LastError;
|
error = LastError;
|
||||||
if (error != CorsairError.Success)
|
if (error != CorsairError.Success)
|
||||||
Throw(error);
|
Throw(error);
|
||||||
|
|||||||
@ -140,8 +140,6 @@ namespace CUE.NET.Devices.Generic
|
|||||||
{
|
{
|
||||||
this.DeviceInfo = info;
|
this.DeviceInfo = info;
|
||||||
|
|
||||||
// ReSharper disable once VirtualMemberCallInConstructor - I know, but I need this ...
|
|
||||||
InitializeLeds();
|
|
||||||
DeviceRectangle = RectangleHelper.CreateRectangleFromRectangles((this).Select(x => x.LedRectangle));
|
DeviceRectangle = RectangleHelper.CreateRectangleFromRectangles((this).Select(x => x.LedRectangle));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -152,9 +150,9 @@ namespace CUE.NET.Devices.Generic
|
|||||||
#region Initialize
|
#region Initialize
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes the LEDs of the device.
|
/// Initializes the device.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
protected abstract void InitializeLeds();
|
public abstract void Initialize();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes the LED-Object with the specified id.
|
/// Initializes the LED-Object with the specified id.
|
||||||
|
|||||||
@ -39,9 +39,9 @@ namespace CUE.NET.Devices.Headset
|
|||||||
#region Methods
|
#region Methods
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes the LEDs of the device.
|
/// Initializes the the headset.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
protected override void InitializeLeds()
|
public override void Initialize()
|
||||||
{
|
{
|
||||||
InitializeLed(CorsairHeadsetLedId.LeftLogo, new RectangleF(0, 0, 1, 1));
|
InitializeLed(CorsairHeadsetLedId.LeftLogo, new RectangleF(0, 0, 1, 1));
|
||||||
InitializeLed(CorsairHeadsetLedId.RightLogo, new RectangleF(1, 0, 1, 1));
|
InitializeLed(CorsairHeadsetLedId.RightLogo, new RectangleF(1, 0, 1, 1));
|
||||||
|
|||||||
@ -134,6 +134,11 @@ namespace CUE.NET.Devices
|
|||||||
|
|
||||||
#region Methods
|
#region Methods
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes the device.
|
||||||
|
/// </summary>
|
||||||
|
void Initialize();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Perform an update for all dirty keys, or all keys if flushLeds is set to true.
|
/// Perform an update for all dirty keys, or all keys if flushLeds is set to true.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@ -42,9 +42,9 @@ namespace CUE.NET.Devices.Keyboard
|
|||||||
#region Methods
|
#region Methods
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes the LEDs of the device.
|
/// Initializes the keyboard.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
protected override void InitializeLeds()
|
public override void Initialize()
|
||||||
{
|
{
|
||||||
_CorsairLedPositions nativeLedPositions = (_CorsairLedPositions)Marshal.PtrToStructure(_CUESDK.CorsairGetLedPositions(), typeof(_CorsairLedPositions));
|
_CorsairLedPositions nativeLedPositions = (_CorsairLedPositions)Marshal.PtrToStructure(_CUESDK.CorsairGetLedPositions(), typeof(_CorsairLedPositions));
|
||||||
int structSize = Marshal.SizeOf(typeof(_CorsairLedPosition));
|
int structSize = Marshal.SizeOf(typeof(_CorsairLedPosition));
|
||||||
|
|||||||
@ -40,9 +40,9 @@ namespace CUE.NET.Devices.Mouse
|
|||||||
#region Methods
|
#region Methods
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes the LEDs of the device.
|
/// Initializes the mouse.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
protected override void InitializeLeds()
|
public override void Initialize()
|
||||||
{
|
{
|
||||||
switch (MouseDeviceInfo.PhysicalLayout)
|
switch (MouseDeviceInfo.PhysicalLayout)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -45,9 +45,9 @@ namespace CUE.NET.Devices.Mousemat
|
|||||||
#region Methods
|
#region Methods
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes the LEDs of the device.
|
/// Initializes the mousemat.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
protected override void InitializeLeds()
|
public override void Initialize()
|
||||||
{
|
{
|
||||||
int deviceCount = _CUESDK.CorsairGetDeviceCount();
|
int deviceCount = _CUESDK.CorsairGetDeviceCount();
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user