Example #1
0
 protected virtual void Start()
 {
     XDevicePlugin.Init();
     if (m_Handle == -1)
     {
         m_Handle = XDevicePlugin.GetInputDeviceHandle(deviceName);
     }
 }
Example #2
0
        /// <summary>
        /// Initialize all the input controller .
        /// </summary>
        public virtual void InitAllControllerInputs()
        {
            //
            int ret = XDevicePlugin.Init();

            if (ret != 0)
            {
                /*...*/
            }
            //
            if (m_ControllerDataTxt != null)
            {
                s_ControllerDatabase = ControllerInfo.ParseFromText(
                    s_ControllerDatabase, m_ControllerDataTxt.text);
            }
            //
#if XDEVICE_EXT
            InitExternalControllerDevices();
#endif
            //
            int    whichBufferSize = XDevicePlugin.GetInputDeviceCount();
            int[]  whichBuffer     = new int[whichBufferSize];
            string name;
            int    handle, i = 0, imax = XDevicePlugin.GetInputDevices(1, whichBuffer, whichBufferSize);
            //
            if (controllerInputs == null)
            {
                controllerInputs = new Dictionary <string, ControllerInput>(imax);
            }
            else
            {
                controllerInputs.Clear();
            }
            System.Text.StringBuilder sb = new System.Text.StringBuilder();
            sb.AppendLine("ControllerInput List:");
            for (; i < imax; ++i)
            {
                handle = whichBuffer[i];
                name   = XDevicePlugin.GetInputDeviceName(handle);
                AddControllerInput(name, new ControllerInput(handle, name));
                //
                sb.AppendLine("\t{ControllerInput name=\"" + name + "\" handle=\"" + handle + "\"}");
            }
            Log.i("ControllerInputManager", sb.ToString());
            //
            m_OnInitialized.Invoke();
        }
Example #3
0
        public virtual int InitInput()
        {
            XDevicePlugin.Init();
            //
            List <IInputModule> list = new List <IInputModule>();
            int ret;

            //
            for (int i = 0, imax = monoInputModules.Length; i < imax; ++i)
            {
                //
                if (monoInputModules[i] != null)
                {
                    if (monoInputModules[i].gameObject.activeSelf && monoInputModules[i].enabled)
                    {
                        ret = (monoInputModules[i] as IInputModule).InitInput();
                    }
                    else
                    {
                        ret = -1;
                    }
                }
                else
                {
                    ret = -1;
                }
                //
                if (ret == 0)
                {
                    list.Add(monoInputModules[i] as IInputModule);
                }
                else
                {
                    if (monoInputModules[i])
                    {
                        monoInputModules[i].enabled = false;
                    }
                    monoInputModules[i] = null;
                }
            }
            inputModules = list.ToArray();
            //
            return(0);
        }
        /// <summary>
        /// Initialize all the input controller .
        /// </summary>
        public virtual void InitAllControllerInputs()
        {
            //
            int ret = XDevicePlugin.Init();

            if (ret != 0)
            {
                /*...*/
            }
            //
            if (m_ControllerDataTxt != null)
            {
                s_ControllerDatabase = ControllerInfo.ParseFromText(
                    s_ControllerDatabase, m_ControllerDataTxt.text);
            }
            //
            int whichBufferSize = XDevicePlugin.GetInputDevices(1, null, 0);

            int[]  whichBuffer = new int[whichBufferSize];
            string name;
            int    handle, i = 0, imax = XDevicePlugin.GetInputDevices(1, whichBuffer, whichBufferSize);

            //
            System.Text.StringBuilder sb = new System.Text.StringBuilder();
            sb.AppendLine("ControllerInput List:");
            for (; i < imax; ++i)
            {
                handle = whichBuffer[i];
                name   = XDevicePlugin.GetInputDeviceName(handle);
                if (GetControllerInput(name) == null)
                {
                    AddControllerInput(name, new ControllerInput(handle, name));
                }
                //
                sb.AppendLine("\t{ControllerInput name=\"" + name + "\" handle=\"" + handle + "\"}");
            }
            Log.i("ControllerInputManager", sb.ToString());
            //
            m_OnInitialized.Invoke();
        }
