/// <summary> /// Handles the button press event to track which focused menu item will get the activation /// </summary> /// <param name="backButton"></param> /// <param name="startButton"></param> /// <param name="systemButton"></param> /// <param name="aButton"></param> /// <param name="bButton"></param> /// <param name="xButton"></param> /// <param name="yButton"></param> /// <param name="leftShoulder"></param> /// <param name="rightShoulder"></param> /// <param name="player"></param> protected override void OnGamePadButtonUpdate(CCGamePadButtonStatus backButton, CCGamePadButtonStatus startButton, CCGamePadButtonStatus systemButton, CCGamePadButtonStatus aButton, CCGamePadButtonStatus bButton, CCGamePadButtonStatus xButton, CCGamePadButtonStatus yButton, CCGamePadButtonStatus leftShoulder, CCGamePadButtonStatus rightShoulder, Microsoft.Xna.Framework.PlayerIndex player) { base.OnGamePadButtonUpdate(backButton, startButton, systemButton, aButton, bButton, xButton, yButton, leftShoulder, rightShoulder, player); if (!HasFocus) { return; } if (backButton == CCGamePadButtonStatus.Pressed || aButton == CCGamePadButtonStatus.Pressed || bButton == CCGamePadButtonStatus.Pressed || xButton == CCGamePadButtonStatus.Pressed || yButton == CCGamePadButtonStatus.Pressed || leftShoulder == CCGamePadButtonStatus.Pressed || rightShoulder == CCGamePadButtonStatus.Pressed) { CCMenuItem item = FocusedItem; item.Selected(); m_pSelectedItem = item; m_eState = CCMenuState.TrackingTouch; } else if (backButton == CCGamePadButtonStatus.Released || aButton == CCGamePadButtonStatus.Released || bButton == CCGamePadButtonStatus.Released || xButton == CCGamePadButtonStatus.Released || yButton == CCGamePadButtonStatus.Released || leftShoulder == CCGamePadButtonStatus.Released || rightShoulder == CCGamePadButtonStatus.Released) { if (m_eState == CCMenuState.TrackingTouch) { // Now we are selecting the menu item CCMenuItem item = FocusedItem; if (item != null && m_pSelectedItem == item) { // Activate this item item.Unselected(); item.Activate(); m_eState = CCMenuState.Waiting; m_pSelectedItem = null; } } } }
private void MyOnGamePadButtonUpdate(CCGamePadButtonStatus backButton, CCGamePadButtonStatus startButton, CCGamePadButtonStatus systemButton, CCGamePadButtonStatus aButton, CCGamePadButtonStatus bButton, CCGamePadButtonStatus xButton, CCGamePadButtonStatus yButton, CCGamePadButtonStatus leftShoulder, CCGamePadButtonStatus rightShoulder, Microsoft.Xna.Framework.PlayerIndex player) { if (aButton == CCGamePadButtonStatus.Pressed) { _aButtonWasPressed = true; } else if (aButton == CCGamePadButtonStatus.Released && _aButtonWasPressed) { // Select the menu restartCallback(null); } if (yButton == CCGamePadButtonStatus.Pressed) { _yButtonWasPressed = true; } else if (yButton == CCGamePadButtonStatus.Released && _yButtonWasPressed) { CCNode node = GetChildByTag(kTagTileMap); node.RunAction(new CCRotateBy (1f, 15f)); } if (xButton == CCGamePadButtonStatus.Pressed) { _xButtonWasPressed = true; } else if (xButton == CCGamePadButtonStatus.Released && _xButtonWasPressed) { CCNode node = GetChildByTag(kTagTileMap); if (node != null) { node.RunAction(new CCRotateBy (1f, -15f)); } } }
private void MyOnGamePadDPadUpdate(CCGamePadButtonStatus leftButton, CCGamePadButtonStatus upButton, CCGamePadButtonStatus rightButton, CCGamePadButtonStatus downButton, Microsoft.Xna.Framework.PlayerIndex player) { // Down and Up only if (rightButton == CCGamePadButtonStatus.Pressed) { if (_FirstTicks == 0L) { _FirstTicks = DateTime.Now.Ticks; _bDownPress = true; } } else if (rightButton == CCGamePadButtonStatus.Released && _FirstTicks > 0L && _bDownPress) { _FirstTicks = 0L; nextCallback(null); _bDownPress = false; } if (leftButton == CCGamePadButtonStatus.Pressed) { if (_FirstTicks == 0L) { _FirstTicks = DateTime.Now.Ticks; _bUpPress = true; } } else if (leftButton == CCGamePadButtonStatus.Released && _FirstTicks > 0L && _bUpPress) { _FirstTicks = 0L; backCallback(null); _bUpPress = false; } }
private void MyOnGamePadDPadUpdate(CCGamePadButtonStatus leftButton, CCGamePadButtonStatus upButton, CCGamePadButtonStatus rightButton, CCGamePadButtonStatus downButton, Microsoft.Xna.Framework.PlayerIndex player) { // Down and Up only if (leftButton == CCGamePadButtonStatus.Pressed) { if (_FirstTicks == 0L) { _FirstTicks = DateTime.Now.Ticks; _bLeftPress = true; } } else if (leftButton == CCGamePadButtonStatus.Released && _FirstTicks > 0L && _bLeftPress) { _FirstTicks = 0L; PreviousTestCase(); _bLeftPress = false; } if (rightButton == CCGamePadButtonStatus.Pressed) { if (_FirstTicks == 0L) { _FirstTicks = DateTime.Now.Ticks; _bRightPress = true; } } else if (rightButton == CCGamePadButtonStatus.Released && _FirstTicks > 0L && _bRightPress) { _FirstTicks = 0L; NextTestCase(); _bRightPress = false; } }
private void application_GamePadButtonUpdate(CCGamePadButtonStatus backButton, CCGamePadButtonStatus startButton, CCGamePadButtonStatus systemButton, CCGamePadButtonStatus aButton, CCGamePadButtonStatus bButton, CCGamePadButtonStatus xButton, CCGamePadButtonStatus yButton, CCGamePadButtonStatus leftShoulder, CCGamePadButtonStatus rightShoulder, PlayerIndex player) { if (backButton == CCGamePadButtonStatus.Pressed) { ProcessBackClick(); } }
private void MyOnGamePadButtonUpdate(CCGamePadButtonStatus backButton, CCGamePadButtonStatus startButton, CCGamePadButtonStatus systemButton, CCGamePadButtonStatus aButton, CCGamePadButtonStatus bButton, CCGamePadButtonStatus xButton, CCGamePadButtonStatus yButton, CCGamePadButtonStatus leftShoulder, CCGamePadButtonStatus rightShoulder, Microsoft.Xna.Framework.PlayerIndex player) { if (aButton == CCGamePadButtonStatus.Pressed) { _aButtonWasPressed = true; } else if (aButton == CCGamePadButtonStatus.Released && _aButtonWasPressed) { // Select the menu restartCallback(null); } if (yButton == CCGamePadButtonStatus.Pressed) { _yButtonWasPressed = true; } else if (yButton == CCGamePadButtonStatus.Released && _yButtonWasPressed) { CCNode node = GetChildByTag(kTagTileMap); node.RunAction(new CCRotateBy(1f, 15f)); } if (xButton == CCGamePadButtonStatus.Pressed) { _xButtonWasPressed = true; } else if (xButton == CCGamePadButtonStatus.Released && _xButtonWasPressed) { CCNode node = GetChildByTag(kTagTileMap); if (node != null) { node.RunAction(new CCRotateBy(1f, -15f)); } } }
protected override void OnGamePadDPadUpdate(CCGamePadButtonStatus leftButton, CCGamePadButtonStatus upButton, CCGamePadButtonStatus rightButton, CCGamePadButtonStatus downButton, Microsoft.Xna.Framework.PlayerIndex player) { if (!HasFocus) { return; } }
private void MyOnGamePadButtonUpdate(CCGamePadButtonStatus backButton, CCGamePadButtonStatus startButton, CCGamePadButtonStatus systemButton, CCGamePadButtonStatus aButton, CCGamePadButtonStatus bButton, CCGamePadButtonStatus xButton, CCGamePadButtonStatus yButton, CCGamePadButtonStatus leftShoulder, CCGamePadButtonStatus rightShoulder, Microsoft.Xna.Framework.PlayerIndex player) { if (aButton == CCGamePadButtonStatus.Pressed) { _aButtonWasPressed = true; } else if (aButton == CCGamePadButtonStatus.Released && _aButtonWasPressed) { // Select the menu _Items[_CurrentItemIndex].Activate(); _Items[_CurrentItemIndex].Unselected(); } }
void SharedApplication_GamePadDPadUpdate(CCGamePadButtonStatus leftButton, CCGamePadButtonStatus upButton, CCGamePadButtonStatus rightButton, CCGamePadButtonStatus downButton, Microsoft.Xna.Framework.PlayerIndex player) { if (!Enabled) { return; } if (leftButton == CCGamePadButtonStatus.Released || upButton == CCGamePadButtonStatus.Released || rightButton == CCGamePadButtonStatus.Released || downButton == CCGamePadButtonStatus.Released) { scrollingPrevious = false; timeOfLastFocus = 0L; } // Left and right d-pad shuffle through the menus else if (leftButton == CCGamePadButtonStatus.Pressed || upButton == CCGamePadButtonStatus.Pressed) { if (scrollingPrevious) { TimeSpan ts = new TimeSpan(DateTime.UtcNow.Ticks - timeOfLastFocus); if (ts.TotalMilliseconds > MenuScrollDelay) { FocusPreviousItem(); } } else { scrollingPrevious = true; timeOfLastFocus = DateTime.UtcNow.Ticks; } } else if (rightButton == CCGamePadButtonStatus.Pressed || downButton == CCGamePadButtonStatus.Pressed) { if (scrollingNext) { TimeSpan ts = new TimeSpan(DateTime.UtcNow.Ticks - timeOfLastFocus); if (ts.TotalMilliseconds > MenuScrollDelay) { FocusNextItem(); } } else { scrollingNext = true; timeOfLastFocus = DateTime.UtcNow.Ticks; } } }
private void MyOnGamePadButtonUpdate(CCGamePadButtonStatus backButton, CCGamePadButtonStatus startButton, CCGamePadButtonStatus systemButton, CCGamePadButtonStatus aButton, CCGamePadButtonStatus bButton, CCGamePadButtonStatus xButton, CCGamePadButtonStatus yButton, CCGamePadButtonStatus leftShoulder, CCGamePadButtonStatus rightShoulder, Microsoft.Xna.Framework.PlayerIndex player) { if (bButton == CCGamePadButtonStatus.Pressed) { _bButtonWasPressed = true; } else if (bButton == CCGamePadButtonStatus.Released && _bButtonWasPressed) { // Select the menu MainMenuCallback(null); _bButtonWasPressed = false; } if (aButton == CCGamePadButtonStatus.Pressed) { _aButtonWasPressed = true; } else if (aButton == CCGamePadButtonStatus.Released && _aButtonWasPressed) { // Select the menu RestTestCase(); _aButtonWasPressed = false; } }
private void SharedApplication_GamePadDPadUpdate(CCGamePadButtonStatus leftButton, CCGamePadButtonStatus upButton, CCGamePadButtonStatus rightButton, CCGamePadButtonStatus downButton, Microsoft.Xna.Framework.PlayerIndex player) { if (!Enabled) { return; } if (leftButton == CCGamePadButtonStatus.Released || upButton == CCGamePadButtonStatus.Released || rightButton == CCGamePadButtonStatus.Released || downButton == CCGamePadButtonStatus.Released) { m_bScrollingPrevious = false; m_lTimeOfLastFocus = 0L; } // Left and right d-pad shuffle through the menus else if (leftButton == CCGamePadButtonStatus.Pressed || upButton == CCGamePadButtonStatus.Pressed) { if (m_bScrollingPrevious) { TimeSpan ts = new TimeSpan(DateTime.Now.Ticks - m_lTimeOfLastFocus); if (ts.TotalMilliseconds > MenuScrollDelay) { FocusPreviousItem(); } } else { m_bScrollingPrevious = true; m_lTimeOfLastFocus = DateTime.Now.Ticks; } } else if (rightButton == CCGamePadButtonStatus.Pressed || downButton == CCGamePadButtonStatus.Pressed) { if (m_bScrollingNext) { TimeSpan ts = new TimeSpan(DateTime.Now.Ticks - m_lTimeOfLastFocus); if (ts.TotalMilliseconds > MenuScrollDelay) { FocusNextItem(); } } else { m_bScrollingNext = true; m_lTimeOfLastFocus = DateTime.Now.Ticks; } } }
protected override void OnGamePadButtonUpdate(CCGamePadButtonStatus backButton, CCGamePadButtonStatus startButton, CCGamePadButtonStatus systemButton, CCGamePadButtonStatus aButton, CCGamePadButtonStatus bButton, CCGamePadButtonStatus xButton, CCGamePadButtonStatus yButton, CCGamePadButtonStatus leftShoulder, CCGamePadButtonStatus rightShoulder, Microsoft.Xna.Framework.PlayerIndex player) { }
protected void OnGamePadButtonUpdate(CCGamePadButtonStatus backButton, CCGamePadButtonStatus startButton, CCGamePadButtonStatus systemButton, CCGamePadButtonStatus aButton, CCGamePadButtonStatus bButton, CCGamePadButtonStatus xButton, CCGamePadButtonStatus yButton, CCGamePadButtonStatus leftShoulder, CCGamePadButtonStatus rightShoulder, PlayerIndex player) { if (player == PlayerIndex.One) { if (aButton == CCGamePadButtonStatus.Pressed) { _ADown = true; } else if (aButton == CCGamePadButtonStatus.Released && _ADown) { if (_SlingshotIsCocked && slingShotNinjaInHand) { // Inver the stick direction because this is the launch direction of the ninja b2Vec2 bv = b2Vec2.Zero; bv.x = -_StickDir.X; bv.y = -_StickDir.Y; FireSlignshot(bv); } _SlingshotIsCocked = false; _ADown = false; } } else if (bButton == CCGamePadButtonStatus.Pressed) { } else { // base.OnGamePadButtonUpdate(backButton, startButton, systemButton, aButton, bButton, xButton, yButton, leftShoulder, rightShoulder, player); } }
private void ProcessGamePad(GamePadState gps, PlayerIndex player) { GamePadState lastState = new GamePadState(); if (m_PriorGamePadState.ContainsKey(player)) { lastState = m_PriorGamePadState[player]; // Notify listeners when the gamepad is connected. if ((lastState.IsConnected != gps.IsConnected) && GamePadConnectionUpdate != null) { GamePadConnectionUpdate(player, false); } // TODO: Check button pressed/released status for button tap events. } if (gps.IsConnected) { GamePadCapabilities caps = GamePad.GetCapabilities(player); if (GamePadButtonUpdate != null) { CCGamePadButtonStatus back = CCGamePadButtonStatus.NotApplicable; CCGamePadButtonStatus start = CCGamePadButtonStatus.NotApplicable; CCGamePadButtonStatus system = CCGamePadButtonStatus.NotApplicable; CCGamePadButtonStatus a = CCGamePadButtonStatus.NotApplicable; CCGamePadButtonStatus b = CCGamePadButtonStatus.NotApplicable; CCGamePadButtonStatus x = CCGamePadButtonStatus.NotApplicable; CCGamePadButtonStatus y = CCGamePadButtonStatus.NotApplicable; CCGamePadButtonStatus leftShoulder = CCGamePadButtonStatus.NotApplicable; CCGamePadButtonStatus rightShoulder = CCGamePadButtonStatus.NotApplicable; if (caps.HasBackButton) { back = (gps.Buttons.Back == ButtonState.Pressed ? CCGamePadButtonStatus.Pressed : CCGamePadButtonStatus.Released); } if (caps.HasStartButton) { start = (gps.Buttons.Start == ButtonState.Pressed ? CCGamePadButtonStatus.Pressed : CCGamePadButtonStatus.Released); } if (caps.HasBigButton) { system = (gps.Buttons.BigButton == ButtonState.Pressed ? CCGamePadButtonStatus.Pressed : CCGamePadButtonStatus.Released); } if (caps.HasAButton) { a = (gps.Buttons.A == ButtonState.Pressed ? CCGamePadButtonStatus.Pressed : CCGamePadButtonStatus.Released); } if (caps.HasBButton) { b = (gps.Buttons.B == ButtonState.Pressed ? CCGamePadButtonStatus.Pressed : CCGamePadButtonStatus.Released); } if (caps.HasXButton) { x = (gps.Buttons.X == ButtonState.Pressed ? CCGamePadButtonStatus.Pressed : CCGamePadButtonStatus.Released); } if (caps.HasYButton) { y = (gps.Buttons.Y == ButtonState.Pressed ? CCGamePadButtonStatus.Pressed : CCGamePadButtonStatus.Released); } if (caps.HasLeftShoulderButton) { leftShoulder = (gps.Buttons.LeftShoulder == ButtonState.Pressed ? CCGamePadButtonStatus.Pressed : CCGamePadButtonStatus.Released); } if (caps.HasRightShoulderButton) { rightShoulder = (gps.Buttons.RightShoulder == ButtonState.Pressed ? CCGamePadButtonStatus.Pressed : CCGamePadButtonStatus.Released); } GamePadButtonUpdate(back, start, system, a, b, x, y, leftShoulder, rightShoulder, player); } // Process the game sticks if (GamePadStickUpdate != null && (caps.HasLeftXThumbStick || caps.HasLeftYThumbStick || caps.HasRightXThumbStick || caps.HasRightYThumbStick || caps.HasLeftStickButton || caps.HasRightStickButton)) { CCPoint vecLeft; if (caps.HasLeftXThumbStick || caps.HasLeftYThumbStick) { vecLeft = new CCPoint(gps.ThumbSticks.Left); vecLeft.Normalize(); } else { vecLeft = CCPoint.Zero; } CCPoint vecRight; if (caps.HasRightXThumbStick || caps.HasRightYThumbStick) { vecRight = new CCPoint(gps.ThumbSticks.Right); vecRight.Normalize(); } else { vecRight = CCPoint.Zero; } CCGameStickStatus left = new CCGameStickStatus(); left.Direction = vecLeft; left.Magnitude = ((caps.HasLeftXThumbStick || caps.HasLeftYThumbStick) ? gps.ThumbSticks.Left.Length() : 0f); left.IsDown = ((caps.HasLeftStickButton) ? gps.IsButtonDown(Buttons.LeftStick) : false); CCGameStickStatus right = new CCGameStickStatus(); right.Direction = vecRight; right.Magnitude = ((caps.HasRightXThumbStick || caps.HasRightYThumbStick) ? gps.ThumbSticks.Right.Length() : 0f); right.IsDown = ((caps.HasLeftStickButton) ? gps.IsButtonDown(Buttons.RightStick) : false); GamePadStickUpdate(left, right, player); } // Process the game triggers if (GamePadTriggerUpdate != null && (caps.HasLeftTrigger || caps.HasRightTrigger)) { GamePadTriggerUpdate(caps.HasLeftTrigger ? gps.Triggers.Left : 0f, caps.HasRightTrigger ? gps.Triggers.Right : 0f, player); } // Process the D-Pad if (GamePadDPadUpdate != null) { CCGamePadButtonStatus left = CCGamePadButtonStatus.NotApplicable; CCGamePadButtonStatus right = CCGamePadButtonStatus.NotApplicable; CCGamePadButtonStatus up = CCGamePadButtonStatus.NotApplicable; CCGamePadButtonStatus down = CCGamePadButtonStatus.NotApplicable; if (caps.HasDPadDownButton) { down = (gps.DPad.Down == ButtonState.Pressed ? CCGamePadButtonStatus.Pressed : CCGamePadButtonStatus.Released); } if (caps.HasDPadUpButton) { up = (gps.DPad.Up == ButtonState.Pressed ? CCGamePadButtonStatus.Pressed : CCGamePadButtonStatus.Released); } if (caps.HasDPadLeftButton) { left = (gps.DPad.Left == ButtonState.Pressed ? CCGamePadButtonStatus.Pressed : CCGamePadButtonStatus.Released); } if (caps.HasDPadRightButton) { right = (gps.DPad.Right == ButtonState.Pressed ? CCGamePadButtonStatus.Pressed : CCGamePadButtonStatus.Released); } GamePadDPadUpdate(left, up, right, down, player); } } m_PriorGamePadState[player] = gps; }
protected override void OnGamePadButtonUpdate(CCGamePadButtonStatus backButton, CCGamePadButtonStatus startButton, CCGamePadButtonStatus systemButton, CCGamePadButtonStatus aButton, CCGamePadButtonStatus bButton, CCGamePadButtonStatus xButton, CCGamePadButtonStatus yButton, CCGamePadButtonStatus leftShoulder, CCGamePadButtonStatus rightShoulder, PlayerIndex player) { base.OnGamePadButtonUpdate(backButton, startButton, systemButton, aButton, bButton, xButton, yButton, leftShoulder, rightShoulder, player); }
protected virtual void OnGamePadButtonUpdate(CCGamePadButtonStatus backButton, CCGamePadButtonStatus startButton, CCGamePadButtonStatus systemButton, CCGamePadButtonStatus aButton, CCGamePadButtonStatus bButton, CCGamePadButtonStatus xButton, CCGamePadButtonStatus yButton, CCGamePadButtonStatus leftShoulder, CCGamePadButtonStatus rightShoulder, Microsoft.Xna.Framework.PlayerIndex player) { }
protected virtual void OnGamePadDPadUpdate(CCGamePadButtonStatus leftButton, CCGamePadButtonStatus upButton, CCGamePadButtonStatus rightButton, CCGamePadButtonStatus downButton, Microsoft.Xna.Framework.PlayerIndex player) { if (!HasFocus) { return; } }