示例#1
0
    public void SetDefaultButtons()
    {
        if (!this.Initialized)
        {
            return;
        }

        #if UNITY_EDITOR
        if (Application.isEditor)
        {
            return;
        }
        #endif

        Log.i(LOG_TAG, "SetDefaultButtons()");

        WVR_InputAttribute_t[] inputAttribtues_hmd = new WVR_InputAttribute_t[1];
        inputAttribtues_hmd [0].id         = WVR_InputId.WVR_InputId_Alias1_Enter;
        inputAttribtues_hmd [0].capability = (uint)WVR_InputType.WVR_InputType_Button;
        inputAttribtues_hmd [0].axis_type  = WVR_AnalogType.WVR_AnalogType_None;

        WVR_DeviceType _type = WaveVR_Controller.Input(WaveVR_Controller.EDeviceType.Head).DeviceType;
        bool           _ret  = Interop.WVR_SetInputRequest(_type, inputAttribtues_hmd, (uint)inputAttribtues_hmd.Length);
        if (_ret)
        {
            uint inputTableSize = (uint)WVR_InputId.WVR_InputId_Max;
            WVR_InputMappingPair_t[] inputTable = new WVR_InputMappingPair_t[inputTableSize];
            uint _size = Interop.WVR_GetInputMappingTable(_type, inputTable, inputTableSize);
            if (_size > 0)
            {
                for (int _i = 0; _i < (int)_size; _i++)
                {
                    PrintDebugLog("SetDefaultButtons() " + _type
                                  + " button: " + inputTable [_i].source.id
                                  + " is mapping to HMD input ID: " + inputTable [_i].destination.id);
                }
            }
        }
    }
