|
4 | 4 | using HTC.UnityPlugin.Vive; |
5 | 5 | using System; |
6 | 6 | using System.Collections.Generic; |
| 7 | +using System.Runtime.InteropServices; |
7 | 8 | using UnityEngine; |
8 | 9 | #if VIU_WAVEVR && UNITY_ANDROID |
9 | 10 | using wvr; |
@@ -543,7 +544,7 @@ private IVRModuleDeviceStateRW UpdateDevicePose(uint deviceIndex, WaveVR.Device |
543 | 544 | { |
544 | 545 | currState.isConnected = true; |
545 | 546 | currState.deviceClass = s_type2class[(int)content.type]; |
546 | | - currState.deviceModel = QueryDeviceModel(s_type2class[(int)content.type]); |
| 547 | + currState.deviceModel = QueryDeviceModel(s_index2type[(int)deviceIndex]); |
547 | 548 | currState.serialNumber = content.type.ToString(); |
548 | 549 | currState.modelNumber = content.type.ToString(); |
549 | 550 | currState.renderModelName = content.type.ToString(); |
@@ -798,27 +799,38 @@ public override void TriggerViveControllerHaptic(uint deviceIndex, ushort durati |
798 | 799 | } |
799 | 800 | } |
800 | 801 |
|
801 | | - private VRModuleDeviceModel QueryDeviceModel(VRModuleDeviceClass device) |
| 802 | + private VRModuleDeviceModel QueryDeviceModel(WVR_DeviceType device) |
802 | 803 | { |
803 | | - if (device.Equals(VRModuleDeviceClass.HMD)) |
| 804 | + switch (device) |
804 | 805 | { |
805 | | - return VRModuleDeviceModel.ViveFocusHMD; |
806 | | - } |
807 | | - else if (device.Equals(VRModuleDeviceClass.Controller)) |
808 | | - { |
809 | | - VRModuleDeviceModel model; |
810 | | - if (m_models.TryGetValue(WaveVR_Utils.GetControllerName(WaveVR_Controller.EDeviceType.Dominant), out model)) |
811 | | - { |
812 | | - return model; |
813 | | - } |
814 | | - else |
815 | | - { |
| 806 | + case WVR_DeviceType.WVR_DeviceType_HMD: |
| 807 | + return VRModuleDeviceModel.ViveFocusHMD; |
| 808 | + case WVR_DeviceType.WVR_DeviceType_Controller_Right: |
| 809 | + case WVR_DeviceType.WVR_DeviceType_Controller_Left: |
| 810 | + int buffer = 128; |
| 811 | + uint resultLength = 128; |
| 812 | + string parameterName = "GetRenderModelName"; |
| 813 | + IntPtr ptrParameterName = Marshal.StringToHGlobalAnsi(parameterName); |
| 814 | + IntPtr ptrResult = Marshal.AllocHGlobal(buffer); |
| 815 | + uint ret = Interop.WVR_GetParameters(device, ptrParameterName, ptrResult, resultLength); |
| 816 | + if (ret > 0) |
| 817 | + { |
| 818 | + VRModuleDeviceModel model; |
| 819 | + if (m_models.TryGetValue(Marshal.PtrToStringAnsi(ptrResult), out model)) |
| 820 | + { |
| 821 | + return model; |
| 822 | + } |
| 823 | + else |
| 824 | + { |
| 825 | + return VRModuleDeviceModel.Unknown; |
| 826 | + } |
| 827 | + } |
| 828 | + else |
| 829 | + { |
| 830 | + return VRModuleDeviceModel.Unknown; |
| 831 | + } |
| 832 | + default: |
816 | 833 | return VRModuleDeviceModel.Unknown; |
817 | | - } |
818 | | - } |
819 | | - else |
820 | | - { |
821 | | - return VRModuleDeviceModel.Unknown; |
822 | 834 | } |
823 | 835 | } |
824 | 836 |
|
|
0 commit comments