Exemplo n.º 1
0
        void setupControllerButtons()
        {
            //a button
            buttonArray[0]        = new ButtonClick();
            buttonArray[0].button = EasyInputConstants.CONTROLLER_BUTTON.AButton;

            //b button
            buttonArray[1]        = new ButtonClick();
            buttonArray[1].button = EasyInputConstants.CONTROLLER_BUTTON.BButton;

            //x button
            buttonArray[2]        = new ButtonClick();
            buttonArray[2].button = EasyInputConstants.CONTROLLER_BUTTON.XButton;

            //y button
            buttonArray[3]        = new ButtonClick();
            buttonArray[3].button = EasyInputConstants.CONTROLLER_BUTTON.YButton;

            //lb button
            buttonArray[4]        = new ButtonClick();
            buttonArray[4].button = EasyInputConstants.CONTROLLER_BUTTON.LeftBumper;

            //rb button
            buttonArray[5]        = new ButtonClick();
            buttonArray[5].button = EasyInputConstants.CONTROLLER_BUTTON.RightBumper;

            //start button
            buttonArray[6]        = new ButtonClick();
            buttonArray[6].button = EasyInputConstants.CONTROLLER_BUTTON.StartButton;

            //back button
            buttonArray[7]        = new ButtonClick();
            buttonArray[7].button = EasyInputConstants.CONTROLLER_BUTTON.Back;

            //ls click button
            buttonArray[8]        = new ButtonClick();
            buttonArray[8].button = EasyInputConstants.CONTROLLER_BUTTON.LeftStickPush;

            //rs click button
            buttonArray[9]        = new ButtonClick();
            buttonArray[9].button = EasyInputConstants.CONTROLLER_BUTTON.RightStickPush;

            //ls click button
            buttonArray[10]        = new ButtonClick();
            buttonArray[10].button = EasyInputConstants.CONTROLLER_BUTTON.GearVRTouchClick;

            //rs click button
            buttonArray[11]        = new ButtonClick();
            buttonArray[11].button = EasyInputConstants.CONTROLLER_BUTTON.GearVRTrigger;

            buttonArray[12]        = new ButtonClick();
            buttonArray[12].button = EasyInputConstants.CONTROLLER_BUTTON.GearVRHMDPadTap;
        }
