Exemple #1
0
        //---------------アクション情報取得系-------------------

        //ハンドルから入力元デバイスの情報を取得する
        //また入力ソースハンドルを逆引きしてpathにまで戻す。
        public OriginSource GetOriginSourceFromInternalHandle(ulong Handle)
        {
            ReadyCheck(); //実行可能な状態かチェック

            EVRInputError inputError = EVRInputError.None;

            //デバイス情報を取得
            InputOriginInfo_t originInfo = new InputOriginInfo_t();
            var size = (uint)System.Runtime.InteropServices.Marshal.SizeOf(typeof(InputOriginInfo_t));

            inputError = vrinput.GetOriginTrackedDeviceInfo(Handle, ref originInfo, size);
            if (inputError != EVRInputError.None)
            {
                return(null); //情報なし
            }

            //デバイス情報を作成
            OriginSource origin = new OriginSource(originInfo, Handle);

            //デバイスハンドルから探索して見つかれば格納
            foreach (KeyValuePair <string, ulong> p in InputSourceHandles)
            {
                if (p.Value == originInfo.devicePath)
                {
                    origin.DevicePath = p.Key;
                }
            }

            return(origin);
        }
Exemple #2
0
        public override void Initialize()
        {
            base.Initialize();

            if (inputOriginInfo_size == 0)
            {
                var inputOriginInfo = new InputOriginInfo_t();
                inputOriginInfo_size = (uint)Marshal.SizeOf(inputOriginInfo);
            }
        }
Exemple #3
0
        protected void UpdateOriginTrackedDeviceInfo()
        {
            if (lastOriginGetFrame != Time.frameCount) //only get once per frame
            {
                EVRInputError err = OpenVR.Input.GetOriginTrackedDeviceInfo(activeOrigin, ref inputOriginInfo, inputOriginInfo_size);

                if (err != EVRInputError.None)
                {
                    Debug.LogError("<b>[SteamVR]</b> GetOriginTrackedDeviceInfo error (" + fullPath + "): " + err.ToString() + " handle: " + handle.ToString() + " activeOrigin: " + activeOrigin.ToString() + " active: " + active);
                }

                lastInputOriginInfo = inputOriginInfo;
                lastOriginGetFrame  = Time.frameCount;
            }
        }
Exemple #4
0
        /// <param name="inputSource">The device you would like to get data from. Any if the action is not device specific.</param>
        protected void UpdateOriginTrackedDeviceInfo(SteamVR_Input_Sources inputSource)
        {
            if (lastOriginGetFrame[inputSource] != Time.frameCount) //only get once per frame
            {
                var inputOriginInfo = new InputOriginInfo_t();
                var err             = OpenVR.Input.GetOriginTrackedDeviceInfo(activeOrigin[inputSource], ref inputOriginInfo, inputOriginInfo_size);

                if (err != EVRInputError.None)
                {
                    Debug.LogError("GetOriginTrackedDeviceInfo error (" + fullPath + "): " + err.ToString() + " handle: " + handle.ToString() + " activeOrigin: " + activeOrigin[inputSource].ToString() + " active: " + active[inputSource]);
                }

                lastInputOriginInfo[inputSource] = inputOriginInfo;
                lastOriginGetFrame[inputSource]  = Time.frameCount;
            }
        }
Exemple #5
0
 public OriginSource(InputOriginInfo_t inputOrigin, ulong InternalHandle)
 {
     DeviceIndex = inputOrigin.trackedDeviceIndex;
     RenderModelComponentName = inputOrigin.rchRenderModelComponentName;
     DeviceInternalHandle     = InternalHandle;
 }