示例#2
0
    public void SetDefaultButtons()
    {
        if (!this.Initialized)
        {
            return;
        }

        PrintInfoLog("SetDefaultButtons()");

        WVR_InputAttribute_t[] inputAttribtues_hmd = new WVR_InputAttribute_t[1];
        inputAttribtues_hmd [0].id         = WVR_InputId.WVR_InputId_Alias1_Enter;
        inputAttribtues_hmd [0].capability = (uint)WVR_InputType.WVR_InputType_Button;
        inputAttribtues_hmd [0].axis_type  = WVR_AnalogType.WVR_AnalogType_None;

        WVR_DeviceType _type = WaveVR_Controller.Input(WaveVR_Controller.EDeviceType.Head).DeviceType;
        bool           _ret  = Interop.WVR_SetInputRequest(_type, inputAttribtues_hmd, (uint)inputAttribtues_hmd.Length);

        if (_ret)
        {
            uint inputTableSize = (uint)WVR_InputId.WVR_InputId_Max;
            WVR_InputMappingPair_t[] inputTable = new WVR_InputMappingPair_t[inputTableSize];
            uint _size = Interop.WVR_GetInputMappingTable(_type, inputTable, inputTableSize);
            if (_size > 0)
            {
                for (int _i = 0; _i < (int)_size; _i++)
                {
                    Log.d(LOG_TAG, Log.CSB
                          .Append("SetDefaultButtons() ")
                          .Append(_type.Name())
                          .Append(" button: ")
                          .Append(inputTable[_i].source.id)
                          .Append(" is mapping to HMD input ID: ")
                          .Append(inputTable[_i].destination.id)
                          .ToString());
                }
            }
        }
    }
        public override void OnActivated()
        {
            if (Object.FindObjectOfType <WaveVR_Init>() == null)
            {
                VRModule.Instance.gameObject.AddComponent <WaveVR_Init>();
            }

#if !UNITY_EDITOR && VIU_WAVEVR_3_0_0_OR_NEWER
            if (Object.FindObjectOfType <WaveVR_ButtonList>() == null)
            {
                VRModule.Instance.gameObject.AddComponent <WaveVR_ButtonList>();
            }
#endif

#if VIU_WAVEVR_3_0_0_OR_NEWER
            var digitalCapability = (uint)WVR_InputType.WVR_InputType_Button;
            var analogCapability  = (uint)(WVR_InputType.WVR_InputType_Button | WVR_InputType.WVR_InputType_Touch | WVR_InputType.WVR_InputType_Analog);
            var inputRequests     = new WVR_InputAttribute_t[]
            {
                new WVR_InputAttribute_t()
                {
                    id = WVR_InputId.WVR_InputId_Alias1_Menu, axis_type = WVR_AnalogType.WVR_AnalogType_None, capability = digitalCapability
                },
                new WVR_InputAttribute_t()
                {
                    id = WVR_InputId.WVR_InputId_Alias1_Grip, axis_type = WVR_AnalogType.WVR_AnalogType_None, capability = digitalCapability
                },
                new WVR_InputAttribute_t()
                {
                    id = WVR_InputId.WVR_InputId_Alias1_DPad_Left, axis_type = WVR_AnalogType.WVR_AnalogType_None, capability = digitalCapability
                },
                new WVR_InputAttribute_t()
                {
                    id = WVR_InputId.WVR_InputId_Alias1_DPad_Up, axis_type = WVR_AnalogType.WVR_AnalogType_None, capability = digitalCapability
                },
                new WVR_InputAttribute_t()
                {
                    id = WVR_InputId.WVR_InputId_Alias1_DPad_Right, axis_type = WVR_AnalogType.WVR_AnalogType_None, capability = digitalCapability
                },
                new WVR_InputAttribute_t()
                {
                    id = WVR_InputId.WVR_InputId_Alias1_DPad_Down, axis_type = WVR_AnalogType.WVR_AnalogType_None, capability = digitalCapability
                },
                new WVR_InputAttribute_t()
                {
                    id = WVR_InputId.WVR_InputId_Alias1_Volume_Up, axis_type = WVR_AnalogType.WVR_AnalogType_None, capability = digitalCapability
                },
                new WVR_InputAttribute_t()
                {
                    id = WVR_InputId.WVR_InputId_Alias1_Volume_Down, axis_type = WVR_AnalogType.WVR_AnalogType_None, capability = digitalCapability
                },
                new WVR_InputAttribute_t()
                {
                    id = WVR_InputId.WVR_InputId_Alias1_Enter, axis_type = WVR_AnalogType.WVR_AnalogType_None, capability = digitalCapability
                },

                new WVR_InputAttribute_t()
                {
                    id = WVR_InputId.WVR_InputId_Alias1_Touchpad, axis_type = WVR_AnalogType.WVR_AnalogType_2D, capability = analogCapability
                },
                new WVR_InputAttribute_t()
                {
                    id = WVR_InputId.WVR_InputId_Alias1_Thumbstick, axis_type = WVR_AnalogType.WVR_AnalogType_2D, capability = analogCapability
                },

                new WVR_InputAttribute_t()
                {
                    id = WVR_InputId.WVR_InputId_Alias1_Digital_Trigger, axis_type = WVR_AnalogType.WVR_AnalogType_1D, capability = analogCapability
                },
                new WVR_InputAttribute_t()
                {
                    id = WVR_InputId.WVR_InputId_Alias1_Trigger, axis_type = WVR_AnalogType.WVR_AnalogType_1D, capability = analogCapability
                },
            };

#if !UNITY_EDITOR
            Interop.WVR_SetInputRequest(WVR_DeviceType.WVR_DeviceType_Controller_Right, inputRequests, (uint)inputRequests.Length);
            Interop.WVR_SetInputRequest(WVR_DeviceType.WVR_DeviceType_Controller_Left, inputRequests, (uint)inputRequests.Length);
#endif
#endif

            EnsureDeviceStateLength(DEVICE_COUNT);

            UpdateTrackingSpaceType();

            s_moduleInstance = this;

            WaveVR_Utils.Event.Listen(WaveVR_Utils.Event.NEW_POSES, OnNewPoses);
        }