public List<KeyShortcut> GetShortcutsStartingWith(KeyPress keys) { var processName = keys.Process.ProcessName; return shortcuts .Where(s => s.Process == processName || string.IsNullOrWhiteSpace(s.Process)) .SelectMany(shortcut => shortcut.GetShortcutsMatching(new[] { keys })) .ToList(); }
/// <summary> /// Initializes a new instance of the <see cref="KeyPressWindowViewModel"/> class. /// </summary> //public KeyPressViewModel() //{ // var viewModel = new KeyPressViewModel(); // var dependencyResolver = this.DependencyResolver; // var uiVisualizerService = dependencyResolver.Resolve(typeof(IUIVisualizerService)) as IUIVisualizerService; // uiVisualizerService.Show(viewModel); //} public KeyPressWindowViewModel(KeyPress keyPress) { Argument.IsNotNull(() => keyPress); this.KeyPress = keyPress; FillKeyList(); }
private void Menu_Selecting(KeyPress keyPress) { if (keyPress.key_Up > 0 && keyPress.key_Down > 0) { select = 0; } else if (keyPress.key_Up == 1) { if (select == 0) { select = 1; } else if (select <= 1) { select = 1; } else { select -= 1; } } else if (keyPress.key_Down == 1) { if (select == 0) { select = select_Max; } else if (select >= select_Max) { select = select_Max; } else { select += 1; } } if (select == 0) { Pause_Menu_Text_1 = Pause_Menu_Text_1_G; Pause_Menu_Text_2 = Pause_Menu_Text_2_G; } else if (select == 1) { Pause_Menu_Text_1 = Pause_Menu_Text_1_B; Pause_Menu_Text_2 = Pause_Menu_Text_2_G; } else if (select == 2) { Pause_Menu_Text_1 = Pause_Menu_Text_1_G; Pause_Menu_Text_2 = Pause_Menu_Text_2_B; } }
public Window_Return_Info Update(GameTime gameTime, KeyPress keyPress) { Window_Return_Info window_Return_Info; window_Return_Info.windowTransition = false; window_Return_Info.newState = Game_Window_State.Credits_State; Base_Components.Camera.offset = Vector2.Zero; // Code Here return window_Return_Info; }
void Add(KeyPress key) { var isFirstKey = keys.Count == 0; if (!isFirstKey && keys[0].Process.ProcessName != key.Process.ProcessName) { NoMatchingShortcut(); return; } keys.Add(key); var newPossibleShortcuts = possibleKeyShortcuts.Where(s => s.StartsWith(keys)).ToList(); EvaluateShortcuts(newPossibleShortcuts); }
public MouseKeyHook() { _hook = Hook.GlobalEvents(); _hook.KeyUp += (S, E) => KeyUp?.Invoke(this, E); _hook.KeyDown += (S, E) => KeyDown?.Invoke(this, E); _hook.MouseUp += (S, E) => MouseUp?.Invoke(this, E); _hook.MouseDown += (S, E) => MouseDown?.Invoke(this, E); _hook.MouseClick += (S, E) => MouseClick?.Invoke(this, E); _hook.MouseDoubleClick += (S, E) => MouseDoubleClick?.Invoke(this, E); _hook.MouseWheel += (S, E) => MouseWheel?.Invoke(this, E); _hook.MouseMove += (S, E) => MouseMove?.Invoke(this, E); _hook.MouseDragStarted += (S, E) => MouseDragStarted?.Invoke(this, E); _hook.MouseDragFinished += (S, E) => MouseDragFinished?.Invoke(this, E); _hook.KeyPress += (S, E) => KeyPress?.Invoke(this, E); }
private void handleKeyPress(KeyPress kp) { var stroke = new ManagedWrapper.Stroke(); stroke.key.code = (ushort)kp.key; if (kp.action == Settings.Action.PRESSED) { stroke.key.state = (ushort)ManagedWrapper.KeyState.Down; } else { stroke.key.state = (ushort)ManagedWrapper.KeyState.Up; } int devId = 4; // Console.WriteLine(stroke.key.code + " " + kp.action); ManagedWrapper.Send(deviceContext, devId, ref stroke, 1); System.Threading.Thread.Sleep(10); }
protected virtual void OnKeyPressCore(KeyPressEventArgs args) { if (args == null || args.Cancel) { return; } KeyPress?.Invoke(this, args); if (args.Cancel) { return; } if (EnterOrSpaceKeyHit(args)) { return; } }
public void Update(KeyPress key) { if (GameStatus != Status.IsPaused) { TryExitGame(); TryChangeLevel(); long Current = GetCurrentTime(); #region Update objects UpdatePlayer(key); UpdateEnemy((int)Current); #endregion FindCollision(); } }
internal override void ImportSettings(string settings) { if (string.IsNullOrEmpty(settings)) { throw new ArgumentException("Import string empty. (KeyBinding)"); } if (settings.StartsWith("RadioPanelKeyDialPos{")) { var parameters = settings.Split(new[] { Constants.SEPARATOR_SYMBOL }, StringSplitOptions.RemoveEmptyEntries); var param0 = parameters[0].Replace("RadioPanelKeyDialPos{", "").Replace("}", ""); _pz69DialPosition = (PZ69DialPosition)Enum.Parse(typeof(PZ69DialPosition), param0); var param1 = parameters[1].Replace("{", "").Replace("}", ""); WhenTurnedOn = param1.Substring(0, 1) == "1"; param1 = param1.Substring(1); _panelPZ69Knob = (RadioPanelPZ69KnobsEmulator)Enum.Parse(typeof(RadioPanelPZ69KnobsEmulator), param1); OSKeyPress = new KeyPress(); OSKeyPress.ImportString(parameters[2]); } }
public void GameUpdate(object source, ElapsedEventArgs e) { Key = OnInputKey(); if (Key == KeyPress.Pause) { Pause(); } else if (Key == KeyPress.Restore) { Restore(); } else { Update(Key); } this.Render(); }
public ShortcutAccumulator ProcessKey(IShortcutProvider shortcutProvider, KeyPress key) { if (HasCompletedValue) return new ShortcutAccumulator().ProcessKey(shortcutProvider, key); if (!keys.Any()) { var possibleShortcuts = shortcutProvider.GetShortcutsStartingWith(key); if (possibleShortcuts.Any()) BeginShortcut(key, possibleShortcuts); else Complete(key); return this; } Add(key); return this; }
public bool PreFilterMessage(ref Message m) { var key = (Keys)m.WParam; Boolean keyPressed = false; if (m.Msg == WM_KEYDOWN) { return(KeysDictionary[key] = true); } else if (m.Msg == WM_KEYUP) { return(!(KeysDictionary[key] = false)); } else if (m.Msg == WM_LBUTTONDOWN) { key = Keys.LButton; return(KeysDictionary[key] = true); } else if (m.Msg == WM_LBUTTONUP) { key = Keys.LButton; return(!(KeysDictionary[key] = false)); } else if (m.Msg == WM_RBUTTONDOWN) { key = Keys.RButton; return(KeysDictionary[key] = true); } else if (m.Msg == WM_RBUTTONUP) { key = Keys.RButton; return(!(KeysDictionary[key] = false)); } if (keyPressed) { KeyPress?.Invoke(this, new KeyEventArgs(key)); } else { KeyUp?.Invoke(this, new KeyEventArgs(key)); } return(false); }
protected override void dispatch_event() { Console.WriteLine("blocking-read event"); evt = display.next_event(); Console.WriteLine("got event " + evt); switch (evt.code()) { case gnu.x11.xevent.ButtonPress.CODE: exit(); break; case ClientMessage.CODE: if (((ClientMessage)evt).delete_window()) { exit(); } break; case Expose.CODE: if (!thread.IsAlive) { thread.Start(); } break; case KeyPress.CODE: { KeyPress e = (KeyPress)evt; int keycode = e.detail(); int keystate = e.state(); int keysym = display.input.keycode_to_keysym(keycode, keystate); if (keysym == 'q' || keysym == 'Q' || keysym == gnu.x11.keysym.Misc.ESCAPE) { exit(); } break; } } }
// TODO - change to events public void OnKeyPressed(char key, SysKeys?sysKey) { if (!ViewModelContainer.ResultsDbViewModel.IsVisible) { if (key == 'q') { CloseAplication(); } else if (sysKey != null) { KeyPress.FindAndExecuteCommand(sysKey.Value); } else { KeyPress.FindAndExecuteCommand(key); } BlinkingCursor.AddBlinkKey(key, sysKey); } }
internal EditKeyboard(KeyPress KeyPress) { this.action = KeyPress; InitializeComponent(); FillComboBox(); int index = 0; for (index = 0; index < TargetKey.Items.Count; index++) { if ((VirtualKeyCode)TargetKey.Items[index] == KeyPress.Key) { System.Diagnostics.Debug.Print("Key Matched."); break; } } System.Diagnostics.Debug.Print(index.ToString()); TargetKey.SelectedIndex = index; switch (KeyPress.PressAction) { case KeyPressActionType.Press: Press.IsChecked = true; break; case KeyPressActionType.Down: Down.IsChecked = true; break; case KeyPressActionType.Up: Up.IsChecked = true; break; default: break; } if (KeyPress.KeyModifier.HasFlag(KeyModifierFlag.Ctrl)) KeyModifier_Ctrl.IsChecked = true; if (KeyPress.KeyModifier.HasFlag(KeyModifierFlag.Alt)) KeyModifier_Alt.IsChecked = true; if (KeyPress.KeyModifier.HasFlag(KeyModifierFlag.Shift)) KeyModifier_Shift.IsChecked = true; }
static void KeyMenuInitialise() { KeyPress.AddControl("Menu"); KeyPress.Set("Menu", ConsoleKey.DownArrow, Keys[needOption.menuDown]); KeyPress.Set("Menu", ConsoleKey.UpArrow, Keys[needOption.menuUp]); KeyPress.Set("Menu", ConsoleKey.Enter, Keys[needOption.menuPress]); KeyPress.AddControl("Snake"); KeyPress.Set("Snake", ConsoleKey.UpArrow, Keys[needOption.snakeUp]); KeyPress.Set("Snake", ConsoleKey.DownArrow, Keys[needOption.snakeDown]); KeyPress.Set("Snake", ConsoleKey.LeftArrow, Keys[needOption.snakeLeft]); KeyPress.Set("Snake", ConsoleKey.RightArrow, Keys[needOption.snakeRigh]); KeyPress.Set("Snake", ConsoleKey.W, Keys[needOption.secondSnakeUp]); KeyPress.Set("Snake", ConsoleKey.S, Keys[needOption.secondSnakeDown]); KeyPress.Set("Snake", ConsoleKey.A, Keys[needOption.secondSnakeLeft]); KeyPress.Set("Snake", ConsoleKey.D, Keys[needOption.secondSnakeRigh]); KeyPress.Set("Snake", ConsoleKey.Escape, Keys[needOption.snakePause]); }
void readNotesFile(string filePath) { //StreamReader reader = new StreamReader(filePath); string[] contents = File.ReadAllLines(filePath); Debug.Log("contents of file: " + contents); for (int j = 0; j < 200; j++) { for (int i = 0; i < contents.Length; i++) { if (contents[i].StartsWith("P")) { songSequence.Add(null); continue; } string[] keyDetails = contents[i].Split(','); KeyPress kp = new KeyPress(keyDetails[0], keyDetails[1], i); songSequence.Add(kp); } } //reader.Close(); }
private static void onUpdate(object sender, UpdateEventArgs e) { if (KeyPress != null) { RLKeyPress key = RootConsole.Keyboard.GetKeyPress(); if (key != null) { KeyPressEventArgs arg = new KeyPressEventArgs(key); foreach (EventHandler <KeyPressEventArgs> func in KeyPress.GetInvocationList()) { func(sender, arg); if (arg.Cancel) { break; } } } } }
protected virtual void dispatch_event() { evt = display.next_event(); switch (evt.code()) { case gnu.x11.xevent.ButtonPress.CODE: exit(); break; case ClientMessage.CODE: if (((ClientMessage)evt).delete_window()) { exit(); } break; case Expose.CODE: if (((Expose)evt).count() == 0) { paint(); } break; case KeyPress.CODE: { KeyPress e = (KeyPress)evt; int keycode = e.detail(); int keystate = e.state(); int keysym = display.input.keycode_to_keysym(keycode, keystate); if (keysym == 'q' || keysym == 'Q' || keysym == gnu.x11.keysym.Misc.ESCAPE) { exit(); } break; } } }
public static Task <bool> JsKeyPress(int e) { var found = false; var consoleKey = default(ConsoleKey); try { consoleKey = (ConsoleKey)e; found = true; } catch { Console.WriteLine($"Cound not find {nameof(ConsoleKey)} for JS key value {e})"); } if (found) { KeyPress?.Invoke(null, consoleKey); } return(Task.FromResult(found)); }
// The method responsible for handling the update private static void Update(object s, EventArgs e) { KeyboardState New = Keyboard.GetState(); Keys[] OldDown = Old.GetPressedKeys(); Keys[] Down = New.GetPressedKeys().Where(a => !Old.IsKeyDown(a)).ToArray(); Keys[] Up = OldDown.Where(a => !New.IsKeyDown(a)).ToArray(); Keys[] Held = OldDown.Where(a => New.IsKeyDown(a)).ToArray(); foreach (Keys key in Down) { KeyDown?.Invoke(key); KeyPress?.Invoke(key); // int[]{ticks,tickRate} Counter.Add(key, new int[2] { 30, 30 }); } foreach (Keys key in Up) { Counter.Remove(key); KeyUp?.Invoke(key); } foreach (Keys key in Held) { Counter[key][0]--; if (Counter[key][0] > 0) { continue; } Counter[key][0] = Counter[key][1]; if (Counter[key][1] > 15) { Counter[key][1]--; } KeyHeld?.Invoke(key); KeyPress?.Invoke(key); } Old = New; }
private void OnStateChanged(object sender, EventArgs e) { if (this.WindowState == WindowState.Minimized) { this.Topmost = false; this.ShowInTaskbar = false; resetPlayer(); // notifyIcon.Visible = true; } else { // notifyIcon.Visible = true; this.ShowInTaskbar = true; this.Topmost = true; this.Activate(); search.Focusable = true; FocusManager.SetFocusedElement(mainw, search); Keyboard.Focus(search); KeyPress.press(); } }
private async Task InterpretKeyPress(KeyPress key, CodePane codePane, CompletionPane completionPane, CancellationToken cancellationToken) { if (!completionPane.WouldKeyPressCommitCompletionItem(key)) { key = await promptCallbacks.TransformKeyPressAsync(codePane.Document.GetText(), codePane.Document.Caret, key, cancellationToken).ConfigureAwait(false); } foreach (var panes in new IKeyPressHandler[] { completionPane, history, codePane }) { await panes.OnKeyDown(key, cancellationToken).ConfigureAwait(false); } foreach (var panes in new IKeyPressHandler[] { completionPane, history, codePane }) { await panes.OnKeyUp(key, cancellationToken).ConfigureAwait(false); } //we don't support text selection while completion list is open //text selection can put completion list into broken state, where filtering does not work //so we want this assert to be true Debug.Assert(!completionPane.IsOpen || (codePane.Selection is null)); }
internal void Test() { ILogger logger = new Logger(); ITriggeredJob triggeredJob = new TriggeredJob(this); Console.WriteLine("TriggeredJobTest.Test, Press a key to stop..."); IJobDirector director = new TriggeredJobDirector(triggeredJob, logger); Task task = director.StartAsync(); var keyPressTask = new KeyPress().GetAsync(); while (true) { var taskIndex = Task.WaitAny(task, keyPressTask); if (taskIndex == 0) { break; } var keyInfo = keyPressTask.Result; if (keyInfo.Value.Key == ConsoleKey.T) { JobTriggered?.Invoke(this, new EventArgs()); } keyPressTask = new KeyPress().GetAsync(); if (keyInfo.Value.Key == ConsoleKey.Escape) { break; } } Console.WriteLine(); director.StopAsync().Wait(); task.Wait(); Console.WriteLine("TriggeredJobTest.Test, Press Escape to exit..."); keyPressTask.Wait(); }
private void AddKeyPress() { var keyPressWindow = new KeyPressReadingBigWindow(_supportIndefinite); keyPressWindow.ShowDialog(); if (keyPressWindow.DialogResult.HasValue && keyPressWindow.DialogResult.Value) { // Clicked OK var keyPressInfo = new KeyPressInfo { LengthOfBreak = (KeyPressLength)keyPressWindow.ComboBoxBreak.SelectedItem, VirtualKeyCodes = KeyPress.SplitStringKeyCodes(keyPressWindow.TextBoxKeyPress.Text), LengthOfKeyPress = (KeyPressLength)keyPressWindow.ComboBoxKeyPressTime.SelectedItem }; _sortedList.Add(GetNewKeyValue(), keyPressInfo); DataGridSequences.DataContext = _sortedList; DataGridSequences.ItemsSource = _sortedList; DataGridSequences.Items.Refresh(); SetIsDirty(); SetFormState(); } }
/// <summary> /// Evaluates the action against a given InputState. /// </summary> /// <param name="state">The InputState to test for the action.</param> /// <param name="controllingPlayer">The player to test, or null to allow any player.</param> /// <param name="player">If controllingPlayer is null, this is the player that performed the action.</param> /// <returns>True if the action occurred, false otherwise.</returns> public bool Evaluate(InputState state, System.Nullable <PlayerIndex> controllingPlayer, ref PlayerIndex player) { // Figure out which delegate methods to map from the state which takes care of our "newPressOnly" logic ButtonPress buttonTest = null; KeyPress keyTest = null; if (newPressOnly) { buttonTest = state.IsNewButtonPress; keyTest = state.IsNewKeyPress; } else { buttonTest = state.IsButtonPressed; keyTest = state.IsKeyPressed; } // Now we simply need to invoke the appropriate methods for each button and key in our collections foreach (Buttons button in buttons) { if (buttonTest(button, controllingPlayer, ref player)) { return(true); } } foreach (Keys key in keys) { if (keyTest(key, controllingPlayer, ref player)) { return(true); } } // If we got here, the action is not matched player = PlayerIndex.One; return(false); }
private static void RealTimeLoopTest(RootConsole console) { TCODSystem.FPS = 25; console.Clear(); console.PrintLine("Keyboard Test Suite", 40, 5, LineAlignment.Center); console.PrintLine("Press 'F10' to enter Turn Based Test.", 40, 6, LineAlignment.Center); KeyPress pressedKey = Keyboard.CheckForKeypress(KeyPressType.Pressed); console.PrintLine("F2 Key Pressed = " + ((pressedKey.KeyCode == KeyCode.TCODK_F2 && pressedKey.Pressed) ? "Yes" : "No"), 10, 10, LineAlignment.Left); console.PrintLine("'d' to disable repeat keys", 10, 11, LineAlignment.Left); console.PrintLine("'e' to enable repeat keys", 10, 12, LineAlignment.Left); console.PrintLine(string.Format("Ctrl: {0}", pressedKey.LeftControl), 10, 13, LineAlignment.Left); console.PrintLine(string.Format("Ctrl Up: {0}", ctrlUpHit), 10, 14, LineAlignment.Left); if (pressedKey.KeyCode == KeyCode.TCODK_UP && pressedKey.Control) { ctrlUpHit = true; } console.Flush(); if (pressedKey.Character == 'd') { Keyboard.DisableRepeat(); } if (pressedKey.Character == 'e') { Keyboard.SetRepeat(0, 10); } if (pressedKey.KeyCode == KeyCode.TCODK_F10 && pressedKey.Pressed) { inRealTimeTest = false; } }
public static void TestKeyboard() { RootConsole.Width = 80; RootConsole.Height = 50; RootConsole.WindowTitle = "Keyboard Tester"; RootConsole.Fullscreen = false; using (RootConsole console = RootConsole.GetInstance()) { KeyPress key = new KeyPress(); do { if (inRealTimeTest) { RealTimeLoopTest(console); } else { TurnBasedLoopTest(console, ref key); } System.Console.Out.WriteLine((char)key.Character); }while (key.Character != 'q' && !console.IsWindowClosed()); } }
protected override void Run() { Screen s = new Screen(); Label l1 = new Label("Welcome!", 10, 10); TextBox t = new TextBox(15, 10, 30); t2 = new TextBox(15, 10, 120); t2.Placeholder = "Username"; btn = new Button("enter", 10, 150); btn.OnEnter += Btn_OnEnter; KeyPress p = new KeyPress(ConsoleKey.D1, ConsoleModifiers.Alt); p.OnPress += Kernel_OnPress; t.KeyPresses.Add(p); t.OnDelete += T_OnDelete; t.OnKeyPress += T_OnKeyPress; l = new Label("--", 10, 80); s.Controls.Add(l1); s.Controls.Add(t); s.Controls.Add(t2); s.Controls.Add(btn); s.Controls.Add(l); driver.RenderScreen(s); }
private async void Run() { int skip = 2;// Config.SkipLast.Value; run = true; long prevTime = _recording.StartTime; for (int i = 0; i < _recording.Events.Count - skip && run; i++) { var evt = _recording.Events[i]; await Task.Delay((int)(evt.Time - prevTime)); prevTime = evt.Time; if (evt.Type == DetailsType.Mouse) { MouseMove.ProcessMouseEvent(_recording.Events[i] as MouseDetails); } else if (_recording.Events[i].Type == DetailsType.Keyboard) { KeyPress.ProcessKeyEvent(_recording.Events[i] as KeyboardDetails); } } }
private void EditKeyPress() { var keyValuePair = (KeyValuePair <int, IKeyPressInfo>)DataGridSequences.SelectedItem; var keyPressWindow = new KeyPressReadingBigWindow((KeyPressInfo)keyValuePair.Value); keyPressWindow.ShowDialog(); if (keyPressWindow.DialogResult.HasValue && keyPressWindow.DialogResult.Value) { //Clicked OK if (!keyPressWindow.IsDirty) { //User made no changes return; } _sortedList[keyValuePair.Key].LengthOfBreak = (KeyPressLength)keyPressWindow.ComboBoxBreak.SelectedItem; _sortedList[keyValuePair.Key].VirtualKeyCodes = KeyPress.SplitStringKeyCodes(keyPressWindow.TextBoxKeyPress.Text); _sortedList[keyValuePair.Key].LengthOfKeyPress = (KeyPressLength)keyPressWindow.ComboBoxKeyPressTime.SelectedItem; DataGridSequences.DataContext = _sortedList; DataGridSequences.ItemsSource = _sortedList; DataGridSequences.Items.Refresh(); SetIsDirty(); } }
/// <summary> /// Process PutKeyPress rpc calls from the keylogger program. /// </summary> public Task<PutKeyPressResponse> PutKeyPress(KeyPress request, ServerCallContext context) { this.q.Enqueue(request); return Task.FromResult(new PutKeyPressResponse()); }
public void Update(GameTime gameTime, KeyPress keypress, bool halt_movement) { // Calculate bounds within texture size. localBounds = new Rectangle(boundingBoxLeft, boundingBoxTop, boundingBoxWidth, boundingBoxHeight); if (halt_movement == false) { GetInput(keypress); } ApplyPhysics(gameTime); if (isOnGround) { if (Math.Abs(velocity.X) /*- 0.02f*/ > 0) { if (isRun) { sprite.PlayAnimation(runAnimation); } else if (Crawl_Toggle) { sprite.PlayAnimation(crawlingAnimation); } else { sprite.PlayAnimation(walkAnimation); } } else if (movement == noSpeed) { if (Crawl_Toggle) { sprite.PlayAnimation(crouch_IdleAnimation); } else { sprite.PlayAnimation(idleAnimation); } } else { sprite.PlayAnimation(idleAnimation); } } // Clear input. movement = noSpeed; isJumping = false; }
private void GetInput(KeyPress keypress) { // Gamepad // Keyboard if (keypress.key_C == 1 && isOnGround) { if (Crawl_Toggle == true) { if (Crawl_Block != true) { Crawl_Toggle = false; } } else if (Crawl_Toggle == false) { Crawl_Toggle = true; } } ///<If both left and right are pressed, there is no horizontal movement> if (keypress.key_Right == 1 && keypress.key_Left == 1) { movement = noSpeed; } ///<Left Movement> ///<If left is pressed, there is horizontal movement> else if (keypress.key_Left >= 1) { if (Crawl_Toggle == true) { movement = -crawlSpeed; isRun = false; } ///<If shift is also pressed, horizontal movement will be at runSpeed> else if (keypress.key_Shift >= 1) { movement = -runSpeed; isRun = true; } ///<If not, the horizontal movement will be at walkspeed> else { movement = -walkSpeed; isRun = false; } } ///<Right Movement> ///<If right is pressed, there is horizontal movement> else if (keypress.key_Right >= 1) { if (Crawl_Toggle == true) { movement = crawlSpeed; isRun = false; } ///<If shift is also pressed, horizontal movement will be at runSpeed> else if (keypress.key_Shift >= 1) { movement = runSpeed; isRun = true; } ///<If not, the horizontal movement will be at walkspeed> else { movement = walkSpeed; isRun = false; } } else if (keypress.key_Right == 0 && keypress.key_Left == 0) { velocity.X = noSpeed; isRun = false; } if (keypress.key_Space >= 1 || keypress.key_Z >= 1 || keypress.key_Up >= 1) { isJumping = true; } }
public override void KeyDown(NSEvent theEvent) { base.KeyDown(theEvent); KeyPress?.Invoke(this, theEvent.KeyCode); }
/* public override void doShowRefundReceiptScreen(string orderId, string refundId) { sendObjectMessage(new RefundReceiptMessage(orderId, refundId)); } public override void doShowCreditReceiptScreen(string orderId, string creditId) { sendObjectMessage(new CreditReceiptMessage(orderId, creditId)); } */ public override void doKeyPress(KeyPress keyPress) { sendObjectMessage(new KeyPressMessage(keyPress)); }
public Window_Return_Info Update(GameTime gameTime, KeyPress keyPress) { Window_Return_Info window_Return_Info; window_Return_Info.windowTransition = false; window_Return_Info.newState = Game_Window_State.Game_Mode_State; Base_Components.Camera.offset = Vector2.Zero; if (reload == true) { Reload(keyPress); } if (keyPress.key_Esc == 1) { limbo_State = Limbo_State.fade_Out; screen_Fade = content.Load<Texture2D>("Fades/Black"); text_Page = 420; } Update_Text(keyPress); switch (limbo_State) { case Limbo_State.fade_In: FadeDelay -= gameTime.ElapsedGameTime.TotalSeconds; if (FadeDelay <= 0) { FadeDelay = fade_Delay; AlphaValue += fadeIncrement; if (AlphaValue >= 1) { AlphaValue = MathHelper.Clamp(AlphaValue, 0, 1); limbo_State = Limbo_State.text; screen_Fade = content.Load<Texture2D>("Fades/Black"); } } break; case Limbo_State.text: if (keyPress.key_Space == 1) { limbo_State = Limbo_State.fade_Out; } break; case Limbo_State.fade_Out: FadeDelay -= gameTime.ElapsedGameTime.TotalSeconds; if (FadeDelay <= 0) { FadeDelay = fade_Delay; AlphaValue -= fadeIncrement; if (AlphaValue <= 0) { AlphaValue = MathHelper.Clamp(AlphaValue, 0, 1); if (text_Page >= 5) { limbo_State = Limbo_State.change_state; } else { limbo_State = Limbo_State.fade_In; text_Page += 1; } } } break; case Limbo_State.change_state: Dismiss(); window_Return_Info.windowTransition = true; window_Return_Info.newState = Game_Window_State.Game_Mode_State; break; } return window_Return_Info; }
void box_KeyUp(object sender, KeyEventArgs e) { var key = new KeyPress { Character = GetChar(e), Code = (VirtualKeys)e.KeyCode, Pressed = false, }; if (e.Alt) key.Special |= ControlKeyState.LEFT_ALT_PRESSED; if (e.Control) key.Special |= ControlKeyState.LEFT_CTRL_PRESSED; if (e.Shift) key.Special |= ControlKeyState.SHIFT_PRESSED; lock (keys) keys.Add(key); }
//private void KeyPressActionCheck(object sender, RoutedEventArgs e) //{ // RadioButton rb = (sender as RadioButton); // if (rb == Press) // { // KeyPressAction = KeyPressAction.Press; // } // else if (rb == Down) // { // KeyPressAction = KeyPressAction.Down; // } // else // { // KeyPressAction = KeyPressAction.Up; // } // //txtb.Text = "You clicked " + li.Content.ToString() + "."; //} //private void KeyModifierCheck(object sender, RoutedEventArgs e) //{ // CheckBox cb = (sender as CheckBox); // if(cb == KeyModifier_Ctrl && cb.IsChecked) // { // KeyModifier = KeyModifier.Ctrl | KeyModifier.Alt | KeyModifier.Shift; // } //} private void Save(object sender, RoutedEventArgs e) { KeyPressActionType KeyPressAction; if ((bool)Press.IsChecked) KeyPressAction = KeyPressActionType.Press; else if ((bool)Down.IsChecked) KeyPressAction = KeyPressActionType.Down; else if ((bool)Up.IsChecked) KeyPressAction = KeyPressActionType.Up; else throw new Exception(); KeyModifier = ((bool)(KeyModifier_Ctrl.IsChecked) ? (KeyModifierFlag.Ctrl) : KeyModifierFlag.None) | ((bool)(KeyModifier_Alt.IsChecked) ? (KeyModifierFlag.Alt) : KeyModifierFlag.None) | ((bool)(KeyModifier_Shift.IsChecked) ? (KeyModifierFlag.Shift) : KeyModifierFlag.None); action = new KeyPress((VirtualKeyCode)TargetKey.SelectionBoxItem, (KeyPressActionType)KeyPressAction, KeyModifier); Cache.keyPress = this.action; DialogResult = true; this.Close(); }
public InputOption(KeyPress kp, string desc) { keyPress = kp; description = desc; }
void Complete(KeyPress key) { if (HasCompletedValue) throw new InvalidOperationException(); HasCompletedValue = true; messages = new[] { new Message(key) }; }
void BeginShortcut(KeyPress key, List<KeyShortcut> possibleShortcuts) { keys.Add(key); EvaluateShortcuts(possibleShortcuts); }
public KeyPressMessage(KeyPress keyPre) : base(Methods.KEY_PRESS) { this.keyPress = keyPre; }
///<summary> /// HookCallback function /// /// Called each time a Hook Event is fired. If the type of event is a KeyPress append the keypress and metadata to a keypress log. /// This function calls the next hook in the hook chain. ///</summary> private static IntPtr HookCallback(int nCode, IntPtr wParam, IntPtr lParam) { if ((client != null) && (client.Channel.State != ChannelState.FatalFailure)){ if (nCode >= 0 && wParam == (IntPtr)WM_KEYDOWN) { // Create a KeyPress object and get keypress metadata. KeyPress ks = new KeyPress(); DateTimeOffset x = new DateTimeOffset(DateTime.Now); ks.Key = Marshal.ReadInt32(lParam); ks.Timestamp = x.ToUnixTimeMilliseconds(); ks.ActiveProgram = GetActiveWindowName(); // Un-Comment these lines to write the KeyStrokes in the JSON human readable format. C# proto // implementation lacks support for the Text encoding, the json encoding is the most human readable format. //StreamWriter o = new StreamWriter(log+".json"); //o.WriteLine(ks.ToString()); //o.Close(); try { client.PutKeyPressAsync(ks); } catch (RpcException e) { //Console.WriteLine("RPC Failed: " + e); } } } return CallNextHookEx(_hookID, nCode, wParam, lParam); }
public Window_Return_Info Update(GameTime gameTime, KeyPress keyPress) { Window_Return_Info window_Return_Info; window_Return_Info.windowTransition = false; window_Return_Info.newState = Game_Window_State.Splash_Screen_State; Base_Components.Camera.offset = Vector2.Zero; if (reload == true) { Reload(); } if (keyPress.key_Up == 1 && konami == 0) { konami += 1; } else if (keyPress.key_Up == 1 && konami == 1) { konami += 1; } else if (keyPress.key_Down == 1 && konami == 2) { konami += 1; } else if (keyPress.key_Down == 1 && konami == 3) { konami += 1; } else if (keyPress.key_Left == 1 && konami == 4) { konami += 1; } else if (keyPress.key_Right == 1 && konami == 5) { konami += 1; } else if (keyPress.key_Left == 1 && konami == 6) { konami += 1; } else if (keyPress.key_Right == 1 && konami == 7) { konami += 1; } else if (keyPress.key_A == 1 && konami == 8) { konami += 1; } else if (keyPress.key_B == 1 && konami == 9) { window_Return_Info.windowTransition = true; window_Return_Info.newState = Game_Window_State.Konami_State; Dismiss(); } switch(splash_state) { case Splash.nwp_Logo: // nwp_logo fade in if (nwp_logo_fade == 0) { nwp_FadeDelay -= gameTime.ElapsedGameTime.TotalSeconds; if (nwp_FadeDelay <= 0) { nwp_FadeDelay = fade_Delay; nwp_AlphaValue -= fadeIncrement; if (nwp_AlphaValue <= 0) { nwp_AlphaValue = MathHelper.Clamp(nwp_AlphaValue, 0, 1); nwp_logo_fade += 1; } } } // nwp_logo pause else if (nwp_logo_fade == 1) { if (elapsedTime >= splash_Pause) { nwp_logo_fade += 1; nwp_AlphaValue = 0f; } else { elapsedTime += gameTime.ElapsedGameTime.TotalSeconds; } } // nwp_logo fade out else if (nwp_logo_fade == 2) { nwp_FadeDelay -= gameTime.ElapsedGameTime.TotalSeconds; if (nwp_FadeDelay <= 0) { nwp_FadeDelay = fade_Delay; nwp_AlphaValue += fadeIncrement; if (nwp_AlphaValue >= 1) { nwp_AlphaValue = MathHelper.Clamp(nwp_AlphaValue, 0, 1); splash_state = Splash.change_State; } } } break; case Splash.change_State: // Change Game_Window_State window_Return_Info.windowTransition = true; window_Return_Info.newState = Game_Window_State.Main_Menu_State; Dismiss(); break; } return window_Return_Info; }
public override void doKeyPress(KeyPress keyPress) { //TODO: implement }
/// <summary> /// Catches the key press activity. /// </summary> /// <param name="key">The key.</param> public void CatchKeyPressActivity(KeyPress key) { key.Catched = true; key.StateString = judge.CurState.ToString(); judge.ResetDormantTimer(); }
private void Update_Text(KeyPress keyPress) { if (text_Page == 0) { if (keyPress.is_GamePad == false) text_1 = "Welcome to Love*"; text_2 = "press space to continue"; if (keyPress.is_GamePad == true) { text_1 = "Welcome to Love*"; text_2 = "press A to continue"; } } else if (text_Page == 1) { if (keyPress.is_GamePad == false) text_1 = "Lets start with some basics"; text_2 = "the left & right keys are used to move"; if (keyPress.is_GamePad == true) { text_1 = "Lets start with some basics"; text_2 = "moving the left joystick will make you move"; } } else if (text_Page == 2) { if (keyPress.is_GamePad == false) text_1 = "To jump you can press"; text_2 = "space or Z"; if (keyPress.is_GamePad == true) { text_1 = "To jump"; text_2 = "press A"; } } else if (text_Page == 3) { if (keyPress.is_GamePad == false) text_1 = "To run"; text_2 = "hold down shift"; if (keyPress.is_GamePad == true) { text_1 = "To run"; text_2 = "hold down a trigger"; } } else if (text_Page == 4) { if (keyPress.is_GamePad == false) text_1 = "To crouch"; text_2 = "press C"; if (keyPress.is_GamePad == true) { text_1 = "To crouch"; text_2 = "press Y"; } } else if (text_Page == 5) { if (keyPress.is_GamePad == false) text_1 = "And to interact"; text_2 = "press X"; if (keyPress.is_GamePad == true) { text_1 = "And to interact"; text_2 = "press X"; } } else if (text_Page == 420) { text_1 = "Skipping"; text_2 = ""; } }
private void Menu_Selecting(KeyPress keyPress) { if (keyPress.key_Esc == 1) { select = select_Max; } if (keyPress.key_Up > 0 && keyPress.key_Down > 0) { select = 0; } else if (keyPress.key_Up == 1) { if (select == 0) { select = 1; } else if (select <= 1) { select = 1; } else { select -= 1; } } else if (keyPress.key_Down == 1) { if (select == 0) { select = select_Max; } else if (select >= select_Max) { select = select_Max; } else { select += 1; } } if (select == 0) { Menu_Text_1 = Menu_Text_1_G; Menu_Text_2 = Menu_Text_2_G; Menu_Text_3 = Menu_Text_3_G; } else if (select == 1) { Menu_Text_1 = Menu_Text_1_B; Menu_Text_2 = Menu_Text_2_G; Menu_Text_3 = Menu_Text_3_G; } else if (select == 2) { Menu_Text_1 = Menu_Text_1_G; Menu_Text_2 = Menu_Text_2_B; Menu_Text_3 = Menu_Text_3_G; } else if (select == 3) { Menu_Text_1 = Menu_Text_1_G; Menu_Text_2 = Menu_Text_2_G; Menu_Text_3 = Menu_Text_3_B; } }
private void Reload(KeyPress keypress) { limbo_State = Limbo_State.fade_In; screen_Fade = content.Load<Texture2D>("Fades/White"); Limbo_Font = content.Load<SpriteFont>("Fonts/Limbo_Font"); AlphaValue = 0f; FadeDelay = 0; sub_KeyPress = keypress; text_Page = 0; Update_Text(keypress); reload = false; }
public Window_Return_Info Update(GameTime gameTime, KeyPress keyPress) { Window_Return_Info window_Return_Info; window_Return_Info.windowTransition = false; window_Return_Info.newState = Game_Window_State.Main_Menu_State; Base_Components.Camera.offset = Vector2.Zero; if (reload == true) { Reload(); } Menu_Selecting(keyPress); switch(menu_State) { case Menu_State.menu_Fade_In: FadeDelay -= gameTime.ElapsedGameTime.TotalSeconds; if (FadeDelay <= 0) { FadeDelay = fade_Delay; AlphaValue += fadeIncrement; if (AlphaValue >= 1) { AlphaValue = MathHelper.Clamp(AlphaValue, 0, 1); menu_State = Menu_State.menu_Select; screen_Fade = content.Load<Texture2D>("Fades/White"); } } break; case Menu_State.menu_Select: if (keyPress.key_Space == 1) { if (select == 1) { next_window_state.newState = Game_Window_State.Limbo_State; } else if (select == 2) { next_window_state.newState = Game_Window_State.Credits_State; } else if (select == 3) { next_window_state.newState = Game_Window_State.Exit_State; } menu_State = Menu_State.menu_Fade_Out; } break; case Menu_State.menu_Fade_Out: FadeDelay -= gameTime.ElapsedGameTime.TotalSeconds; if (FadeDelay <= 0) { FadeDelay = fade_Delay; AlphaValue -= fadeIncrement; if (AlphaValue <= 0) { AlphaValue = MathHelper.Clamp(AlphaValue, 0, 1); menu_State = Menu_State.menu_Change_State; } } break; case Menu_State.menu_Change_State: AlphaValue = 0f; Dismiss(); window_Return_Info.windowTransition = true; window_Return_Info.newState = next_window_state.newState; break; } return window_Return_Info; }
public Window_Return_Info Update(GameTime gameTime, KeyPress keyPress) { Window_Return_Info window_Return_Info; window_Return_Info.windowTransition = false; window_Return_Info.newState = Game_Window_State.Game_Mode_State; if (reload == true) { Reload(); } if (change_level_bool == true) { playing_State = Playing_State.fade_out_state; change_level_bool = false; } // Change Game_States between Game and Pause States if (keyPress.key_Esc == 1) { if (is_paused == true && playing_State == Playing_State.pause_state) { playing_State = Playing_State.game_state; is_paused = false; } else if (is_paused == false && playing_State == Playing_State.game_state) { playing_State = Playing_State.pause_state; is_paused = true; } } // Display Dev_Info if (keyPress.key_T == 1) { if (dev_display == true) { dev_display = false; } else if (dev_display == false) { dev_display = true; } } CameraStroll(); switch (playing_State) { case Playing_State.fade_in_state: FadeDelay -= gameTime.ElapsedGameTime.TotalSeconds; if (FadeDelay <= 0) { FadeDelay = fade_Delay; fade_AlphaValue += fadeIncrement; if (fade_AlphaValue >= 1) { fade_AlphaValue = MathHelper.Clamp(fade_AlphaValue, 0, 1); playing_State = Playing_State.game_state; } } break; case Playing_State.game_state: player.Update(gameTime, keyPress, halt_movement); for (int i = 0; i < gameObjectsStore.elementStore.Count(); i++) { gameObjectsStore.elementStore[i].Update( this, gameTime, keyPress, player.BoundingRectangle, player.Position); } Exits_Map_Based(); break; case Playing_State.fade_out_state: player.animation_To_Idle(); FadeDelay -= gameTime.ElapsedGameTime.TotalSeconds; if (FadeDelay <= 0) { FadeDelay = fade_Delay; fade_AlphaValue -= fadeIncrement; if (fade_AlphaValue <= 0) { if (next_Window_State_Bool == true) { window_Return_Info.windowTransition = true; window_Return_Info.newState = Game_Window_State.Splash_Screen_State; Dismiss(); fade_AlphaValue = 0; } else { fade_AlphaValue = MathHelper.Clamp(fade_AlphaValue, 0, 1); playing_State = Playing_State.loading_state; } } } break; case Playing_State.loading_state: Refresh(); playing_State = Playing_State.fade_in_state; break; case Playing_State.pause_state: Pause_Update(keyPress); break; } return window_Return_Info; }
/// <summary> /// A callback function which will be called every time a keyboard activity detected. /// https://docs.microsoft.com/en-us/windows/win32/winmsg/lowlevelkeyboardproc /// </summary> /// <param name="code"> /// Specifies whether the hook procedure must process the message. /// If code is HC_ACTION, the hook procedure must process the message. /// If code is less than zero, the hook procedure must pass the message to the /// CallNextHookEx function without further processing and must return the /// value returned by CallNextHookEx. /// </param> /// <param name="wParam"> /// Specifies whether the message was sent by the current thread. /// If the message was sent by the current thread, it is nonzero; otherwise, it is zero. /// </param> /// <param name="lParam"> /// Pointer to a CWPSTRUCT structure that contains details about the message. /// </param> /// <returns> /// If code is less than zero, the hook procedure must return the value returned by CallNextHookEx. /// If code is greater than or equal to zero, it is highly recommended that you call CallNextHookEx /// and return the value it returns; otherwise, other applications that have installed WH_CALLWNDPROC /// hooks will not receive hook notifications and may behave incorrectly as a result. If the hook /// procedure does not call CallNextHookEx, the return value should be zero. /// </returns> private IntPtr KeyboardHookProc(int code, uint wParam, IntPtr lParam) { //Indicates if any of the underlaying events set the e.Handled flag. var handled = false; //If it was Ok and there are no listeners. if (code < 0 || KeyDown == null && KeyUp == null && KeyPress == null) { return(CallNextHookEx(_keyboardHookHandle, code, wParam, lParam)); } //Read structure KeyboardHookStruct at lParam var keyboard = (KeyboardHookStruct)Marshal.PtrToStructure(lParam, typeof(KeyboardHookStruct)); var isInjected = (keyboard.Flags & 0x10) != 0; if (KeyDown != null && (wParam == MessageKeydown || wParam == MessageSystemKeyDown)) { #region Raise KeyDown var isDownShift = (GetKeyState(KeyShift) & 0x80) == 0x80; var isDownCapslock = GetKeyState(KeyCapital) != 0; var e = new CustomKeyEventArgs(KeyInterop.KeyFromVirtualKey(keyboard.KeyCode), isDownCapslock ^ isDownShift, isInjected); KeyDown?.Invoke(this, e); handled = e.Handled; #endregion } if (KeyPress != null && wParam == MessageKeydown) { #region Raise KeyPress var isDownShift = (GetKeyState(KeyShift) & 0x80) == 0x80; var isDownCapslock = GetKeyState(KeyCapital) != 0; var keyState = new byte[256]; GetKeyboardState(keyState); var inBuffer = new byte[2]; if (ToAscii(keyboard.KeyCode, keyboard.ScanCode, keyState, inBuffer, keyboard.Flags) == 1) { var key = (char)inBuffer[0]; if (isDownCapslock ^ isDownShift && char.IsLetter(key)) { key = char.ToUpper(key); } var e = new CustomKeyPressEventArgs(key); KeyPress?.Invoke(this, e); handled = handled || e.Handled; } #endregion } if (KeyUp != null && (wParam == MessageKeyUp || wParam == MessageSystemKeyUp)) { #region Raise KeyUp var e = new CustomKeyEventArgs(KeyInterop.KeyFromVirtualKey(keyboard.KeyCode), false, isInjected); KeyUp?.Invoke(this, e); handled = handled || e.Handled; #endregion } //If event handled in application do not handoff to other listeners. return(handled ? new IntPtr(1) : CallNextHookEx(_keyboardHookHandle, code, wParam, lParam)); }
private void EditOnKeyPress(object sender, KeyPressEventArgs e) { KeyPress?.Invoke(sender, e); }
//--------------------------------------------------------------------------------------------------------------------------------------- //--------------------------------------------------------Update------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------------------------------------------- public void Update(Game_Mode game_Mode, GameTime gameTime, KeyPress keyPress, Rectangle player_BoundingBox, Vector2 player_Position) { Update_Interaction_Symbol(); this.player_Position = player_Position; // ---------------------------------------------------------99------------------------------------------------------- if (element_reference == 99) { interact_display = false; if (boundingBox_Outer.Intersects(player_BoundingBox) == true) { interact_display = false; Vector2 Depth = Base_Components.RectangleExtensions.GetIntersectionDepth(boundingBox_Outer, player_BoundingBox); if (Depth.X >= 0) { sprite_Opacity = 1 - (Depth.X / 100); if (Depth.X >= 75) { secondary_Opacity = 1 - ((Depth.X - 75) / 25); } else { secondary_Opacity = 1; } } else if (Depth.X < 0) { sprite_Opacity = 1 + (Depth.X / 100); if (Depth.X < -75) { secondary_Opacity = 1 + ((Depth.X + 75) / 25); } else { secondary_Opacity = 1; } } } else { sprite_Opacity = 1; secondary_Opacity = 1; } } // ---------------------------------------------------------100------------------------------------------------------- if (element_reference == 100) { if (boundingBox_Inner.Intersects(player_BoundingBox) == true) { if (interact_Stage == 0) { interact_display = true; if (keyPress.key_X == 1) { sprite.PlayAnimation(animation_1); interact_Stage += 1; } } else if (interact_Stage == 1) { interact_display = false; if (sprite.FrameIndex == 7) { sprite.PlayAnimation(animation_2); interact_Stage += 1; } } else if (interact_Stage == 2) { interact_display = true; if (keyPress.key_X == 1) { interact_Stage += 1; } } // Change Level else if (interact_Stage == 3) { interact_display = false; game_Mode.next_Level = 17; game_Mode.change_level_bool = true; } } else { interact_display = false; } } // ---------------------------------------------------------101------------------------------------------------------- if (element_reference == 101) { if (boundingBox_Inner.Intersects(player_BoundingBox) == true) { if (interact_Stage == 0) { interact_display = true; if (keyPress.key_X == 1) { sprite.PlayAnimation(animation_1); interact_Stage += 1; } } else if (interact_Stage == 1) { interact_display = false; if (sprite.FrameIndex == 7) { interact_Stage += 1; } } else if (interact_Stage == 2) { interact_display = true; if (keyPress.key_X == 1) { sprite.PlayAnimation(animation_2); interact_Stage += 1; } } else if (interact_Stage == 3) { interact_display = false; if (sprite.FrameIndex == 7) { interact_Stage += 1; } } else if (interact_Stage == 4) { interact_display = true; if (keyPress.key_X == 1) { interact_Stage += 1; } } // Change Level else if (interact_Stage == 5) { interact_display = false; game_Mode.next_Level = 15; game_Mode.change_level_bool = true; } } else { interact_display = false; } } // ---------------------------------------------------------102------------------------------------------------------- if (element_reference == 102) { if (boundingBox_Inner.Intersects(player_BoundingBox) == true) { if (interact_Stage == 0) { interact_display = true; if (keyPress.key_X == 1) { sprite.PlayAnimation(animation_1); game_Mode.Change_Outfit("a10"); interact_Stage += 1; } } else if (interact_Stage == 1) { interact_display = false; } } else { interact_display = false; } } // ---------------------------------------------------------103------------------------------------------------------- if (element_reference == 103) { if (boundingBox_Inner.Intersects(player_BoundingBox) == true) { if (interact_Stage == 0) { interact_display = true; if (keyPress.key_X == 1) { sprite.PlayAnimation(animation_1); if (game_Mode.Outfit_Check() == "a10") { game_Mode.Change_Outfit("a11"); } else { game_Mode.Change_Outfit("a01"); } interact_Stage += 1; } } else if (interact_Stage == 1) { interact_display = false; } } else { interact_display = false; } } // ---------------------------------------------------------104------------------------------------------------------- if (element_reference == 104) { if (boundingBox_Inner.Intersects(player_BoundingBox) == true) { if (interact_Stage == 0) { interact_display = true; if (keyPress.key_X == 1) { sprite.PlayAnimation(animation_1); interact_Stage += 1; } } else if (interact_Stage == 1) { interact_display = false; if (sprite.FrameIndex == 8) { interact_Stage += 1; } } else if (interact_Stage == 2) { interact_display = true; if (keyPress.key_X == 1) { interact_Stage += 1; } } // Change Level else if (interact_Stage == 3) { interact_display = false; game_Mode.next_Level = 11; game_Mode.change_level_bool = true; } } else { interact_display = false; } } // ---------------------------------------------------------105------------------------------------------------------- if (element_reference == 105) { if (boundingBox_Inner.Intersects(player_BoundingBox) == true) { if (interact_Stage == 0) { interact_display = true; if (keyPress.key_X == 1) { sprite.PlayAnimation(animation_1); if (game_Mode.Outfit_Check() == "a01") { game_Mode.Change_Outfit("g01"); } else if (game_Mode.Outfit_Check() == "a10") { game_Mode.Change_Outfit("g10"); } else if (game_Mode.Outfit_Check() == "a11") { game_Mode.Change_Outfit("g11"); } else { game_Mode.Change_Outfit("g00"); } interact_Stage += 1; } } else if (interact_Stage == 1) { interact_display = false; } } else { interact_display = false; } } // ---------------------------------------------------------106------------------------------------------------------- if (element_reference == 106) { //Self_Animating if (sprite.Animation == animation_0 && sprite.FrameIndex == 5) { sprite.PlayAnimation(animation_1); } if (sprite.Animation == animation_1 && sprite.FrameIndex == 5) { sprite.PlayAnimation(animation_2); } if (sprite.Animation == animation_2 && sprite.FrameIndex == 5) { sprite.PlayAnimation(animation_0); } } // ---------------------------------------------------------107------------------------------------------------------- if (element_reference == 107) { //Self_Animating on_top_animation = true; } // ---------------------------------------------------------108------------------------------------------------------- if (element_reference == 108) { } // ---------------------------------------------------------109------------------------------------------------------- if (element_reference == 109) { if (interact_Stage == 0 && boundingBox_Outer.Intersects(player_BoundingBox) == true) { sprite.PlayAnimation(animation_1); } if (interact_Stage == 0 && boundingBox_Inner.Intersects(player_BoundingBox) == true) { interact_Stage = 1; } if (interact_Stage == 1 && sprite.Animation == animation_1 && sprite.FrameIndex == 4) { game_Mode.halt_Movement(true); sprite.PlayAnimation(animation_2); interact_Stage = 3; } if (interact_Stage == 3) { game_Mode.halt_Movement(true); if (game_Mode.Outfit_Check() == "g00" || game_Mode.Outfit_Check() == "g01" || game_Mode.Outfit_Check() == "g10" || game_Mode.Outfit_Check() == "g11") { write_text("You have a gun"); if (keyPress.key_X == 1) { close_text(game_Mode); interact_Stage = 6; game_Mode.halt_Movement(false); } } else { write_text("You have no gun"); game_Mode.halt_Movement(true); if (keyPress.key_X == 1) { close_text(game_Mode); interact_Stage = 5; game_Mode.halt_Movement(false); } } } if (interact_Stage == 5) { game_Mode.next_Level = 22; game_Mode.change_level_bool = true; } } // ---------------------------------------------------------110------------------------------------------------------- if (element_reference == 110) { //Self_Animating } }
public void PerformKeyPress(KeyPressEventArgs e) { KeyPress?.Invoke(e); FocusedControl?.PerformKeyPress(e); }
/// <summary> /// Evaluates the action against a given InputState. /// </summary> /// <param name="state">The InputState to test for the action.</param> /// <param name="controllingPlayer">The player to test, or null to allow any player.</param> /// <param name="player">If controllingPlayer is null, this is the player that performed the action.</param> /// <returns>True if the action occurred, false otherwise.</returns> public bool Evaluate(InputState state, PlayerIndex? controllingPlayer, out PlayerIndex player) { // Figure out which delegate methods to map from the state which takes care of our "newPressOnly" logic if (newPressOnly) { buttonTest = state.IsNewButtonPress; keyTest = state.IsNewKeyPress; } else { buttonTest = state.IsButtonPressed; keyTest = state.IsKeyPressed; } // Now we simply need to invoke the appropriate methods for each button and key in our collections for (int i = 0; i < buttons.Length; i++) { if (buttonTest(buttons[i], controllingPlayer, out player)) { playMenuSound(); return true; } } for (int i = 0; i < keys.Length; i++) { if (keyTest(keys[i], controllingPlayer, out player)) { playMenuSound(); return true; } } // If we got here, the action is not matched player = PlayerIndex.One; return false; }
public void dispatch_event() { Event evt = display.next_event(); switch (evt.code()) { case ButtonPress.CODE: { int button = ((ButtonPress)evt).detail(); if (button == gnu.x11.Input.BUTTON1) { restart(); } else if (button == gnu.x11.Input.BUTTON3) { exit(); } break; } case ConfigureNotify.CODE: window.set_geometry_cache(((ConfigureNotify)evt).rectangle()); break; case Expose.CODE: if (thread.IsAlive) { restart(); } else { if (clear) { window.clear(false); // before thread starts } thread.Start(); } break; case KeyPress.CODE: { KeyPress e = (KeyPress)evt; int keycode = e.detail(); int keystate = e.state(); int keysym = display.input.keycode_to_keysym(keycode, keystate); if (keysym == ' ') { restart(); } else if (keysym == 'q' || keysym == 'Q' || keysym == gnu.x11.keysym.Misc.ESCAPE) { exit(); } break; } case ClientMessage.CODE: if (((ClientMessage)evt).delete_window()) { exit(); } break; } }
private void Pause_Update(KeyPress keyPress) { Menu_Selecting(keyPress); if (keyPress.key_Space == 1) { if (select == 1) { playing_State = Playing_State.game_state; is_paused = false; player.isOnGround = false; } else if (select == 2) { playing_State = Playing_State.fade_out_state; next_Window_State_Bool = true; } } }