예제 #1
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);
        }
예제 #2
0
        private static ACTDataTemplate ReadActDataFile()
        {
            var actData = new ACTDataTemplate();

            try
            {
                var enviroment = new FileInfo(Assembly.GetExecutingAssembly().Location).DirectoryName;
                var path       = enviroment + @"\actdata.chromatics";

                if (File.Exists(path))
                {
                    using (var fs = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
                        using (var r = new StreamReader(fs))
                        {
                            var json = r.ReadToEnd();
                            actData = JsonConvert.DeserializeObject <ACTDataTemplate>(json);
                        }
                }
                else
                {
                    var ret = new ACTDataTemplate();
                    ret.Version = 0;
                    return(ret);
                }

                return(actData.IsConnected ? actData : new ACTDataTemplate());
            }
            catch (Exception e)
            {
                Write.WriteConsole(ConsoleTypes.Error, @"Error: " + e.Message);
                return(new ACTDataTemplate());
            }
        }
예제 #3
0
        public bool InitializeSdk()
        {
            try
            {
                _client = new RyosTalkFXConnection();
                _client.Initialize();
                _client.EnterSdkMode();
                _initialized = true;

                //client.SetLedOn(KeyboardLayout_EN);

                return(true);
            }
            catch (Exception ex)
            {
                Write.WriteConsole(ConsoleTypes.Roccat, @"Roccat SDK failed to load. Error: " + ex.Message);
                return(false);
            }
        }
예제 #4
0
        public bool InitializeLights()
        {
            var result = true;

            try
            {
                MysticSdkWrapper.Reload();

                int errorCode;
                if ((errorCode = MysticSdkWrapper.Initialize()) != 0)
                {
                    return(false);
                }

                result        = true;
                IsInitialized = true;

                string[] devTypes = null;
                int[]    devLeds  = null;

                var devs = MysticSdkWrapper.GetDeviceInfo(out devTypes, out devLeds);

                var x = 0;
                foreach (var device in devTypes)
                {
                    Write.WriteConsole(ConsoleTypes.Mystic, @"DEBUG: Mystic Device: " + device + " (" + devLeds[x] + ")");
                    x++;
                }
            }
            catch (Exception)
            {
                result = false;
            }
            return(result);
        }
예제 #5
0
        public async Task <bool> InitializeSdk(string hueDefault)
        {
            Write.WriteConsole(ConsoleTypes.Hue, @"Attempting to load HUE SDK..");

            try
            {
                IBridgeLocator locator = new HttpBridgeLocator();
                var            devices = new Dictionary <string, LocatedBridge>();

                var bridgeIPs = await locator.LocateBridgesAsync(TimeSpan.FromSeconds(5));

                foreach (var bridge in bridgeIPs)
                {
                    Write.WriteConsole(ConsoleTypes.Hue,
                                       "Found HUE Bridge (" + bridge.BridgeId + ") at " + bridge.IpAddress);
                    devices.Add(bridge.BridgeId, bridge);
                }

                var selectdevice = "";

                if (devices.Count > 0)
                {
                    if (!string.IsNullOrWhiteSpace(hueDefault))
                    {
                        if (devices.ContainsKey(hueDefault))
                        {
                            selectdevice = devices[hueDefault].BridgeId;
                            Write.WriteConsole(ConsoleTypes.Hue,
                                               "Connected to preferred HUE Bridge (" + devices[hueDefault].BridgeId + ") at " +
                                               devices[hueDefault].IpAddress);
                        }
                        else
                        {
                            selectdevice = devices.FirstOrDefault().Key;
                            Write.WriteConsole(ConsoleTypes.Hue, @"Unable to find your preferred HUE Bridge.");
                            Write.WriteConsole(ConsoleTypes.Hue,
                                               "Connected to HUE Bridge (" + devices.FirstOrDefault().Value.BridgeId + ") at " +
                                               devices.FirstOrDefault().Value.IpAddress);
                        }
                    }
                    else
                    {
                        selectdevice = devices.FirstOrDefault().Key;
                        Write.WriteConsole(ConsoleTypes.Hue,
                                           "Connected to HUE Bridge (" + devices.FirstOrDefault().Value.BridgeId + ") at " +
                                           devices.FirstOrDefault().Value.IpAddress);
                    }
                }
                else
                {
                    Write.WriteConsole(ConsoleTypes.Hue, @"Unable to find any HUE Bridges.");
                    return(false);
                }

                if (!string.IsNullOrWhiteSpace(selectdevice))
                {
                    _client = new LocalHueClient(devices[selectdevice].IpAddress);
                    var appKey = await _client.RegisterAsync("Chromatics", "Chromatics_Bridge");

                    _client.Initialize("Chromatics");

                    //Get lights
                    var lights = await _client.GetLightsAsync();

                    foreach (var light in lights)
                    {
                        var defaultmode = BulbModeTypes.Standby;

                        if (!_HueModeMemory.ContainsKey(light.UniqueId))
                        {
                            //Save to devices.chromatics
                            _HueModeMemory.Add(light.UniqueId, defaultmode);
                            _HueStateMemory.Add(light.UniqueId, 1);

                            Write.SaveDevices();
                        }
                        else
                        {
                            //Load from devices.chromatics
                            defaultmode = _HueModeMemory[light.UniqueId];
                        }

                        _HueDevices.Add(light.UniqueId, light);
                        _HueBulbsDat.Add(light, defaultmode);
                        _HueBulbsRestore.Add(light, light.State);

                        _hueBulbs++;

                        Write.WriteConsole(ConsoleTypes.Hue, @"HUE Bulb Found: " + light.Name + " (" + light.Id + ").");

                        Write.ResetDeviceDataGrid();
                    }

                    return(true);
                }
                Write.WriteConsole(ConsoleTypes.Hue, @"HUE SDK Failed to Load. Error: Bridge Scan Error");
                return(false);
            }
            catch (Exception ex)
            {
                Write.WriteConsole(ConsoleTypes.Hue, @"HUE SDK Failed to Load. Error: " + ex.Message);
                return(false);
            }
        }
예제 #6
0
 public static void WatchdogGo()
 {
     Write.WriteConsole(ConsoleTypes.System, @"Watchdog Started");
     _timer.Start();
 }
예제 #7
0
        public Task Ripple1(Color burstcol, int speed, Color baseColor)
        {
            return(new Task(() =>
            {
                if (!_logitechDeviceKeyboard)
                {
                    return;
                }

                for (var i = 0; i <= 9; i++)
                {
                    if (i == 0)
                    {
                        //Setup

                        foreach (var key in DeviceEffects.GlobalKeys)
                        {
                            try
                            {
                                KeyboardNames keyName;
                                if (Enum.TryParse(key, out keyName))
                                {
                                    LogitechSdkWrapper.LogiLedSaveLightingForKey(keyName);
                                }
                            }
                            catch (Exception ex)
                            {
                                Write.WriteConsole(ConsoleTypes.Error, "(" + key + "): " + ex.Message);
                            }
                        }
                    }
                    else if (i == 1)
                    {
                        //Step 0
                        foreach (var key in DeviceEffects.GlobalKeys)
                        {
                            var pos = Array.IndexOf(DeviceEffects.PulseOutStep0, key);
                            if (pos > -1)
                            {
                                ApplyMapKeyLighting(key, burstcol, false);
                            }
                            else
                            {
                                LogitechSdkWrapper.LogiLedRestoreLightingForKey(ToKeyboardNames(key));
                            }
                        }
                    }
                    else if (i == 2)
                    {
                        //Step 1
                        foreach (var key in DeviceEffects.GlobalKeys)
                        {
                            var pos = Array.IndexOf(DeviceEffects.PulseOutStep1, key);
                            if (pos > -1)
                            {
                                ApplyMapKeyLighting(key, burstcol, false);
                            }
                            else
                            {
                                LogitechSdkWrapper.LogiLedRestoreLightingForKey(ToKeyboardNames(key));
                            }
                        }
                    }
                    else if (i == 3)
                    {
                        //Step 2
                        foreach (var key in DeviceEffects.GlobalKeys)
                        {
                            var pos = Array.IndexOf(DeviceEffects.PulseOutStep2, key);
                            if (pos > -1)
                            {
                                ApplyMapKeyLighting(key, burstcol, false);
                            }
                            else
                            {
                                LogitechSdkWrapper.LogiLedRestoreLightingForKey(ToKeyboardNames(key));
                            }
                        }
                    }
                    else if (i == 4)
                    {
                        //Step 3
                        foreach (var key in DeviceEffects.GlobalKeys)
                        {
                            var pos = Array.IndexOf(DeviceEffects.PulseOutStep3, key);
                            if (pos > -1)
                            {
                                ApplyMapKeyLighting(key, burstcol, false);
                            }
                            else
                            {
                                LogitechSdkWrapper.LogiLedRestoreLightingForKey(ToKeyboardNames(key));
                            }
                        }
                    }
                    else if (i == 5)
                    {
                        //Step 4
                        foreach (var key in DeviceEffects.GlobalKeys)
                        {
                            var pos = Array.IndexOf(DeviceEffects.PulseOutStep4, key);
                            if (pos > -1)
                            {
                                ApplyMapKeyLighting(key, burstcol, false);
                            }
                            else
                            {
                                LogitechSdkWrapper.LogiLedRestoreLightingForKey(ToKeyboardNames(key));
                            }
                        }
                    }
                    else if (i == 6)
                    {
                        //Step 5
                        foreach (var key in DeviceEffects.GlobalKeys)
                        {
                            var pos = Array.IndexOf(DeviceEffects.PulseOutStep5, key);
                            if (pos > -1)
                            {
                                ApplyMapKeyLighting(key, burstcol, false);
                            }
                            else
                            {
                                LogitechSdkWrapper.LogiLedRestoreLightingForKey(ToKeyboardNames(key));
                            }
                        }
                    }
                    else if (i == 7)
                    {
                        //Step 6
                        foreach (var key in DeviceEffects.GlobalKeys)
                        {
                            var pos = Array.IndexOf(DeviceEffects.PulseOutStep6, key);
                            if (pos > -1)
                            {
                                ApplyMapKeyLighting(key, burstcol, false);
                            }
                            else
                            {
                                LogitechSdkWrapper.LogiLedRestoreLightingForKey(ToKeyboardNames(key));
                            }
                        }
                    }
                    else if (i == 8)
                    {
                        //Step 7
                        foreach (var key in DeviceEffects.GlobalKeys)
                        {
                            var pos = Array.IndexOf(DeviceEffects.PulseOutStep7, key);
                            if (pos > -1)
                            {
                                ApplyMapKeyLighting(key, burstcol, false);
                            }
                            else
                            {
                                LogitechSdkWrapper.LogiLedRestoreLightingForKey(ToKeyboardNames(key));
                            }
                        }
                    }
                    else if (i == 9)
                    {
                        //Spin down

                        foreach (var key in DeviceEffects.GlobalKeys)
                        {
                            LogitechSdkWrapper.LogiLedRestoreLightingForKey(ToKeyboardNames(key));
                        }

                        ApplyMapKeyLighting("D1", baseColor, false);
                        ApplyMapKeyLighting("D2", baseColor, false);
                        ApplyMapKeyLighting("D3", baseColor, false);
                        ApplyMapKeyLighting("D4", baseColor, false);
                        ApplyMapKeyLighting("D5", baseColor, false);
                        ApplyMapKeyLighting("D6", baseColor, false);
                        ApplyMapKeyLighting("D7", baseColor, false);
                        ApplyMapKeyLighting("D8", baseColor, false);
                        ApplyMapKeyLighting("D9", baseColor, false);
                        ApplyMapKeyLighting("D0", baseColor, false);
                        ApplyMapKeyLighting("OemMinus", baseColor, false);
                        ApplyMapKeyLighting("OemEquals", baseColor, false);
                    }

                    if (i < 9)
                    {
                        Thread.Sleep(speed);
                    }
                }
            }));
        }