예제 #1
0
 /// <summary>
 /// Send keys packet to device
 /// </summary>
 public static void sendPacket()
 {
     if (connected)
     {
         connection.SetMkFxKeyboardState(keysLight, keysColor, 1);
     }
 }
예제 #2
0
        public override bool UpdateDevice(Dictionary <DeviceKeys, Color> keyColors, DoWorkEventArgs e, bool forced = false)
        {
            if (!isInitialized)
            {
                return(false);
            }

            if (enable_ryos)
            {
                foreach (var key in keyColors)
                {
                    if (KeyMap.DeviceKeysMap.TryGetValue(KeyMap.LocalizeKey(key.Key), out var k))
                    {
                        colorStruct[k] = ToRoccatColor(key.Value);
                        stateStruct[k] = IsLedOn(key.Value);
                    }
                }
                ryosTalkFx.SetMkFxKeyboardState(stateStruct, colorStruct, (byte)KeyMap.GetLayout());
            }

            //Set 1 color devices
            if (enable_generic && keyColors.TryGetValue(device_key, out var clr))
            {
                talkFx.SetLedRgb(Zone.Event, KeyEffect.On, Speed.Fast, ToRoccatColor(clr));
            }

            return(true);
        }
예제 #3
0
        public bool UpdateDevice(Dictionary <DeviceKeys, System.Drawing.Color> keyColors, DoWorkEventArgs e, bool forced = false)
        {
            if (RyosTalkFX == null || !RyosInitialized)
            {
                return(false);
            }

            if (e.Cancel)
            {
                return(false);
            }

            try
            {
                DeviceLayout layout = DeviceLayout.ISO;
                if (Global.Configuration.keyboard_localization == PreferredKeyboardLocalization.dvorak ||
                    Global.Configuration.keyboard_localization == PreferredKeyboardLocalization.us ||
                    Global.Configuration.keyboard_localization == PreferredKeyboardLocalization.ru)
                {
                    layout = DeviceLayout.ANSI;
                }
                else if (Global.Configuration.keyboard_localization == PreferredKeyboardLocalization.jpn)
                {
                    layout = DeviceLayout.JP;
                }

                foreach (KeyValuePair <DeviceKeys, System.Drawing.Color> key in keyColors)
                {
                    if (e.Cancel)
                    {
                        return(false);
                    }
                    DeviceKeys dev_key = key.Key;
                    //Solution to slightly different mapping rather than giving a whole different dictionary
                    if (layout == DeviceLayout.ANSI)
                    {
                        if (dev_key == DeviceKeys.ENTER)
                        {
                            dev_key = DeviceKeys.BACKSLASH;
                        }
                        if (dev_key == DeviceKeys.HASHTAG)
                        {
                            dev_key = DeviceKeys.ENTER;
                        }
                    }

                    //set peripheral color to Roccat generic peripheral if enabled
                    if (Global.Configuration.VarRegistry.GetVariable <bool>($"{devicename}_enable_generic") == true)
                    {
                        generic_deactivated_first_time = true;
                        if (key.Key == DeviceKeys.Peripheral_Logo)
                        {
                            //Send to generic roccat device if color not equal or 1. time after generic got enabled
                            if (!previous_peripheral_Color.Equals(key.Value) || generic_activated_first_time == true)
                            {
                                send_to_roccat_generic(key.Value);
                                //talkFX.RestoreLedRgb(); //Does not even here work

                                previous_peripheral_Color    = key.Value;
                                generic_activated_first_time = false;
                            }
                        }
                    }
                    else
                    {
                        if (generic_deactivated_first_time == true)
                        {
                            Restoregeneric();
                            generic_deactivated_first_time = false;
                            //Global.logger.LogLine("first time");
                        }
                        generic_activated_first_time = true;
                    }

                    if (DeviceKeysMap.TryGetValue(dev_key, out byte i))
                    {
                        //Global.logger.LogLine("Roccat update device: " + key + " , " + key.Value);
                        Color roccatColor = ConvertToRoccatColor(key.Value);
                        stateStruct[i] = IsLedOn(roccatColor);
                        colorStruct[i] = roccatColor;
                    }
                }

                //send KeyboardState to Ryos only when enabled
                if (Global.Configuration.VarRegistry.GetVariable <bool>($"{devicename}_enable_ryos"))
                {
                    RyosTalkFX.SetMkFxKeyboardState(stateStruct, colorStruct, (byte)layout);
                }

                return(true);
            }
            catch (Exception exc)
            {
                Global.logger.Error("Roccat device, error when updating device. Error: " + exc);
                return(false);
            }
        }