Example #1
0
        //We need to stop holding buttons if a release input for that same key is sent
        bool CheckForInstructionOverlap(Instruction incomingInstruction)
        {
            foreach (var instruction in liveInstructions)
            {
                switch (instruction.instructionType)
                {
                case InstructionType.MOUSE:
                {
                    MouseInput temp = (MouseInput)instruction.input;

                    if (temp.mouseInputType == MouseInputType.PRESS_MOUSE_BUTTON || temp.mouseInputType == MouseInputType.PRESS_AND_RELEASE)
                    {
                        MouseInput tempIncomming = (MouseInput)instruction.input;
                        //If the same key is being held that we want to release
                        if (tempIncomming.clickType == temp.clickType)
                        {
                            instruction.StopProcessing();
                            return(true);
                        }
                    }

                    break;
                }

                case InstructionType.KEYBOARD:
                {
                    KeyboardInput temp = (KeyboardInput)instruction.input;
                    if (temp.keyboardInputType == KeyboardInputType.PRESS_KEY || temp.keyboardInputType == KeyboardInputType.PRESS_AND_RELEASE)
                    {
                        KeyboardInput tempIncomming = (KeyboardInput)instruction.input;
                        if (tempIncomming.hotkey.KeyCode == temp.hotkey.KeyCode)
                        {
                            instruction.StopProcessing();
                            return(true);
                        }
                    }
                    break;
                }
                }
            }

            return(false);
        }
 public SavedInstruction(Instruction _instruction, KeyboardInput _keyboardInput)
 {
     instruction   = _instruction;
     keyboardInput = _keyboardInput;
 }