Exemplo n.º 2
0
        void processSpecificButton(ref ButtonClick buttonClick)
        {
            buttonClick.currentlyPressed = getControllerButtonState(buttonClick.button);

            if (buttonClick.currentlyPressed)
            {
                if (!buttonClick.previousFramePressed)
                {
                    //start of a click
                    buttonClick.currentClickBeginTimestamp = Time.time;

                    //touchtype starts at quick if new or double if were in the time factor for double press
                    if (buttonClick.previousClickBeginTimestamp != EasyInputConstants.NO_TIMESTAMP &&
                        (buttonClick.currentClickBeginTimestamp - buttonClick.previousClickBeginTimestamp) < maxDoubleTapTime)
                    {
                        //possible start of a double tap
                        buttonClick.clickType = EasyInputConstants.CLICK_TYPE.DoublePress;
                    }
                    else
                    {
                        buttonClick.clickType = EasyInputConstants.CLICK_TYPE.QuickPress;
                    }

                    //fire off the click start event and touch event
                    if (On_ClickStart != null)
                    {
                        On_ClickStart(buttonClick);
                    }
                    if (On_Click != null)
                    {
                        On_Click(buttonClick);
                    }
                }
                else
                {
                    //continue of a press

                    //change to quickpress
                    if (buttonClick.clickType == EasyInputConstants.CLICK_TYPE.Miscellaneous &&
                        Time.time - buttonClick.currentClickBeginTimestamp < maxQuickTapTime)
                    {
                        buttonClick.clickType = EasyInputConstants.CLICK_TYPE.QuickPress;
                    }
                    //change to longpress
                    if (buttonClick.clickType != EasyInputConstants.CLICK_TYPE.LongPress &&
                        Time.time - buttonClick.currentClickBeginTimestamp > minLongTapTime)
                    {
                        buttonClick.clickType = EasyInputConstants.CLICK_TYPE.LongPress;
                        if (On_LongClickStart != null)
                        {
                            On_LongClickStart(buttonClick);
                        }
                    }

                    //change to miscellaneous
                    if (buttonClick.clickType != EasyInputConstants.CLICK_TYPE.Miscellaneous)
                    {
                        //downgraded from quickpress
                        if (buttonClick.clickType == EasyInputConstants.CLICK_TYPE.QuickPress)
                        {
                            if (Time.time - buttonClick.currentClickBeginTimestamp > maxQuickTapTime)
                            {
                                //we were a quick press but now we've taken too long revert to misc
                                buttonClick.clickType = EasyInputConstants.CLICK_TYPE.Miscellaneous;
                            }
                        }

                        //downgraded from double press
                        else if (buttonClick.clickType == EasyInputConstants.CLICK_TYPE.DoublePress)
                        {
                            if (Time.time - buttonClick.currentClickBeginTimestamp > maxDoubleTapTime)
                            {
                                //we were a double press but now we've taken too long revert to misc
                                buttonClick.clickType = EasyInputConstants.CLICK_TYPE.Miscellaneous;
                            }
                        }
                    }



                    //if touching we always fire off the touch event
                    if (On_Click != null)
                    {
                        On_Click(buttonClick);
                    }

                    //if touching and currently a long press always fire that too
                    if (buttonClick.clickType == EasyInputConstants.CLICK_TYPE.LongPress)
                    {
                        if (On_LongClick != null)
                        {
                            On_LongClick(buttonClick);
                        }
                    }
                }
                buttonClick.previousFramePressed = true;
            }
            else
            {
                //no current touch

                //first look at previous values to determine if we need to do anything
                if (buttonClick.previousFramePressed == true)
                {
                    //we just ended a touch
                    if (On_ClickEnd != null)
                    {
                        On_ClickEnd(buttonClick);
                    }

                    //also fire end of quick or long if it was this (remember we don't fire a swipe event on end we fire it
                    //on each time we hit the swipe length
                    if (buttonClick.clickType == EasyInputConstants.CLICK_TYPE.QuickPress)
                    {
                        //double check that we've just ended a quick touch
                        if (Time.time - buttonClick.currentClickBeginTimestamp < maxQuickTapTime)
                        {
                            if (On_QuickClickEnd != null)
                            {
                                On_QuickClickEnd(buttonClick);
                            }
                        }
                    }
                    else if (buttonClick.clickType == EasyInputConstants.CLICK_TYPE.LongPress)
                    {
                        //double check that we've just ended a long touch
                        if (Time.time - buttonClick.currentClickBeginTimestamp > minLongTapTime)
                        {
                            if (On_LongClickEnd != null)
                            {
                                On_LongClickEnd(buttonClick);
                            }
                        }
                    }
                    else if (buttonClick.clickType == EasyInputConstants.CLICK_TYPE.DoublePress)
                    {
                        //double check that we've just ended a double touch
                        if (Time.time - buttonClick.previousClickBeginTimestamp < maxDoubleTapTime)
                        {
                            if (On_DoubleClickEnd != null)
                            {
                                On_DoubleClickEnd(buttonClick);
                            }
                        }
                    }

                    //since we were previously touching set the timestamp
                    buttonClick.previousClickBeginTimestamp = buttonClick.currentClickBeginTimestamp;
                }


                //reset the variables since there is no current touch
                buttonClick.currentClickBeginTimestamp = EasyInputConstants.NO_TIMESTAMP;
                buttonClick.clickType            = EasyInputConstants.CLICK_TYPE.Miscellaneous;
                buttonClick.previousFramePressed = false;
            }
        }