//protected Peripheralstatus peripheralstatus = null; //protected Peripheralstatus prevperipheralstatus = null; public virtual bool OpenPeripheral(DPNP_DEVICE_TYPE type, int index) { if (DpnDevice._instance == null) { DpnDevice.create(); } #if UNITY_ANDROID && !UNITY_EDITOR if (type == DPNP_DEVICE_TYPE.DPNP_DEVICE_TYPE_HEAD_TRACKER) { peripheral = DpnDevice.OpenPeripheral(string.Empty, this); return(true); } #endif int count = DpnPeripheral.DpnupQueryDeviceCount(type); if (count < 0 || index >= count) { return(false); } string devicename = DpnPeripheral.DpnupGetDeviceId(type, index); if (devicename != null) { return(OpenPeripheral(devicename)); } return(false); }
public string DpnupGetAssociatedDevice(DPNP_DEVICE_TYPE type) { if (_device != IntPtr.Zero) { return(Marshal.PtrToStringAnsi(DpnpUnity.DpnupGetAssociatedDevice(_device, type))); } return(""); }
public override bool OpenPeripheral(DPNP_DEVICE_TYPE type, int index) { bool ret = base.OpenPeripheral(type, index); if (ret && (DpnManager.controllerKeyMode == DPVRKeyMode.STEAM)) { if (!SteamController.ContainsKey(index) || SteamController[index] == null) { SteamControllerPeripheral = new DPVR_Steam_Controller_Peripheral(peripheral, device_type); SteamController.Add(index, SteamControllerPeripheral); } else { SteamControllerPeripheral = SteamController[index]; } } return(ret); }
public static string DpnupGetDeviceId(DPNP_DEVICE_TYPE type, int index) { return(Marshal.PtrToStringAnsi(DpnpUnity.DpnupGetDeviceId(type, index))); }
public static int DpnupQueryDeviceCount(DPNP_DEVICE_TYPE type) { return(DpnpUnity.DpnupQueryDeviceCount(type)); }
public void OnEnable() { if (DpnManager.peripheral != DPVRPeripheral.Polaris) { this.gameObject.SetActive(false); return; } DPNP_DEVICE_TYPE type = DPNP_DEVICE_TYPE.DPNP_DEVICE_TYPE_NONE; switch (device_type) { case DPVRControllerType.DPVR_CONTROLLER_LEFT: type = DPNP_DEVICE_TYPE.DPNP_DEVICE_TYPE_LEFT_CONTROLLER; break; case DPVRControllerType.DPVR_CONTROLLER_RIGHT: type = DPNP_DEVICE_TYPE.DPNP_DEVICE_TYPE_RIGHT_CONTROLLER; break; case DPVRControllerType.DPVR_CONTROLLER_MR: type = DPNP_DEVICE_TYPE.DPNP_DEVICE_TYPE_MR_CONTROLLER; break; } if (!OpenPeripheral(type, device_index)) { Debug.Log("Open Peripheral type: " + type.ToString() + " index:" + device_index.ToString() + " fails."); return; } switch (DpnManager.controllerKeyMode) { case DPVRKeyMode.DPVR: { _dpvrController = this.GetComponent <DPVR_Controller>(); if (_dpvrController == null) { _dpvrController = this.gameObject.AddComponent <DPVR_Controller>(); } if (this.GetComponent <DPVR_STEAM_Controller>() != null) { Destroy(this.GetComponent <DPVR_STEAM_Controller>()); } break; } case DPVRKeyMode.STEAM: { _dpvrSteamController = this.GetComponent <DPVR_STEAM_Controller>(); if (_dpvrSteamController == null) { _dpvrSteamController = this.gameObject.AddComponent <DPVR_STEAM_Controller>(); } if (this.GetComponent <DPVR_Controller>() != null) { Destroy(this.GetComponent <DPVR_Controller>()); } break; } } if (DpnManager.DPVRPointer) { _pointer = Instantiate(reticlePointer); _pointer.SetParent(this.transform, false); _pointer.localPosition = new Vector3(0, 0, 2); _pointer.gameObject.SetActive(false); } if (peripheral != null) { int event_mask = (int)DPNP_EVENT_TYPE.DPNP_EVENT_TYPE_BASE_A_TRACK | (int)DPNP_EVENT_TYPE.DPNP_EVENT_TYPE_BASE_A_UNTRACK | (int)DPNP_EVENT_TYPE.DPNP_EVENT_TYPE_BASE_B_TRACK | (int)DPNP_EVENT_TYPE.DPNP_EVENT_TYPE_BASE_B_UNTRACK; peripheral.DpnupRegisterEventNotificationFunction(null, event_mask, IntPtr.Zero); } EnableInternalObjects(false); }