Exemplo n.º 1
0
        internal void HandleInputs(RuntimeTask runtime)
        {
            if (!IsAvailable())
            {
                return;
            }

            Log.Write(LOG_CAT, (LogLevel)10, $"HandleInputs");

            var inputs = Program.Current.Me.GetValue <Dictionary <string, object> >("ControlModule.Inputs");

            foreach (var action in actions)
            {
                if (action.Value.ContainsKey(InputEvent.Press))
                {
                    var methods = action.Value[InputEvent.Press];
                    if (inputs.ContainsKey(action.Key) &&
                        !lastActions.Contains(action.Key))
                    {
                        foreach (var method in methods)
                        {
                            runtime.StartProgram(method);
                        }
                    }
                }
                if (action.Value.ContainsKey(InputEvent.Release))
                {
                    var methods = action.Value[InputEvent.Release];
                    if (!inputs.ContainsKey(action.Key) &&
                        lastActions.Contains(action.Key))
                    {
                        foreach (var method in methods)
                        {
                            runtime.StartProgram(method);
                        }
                    }
                }
            }

            lastActions = new HashSet <string>(inputs.Keys);
        }
Exemplo n.º 2
0
        private void ScheduleParse(bool runLoad)
        {
            var parse = new ParserTask(Current.Me.CustomData);

            parse.Done = r =>
            {
                if (r.Item1 != null)
                {
                    Log.Write(LOG_CAT, LogLevel.Verbose, "Parsing done");
                    runtime.RegisterPrograms(r.Item1);
                    if (runLoad)
                    {
                        if (runtime.StartProgram("_load", true))
                        {
                            timerController.ScheduleStart(0);
                        }
                    }
                }
            };
            sch.EnqueueTask(parse);
        }