Example #5
0
 /// <summary>
 ///
 /// </summary>
 public virtual bool InitAllControllers()
 {
     return(XDevicePlugin.Init() == 0);
 }
Example #6
0
        /// <summary>
        /// This function will be called by ControllerInputManager or Start().
        /// XCobra controller's position will be overwritten by this class.
        /// </summary>
        public virtual void Launch(bool checkOthers)
        {
            if (m_IsLaunched)
            {
                return;
            }
            m_IsLaunched = true;
            //
            deviceName = "XHawk-0";
            if (checkOthers)
            {
                XHawkInput other = FindAll(deviceName).Find((x) => (x != this)) as XHawkInput;
                if (other != null)
                {
                    // This will be not found by TrackingInput.Find(string).
                    gameObject.SetActive(false);
                    other.Launch(false);
                    //Log.i("XHawkInput","Use the default TrackingInput in scene.");
                    return;
                }
            }
            //
            XDevicePlugin.Init();
            if (m_Handle == -1)
            {
                m_Handle = XDevicePlugin.GetInputDeviceHandle(deviceName);
            }
            m_HmdHandle = XDevicePlugin.GetInputDeviceHandle("VRDevice");
            XDevicePlugin.SetInt(m_Handle, XDevicePlugin.kField_TrackingOrigin, (int)VRContext.trackingOrigin);
            // Set values to the plugin
            if (overridePlugin)             //&&m_Handle>0) {
            {
                if ((XDevicePlugin.GetInt(-1, XDevicePlugin.kField_CtxDeviceVersion, 0x4000) & 0xF000) == 0x4000)
                {
                    Vector3 trackerPos = PlayerPrefsEx.GetVector3("XimmerseTracker[Outside-in].position", new Vector3(0.0f, 1.675f, 1.5f));
                    Vector3 trackerRot = PlayerPrefsEx.GetVector3("XimmerseTracker[Outside-in].rotation", new Vector3(15.0f, 180.0f, 0.0f));
                    XDevicePlugin.SetTrackerPose(m_Handle, trackerPos.y, trackerPos.z, -trackerRot.x);
                }
            }
            // TODO :
            XDevicePlugin.SendMessage(m_Handle, XDevicePlugin.kMessage_RecenterSensor, 0, 0);
            //
#if XDEVICE_RELEASE
            //if((XDevicePlugin.GetInt(-1,XDevicePlugin.kField_CtxDeviceVersion,0x4000)&0xF000)!=0x4000)
#endif
            {
                int i = 0, imax = controllers.Length;
                inputs = new XCobraInput[imax];
                //
                ControllerInputManager mgr = ControllerInputManager.instance;
                ControllerInput        ci;
                if (mgr != null)
                {
                    for (; i < imax; ++i)
                    {
                        ci = mgr.GetControllerInput(controllers[i].key);
                        if (ci is XCobraInput)
                        {
                            inputs[i] = ci as XCobraInput;
                        }
                        else
                        {
                            inputs[i] = new XCobraInput(this, controllers[i].key, controllers[i].value);
                            mgr.AddControllerInput(inputs[i].name, inputs[i]);
                        }
                        //
                    }
                }
            }
            m_HmdInput = ControllerInputManager.GetInput(ControllerType.Hmd);
            // VRContext must have a CenterEyeAnchor at least.
            m_IsRequestVR = (VRContext.GetAnchor(VRNode.CenterEye) != null);
            EnsureAnchor();
            //
            if (XDevicePlugin.GetInt(-1, XDevicePlugin.kField_CtxDeviceVersion, 0) == 0x1010)
            {
                XDevicePlugin.SetInt(m_Handle, XDevicePlugin.kField_ConnectionState, (int)DeviceConnectionState.Connected);
                m_AsDaydreamEmulator = true;
                LoadHandConfigs();
            }
            //
            Log.i("XHawkInput", "Initialize successfully.");
        }