Exemplo n.º 1
0
 public void RegisterManager(IPCManager manager)
 {
     if (ipcManager == null)
     {
         ipcManager = manager;
     }
 }
Exemplo n.º 2
0
 public ActionController()
 {
     currentActions   = new Dictionary <string, IHandler>();
     ipcManager       = new IPCManager(AppSettings.groupStringRead);
     imgManager       = new ImageManager();
     manifestProfiles = new List <StreamDeckProfile>();
 }
Exemplo n.º 3
0
        public static bool SendControlsSeq(IPCManager ipcManager, string address, bool useControlDelay)
        {
            int fails = 0;

            string codeControl;

            while (address.Length > 0)
            {
                codeControl = GetNextTokenMove(ref address, ":");

                if (codeControl != null)
                {
                    if (!ipcManager.SendControl(codeControl))
                    {
                        fails++;
                    }
                    if (PeekNextDelim(address, ":") && useControlDelay)
                    {
                        Thread.Sleep(AppSettings.controlDelay);
                    }
                }
            }

            return(fails == 0);
        }
Exemplo n.º 4
0
        public static bool RunMacros(IPCManager ipcManager, string address)
        {
            bool result = false;

            string[] tokens = address.Split(':');
            if (tokens.Length == 2)
            {
                result = ipcManager.RunMacro(address);
            }
            else
            {
                string macroFile = tokens[0];
                int    fails     = 0;
                for (int i = 1; i < tokens.Length; i++)
                {
                    if (!ipcManager.RunMacro(macroFile + ":" + tokens[i]))
                    {
                        fails++;
                    }
                }
                if (fails == 0)
                {
                    result = true;
                }
            }

            return(result);
        }
Exemplo n.º 5
0
        public override void Register(ImageManager imgManager, IPCManager ipcManager)
        {
            base.Register(imgManager, ipcManager);
            RenderDefaultImage(imgManager);

            ValueManager.RegisterValue(ID.Bot, KorrySettings.AddressBot);
        }
Exemplo n.º 6
0
        public override bool OnButtonUp(IPCManager ipcManager, long tick)
        {
            if (BaseSettings.SwitchOnCurrentValue)
            {
                ValueManager.SetVariable(ID.SwitchState, ValueManager[ID.ControlState]);
            }

            return(base.OnButtonUp(ipcManager, tick));
        }
Exemplo n.º 7
0
        public override void Register(ImageManager imgManager, IPCManager ipcManager)
        {
            base.Register(imgManager, ipcManager);

            if (HasAction)
            {
                RegisterAction();
            }
        }
Exemplo n.º 8
0
        public override bool OnButtonUp(IPCManager ipcManager, long tick)
        {
            bool result = RunButtonUp(ipcManager, (tick - tickDown) >= AppSettings.longPressTicks, ValueManager[ID.SwitchState], ValueManager[ID.SwitchStateLong], BaseSettings, out string[] newValues);

            ValueManager[ID.SwitchState]     = newValues[0];
            ValueManager[ID.SwitchStateLong] = newValues[1];
            tickDown = 0;

            return(result);
        }
Exemplo n.º 9
0
        public override bool OnButtonUp(IPCManager ipcManager, long tick)
        {
            bool result = base.OnButtonUp(ipcManager, tick);

            if (result)
            {
                wasPushed = true;
            }

            return(result);
        }
Exemplo n.º 10
0
 public static bool WriteOffset(IPCManager ipcManager, string address, string newValue)
 {
     if (newValue != "")
     {
         return(ipcManager.WriteOffset(address, newValue));
     }
     else
     {
         return(false);
     }
 }
Exemplo n.º 11
0
 public static bool VjoyClearSet(IPCManager ipcManager, string address, bool clear)
 {
     if (clear)
     {
         return(ipcManager.SendVjoy(address, 2));
     }
     else
     {
         return(ipcManager.SendVjoy(address, 1));
     }
 }
