Пример #1
0
        void init()
        {
            try {
                JavaBridgeManager.Instance.Initialize();
                //BluetoothManager.Instance.Initialize();

#if !UNITY_ANDROID || UNITY_EDITOR
                registerDevice(new Keyboard());
#endif
                //IMPORTANT! The GearVR Gamepad registers on unity android as keyboard instead of a joystick for some reason.
#if UNITY_ANDROID && !UNITY_EDITOR
                registerDevice(new Keyboard()
                {
                    deviceName = "Gear VR Gamepad"
                });
#endif
                foreach (string jname in UnityEngine.Input.GetJoystickNames())
                {
                    GenericJoystick joystick = new GenericJoystick();
                    joystick.deviceName = jname;
                    registerDevice(joystick);
                }
            } catch (System.Exception e) {
                Debug.Log(e.Message);
                //Test.addDebugMessage(e.Message);
            }
        }
Пример #2
0
        public void UseDevice(IInputDevice device)
        {
            if (device.GetType() == typeof(IcarosController))
            {
                IcarosController con = device as IcarosController;
#if UNITY_ANDROID && !UNITY_EDITOR
                JavaBridgeManager.Instance.OnNewBytes += con.HandleNewBytes;
                JavaBridgeManager.Instance.ConnectToController(con.GetDeviceName());
                deviceWaitingForJBM = device;
#endif
#if UNITY_STANDALONE_WIN
                BluetoothManager.Instance.ConnectToController(con.GetDeviceName());
                DeviceUsed(device);
#endif
                con.used = true;
            }
            if (device.GetType() == typeof(Keyboard))
            {
                Keyboard key = device as Keyboard;
                key.used = true;
                DeviceUsed(device);
            }
            if (device.GetType() == typeof(GenericJoystick))
            {
                GenericJoystick joy = device as GenericJoystick;
                joy.used = true;
                DeviceUsed(device);
            }
        }