Exemple #1
0
            bool GetNewDown()
            {
                if (!KeyCombos.GetInstance().IsPressed(command))
                {
                    return(false);
                }
                List <string> allkeysforcommand = new List <string>();

                foreach (CommandCombo commandcombo in Config.GetInstance().CommandCombos)
                {
                    if (commandcombo.command == command)
                    {
                        foreach (string key in commandcombo.keycombo)
                        {
                            if (!allkeysforcommand.Contains(key))
                            {
                                allkeysforcommand.Add(key);
                            }
                        }
                    }
                }

                // check if eligible commands have any extra keys
                foreach (string key in KeyNameCache.GetInstance().keynamesdown)
                {
                    if (!allkeysforcommand.Contains(key))
                    {
                        return(false);
                    }
                }
                return(true);
            }
Exemple #2
0
            public override void Check()
            {
                bool newdown = KeyCombos.GetInstance().IsPressed(command);

                if (newdown)
                {
                    if (!isdown)
                    {
                        //LogFile.WriteLine("Registration down: " + command);
                        handler(command, true);
                    }
                }
                else
                {
                    if (isdown)
                    {
                        //LogFile.WriteLine("Registration up: " + command);
                        handler(command, false);
                    }
                }
                isdown = newdown;
            }
Exemple #3
0
        //List<Registration> registrationsdown = new List<Registration>();

        CommandCombos()
        {
            KeyCombos.GetInstance().ComboDown += new KeyCombos.ComboDownHandler(CommandCombos_ComboDown);
            KeyCombos.GetInstance().ComboUp   += new KeyCombos.ComboUpHandler(CommandCombos_ComboUp);
        }
Exemple #4
0
            // we filter all keys out that dont match our commands
            // then we check if any commands exactly match the down keys, with no additional keys
            public override void Check()
            {
                // get allowed keys
                List <string> correspondingkeys = new List <string>();

                foreach (CommandCombo commandcombo in Config.GetInstance().CommandCombos)
                {
                    if (commands.Contains(commandcombo.command))
                    {
                        foreach (string key in commandcombo.keycombo)
                        {
                            if (!correspondingkeys.Contains(key))
                            {
                                correspondingkeys.Add(key);
                            }
                        }
                    }
                }
                // get eligible commands, must be down
                List <string> newdowncommands = new List <string>();

                foreach (string command in commands)
                {
                    if (KeyCombos.GetInstance().IsPressed(command))
                    {
                        newdowncommands.Add(command);
                    }
                }

                // build list of all possible keys for each command
                Dictionary <string, List <string> > allkeysforeachcommand = new Dictionary <string, List <string> >();

                foreach (CommandCombo commandcombo in Config.GetInstance().CommandCombos)
                {
                    if (newdowncommands.Contains(commandcombo.command))
                    {
                        if (!allkeysforeachcommand.ContainsKey(commandcombo.command))
                        {
                            allkeysforeachcommand.Add(commandcombo.command, new List <string>());
                        }
                        foreach (string key in commandcombo.keycombo)
                        {
                            if (!allkeysforeachcommand[commandcombo.command].Contains(key))
                            {
                                allkeysforeachcommand[commandcombo.command].Add(key);
                            }
                        }
                    }
                }

                // check if eligible commands have any extra keys
                foreach (string key in KeyNameCache.GetInstance().keynamesdown)
                {
                    if (correspondingkeys.Contains(key))
                    {
                        foreach (string command in allkeysforeachcommand.Keys)
                        {
                            if (!allkeysforeachcommand[command].Contains(key))
                            {
                                if (newdowncommands.Contains(command))
                                {
                                    newdowncommands.Remove(command);
                                }
                            }
                        }
                    }
                }

                foreach (string command in currentdowncommands)
                {
                    if (!newdowncommands.Contains(command))
                    {
                        //LogFile.WriteLine("Commandcombo up: " + command);
                        handler(command, false);
                    }
                }
                foreach (string command in newdowncommands)
                {
                    if (!currentdowncommands.Contains(command))
                    {
                        //LogFile.WriteLine("Commandcombo down: " + command);
                        handler(command, true);
                    }
                }
                currentdowncommands = newdowncommands;
            }