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(); }
KeyEvent(bool isEmpty) { Key = (G13Keys)0; IsPressed = false; IsEmpty = isEmpty; KeyboardEvent = null; MouseEvent = null; }
public KeyEvent(MouseEventArgs e, bool isPressed) { Key = G13Keys.None; IsPressed = isPressed; KeyboardEvent = null; MouseEvent = e; IsEmpty = false; }
public KeyEvent(G13Keys key, bool isPressed) { Key = key; IsPressed = isPressed; KeyboardEvent = null; MouseEvent = null; IsEmpty = false; }
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); } }
public virtual void SingleKeyPressed(G13Keys key) { Macro macro; if (keyMacros.TryGetValue(key, out macro)) { macro.Canceled = false; macroRunner.Enqueue(macro); } else { AddKeyEvent(key, true); } }
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(); }
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); }
public virtual void SingleKeyPressed(G13Keys key) { Macro macro; if (keyMacros.TryGetValue(key, out macro)) { macro.Canceled = false; macroRunner.Enqueue(macro); } else AddKeyEvent(key, true); }