Beispiel #1
0
 static void ResetPressInfo()
 {
     ClickPressInfo.Clear();
     ClickCDPressInfo.Clear();
     DoublePressInfo.Clear();
     LongPressInfo.Clear();
     JoyAxisStateInfo.Clear();
 }
Beispiel #2
0
        public static void Register(KeyCode key, float[] para)
        {
            int idx = s_doublePressKeys.FindIndex(x => x._key == key);

            if (idx < 0)
            {
                s_doublePressKeys.Add(new DoublePressInfo(key, para));
            }
            else
            {
                s_doublePressKeys[idx] = new DoublePressInfo(key, para);
            }
        }
Beispiel #3
0
    static Func <bool> CreatePressTestFunc(KeyCode key, KeyPressType pressType, float[] para)
    {
        if (pressType < KeyPressType.JoyStickBegin)
        {
            if (key == KeyCode.None)
            {
                return(() => false);
            }
            int mask = (int)key & KeyMask;                      // use excluder to check key mask
            if (mask != 0)
            {
                key = key - mask;
            }
        }

        switch (pressType)
        {
        default:
        case KeyPressType.Up:                           return(() => Input.GetKeyUp(key) && NotExcluderByOther());

        case KeyPressType.Down:                         return(() => Input.GetKeyDown(key) && NotExcluderByOther());

        case KeyPressType.Press:                        return(() => Input.GetKey(key) && NotExcluderByOther());

        case KeyPressType.UpHPrior:                     return(() => Input.GetKeyUp(key));

        case KeyPressType.PressHPrior:          return(() => Input.GetKey(key));

        case KeyPressType.ClickNoMove:          return(() => key.IsClickNoMove());

        case KeyPressType.Click:                        ClickPressInfo.Register(key, para);             return(() => key.IsClickPress());

        case KeyPressType.ClickCD:                      ClickCDPressInfo.Register(key, para);   return(() => key.IsClickCDPress());

        case KeyPressType.DoublePress:          DoublePressInfo.Register(key, para);    return(() => key.IsDoublePress());

        case KeyPressType.LongPress:            LongPressInfo.Register(key, para);              return(() => key.IsLongPress());

        case KeyPressType.DirU:                         s_keyAxisU = key;       return(delegate { return s_curAxisV > PETools.PEMath.Epsilon; });

        case KeyPressType.DirD:                         s_keyAxisD = key;       return(delegate { return s_curAxisV < -PETools.PEMath.Epsilon; });

        case KeyPressType.DirR:                         s_keyAxisR = key;       return(delegate { return s_curAxisH > PETools.PEMath.Epsilon; });

        case KeyPressType.DirL:                         s_keyAxisL = key;       return(delegate { return s_curAxisH < -PETools.PEMath.Epsilon; });

        case KeyPressType.MouseWheelU:          return(delegate { return Input.GetAxis("Mouse ScrollWheel") > PETools.PEMath.Epsilon; });

        case KeyPressType.MouseWheelD:          return(delegate { return Input.GetAxis("Mouse ScrollWheel") < -PETools.PEMath.Epsilon; });
        }
    }
Beispiel #4
0
        public static bool TryGetValue(KeyCode key, out DoublePressInfo info)
        {
            info = null;

            int idx = s_doublePressKeys.FindIndex(x => x._key == key);

            if (idx < 0)
            {
                return(false);
            }

            info = s_doublePressKeys [idx];
            return(true);
        }
Beispiel #5
0
    public static bool IsDoublePress(this KeyCode key)
    {
        DoublePressInfo pressInfo;

        if (Input.GetKeyDown(key) && NotExcluderByOther() && DoublePressInfo.TryGetValue(key, out pressInfo))
        {
            pressInfo._lastDown1 = Time.time;

            float deltaTime = Time.time - pressInfo._lastDown0;
            if (deltaTime < pressInfo._interval)
            {
                //Debug.LogError("DoublePress 111111");
                return(true);
            }
            //Debug.LogError("DoublePress 000000");
            return(false);
        }
        else if (Input.GetKeyUp(key) && NotExcluderByOther() && DoublePressInfo.TryGetValue(key, out pressInfo))
        {
            pressInfo._lastDown0 = pressInfo._lastDown1;
        }
        return(false);
    }