void _UpdateThumbSticks(DirectInputThumbSticks thumbSticks) { thumbSticks.Refresh(); #if DEBUG if (thumbSticks.HasLeft) { _UpdateThumbStick(thumbSticks.Left, ThumbStickGauge_Left, thumbSticks.RawPositions[0]); } if (thumbSticks.HasRight) { _UpdateThumbStick(thumbSticks.Right, ThumbStickGauge_Right, thumbSticks.RawPositions[1]); } if (thumbSticks.HasThird) { _UpdateThumbStick(thumbSticks.Third, ThumbStickGauge_Third, thumbSticks.RawPositions[2]); } #else if (thumbSticks.HasLeft) { _UpdateThumbStick(thumbSticks.Left, ThumbStickGauge_Left); } if (thumbSticks.HasRight) { _UpdateThumbStick(thumbSticks.Right, ThumbStickGauge_Right); } if (thumbSticks.HasThird) { _UpdateThumbStick(thumbSticks.Third, ThumbStickGauge_Third); } #endif }
void _SetThumbStickGaugeControls(DirectInputThumbSticks thumbSticks) { ThumbStickGauge_Left.Visibility = Common.BoolToVisibility(thumbSticks.HasLeft); ThumbStickGauge_Right.Visibility = Common.BoolToVisibility(thumbSticks.HasRight); ThumbStickGauge_Third.Visibility = Common.BoolToVisibility(thumbSticks.HasThird); }
public virtual MenuWindow ProcessInput(KeyboardState lastKeybState, KeyboardState currentKeybState, ButtonState[] lastButtonState, ButtonState[] currentButtonState, DirectInputThumbSticks lastTSticks, DirectInputThumbSticks currentTSticks, GameTime gameTime) { oldSelectedItem = selectedItem; // check keyboard states to see if a key has been held down long enough for autoscroll if ((currentTSticks.Left.Y > 0.5f && lastTSticks.Left.Y > 0.5f) || currentKeybState.IsKeyDown(Keys.Down) && lastKeybState.IsKeyDown(Keys.Down)) { if (game.inputControl.isSetting) { return(this); } bool holder = true; if (holdKeyProgressRamped >= 1.0f && holdKeySpacingProgressRamped >= 1.0f) { selectedItem++; holdKeySpacingProgressRamped = 0.0f; holder = false; } else if (holdKeyProgress >= 1.0f && holdKeySpacingProgress >= 1.0f && holder) { selectedItem++; holdKeySpacingProgress = 0.0f; } } // check for someone holding the up direction if ((currentTSticks.Left.Y < -0.5f && lastTSticks.Left.Y < -0.5f) || currentKeybState.IsKeyDown(Keys.Up) && lastKeybState.IsKeyDown(Keys.Up)) { if (game.inputControl.isSetting) { return(this); } if (holdKeyProgressRamped >= 1.0f && holdKeySpacingProgressRamped >= 1.0f) { selectedItem--; holdKeySpacingProgressRamped = 0.0f; } else if (holdKeyProgress >= 1.0f && holdKeySpacingProgress >= 1.0f) { selectedItem--; holdKeySpacingProgress = 0.0f; } } // check for someone pressing (not holding) down if ((currentTSticks.Left.Y > 0.5f && lastTSticks.Left.Y < 0.5f) || lastKeybState.IsKeyUp(Keys.Down) && currentKeybState.IsKeyDown(Keys.Down)) { if (game.inputControl.isSetting) { return(this); } selectedItem++; holdKeyProgress = 0.0f; holdKeyProgressRamped = 0.0f; if (game.logoState == Game1.LogoState.Active) { game.logoState = Game1.LogoState.Ending; } game.waitProgress = 0; } // check for someone pressing (not holding) up if ((currentTSticks.Left.Y < -0.5f && lastTSticks.Left.Y > -0.5f) || lastKeybState.IsKeyUp(Keys.Up) && currentKeybState.IsKeyDown(Keys.Up)) { if (game.inputControl.isSetting) { return(this); } selectedItem--; holdKeyProgress = 0.0f; holdKeyProgressRamped = 0.0f; if (game.logoState == Game1.LogoState.Active) { game.logoState = Game1.LogoState.Ending; } game.waitProgress = 0; } // handle fast scrolling (10 at a time) if ((lastKeybState.IsKeyUp(Keys.PageUp) && currentKeybState.IsKeyDown(Keys.PageUp)) || currentButtonState[6] == ButtonState.Pressed && lastButtonState[6] == ButtonState.Released) { if (itemList.Count > 10 && selectedItem > 9) { if (game.isSoundOn) { game.scrollSoundEffect.Play(); } scrollState = ScrollState.ScrollDown; } if (selectedItem > 10) { selectedItem -= 10; } else { selectedItem = 0; } } if ((lastKeybState.IsKeyUp(Keys.PageDown) && currentKeybState.IsKeyDown(Keys.PageDown)) || currentButtonState[7] == ButtonState.Pressed && lastButtonState[7] == ButtonState.Released) { if (itemList.Count > 10 && selectedItem < itemList.Count - (itemList.Count % 10)) { if (game.isSoundOn) { game.scrollSoundEffect.Play(); } scrollState = ScrollState.ScrollUp; } if (selectedItem < itemList.Count - 11) { selectedItem += 10; } else { selectedItem = itemList.Count - 1; } } if (selectedItem < 0) { selectedItem = 0; } if (selectedItem >= itemList.Count) { selectedItem = itemList.Count - 1; } sysItem = selectedItem; if (((lastButtonState[0] == ButtonState.Released && currentButtonState[0] == ButtonState.Pressed) || ((lastKeybState.IsKeyUp(Keys.Enter) && currentKeybState.IsKeyDown(Keys.Enter))) || (lastKeybState.IsKeyUp(Keys.Right) && currentKeybState.IsKeyDown(Keys.Right) || (currentTSticks.Left.X > 0.5f && lastTSticks.Left.X < 0.5f)))) { if ((game.activeMenu == game.menuList[4] || game.activeMenu == game.menuList[6]) && game.activeMenu.selectedItem > 0 && game.activeMenu.selectedItem != game.activeMenu.itemList.Count - 1) { return(this); } else if ((game.activeMenu == game.menuList[5]) && game.activeMenu.selectedItem != game.activeMenu.itemList.Count - 1) { return(this); } else if (game.activeMenu == game.menuList[8] || game.activeMenu == game.menuList[9]) { return(this); } else { windowState = WindowState.Ending; return(itemList[selectedItem].itemLink); } } else if (lastKeybState.IsKeyUp(Keys.Escape) && currentKeybState.IsKeyDown(Keys.Escape) || lastButtonState[8] == ButtonState.Released && currentButtonState[8] == ButtonState.Pressed) { return(null); } else { return(this); } }
private void CheckInput() { KeyboardState currentKeyState = Keyboard.GetState(); ButtonState[] buttonState = new ButtonState[13]; DirectInputThumbSticks thumbState = new DirectInputThumbSticks(); if (DirectInputGamepad.Gamepads.Count > 0) { buttonState = game.gamePad[0].Buttons.List.ToArray(); thumbState = game.gamePad[0].ThumbSticks; } if ((currentKeyState.IsKeyDown(Keys.Tab) && lastKeyState.IsKeyUp(Keys.Tab))) { isSetting = !isSetting; if (isSetting) { game.fireEffect.sourceEmitters.Add(new Rectangle(game.m_Width / 2 + 300, game.m_Height - (80), 12, 10)); game.fireEffect.isSmallFileOn = true; } else { game.particleEngine.StopEffects(); } lastKeyState = currentKeyState; lastButtonState = buttonState; return; } if (!isSetting) { if ((currentKeyState.IsKeyDown(Keys.C) && lastKeyState.IsKeyUp(Keys.C)) || (lastButtonState[4] == ButtonState.Released && buttonState[4] == ButtonState.Pressed)) { oldItem = selectedItem; selectedItem++; if (selectedItem > 2) { selectedItem = 0; } imageState = ImageState.Starting; oldImageState = ImageState.Ending; fadeProgress = 0; } } else { Keys[] k2 = currentKeyState.GetPressedKeys(); if (k2.Length < 2 && k2.Length > 0 && k2[0] != Keys.Escape && k2[0] != Keys.Tab && (currentKeyState.IsKeyDown(k2[0]) && lastKeyState.IsKeyUp(k2[0]))) { if (game.activeMenu == game.menuList[8]) { k[game.activeMenu.selectedItem] = k2[0]; f[game.activeMenu.selectedItem] = false; } else if (game.activeMenu == game.menuList[9]) { player2k[game.activeMenu.selectedItem] = k2[0]; player2f[game.activeMenu.selectedItem] = false; } if (game.activeMenu.selectedItem == 13) { game.particleEngine.StopEffects(); isSetting = !isSetting; } else { game.activeMenu.selectedItem++; } } List <ButtonState> bState = new List <ButtonState>(); int j = 0; for (int i = 0; i < buttonState.Length; i++) { if (buttonState[i] == ButtonState.Pressed) { bState.Add(buttonState[i]); j = i; } } if (bState.Count < 2 && bState.Count > 0 && (buttonState[j] == ButtonState.Pressed && lastButtonState[j] == ButtonState.Released)) { if (game.activeMenu == game.menuList[8]) { b[game.activeMenu.selectedItem] = j; f[game.activeMenu.selectedItem] = true; } else if (game.activeMenu == game.menuList[9]) { player2b[game.activeMenu.selectedItem] = j; player2f[game.activeMenu.selectedItem] = true; } if (game.activeMenu.selectedItem == 13) { game.particleEngine.StopEffects(); isSetting = !isSetting; } else { game.activeMenu.selectedItem++; } } if (thumbState.HasLeft && (thumbState.Left.X != thumbState.Left.Y)) { if (game.activeMenu == game.menuList[8]) { if (thumbState.Left.X < -0.5f && lastSticks.Left.X > -0.5f) // { b[game.activeMenu.selectedItem] = -15; f[game.activeMenu.selectedItem] = true; hasMoved = false; } if (thumbState.Left.X > 0.5f && lastSticks.Left.X < 0.5f) { b[game.activeMenu.selectedItem] = -16; f[game.activeMenu.selectedItem] = true; hasMoved = false; } if (thumbState.Left.Y < -0.5f && lastSticks.Left.Y > -0.5f) { b[game.activeMenu.selectedItem] = -13; f[game.activeMenu.selectedItem] = true; hasMoved = false; } if (thumbState.Left.Y > 0.5f && lastSticks.Left.Y < 0.5f) { b[game.activeMenu.selectedItem] = -14; f[game.activeMenu.selectedItem] = true; hasMoved = false; } } else if (game.activeMenu == game.menuList[9]) { if (thumbState.Left.X > -0.5f && lastSticks.Left.X < -0.5f) { player2b[game.activeMenu.selectedItem] = 99; player2f[game.activeMenu.selectedItem] = true; hasMoved = false; } if (thumbState.Left.X > 0.5f && lastSticks.Left.X < 0.5f) { player2b[game.activeMenu.selectedItem] = 98; player2f[game.activeMenu.selectedItem] = true; hasMoved = false; } if (thumbState.Left.Y > -0.5f && lastSticks.Left.Y < -0.5f) { player2b[game.activeMenu.selectedItem] = 97; player2f[game.activeMenu.selectedItem] = true; hasMoved = false; } if (thumbState.Left.Y > 0.5f && lastSticks.Left.Y < 0.5f) { player2b[game.activeMenu.selectedItem] = 96; player2f[game.activeMenu.selectedItem] = true; hasMoved = false; } } if (game.activeMenu.selectedItem == 13) { game.particleEngine.StopEffects(); isSetting = !isSetting; } else { if (!hasMoved) { game.activeMenu.selectedItem++; hasMoved = true; } } } } lastKeyState = currentKeyState; lastButtonState = buttonState; lastSticks = thumbState; }
public override MenuWindow ProcessInput(KeyboardState lastKeybState, KeyboardState currentKeybState, ButtonState[] lastButtonState, ButtonState[] currentButtonState, DirectInputThumbSticks lastTSticks, DirectInputThumbSticks currentTSticks, GameTime gameTime) { if (isArrowable) { if (selectedItem >= arrowShowInt) { isDownable = false; } else { isDownable = true; } if (selectedItem < 10) { isUpable = false; } else { isUpable = true; } } if (isRomMenu || isSysMenu) { // avoid this one on the system menu if (!isSysMenu) { if ((lastKeybState.IsKeyUp(Keys.Left) && currentKeybState.IsKeyDown(Keys.Left)) || (currentTSticks.Left.X < -0.5f && lastTSticks.Left.X > -0.5f) || (lastButtonState[1] == ButtonState.Released && currentButtonState[1] == ButtonState.Pressed)) { imageState = ImageState.Ending; return(this); } } if ((lastKeybState.IsKeyUp(Keys.Right) && currentKeybState.IsKeyDown(Keys.Right)) || (currentTSticks.Left.X > 0.5f && lastTSticks.Left.X < 0.5f)) { windowState = WindowState.Ending; imageState = ImageState.Ending; return(itemList[selectedItem].itemLink); } if ((lastKeybState.IsKeyUp(Keys.Enter) && currentKeybState.IsKeyDown(Keys.Enter)) || (lastButtonState[0] == ButtonState.Released && currentButtonState[0] == ButtonState.Pressed) && game.activeMenu != game.menuList[4] && game.activeMenu != game.menuList[5] && game.activeMenu != game.menuList[6] && game.activeMenu != game.menuList[7] && game.activeMenu != game.menuList[8] && game.activeMenu != game.menuList[9]) { windowState = WindowState.Ending; imageState = ImageState.Ending; return(itemList[selectedItem].itemLink); } else if (lastKeybState.IsKeyDown(Keys.Escape) || lastButtonState[8] == ButtonState.Pressed) { imageState = ImageState.Ending; } } return(base.ProcessInput(lastKeybState, currentKeybState, lastButtonState, currentButtonState, lastTSticks, currentTSticks, gameTime)); }