예제 #1
0
        public ControllerForm()
        {
            InitializeComponent();

            this.keyboard = new KeyboardState();

            this.DoubleBuffered = true;
            this.KeyPreview = true;
            this.KeyDown += Control_KeyDown;
            this.KeyUp += Control_KeyUp;
            this.Paint += ControllerForm_Paint;

            this.FormClosed += ControllerForm_FormClosed;

            this.Width = 300;
            this.Height = 300;
        }
예제 #2
0
        public void SimulateDif(KeyboardState oldstate)
        {
            HashSet<Keys> oldkeys = new HashSet<Keys>(oldstate._pressedKeys);
            HashSet<Keys> newkeys = new HashSet<Keys>(_pressedKeys);

            newkeys.ExceptWith(oldstate._pressedKeys);
            oldkeys.ExceptWith(_pressedKeys);

            InputSimulator iss = new InputSimulator();
            foreach (Keys key in oldkeys)
            {
                iss.Keyboard.KeyUp((VirtualKeyCode)(int)key);
            }

            foreach (Keys key in newkeys)
            {
                iss.Keyboard.KeyDown((VirtualKeyCode)(int)key);
            }
        }