Exemplo n.º 12
0
        public override void Register(ImageManager imgManager, IPCManager ipcManager)
        {
            base.Register(imgManager, ipcManager);

            imgManager.AddImage(DisplaySettings.OnImage, DeckType);
            imgManager.AddImage(DisplaySettings.OffImage, DeckType);
            if (DisplaySettings.HasIndication)
            {
                imgManager.AddImage(DisplaySettings.IndicationImage, DeckType);
            }

            ValueManager.RegisterValue(ID.ControlState, DisplaySettings.Address);
        }
Exemplo n.º 13
0
 public static bool RunButtonDown(IPCManager ipcManager, IModelSwitch switchSettings)
 {
     if (IPCTools.IsVjoyAddress(switchSettings.AddressAction, switchSettings.ActionType) && !IPCTools.IsVjoyToggle(switchSettings.AddressAction, switchSettings.ActionType))
     {
         return(IPCTools.VjoyClearSet(ipcManager, switchSettings.AddressAction, false));
     }
     else if (IPCTools.IsWriteAddress(switchSettings.AddressAction, (ActionSwitchType)switchSettings.ActionType))
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
Exemplo n.º 14
0
        public override void Register(ImageManager imgManager, IPCManager ipcManager)
        {
            base.Register(imgManager, ipcManager);

            if (TextSettings.HasIndication)
            {
                imgManager.AddImage(TextSettings.IndicationImage, DeckType);
            }

            if (TextSettings.DrawBox)
            {
                RenderImages(imgManager);
            }

            ValueManager.RegisterValue(ID.ControlState, Address);
        }
Exemplo n.º 15
0
        public static bool WriteLvar(IPCManager ipcManager, string address, string newValue)
        {
            bool result = false;

            if (newValue?.Length < 1)
            {
                return(result);
            }

            double value = Convert.ToDouble(newValue, new RealInvariantFormat(newValue));

            address.Replace("L:", "");
            result = ipcManager.WriteLvar(address, value);

            return(result);
        }
Exemplo n.º 16
0
        public static bool SendControls(IPCManager ipcManager, string address, bool useControlDelay)
        {
            if (!address.Contains("=") && address.Contains(":") && rxControlSeq.IsMatch(address))
            {
                return(SendControlsSeq(ipcManager, address, useControlDelay));
            }
            else if (!address.Contains("=") && !address.Contains(":"))
            {
                return(ipcManager.SendControl(address));
            }

            int fails = 0;

            string codeControl;
            string codeParam;

            while (address.Length > 0)
            {
                codeControl = GetNextTokenMove(ref address, "=");

                if (address.Length == 0)
                {
                    if (!ipcManager.SendControl(codeControl))
                    {
                        fails++;
                    }
                }

                while (address.Length > 0 && !PeekNextDelim(address, "="))
                {
                    codeParam = GetNextTokenMove(ref address, ":");
                    if (!ipcManager.SendControl(codeControl, codeParam))
                    {
                        fails++;
                    }
                    if (useControlDelay)
                    {
                        Thread.Sleep(AppSettings.controlDelay);
                    }
                }
            }

            return(fails == 0);
        }
Exemplo n.º 17
0
        public static bool RunAction(IPCManager ipcManager, string Address, ActionSwitchType actionType, string newValue, bool useControlDelay)
        {
            if (ipcManager.IsConnected && IsWriteAddress(Address, actionType))
            {
                Log.Logger.Debug($"IPCTools: Writing to {Address}");
                switch (actionType)
                {
                case ActionSwitchType.MACRO:
                    return(RunMacros(ipcManager, Address));

                case ActionSwitchType.SCRIPT:
                    return(RunScript(ipcManager, Address));

                case ActionSwitchType.LVAR:
                    return(WriteLvar(ipcManager, Address, newValue));

                case ActionSwitchType.CONTROL:
                    return(SendControls(ipcManager, Address, useControlDelay));

                case ActionSwitchType.OFFSET:
                    return(WriteOffset(ipcManager, Address, newValue));

                case ActionSwitchType.VJOY:
                    if (IsVjoyToggle(Address, (int)actionType))
                    {
                        return(VjoyToggle(ipcManager, Address));
                    }
                    else
                    {
                        return(false);
                    }

                default:
                    return(false);
                }
            }
            else
            {
                Log.Logger.Error($"IPCTools: not connected or Address not passed {Address}");
            }

            return(false);
        }
Exemplo n.º 18
0
        public static bool RunButtonUp(IPCManager ipcManager, bool longPress, string lastState, string lastStateLong, IModelSwitch switchSettings, out string[] newValues)
        {
            bool result = false;

            newValues    = new string[2];
            newValues[0] = lastState;
            newValues[1] = lastStateLong;

            if (IPCTools.IsVjoyAddress(switchSettings.AddressAction, switchSettings.ActionType) && !IPCTools.IsVjoyToggle(switchSettings.AddressAction, switchSettings.ActionType))
            {
                result = IPCTools.VjoyClearSet(ipcManager, switchSettings.AddressAction, true);
            }
            else if (!longPress)
            {
                string newValue = ToggleValue(lastState, switchSettings.SwitchOffState, switchSettings.SwitchOnState);
                result = IPCTools.RunAction(ipcManager, switchSettings.AddressAction, (ActionSwitchType)switchSettings.ActionType, newValue, switchSettings.UseControlDelay);
                if (result)
                {
                    newValues[0] = newValue;
                }
            }
            else if (longPress && switchSettings.HasLongPress)
            {
                if (IPCTools.IsVjoyAddress(switchSettings.AddressActionLong, switchSettings.ActionTypeLong) && IPCTools.IsVjoyToggle(switchSettings.AddressActionLong, switchSettings.ActionTypeLong))
                {
                    result = IPCTools.VjoyToggle(ipcManager, switchSettings.AddressActionLong);
                }
                else if (IPCTools.IsWriteAddress(switchSettings.AddressActionLong, (ActionSwitchType)switchSettings.ActionTypeLong) && !IPCTools.IsVjoyAddress(switchSettings.AddressActionLong, switchSettings.ActionTypeLong))
                {
                    string newValue = ToggleValue(lastStateLong, switchSettings.SwitchOffStateLong, switchSettings.SwitchOnStateLong);
                    result = IPCTools.RunAction(ipcManager, switchSettings.AddressActionLong, (ActionSwitchType)switchSettings.ActionTypeLong, newValue, switchSettings.UseControlDelay);
                    if (result)
                    {
                        newValues[1] = newValue;
                    }
                }
            }

            return(result);
        }
Exemplo n.º 19
0
 public static bool VjoyToggle(IPCManager ipcManager, string address)
 {
     return(ipcManager.SendVjoy(address, 0));
 }
Exemplo n.º 20
0
        public override void Register(ImageManager imgManager, IPCManager ipcManager)
        {
            base.Register(imgManager, ipcManager);

            ValueManager.RegisterValue(ID.Second, Settings.Address2);
        }
Exemplo n.º 21
0
 public override void Register(ImageManager imgManager, IPCManager ipcManager)
 {
     base.Register(imgManager, ipcManager);
     RenderDefaultImage(imgManager);
 }
Exemplo n.º 22
0
 public static bool RunScript(IPCManager ipcManager, string address)
 {
     return(ipcManager.RunScript(address));
 }
Exemplo n.º 23
0
 public override bool OnButtonUp(IPCManager ipcManager, long tick)
 {
     return(false);
 }
Exemplo n.º 24
0
 public override bool OnButtonDown(IPCManager ipcManager, long tick)
 {
     tickDown = tick;
     return(RunButtonDown(ipcManager, BaseSettings));
 }
Exemplo n.º 25
0
        public override void Register(ImageManager imgManager, IPCManager ipcManager)
        {
            base.Register(imgManager, ipcManager);

            ValueManager.RegisterValue(ID.Standby, Settings.AddressRadioStandby);
        }