public void Shutdown()
 {
     foreach (var keyboard in _keyboards)
     {
         CoolermasterSdkWrapper.SetControlDevice(keyboard);
         CoolermasterSdkWrapper.EnableLedControl(false);
     }
 }
Exemplo n.º 2
0
        public bool InitializeSdk()
        {
            try
            {
                lock (_initLock)
                {
                    if (IsInitialized)
                    {
                        return(true);
                    }

                    Write.WriteConsole(ConsoleTypes.Coolermaster, @"Attempting to initializer Coolermaster support...");

                    foreach (var supportedDevice in SupportedKeyboardDevices)
                    {
                        CoolermasterSdkWrapper.SetControlDevice(supportedDevice);
                        if (CoolermasterSdkWrapper.IsDevicePlug(supportedDevice))
                        {
                            Write.WriteConsole(ConsoleTypes.Coolermaster, $"Found a {supportedDevice} Coolermaster keyboard.");
                            _keyboards.Add(supportedDevice);
                            CoolermasterSdkWrapper.EnableLedControl(true);
                        }
                    }

                    foreach (var supportedDevice in SupportedMouseDevices)
                    {
                        CoolermasterSdkWrapper.SetControlDevice(supportedDevice);
                        if (CoolermasterSdkWrapper.IsDevicePlug(supportedDevice))
                        {
                            Write.WriteConsole(ConsoleTypes.Coolermaster, $"Found a {supportedDevice} Coolermaster mouse.");
                            _mice.Add(supportedDevice);
                            CoolermasterSdkWrapper.EnableLedControl(true);
                        }
                    }

                    if (_keyboards.Any() || _mice.Any())
                    {
                        IsInitialized = true;
                        return(true);
                    }
                    else
                    {
                        Write.WriteConsole(ConsoleTypes.Coolermaster, @"Did not find any supported Coolermaster devices.");
                    }
                }
            }
            catch (Exception ex)
            {
                Write.WriteConsole(ConsoleTypes.Coolermaster, @"Coolermaster SDK failed to load. Error: " + ex.Message);
            }
            return(false);
        }