예제 #1
0
 // Returns whether a MOGA Controller is connected ------------------------------------------------
 // -----------------------------------------------------------------------------------------------
 public bool isControllerConnected()
 {
     if (Moga_Controller.getState(Moga_Controller.STATE_CONNECTION) == Moga_Controller.ACTION_CONNECTED)
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
예제 #2
0
    // Create the MOGA Controller Manager -------------------------------------------------------------
    // ------------------------------------------------------------------------------------------------
    void Awake()
    {
        if (sMogaController == null)
        {
            DontDestroyOnLoad(transform.gameObject);

            AndroidJavaClass  jc       = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
            AndroidJavaObject activity = jc.GetStatic <AndroidJavaObject> ("currentActivity");

            AndroidJavaObject controller = Moga_Controller.getInstance(activity);
            sMogaController = new Moga_Controller(activity, controller);
            sMogaController.init();
        }
    }
예제 #3
0
 // Use this for initialization
 void Start()
 {
     mControllerManager = GameObject.Find("MogaControllerManager").GetComponent <Moga_ControllerManager>().sMogaController;
 }
예제 #4
0
    void Update()
    {
        foreach (Dictionary <int, float> axes in mAxes.Values)
        {
            foreach (int axisKey in new List <int>(axes.Keys))
            {
                axes[axisKey] = Moga_Controller.getAxisValue(axisKey);
            }
        }

        foreach (int buttonKey in new List <int>(mogaButtons.Keys))
        {
            int action = Moga_Controller.getKeyCode(buttonKey);

            switch (mogaButtons[buttonKey])
            {
            case ButtonState.RELEASED:
                if (action == Moga_Controller.ACTION_DOWN)
                {
                    mogaButtons[buttonKey] = ButtonState.PRESSING;
                }
                break;

            case ButtonState.PRESSING:
                if (action == Moga_Controller.ACTION_UP)
                {
                    mogaButtons[buttonKey] = ButtonState.RELEASING;
                }
                else
                {
                    mogaButtons[buttonKey] = ButtonState.PRESSED;
                }
                break;

            case ButtonState.PRESSED:

                mAnyKeyDown = true;
                mAnyKey     = true;

                if (action == Moga_Controller.ACTION_UP)
                {
                    mogaButtons[buttonKey] = ButtonState.RELEASING;
                }
                break;

            case ButtonState.RELEASING:

                mAnyKeyDown = false;
                mAnyKey     = false;

                if (action == Moga_Controller.ACTION_DOWN)
                {
                    mogaButtons[buttonKey] = ButtonState.PRESSING;
                }
                else
                {
                    mogaButtons[buttonKey] = ButtonState.RELEASED;
                }
                break;
            }
        }
    }
예제 #5
0
 // Returns the number of MOGA Controllers connected ----------------------------------------------
 // -----------------------------------------------------------------------------------------------
 public int numberOfConnectedControllers()
 {
     return(Moga_Controller.getInfo(Moga_Controller.INFO_KNOWN_DEVICE_COUNT));
 }