/// <inheritdoc /> protected override void InitializeLayout() { _CorsairLedPositions nativeLedPositions = (_CorsairLedPositions) Marshal.PtrToStructure(_CUESDK.CorsairGetLedPositionsByDeviceIndex(DeviceInfo.CorsairDeviceIndex), typeof(_CorsairLedPositions)); int structSize = Marshal.SizeOf(typeof(_CorsairLedPosition)); IntPtr ptr = nativeLedPositions.pLedPosition; // Put the positions in an array for sorting later on List <_CorsairLedPosition> positions = new List <_CorsairLedPosition>(); for (int i = 0; i < nativeLedPositions.numberOfLed; i++) { _CorsairLedPosition ledPosition = (_CorsairLedPosition)Marshal.PtrToStructure(ptr, typeof(_CorsairLedPosition)); ptr = new IntPtr(ptr.ToInt64() + structSize); positions.Add(ledPosition); } foreach (_CorsairLedPosition ledPosition in positions.OrderBy(p => p.ledId)) { InitializeLed(new CorsairLedId(this, ledPosition.ledId), new Rectangle(ledPosition.left, ledPosition.top, ledPosition.width, ledPosition.height)); } ApplyLayoutFromFile(PathHelper.GetAbsolutePath($@"Layouts\Corsair\HeadsetStands\{DeviceInfo.Model.Replace(" ", string.Empty).ToUpper()}.xml"), null, PathHelper.GetAbsolutePath(@"Images\Corsair\HeadsetStands")); }
/// <inheritdoc /> protected override void InitializeLayout() { _CorsairLedPositions nativeLedPositions = (_CorsairLedPositions)Marshal.PtrToStructure(_CUESDK.CorsairGetLedPositionsByDeviceIndex(DeviceInfo.CorsairDeviceIndex), typeof(_CorsairLedPositions)); int structSize = Marshal.SizeOf(typeof(_CorsairLedPosition)); IntPtr ptr = nativeLedPositions.pLedPosition; List <_CorsairLedPosition> positions = new List <_CorsairLedPosition>(); for (int i = 0; i < nativeLedPositions.numberOfLed; i++) { _CorsairLedPosition ledPosition = (_CorsairLedPosition)Marshal.PtrToStructure(ptr, typeof(_CorsairLedPosition)); ptr = new IntPtr(ptr.ToInt64() + structSize); positions.Add(ledPosition); } Dictionary <CorsairLedId, LedId> mapping = HeadsetStandIdMapping.DEFAULT.SwapKeyValue(); foreach (_CorsairLedPosition ledPosition in positions.OrderBy(p => p.LedId)) { InitializeLed(mapping.TryGetValue(ledPosition.LedId, out LedId ledId) ? ledId : LedId.Invalid, ledPosition.ToRectangle()); } ApplyLayoutFromFile(PathHelper.GetAbsolutePath(this, @"Layouts\Corsair\HeadsetStands", $"{DeviceInfo.Model.Replace(" ", string.Empty).ToUpper()}.xml"), null); }
internal static Rectangle ToRectangle(this _CorsairLedPosition position) { //HACK DarthAffe 08.07.2018: It seems like corsair introduced a bug here - it's always 0. double width = position.width < 0.5 ? 10 : position.width; double height = position.height < 0.5 ? 10 : position.height; double posX = position.left; double posY = position.top; return(new Rectangle(posX, posY, width, height)); }
/// <summary> /// Initializes the keyboard. /// </summary> public override void Initialize() { _CorsairLedPositions nativeLedPositions = (_CorsairLedPositions)Marshal.PtrToStructure(_CUESDK.CorsairGetLedPositions(), typeof(_CorsairLedPositions)); int structSize = Marshal.SizeOf(typeof(_CorsairLedPosition)); IntPtr ptr = nativeLedPositions.pLedPosition; for (int i = 0; i < nativeLedPositions.numberOfLed; i++) { _CorsairLedPosition ledPosition = (_CorsairLedPosition)Marshal.PtrToStructure(ptr, typeof(_CorsairLedPosition)); InitializeLed(ledPosition.ledId, new RectangleF((float)ledPosition.left, (float)ledPosition.top, (float)ledPosition.width, (float)ledPosition.height)); ptr = new IntPtr(ptr.ToInt64() + structSize); } base.Initialize(); }
/// <summary> /// Initializes the headset stand. /// </summary> public override void Initialize() { int deviceCount = _CUESDK.CorsairGetDeviceCount(); // Get headset stand device index int MemoryModuleIndex = -1; for (int i = 0; i < deviceCount; i++) { _CorsairDeviceInfo nativeDeviceInfo = (_CorsairDeviceInfo)Marshal.PtrToStructure(_CUESDK.CorsairGetDeviceInfo(i), typeof(_CorsairDeviceInfo)); GenericDeviceInfo info = new GenericDeviceInfo(nativeDeviceInfo); if (info.Type != CorsairDeviceType.MemoryModule) { continue; } MemoryModuleIndex = i; break; } if (MemoryModuleIndex < 0) { throw new WrapperException("Can't determine headset stand device index"); } _CorsairLedPositions nativeLedPositions = (_CorsairLedPositions)Marshal.PtrToStructure(_CUESDK.CorsairGetLedPositionsByDeviceIndex(MemoryModuleIndex), typeof(_CorsairLedPositions)); int structSize = Marshal.SizeOf(typeof(_CorsairLedPosition)); IntPtr ptr = nativeLedPositions.pLedPosition; // Put the positions in an array for sorting later on List <_CorsairLedPosition> positions = new List <_CorsairLedPosition>(); for (int i = 0; i < nativeLedPositions.numberOfLed; i++) { _CorsairLedPosition ledPosition = (_CorsairLedPosition)Marshal.PtrToStructure(ptr, typeof(_CorsairLedPosition)); ptr = new IntPtr(ptr.ToInt64() + structSize); positions.Add(ledPosition); } // Sort for easy iteration by clients foreach (_CorsairLedPosition ledPosition in positions.OrderBy(p => p.ledId)) { InitializeLed(ledPosition.ledId, new RectangleF((float)ledPosition.left, (float)ledPosition.top, (float)ledPosition.width, (float)ledPosition.height)); } base.Initialize(); }
/// <inheritdoc /> protected override void InitializeLayout() { _CorsairLedPositions nativeLedPositions = (_CorsairLedPositions)Marshal.PtrToStructure(_CUESDK.CorsairGetLedPositionsByDeviceIndex(DeviceInfo.CorsairDeviceIndex), typeof(_CorsairLedPositions)); int structSize = Marshal.SizeOf(typeof(_CorsairLedPosition)); IntPtr ptr = nativeLedPositions.pLedPosition; Dictionary <CorsairLedId, LedId> mapping = MemoryIdMapping.DEFAULT.SwapKeyValue(); for (int i = 0; i < nativeLedPositions.numberOfLed; i++) { _CorsairLedPosition ledPosition = (_CorsairLedPosition)Marshal.PtrToStructure(ptr, typeof(_CorsairLedPosition)); InitializeLed(mapping.TryGetValue(ledPosition.LedId, out LedId ledId) ? ledId : LedId.Invalid, ledPosition.ToRectangle()); ptr = new IntPtr(ptr.ToInt64() + structSize); } string model = DeviceInfo.Model.Replace(" ", string.Empty).ToUpper(); ApplyLayoutFromFile(PathHelper.GetAbsolutePath($@"Layouts\Corsair\Memory\{model}.xml"), null); }
/// <inheritdoc /> protected override void InitializeLayout() { _CorsairLedPositions nativeLedPositions = (_CorsairLedPositions)Marshal.PtrToStructure(_CUESDK.CorsairGetLedPositions(), typeof(_CorsairLedPositions)); int structSize = Marshal.SizeOf(typeof(_CorsairLedPosition)); IntPtr ptr = nativeLedPositions.pLedPosition; Dictionary <CorsairLedId, LedId> mapping = KeyboardIdMapping.DEFAULT.SwapKeyValue(); for (int i = 0; i < nativeLedPositions.numberOfLed; i++) { _CorsairLedPosition ledPosition = (_CorsairLedPosition)Marshal.PtrToStructure(ptr, typeof(_CorsairLedPosition)); InitializeLed(mapping.TryGetValue(ledPosition.LedId, out LedId ledId) ? ledId : LedId.Invalid, new Rectangle(ledPosition.left, ledPosition.top, ledPosition.width, ledPosition.height)); ptr = new IntPtr(ptr.ToInt64() + structSize); } string model = DeviceInfo.Model.Replace(" ", string.Empty).ToUpper(); ApplyLayoutFromFile(PathHelper.GetAbsolutePath( $@"Layouts\Corsair\Keyboards\{model}\{DeviceInfo.PhysicalLayout.ToString().ToUpper()}.xml"), DeviceInfo.LogicalLayout.ToString()); }
/// <inheritdoc /> protected override void InitializeLayout() { _CorsairLedPositions nativeLedPositions = (_CorsairLedPositions)Marshal.PtrToStructure(_CUESDK.CorsairGetLedPositions(), typeof(_CorsairLedPositions)); int structSize = Marshal.SizeOf(typeof(_CorsairLedPosition)); IntPtr ptr = nativeLedPositions.pLedPosition; for (int i = 0; i < nativeLedPositions.numberOfLed; i++) { _CorsairLedPosition ledPosition = (_CorsairLedPosition)Marshal.PtrToStructure(ptr, typeof(_CorsairLedPosition)); InitializeLed(new CorsairLedId(this, ledPosition.ledId), new Rectangle(ledPosition.left, ledPosition.top, ledPosition.width, ledPosition.height)); ptr = new IntPtr(ptr.ToInt64() + structSize); } string model = DeviceInfo.Model.Replace(" ", string.Empty).ToUpper(); ApplyLayoutFromFile(PathHelper.GetAbsolutePath( $@"Layouts\Corsair\Keyboards\{model}\{DeviceInfo.PhysicalLayout.ToString().ToUpper()}.xml"), DeviceInfo.LogicalLayout.ToString(), PathHelper.GetAbsolutePath(@"Images\Corsair\Keyboards")); }