Beispiel #1
0
        protected void AddKeyEvent(G13Keys key, bool isPressed)
        {
            if (!IsRunning)
            {
                return;
            }

            lock (keyEvents)
            {
                keyEvents.Enqueue(new KeyEvent(key, isPressed));

                if (keyEvents.Count > 4)
                {
                    // cleanup any duplicate MKey events
                    byte     mkeyEvents = 0;
                    byte     mkey;
                    int      shift;
                    G13Keys  kval;
                    KeyEvent k;

                    int length = keyEvents.Count;
                    for (int i = 0; i < length; i++)
                    {
                        k = keyEvents.Dequeue();

                        kval = k.Key;
                        if (kval >= G13Keys.M1 && kval <= G13Keys.M4)
                        {
                            shift = k.IsPressed ? 29 : 25;
                            mkey  = (byte)((uint)kval >> shift);

                            // check to see if there is was already a key press and release event pair
                            // for this mkey
                            if ((mkey & mkeyEvents) > 0 && ((mkey >> 4) & mkeyEvents) > 0)
                            {
                                // the pair already exists
                                if (mkey <= 8 && i < length)
                                {
                                    // don't remove a key-press event if it's the last event in the queue (wait for a key-release)
                                    keyEvents.Enqueue(k);
                                }
                            }
                            else
                            {
                                mkeyEvents |= mkey;
                                keyEvents.Enqueue(k);
                            }
                        }
                        else
                        {
                            // put it back on the queue
                            keyEvents.Enqueue(k);
                        }
                    }
                }
            }

            inputEvent.Set();
        }
Beispiel #2
0
 KeyEvent(bool isEmpty)
 {
     Key           = (G13Keys)0;
     IsPressed     = false;
     IsEmpty       = isEmpty;
     KeyboardEvent = null;
     MouseEvent    = null;
 }
Beispiel #3
0
 public KeyEvent(MouseEventArgs e, bool isPressed)
 {
     Key           = G13Keys.None;
     IsPressed     = isPressed;
     KeyboardEvent = null;
     MouseEvent    = e;
     IsEmpty       = false;
 }
Beispiel #4
0
 KeyEvent(bool isEmpty)
 {
     Key = (G13Keys)0;
     IsPressed = false;
     IsEmpty = isEmpty;
     KeyboardEvent = null;
     MouseEvent = null;
 }
Beispiel #5
0
 public KeyEvent(G13Keys key, bool isPressed)
 {
     Key           = key;
     IsPressed     = isPressed;
     KeyboardEvent = null;
     MouseEvent    = null;
     IsEmpty       = false;
 }
Beispiel #6
0
 public KeyEvent(MouseEventArgs e, bool isPressed)
 {
     Key = G13Keys.None;
     IsPressed = isPressed;
     KeyboardEvent = null;
     MouseEvent = e;
     IsEmpty = false;
 }
Beispiel #7
0
 public KeyEvent(G13Keys key, bool isPressed)
 {
     Key = key;
     IsPressed = isPressed;
     KeyboardEvent = null;
     MouseEvent = null;
     IsEmpty = false;
 }
Beispiel #8
0
        public virtual void SingleKeyReleased(G13Keys key)
        {
            Macro macro;

            if (keyMacros.TryGetValue(key, out macro))// && macro.EndOnKeyup)
            {
                macro.Canceled = true;
            }
            //macroRunner.Enqueue(new CancelMacro(macro));
            else
            {
                AddKeyEvent(key, false);
            }
        }
Beispiel #9
0
        public virtual void SingleKeyPressed(G13Keys key)
        {
            Macro macro;

            if (keyMacros.TryGetValue(key, out macro))
            {
                macro.Canceled = false;
                macroRunner.Enqueue(macro);
            }
            else
            {
                AddKeyEvent(key, true);
            }
        }
Beispiel #10
0
        protected void AddKeyEvent(G13Keys key, bool isPressed)
        {
            if (!IsRunning)
                return;

            lock (keyEvents)
            {
                keyEvents.Enqueue(new KeyEvent(key, isPressed));

                if (keyEvents.Count > 4)
                {
                    // cleanup any duplicate MKey events
                    byte mkeyEvents = 0;
                    byte mkey;
                    int shift;
                    G13Keys kval;
                    KeyEvent k;

                    int length = keyEvents.Count;
                    for (int i = 0; i < length; i++)
                    {
                        k = keyEvents.Dequeue();

                        kval = k.Key;
                        if (kval >= G13Keys.M1 && kval <= G13Keys.M4)
                        {
                            shift = k.IsPressed ? 29 : 25;
                            mkey = (byte)((uint)kval >> shift);

                            // check to see if there is was already a key press and release event pair
                            // for this mkey
                            if ((mkey & mkeyEvents) > 0 && ((mkey >> 4) & mkeyEvents) > 0)
                            {
                                // the pair already exists
                                if (mkey <= 8 && i < length)
                                {
                                    // don't remove a key-press event if it's the last event in the queue (wait for a key-release)
                                    keyEvents.Enqueue(k);
                                }
                            }
                            else
                            {
                                mkeyEvents |= mkey;
                                keyEvents.Enqueue(k);
                            }
                        }
                        else
                        {
                            // put it back on the queue
                            keyEvents.Enqueue(k);
                        }
                    }
                }
            }

            inputEvent.Set();
        }
Beispiel #11
0
        public virtual void SingleKeyReleased(G13Keys key)
        {
            Macro macro;

            if (keyMacros.TryGetValue(key, out macro))// && macro.EndOnKeyup)
                macro.Canceled = true;
                //macroRunner.Enqueue(new CancelMacro(macro));
            else
                AddKeyEvent(key, false);
        }
Beispiel #12
0
        public virtual void SingleKeyPressed(G13Keys key)
        {
            Macro macro;

            if (keyMacros.TryGetValue(key, out macro))
            {
                macro.Canceled = false;
                macroRunner.Enqueue(macro);
            }
            else
                AddKeyEvent(key, true);
        }