/// <summary> /// Stops the debouncer and raises the <see cref="Debounce"/> event if <see cref="Running"/> is enabled. /// </summary> public void Flush() { if (Running) { timer.Stop(); Debounce?.Invoke(this, value); } }
public void GetScanCode(uint ScanCode) { //Settings if (_inputValue == 0 && ScanCode == 28) { settingsCounter++; } else { settingsCounter = 0; } //Debouncing if (!(ScanCode == 74 && _inputValue == 0)) { if (!Debounce.IsDebounceOk(this, ScanCode)) { return; } } /* * ScanCode of KeyPad * ScanCode: 69 NumberKeyLock * ScanCode: 82 0 * ScanCode: 79 1 * ScanCode: 80 2 * ScanCode: 81 3 * ScanCode: 75 4 * ScanCode: 76 5 * ScanCode: 77 6 * ScanCode: 71 7 * ScanCode: 72 8 * ScanCode: 73 9 * ScanCode: 53 / --> ROT * ScanCode: 55 * --> GRÜN * ScanCode: 74 - --> BLAU * ScanCode: 78 + --> GELB * ScanCode: 28 Enter * ScanCode: 83 , * ScanCode: 14 BackSpace --> ROT * */ switch (ScanCode) { case 69: // NumLock case 83: // , break; case 28: // Enter ShowSettingsPage(); break; case 55: // * --> GRÜN AddToGreen(); break; case 74: // - --> BLAU DeleteLastTurn(); break; case 53: // / --> ROT case 14: // BackSpace AddToRed(); break; case 78: // + --> GELB Reset(); break; #region Numbers 1 to 0 case 79: //MyWertung.InputText = "1"; AddInput(1); break; case 80: //MyWertung.InputText = "2"; AddInput(2); break; case 81: //MyWertung.InputText = "3"; AddInput(3); break; case 75: //MyWertung.InputText = "4"; AddInput(4); break; case 76: //MyWertung.InputText = "5"; AddInput(5); break; case 77: //MyWertung.InputText = "6"; AddInput(6); break; case 71: //MyWertung.InputText = "7"; AddInput(7); break; case 72: //MyWertung.InputText = "8"; AddInput(8); break; case 73: //MyWertung.InputText = "9"; AddInput(9); break; case 82: //MyWertung.InputText = "0"; AddInput(0); break; #endregion } RaiseAllPropertysChanged(); // Send after each key press a network notification if (Settings.Instance.IsBroadcasting) { NetworkService.SendData(Match.Serialize(true)); } }
/// <summary> /// Invokes the <see cref="Debounce"/> event. /// </summary> /// <param name="source">Reference to the object tha raised the event.</param> /// <param name="eventArgs">Timer event arguments.</param> private void OnElapsed(object source, ElapsedEventArgs eventArgs) { Debounce?.Invoke(this, value); }
// Pause and resume the game in here private void Update() { // commented out for the showcase if (gamePaused) { pausePanel.anchoredPosition = Vector2.Lerp(pausePanel.anchoredPosition, target_transform, 0.1f); foreach (InputDevice pauseDevice in InputManager.Devices) { if (pauseDevice.DPad.WasPressed || Debounce.On("pmnav", pauseDevice.LeftStickY != 0, 150)) { audio.Play(); if (pauseDevice.DPadY < 0 || pauseDevice.LeftStickY < 0) { selection++; } else { selection--; } // bound the button count selection = selection % buttons.Length; if (selection < 0) { selection = buttons.Length - 1; } // update the button visual flair DrawButtons(selection); } // Advance by pressing A if (pauseDevice.Action1.WasPressed) { // check the selection index, and act accordingly // 0: resume, 1: restart the current scene, 2: load the main menu, 3: quit switch (selection) { case 0: ResumeGame(); break; case 1: Time.timeScale = 1f; gamePaused = false; GameController.ResetLevel(); break; case 2: Time.timeScale = 1f; gamePaused = false; GameController.RequestRestartGame(); break; /*case 3: // remove exit option ****showcase * Application.Quit(); * break;*/ } } // alternatively, exit the paused state by hitting start again if (pauseDevice.CommandWasPressed || pauseDevice.Action2.WasPressed) { ResumeGame(); } } } else { pausePanel.anchoredPosition = Vector3.Lerp(pausePanel.anchoredPosition, original_transform, 0.1f); foreach (InputDevice pauseDevice in InputManager.Devices) { if (pauseDevice.CommandWasPressed) { PauseGame(); } } } }