Exemple #1
0
        // given a gamepad button, return the keyboard
        // key to which it maps (if any). in the case of
        // PlayerIndex.Three and PlayerIndex.Four, this
        // method will always return a zero (Keys.None).
        public Keys GetKey(PadButtons button)
        {
            Keys key = Keys.None;

            if (m_KeyMap.ContainsKey(button))
            {
                key = m_KeyMap[button];
            }
            return key;
        }
Exemple #2
0
        // map a keyboard key to a gamepad button
        public void AddMapping(PadButtons button, Keys key)
        {
            // make sure the button isn't already mapped
            if (m_KeyMap.ContainsKey(button))
            {
                m_KeyMap.Remove(button);
            }

            // map the button to the key
            m_KeyMap.Add(button,key);
        }
        /// <summary>
        /// Action when a button is released
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected virtual void Pad_Released(object sender, MouseReleaseEntityEventArgs e)
        {
            YnSprite button = sender as YnSprite;

            if (button != null)
            {
                PadButtons direction = GetDirection(button.Name);
                VirtualPadPressedEventArgs vpEvent = new VirtualPadPressedEventArgs(direction);

                OnReleased(vpEvent);
            }
        }
Exemple #4
0
        // get the state of a mapped digital button
        public ButtonState GetButtonState(
            KeyboardState keyState,
            ButtonState btnState,
            PadButtons button)
        {
            // is the mapped key pressed?
            bool keyPressed = keyState.IsKeyDown(GetKey(button));
            // is the actual gamepad button pressed?
            bool btnPressed = (btnState == ButtonState.Pressed);

            // if either is pressed, treat the virtual button as
            // pressed; otherwise, report the state as released
            return keyPressed || btnPressed ?
                ButtonState.Pressed :
                ButtonState.Released;
        }
 /// <summary>
 /// Create an event with a direction.
 /// </summary>
 /// <param name="direction"></param>
 public VirtualPadPressedEventArgs(PadButtons direction)
 {
     Direction = direction;
 }
 /// <summary>
 /// Create an empty event.
 /// </summary>
 public VirtualPadPressedEventArgs()
 {
     Direction = PadButtons.None;
 }
Exemple #7
0
 // get the state of a mapped thumbstick
 public float GetStickState(
     KeyboardState keyState,
     float btnState,
     PadButtons btnMin,
     PadButtons btnMax)
 {
     // if the thumbstick on the controller isn't
     // being used, check the keyboard
     if (btnState == 0.0f)
     {
         // since the keyboard is digital, and the
         // thumbstick is analog, map pressed keys
         // to one of the extreme thumbstick values
         if (keyState.IsKeyDown(GetKey(btnMin)))
         {
             btnState = KeyMapHelper.THUMBSTICK_MIN;
         }
         else if (keyState.IsKeyDown(GetKey(btnMax)))
         {
             btnState = KeyMapHelper.THUMBSTICK_MAX;
         }
     }
     return btnState;
 }
		public bool Released(PadButtons button)
		{
			return !_buttons[(int)button];
		}
Exemple #9
0
 // get the state of a mapped trigger
 public float GetTriggerState(
     KeyboardState keyState,
     float btnState,
     PadButtons button)
 {
     // if the trigger on the controller isn't
     // being used, check the keyboard
     if (btnState == 0.0f)
     {
         // since the keyboard is digital, and the
         // trigger is analog, map pressed keys to
         // the extreme trigger value
         if (keyState.IsKeyDown(GetKey(button)))
         {
             btnState = KeyMapHelper.TRIGGER_MAX;
         }
     }
     return btnState;
 }
 public bool Pressed(PadButtons button)
 {
     return _buttons[(int)button];
 }
		public bool JustPressed(PadButtons button)
		{
            return false;
		}
 /// <summary>
 /// Create an event with a direction.
 /// </summary>
 /// <param name="direction"></param>
 public VirtualPadPressedEventArgs(PadButtons direction)
 {
     Direction = direction;
 }
 /// <summary>
 /// Create an empty event.
 /// </summary>
 public VirtualPadPressedEventArgs()
 {
     Direction = PadButtons.None;
 }
Exemple #14
0
 public bool Released(PadButtons button)
 {
     return(!_buttons[(int)button]);
 }
Exemple #15
0
 public bool JustPressed(PadButtons button)
 {
     return(false);
 }
Exemple #16
0
 public bool Pressed(PadButtons button)
 {
     return(_buttons[(int)button]);
 }