Exemplo n.º 1
0
        /// <summary>
        /// Check if joystick id, down the key?
        /// </summary>
        /// <param name="joystickIndex"> id. </param>
        /// <param name="btn"> target button. </param>
        /// <returns>
        /// true: did uo.
        /// false: not up.
        /// </returns>
        public static bool GetJoystickKeyDown(JCS_JoystickIndex joystickIndex, JCS_JoystickButton btn, bool ignorePause = false)
        {
            if (!ignorePause)
            {
                if (JCS_GameManager.instance.GAME_PAUSE)
                {
                    return(false);
                }
            }

            string idString = JCS_InputSettings.GetJoystickButtonIdName(joystickIndex, btn);

            if (GetJoystickKey(joystickIndex, btn, ignorePause))
            {
                if (!mJoystickKeyPressed.ContainsKey(idString))
                {
                    mJoystickKeyPressed.Add(idString, false);
                    return(true);
                }
                // Key contains!
                else
                {
                    if (mJoystickKeyPressed[idString])
                    {
                        return(false);
                    }
                    else
                    {
                        if (!mJoystickKeyWasPreseed.Contains(idString))
                        {
                            mJoystickKeyWasPreseed.Add(idString);
                        }
                        return(true);
                    }
                }
            }
            else
            {
                if (mJoystickKeyPressed.ContainsKey(idString))
                {
                    mJoystickKeyPressed[idString] = false;
                }
            }

            return(false);
        }
Exemplo n.º 2
0
        public static bool GetJoystickKeyByAction(
            JCS_KeyActionType act,
            JCS_JoystickIndex id,
            JCS_JoystickButton key,
            bool ignorePause = false)
        {
            switch (act)
            {
            case JCS_KeyActionType.KEY:
                return(GetJoystickKey(id, key, ignorePause));

            case JCS_KeyActionType.KEY_DOWN:
                return(GetJoystickKeyDown(id, key, ignorePause));

            case JCS_KeyActionType.KEY_UP:
                return(GetJoystickKeyUp(id, key, ignorePause));
            }

            JCS_Debug.LogError("This cannot happed.");
            return(false);
        }
 /// <summary>
 /// Get the joystick button name by joystick button label.
 /// </summary>
 /// <param name="index"> joystick id. </param>
 /// <param name="label"> joystick button label </param>
 /// <returns> name of the joystick button id. </returns>
 public static string GetJoystickButtonIdName(JCS_JoystickIndex index, JCS_JoystickButton label)
 {
     return(GetJoystickButtonName(label) + " " + (int)index);
 }
Exemplo n.º 4
0
 /// <summary>
 /// Check if joystick id, pressed the key?
 /// </summary>
 /// <param name="joystickIndex"> id. </param>
 /// <param name="btn"> target button. </param>
 /// <returns>
 /// true: did pressed.
 /// false: not pressed.
 /// </returns>
 public static bool GetJoystickKey(JCS_JoystickIndex joystickIndex, JCS_JoystickButton btn, bool ignorePause = false)
 {
     return(GetJoystickKey((int)joystickIndex, btn, ignorePause));
 }
Exemplo n.º 5
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="joystickIndex"></param>
 /// <param name="btn"></param>
 /// <returns></returns>
 public static float GetAxis(JCS_JoystickIndex joystickIndex, JCS_JoystickButton btn, bool ignorePause = false)
 {
     return(GetAxis((int)joystickIndex, btn, ignorePause));
 }