internal CCEventListenerGamePad(CCEventListenerGamePad gamePad)
     : this()
 {
     OnButtonStatus     = gamePad.OnButtonStatus;
     OnConnectionStatus = gamePad.OnConnectionStatus;
     OnDPadStatus       = gamePad.OnDPadStatus;
     OnStickStatus      = gamePad.OnStickStatus;
     OnTriggerStatus    = gamePad.OnTriggerStatus;
 }
Ejemplo n.º 2
0
        void EnableGamePad()
        {
            var AButtonWasPressed = false;

            var gamePadListener = new CCEventListenerGamePad ();

            gamePadListener.OnButtonStatus = (buttonStatus) => 
            {
                if (buttonStatus.A == CCGamePadButtonStatus.Pressed)
                {
                    AButtonWasPressed = true;
                }
                else if (buttonStatus.A == CCGamePadButtonStatus.Released && AButtonWasPressed)
                {
                    // Select the menu
                    testListMenuItems[currentItemIndex].Activate();
                    testListMenuItems[currentItemIndex].Selected = false;
                }
            };

            long firstTicks = 0;
            bool isDownPressed = false;
            bool isUpPressed = false;

            gamePadListener.OnDPadStatus = (dpadStatus) => 
            {
                // Down and Up only
                if (dpadStatus.Down == CCGamePadButtonStatus.Pressed) 
                {
                    if (firstTicks == 0L) 
                    {
                        firstTicks = DateTime.Now.Ticks;
                        isDownPressed = true;
                    }
                } 
                else if (dpadStatus.Down == CCGamePadButtonStatus.Released && firstTicks > 0L && isDownPressed) 
                {
                    firstTicks = 0L;
                    NextMenuItem ();
                    isDownPressed = false;
                }
                if (dpadStatus.Up == CCGamePadButtonStatus.Pressed) 
                {
                    if (firstTicks == 0L) {
                        firstTicks = DateTime.Now.Ticks;
                        isUpPressed = true;
                    }
                } 
                else if (dpadStatus.Up == CCGamePadButtonStatus.Released && firstTicks > 0L && isUpPressed) 
                {
                    firstTicks = 0L;
                    PreviousMenuItem ();
                    isUpPressed = false;
                }


            };

            gamePadListener.OnConnectionStatus = (connectionStatus) => 
            {
                CCLog.Log("Player {0} is connected {1}", connectionStatus.Player, connectionStatus.IsConnected);
            };

            AddEventListener(gamePadListener);
        }
Ejemplo n.º 3
0
		internal CCEventListenerGamePad(CCEventListenerGamePad gamePad)
			: this()
		{
			OnButtonStatus = gamePad.OnButtonStatus;
			OnConnectionStatus = gamePad.OnConnectionStatus;
			OnDPadStatus = gamePad.OnDPadStatus;
			OnStickStatus = gamePad.OnStickStatus;
			OnTriggerStatus = gamePad.OnTriggerStatus;
		}