private Func <bool> createKeyCodeFunc(KeyPressType keyPressType, VirtualKeyCode virtualKeyCode) { Func <bool> result = () => { return(false); }; if (keyPressType == KeyPressType.Down) { result = () => { inputSim.Keyboard.KeyDown(virtualKeyCode); return(true); }; } else if (keyPressType == KeyPressType.Up) { result = () => { inputSim.Keyboard.KeyUp(virtualKeyCode); return(true); }; } else if (keyPressType == KeyPressType.Press) { result = () => { inputSim.Keyboard.KeyPress(virtualKeyCode); return(true); }; } return(result); }
static Func <bool> CreatePressTestFuncJoy(InputControlType key, KeyPressType pressType, float[] para) { if (InputControlType.None == key) { return(() => false); } switch (pressType) { default: return(() => false); case KeyPressType.JoyDown: return(() => InputManager.ActiveDevice.GetControl(key).WasPressed); case KeyPressType.JoyUp: return(() => InputManager.ActiveDevice.GetControl(key).WasReleased); case KeyPressType.JoyPress: return(() => InputManager.ActiveDevice.GetControl(key).IsPressed); case KeyPressType.JoyStickUpDoublePress: JoyAxisStateInfo.Register(InputControlType.LeftStickY, para); return(() => JoyAxisStateInfo.GetValue(InputControlType.LeftStickY).positiveDoubleDown); case KeyPressType.JoyStickDownDoublePress: JoyAxisStateInfo.Register(InputControlType.LeftStickY, para); return(() => JoyAxisStateInfo.GetValue(InputControlType.LeftStickY).negativeDoubleDown); case KeyPressType.JoyStickRightDoublePress: JoyAxisStateInfo.Register(InputControlType.LeftStickX, para); return(() => JoyAxisStateInfo.GetValue(InputControlType.LeftStickX).positiveDoubleDown); case KeyPressType.JoyStickLeftDoublePress: JoyAxisStateInfo.Register(InputControlType.LeftStickX, para); return(() => JoyAxisStateInfo.GetValue(InputControlType.LeftStickX).negativeDoubleDown); } }
public KeyPressKeyValue(string key, KeyPressType type = default(KeyPressType), int duration = 0) : base() { this.key = key; this.type = type; this.durationMs = duration; }
public void handleKeyPress(Keys key, KeyPressType type) { if (key == Keys.W || key == Keys.Space) { return; } var keys = Program.moduleManager.getModules().Keys; foreach (String k in keys) { Module module = getModule(k); if (module.isEnabled()) { if (type == KeyPressType.KEY_DOWN) { module.onKeyDown(key); continue; } module.onKeyUp(key); } } }
/// <summary> /// Accuracy Calculation component of CalculateScore() if a note has been pressed/released properly /// </summary> /// <param name="hitDifference"></param> /// <param name="keyPressType"></param> /// <param name="calculateAllStats"></param> public Judgement CalculateScore(int hitDifference, KeyPressType keyPressType, bool calculateAllStats = true) { int absoluteDifference = 0; if (hitDifference != int.MinValue) { absoluteDifference = Math.Abs(hitDifference); } else { return(Judgement.Miss); } var judgement = Judgement.Ghost; // Find judgement of hit for (var i = 0; i < JudgementWindow.Count; i++) { var j = (Judgement)i; // Handles the case of if you release too early on a LN. if (keyPressType == KeyPressType.Release && j == Judgement.Miss) { break; } var window = keyPressType == KeyPressType.Release ? JudgementWindow[j] * WindowReleaseMultiplier[j] : JudgementWindow[j]; if (!(absoluteDifference <= window)) { continue; } // With HealthAdjust, okays are no longer possible on releases if (Mods.HasFlag(ModIdentifier.HeatlthAdjust)) { if (keyPressType == KeyPressType.Release && j == Judgement.Okay) { judgement = Judgement.Good; break; } } judgement = j; break; } // If the press/release was outside of hit window, do not score. if (judgement == Judgement.Ghost) { return(judgement); } if (calculateAllStats) { CalculateScore(judgement, keyPressType == KeyPressType.Release); } return(judgement); }
public KeyPressShow GetKeyPressShow(KeyPressType keyPressType) { if (KeyPresses.ContainsKey(keyPressType)) { return(KeyPresses[keyPressType]); } else { return(null); } }
public LogicInput(KeyJoySettingPair keyJoy, Func <bool> excluder = null, KeyPressType keyPressType = KeyPressType.Down, float[] keyPara = null, KeyPressType joyPressType = KeyPressType.JoyDown, float[] joyPara = null, LogicInput alternate = null) { _keyPressType = keyPressType; _joyPressType = joyPressType; KeyJoy = keyJoy; Excluder = excluder; Alternate = alternate; }
/// <summary> /// Ctor /// </summary> /// <param name="type"></param> /// <param name="keyPressType"></param> /// <param name="hitObject"></param> /// <param name="songPos"></param> /// <param name="judgement"></param> /// <param name="hitDifference"></param> /// <param name="acc"></param> /// <param name="health"></param> public HitStat(HitStatType type, KeyPressType keyPressType, HitObjectInfo hitObject, int songPos, Judgement judgement, int hitDifference, double acc, float health) { HitObject = hitObject; SongPosition = songPos; Judgement = judgement; HitDifference = hitDifference; Accuracy = acc; Health = health; Type = type; KeyPressType = keyPressType; }
/// <summary> /// </summary> /// <param name="type"></param> /// <param name="keyPressType"></param> /// <param name="hitDifference"></param> public HitStat(HitStatType type, KeyPressType keyPressType, int hitDifference) { Type = type; KeyPressType = keyPressType; HitDifference = hitDifference; HitObject = null; Judgement = Judgement.Ghost; SongPosition = 0; Accuracy = 0; Health = 0; }
static Func <bool> CreatePressTestFunc(KeyCode key, KeyPressType pressType, float[] para) { if (pressType < KeyPressType.JoyStickBegin) { if (key == KeyCode.None) { return(() => false); } int mask = (int)key & KeyMask; // use excluder to check key mask if (mask != 0) { key = key - mask; } } switch (pressType) { default: case KeyPressType.Up: return(() => Input.GetKeyUp(key) && NotExcluderByOther()); case KeyPressType.Down: return(() => Input.GetKeyDown(key) && NotExcluderByOther()); case KeyPressType.Press: return(() => Input.GetKey(key) && NotExcluderByOther()); case KeyPressType.UpHPrior: return(() => Input.GetKeyUp(key)); case KeyPressType.PressHPrior: return(() => Input.GetKey(key)); case KeyPressType.ClickNoMove: return(() => key.IsClickNoMove()); case KeyPressType.Click: ClickPressInfo.Register(key, para); return(() => key.IsClickPress()); case KeyPressType.ClickCD: ClickCDPressInfo.Register(key, para); return(() => key.IsClickCDPress()); case KeyPressType.DoublePress: DoublePressInfo.Register(key, para); return(() => key.IsDoublePress()); case KeyPressType.LongPress: LongPressInfo.Register(key, para); return(() => key.IsLongPress()); case KeyPressType.DirU: s_keyAxisU = key; return(delegate { return s_curAxisV > PETools.PEMath.Epsilon; }); case KeyPressType.DirD: s_keyAxisD = key; return(delegate { return s_curAxisV < -PETools.PEMath.Epsilon; }); case KeyPressType.DirR: s_keyAxisR = key; return(delegate { return s_curAxisH > PETools.PEMath.Epsilon; }); case KeyPressType.DirL: s_keyAxisL = key; return(delegate { return s_curAxisH < -PETools.PEMath.Epsilon; }); case KeyPressType.MouseWheelU: return(delegate { return Input.GetAxis("Mouse ScrollWheel") > PETools.PEMath.Epsilon; }); case KeyPressType.MouseWheelD: return(delegate { return Input.GetAxis("Mouse ScrollWheel") < -PETools.PEMath.Epsilon; }); } }
private extern static KeyPress TCOD_console_check_for_keypress(KeyPressType flags);
/// <summary> /// Non-blockingly check for user key press /// </summary> /// <param name="pressFlags">Determines what type of events are returned</param> /// <returns>Keypress</returns> public static KeyPress CheckForKeypress(KeyPressType pressFlags) { return(TCOD_console_check_for_keypress(pressFlags)); }
/// <summary> /// Non-blockingly check for user key press /// </summary> /// <param name="pressFlags">Determines what type of events are returned</param> /// <returns>Keypress</returns> public static KeyPress CheckForKeypress(KeyPressType pressFlags) { return TCOD_console_check_for_keypress(pressFlags); }
public void FakeKey(Keys k, KeyPressType t) { if (m_hWnd <= 0 || m_pause) return; try { UInt32 key = (UInt32)(k & Keys.KeyCode); if (t == KeyPressType.Down || t == KeyPressType.Both) { if (!PostMessage(m_hWnd, WM_KEYDOWN, key, 0x00000000)) throw new Exception("WoW window lost."); } if (t == KeyPressType.Up || t == KeyPressType.Both) { if (!PostMessage(m_hWnd, WM_KEYUP, key, 0xC0000000)) throw new Exception("WoW window lost."); } } catch (Exception e) { m_statusTxt.Text = e.Message; // something went wrong (assume we lost the window OnLostWindow(); } }
public void FakeMouse(MouseButton b, KeyPressType t) { if (m_hWnd <= 0 || m_pause) return; if (t == KeyPressType.Both) { UInt32 pos = (UInt32)((Cursor.Position.Y << 16) | Cursor.Position.X); if (b == MouseButton.Left) { // left click SendMessage(m_hWnd, WM_MOUSEMOVE, 0x01, pos); SendMessage(m_hWnd, WM_LBUTTONDOWN, 0x01, pos); SendMessage(m_hWnd, WM_LBUTTONUP, 0x01, pos); m_fLMouseDown = false; } else { // right click SendMessage(m_hWnd, WM_MOUSEMOVE, 0x02, pos); SendMessage(m_hWnd, WM_RBUTTONDOWN, 0x02, pos); SendMessage(m_hWnd, WM_RBUTTONUP, 0x02, pos); m_fRMouseDown = false; } return; } try { bool btnDown = (b == MouseButton.Left) ? m_fLMouseDown : m_fRMouseDown; if (t == KeyPressType.Down || t == KeyPressType.Both && !btnDown) { // figure out what message to send UInt32 command = 0; UInt32 wParam = 0; switch (b) { case MouseButton.Right: command = WM_RBUTTONDOWN; wParam = 0x02; break; default: command = WM_LBUTTONDOWN; wParam = 0x01; break; } // send the message if (!PostMessage(m_hWnd, command, wParam, (UInt32)((Cursor.Position.Y << 16) | Cursor.Position.X))) throw new Exception("WoW window lost."); if (b == MouseButton.Left) m_fLMouseDown = true; else m_fRMouseDown = true; } if (t == KeyPressType.Up || t == KeyPressType.Both && btnDown) { // figure out what message to send UInt32 command = 0; UInt32 wParam = 0; switch (b) { case MouseButton.Right: command = WM_RBUTTONUP; wParam = 0x02; break; default: command = WM_LBUTTONUP; wParam = 0x01; break; } // send the message if (!PostMessage(m_hWnd, command, wParam, (UInt32)((Cursor.Position.Y << 16) | Cursor.Position.X))) throw new Exception("WoW window lost."); if (b == MouseButton.Left) m_fLMouseDown = false; else m_fRMouseDown = false; } } catch (Exception e) { m_statusTxt.Text = e.Message; // something went wrong (assume we lost the window OnLostWindow(); } }
public InputAction(InputActionType type, Action action, KeyPressType keyPressType = KeyPressType.Press) { Type = type; Action = action; KeyPressType = keyPressType; }
/// <summary> /// Creates a new Voice Command :) /// </summary> /// <param name="command">What the user should say</param> /// <param name="pressOrReleaseKey">What we should press</param> /// <param name="textToSpeechResponse">What we should say</param> /// <param name="pressType">if true, SaveButton will be pressed if false, SaveButton will be released</param> public void Create(string command, Key pressOrReleaseKey, string textToSpeechResponse, KeyPressType pressType) { if (string.IsNullOrEmpty(command)) { return; } command = command.ToLowerInvariant(); Response = textToSpeechResponse; Keys = new[] { pressOrReleaseKey }; if (pressType == KeyPressType.KeyDown) { KeyDownDuration = int.MaxValue; } else { KeyDownDuration = -1; } CommandStorage.AllCommands.TryAdd(command, this); }
private void OnButton(UInt32 mask, KeyPressType t) { // button keys are all front loaded if (t == KeyPressType.Down) { if (m_LTriggerDown && m_RTriggerDown) // Check if both triggers are pulled { if ((mask & GamePad.BTN_A) != 0) //Assisst Party member 1 { FakeKey(Keys.F2, KeyPressType.Both); if (m_settings.AssistMode) FakeKey(Keys.F, KeyPressType.Both); } if ((mask & GamePad.BTN_B) != 0) //Assisst Party member 2 { FakeKey(Keys.F3, KeyPressType.Both); if (m_settings.AssistMode) FakeKey(Keys.F, KeyPressType.Both); } if ((mask & GamePad.BTN_X) != 0) //Assisst Party member 3 { FakeKey(Keys.F4, KeyPressType.Both); if (m_settings.AssistMode) FakeKey(Keys.F, KeyPressType.Both); } if ((mask & GamePad.BTN_Y) != 0) //Assisst Party member 4 { FakeKey(Keys.F5, KeyPressType.Both); if (m_settings.AssistMode) FakeKey(Keys.F, KeyPressType.Both); } if (m_settings.StickyBars) { if ((mask & GamePad.BTN_DPAD_UP) != 0) { // Scroll action bar up FakeKey(Keys.ShiftKey, KeyPressType.Down); FakeKey(Keys.Up, KeyPressType.Both); FakeKey(Keys.ShiftKey, KeyPressType.Up); } if ((mask & GamePad.BTN_DPAD_DOWN) != 0) { // Scroll action bar down FakeKey(Keys.ShiftKey, KeyPressType.Down); FakeKey(Keys.Down, KeyPressType.Both); FakeKey(Keys.ShiftKey, KeyPressType.Up); } } } else if (m_LTriggerDown) // Check if Left Trigger is pulled { if ((mask & GamePad.BTN_A) != 0) FakeKey(Keys.D5, KeyPressType.Both); if ((mask & GamePad.BTN_B) != 0) FakeKey(Keys.D6, KeyPressType.Both); if ((mask & GamePad.BTN_X) != 0) FakeKey(Keys.D7, KeyPressType.Both); if ((mask & GamePad.BTN_Y) != 0) FakeKey(Keys.D8, KeyPressType.Both); /* Used to be for sending in the pet. if ((mask & GamePad.BTN_DPAD_LEFT) != 0) { FakeKey(Keys.ControlKey, KeyPressType.Down); FakeKey(Keys.D1, KeyPressType.Both); FakeKey(Keys.ControlKey, KeyPressType.Up); } if ((mask & GamePad.BTN_DPAD_UP) != 0) { FakeKey(Keys.ControlKey, KeyPressType.Down); FakeKey(Keys.D2, KeyPressType.Both); FakeKey(Keys.ControlKey, KeyPressType.Up); } if ((mask & GamePad.BTN_DPAD_RIGHT) != 0) { FakeKey(Keys.ControlKey, KeyPressType.Down); FakeKey(Keys.D3, KeyPressType.Both); FakeKey(Keys.ControlKey, KeyPressType.Up); } */ } else if (m_RTriggerDown) // Check if Right Trigger is pulled { if ((mask & GamePad.BTN_A) != 0) FakeKey(Keys.D9, KeyPressType.Both); if ((mask & GamePad.BTN_B) != 0) FakeKey(Keys.D0, KeyPressType.Both); if ((mask & GamePad.BTN_X) != 0) FakeKey(Keys.OemMinus, KeyPressType.Both); if ((mask & GamePad.BTN_Y) != 0) FakeKey(Keys.Oemplus, KeyPressType.Both); if ((mask & GamePad.BTN_DPAD_LEFT) != 0) /* { FakeKey(Keys.ControlKey, KeyPressType.Down); FakeKey(Keys.D4, t); FakeKey(Keys.ControlKey, KeyPressType.Up); } if ((mask & GamePad.BTN_DPAD_UP) != 0) { FakeKey(Keys.ControlKey, KeyPressType.Down); FakeKey(Keys.D5, t); FakeKey(Keys.ControlKey, KeyPressType.Up); } if ((mask & GamePad.BTN_DPAD_RIGHT) != 0) { FakeKey(Keys.ControlKey, KeyPressType.Down); FakeKey(Keys.D6, t); FakeKey(Keys.ControlKey, KeyPressType.Up); } if ((mask & GamePad.BTN_DPAD_DOWN) != 0) { FakeKey(Keys.ControlKey, KeyPressType.Down); FakeKey(Keys.D7, t); FakeKey(Keys.ControlKey, KeyPressType.Up); } */ // left trigger targets if ((mask & BTN_TARGET) != 0) { FakeKey(Keys.ControlKey, KeyPressType.Down); FakeKey(Keys.Tab, KeyPressType.Both); FakeKey(Keys.ControlKey, KeyPressType.Up); } if ((mask & GamePad.BTN_DPAD_RIGHT) != 0) { // Open Map FakeKey(Keys.M, KeyPressType.Both); } } else { if ((mask & GamePad.BTN_A) != 0) FakeKey(Keys.D1, KeyPressType.Both); if ((mask & GamePad.BTN_B) != 0) FakeKey(Keys.D2, KeyPressType.Both); if ((mask & GamePad.BTN_X) != 0) FakeKey(Keys.D3, KeyPressType.Both); if ((mask & GamePad.BTN_Y) != 0) FakeKey(Keys.D4, KeyPressType.Both); // left trigger targets if ((mask & BTN_TARGET) != 0) { FakeKey(Keys.Tab, KeyPressType.Both); } if ((mask & GamePad.BTN_DPAD_RIGHT) != 0) { // Open Bag FakeKey(Keys.B, KeyPressType.Both); } if (m_settings.StickyBars) { if ((mask & GamePad.BTN_DPAD_UP) != 0) { // Scroll action bar up FakeKey(Keys.ShiftKey, KeyPressType.Down); FakeKey(Keys.Up, KeyPressType.Both); FakeKey(Keys.ShiftKey, KeyPressType.Up); } if ((mask & GamePad.BTN_DPAD_DOWN) != 0) { // Scroll action bar down FakeKey(Keys.ShiftKey, KeyPressType.Down); FakeKey(Keys.Down, KeyPressType.Both); FakeKey(Keys.ShiftKey, KeyPressType.Up); } } } } // center cursor on exit mousemove mode if ((mask & BTN_SHIFT) != 0) //was BTN_RIGHT_SHOULDER { if (t == KeyPressType.Up) { CenterCursor(); FakeMouse(MouseButton.Right, KeyPressType.Down); } else FakeMouse(MouseButton.Right, KeyPressType.Up); } // only right/left click in mousemove mode if ((m_pad.Buttons & BTN_SHIFT) != 0) //was GamePad.BTN_RIGHT_SHOULDER { if (t == KeyPressType.Up) { if ((mask & GamePad.BTN_RIGHT_THUMB) != 0) FakeMouse(MouseButton.Right, KeyPressType.Both); if ((mask & GamePad.BTN_LEFT_THUMB) != 0) FakeMouse(MouseButton.Left, KeyPressType.Both); } } else { // otherwise, right thumbclick is Space (Jump) if ((mask & GamePad.BTN_RIGHT_THUMB) != 0) { if (m_LTriggerDown) { FakeKey(Keys.X, t); } else { FakeKey(Keys.Space, t); } } if ((mask & GamePad.BTN_LEFT_THUMB) != 0) FakeKey((m_settings.AutoRunUseTilde ? Keys.Oemtilde : Keys.NumLock), t); } if (!m_settings.StickyBars && (!m_LTriggerDown || !m_RTriggerDown)) { if ((mask & GamePad.BTN_DPAD_UP) != 0) { // Press shift when sticky bars enabled. FakeKey(Keys.ShiftKey, t); } if ((mask & GamePad.BTN_DPAD_DOWN) != 0) { // Press alt when sticky bars enabled. FakeKey(Keys.LMenu, t); } if ((mask & GamePad.BTN_DPAD_LEFT) != 0) { // Press Control Key when sticky bars enabled. FakeKey(Keys.ControlKey, t); } } // Back = Esc if ((mask & GamePad.BTN_BACK) != 0) { if (!m_LTriggerDown || !m_RTriggerDown) { if (m_settings.ESCMode) FakeKey(Keys.Escape, t); else FakeKey(Keys.Oemtilde, t); } } if ((mask & GamePad.BTN_START) != 0) { if (m_LTriggerDown && m_RTriggerDown && t == KeyPressType.Up) if ((m_pad.Buttons & GamePad.BTN_DPAD_UP) != 0) // up is held down FakeKey(Keys.NumLock, KeyPressType.Both); // autorun else this.Paused = !this.Paused; // toggle pause mode } else FakeKey(Keys.Escape, t); } // check for pause being pressed /* if (m_LTriggerDown && m_RTriggerDown) { if ((mask & GamePad.BTN_START) != 0 && t == KeyPressType.Up) { if ((m_pad.Buttons & GamePad.BTN_DPAD_UP) != 0) // up is held down FakeKey(Keys.NumLock, KeyPressType.Both); // autorun else this.Paused = !this.Paused; // toggle pause mode } }*/ }
public KeyPressKeyValue() : base() { this.key = null; this.type = KeyPressType.PressAndRelease; this.durationMs = 0; }
public KeyPressType Type; // type of press public KeyPress(KeyCode code, KeyPressType type) { Code = code; Type = type; }
/// <summary> /// Create a new input action instance with given values. /// </summary> /// <param name="actionValue">The enumeration value to generate when this action is triggered</param> /// <param name="keyPressType">What type of key press to detect</param> /// <param name="keyCombo">The key combination that triggers this action</param> public InputAction(TActionEnum actionValue, KeyPressType keyPressType, params Key[] keyCombo) { this.Keys = keyCombo; this.KeyPressType = keyPressType; this.ActionValue = actionValue; }
private void keyEvent(Keys key, KeyPressType type) { //Debug.WriteLine(type.ToString() + " " + key.ToString()); Program.moduleManager.handleKeyPress(key, type); }