public override void OnConnectedDeviceChanged(uint deviceIndex, VRModuleDeviceClass deviceClass, string deviceSN, bool connected) { if (deviceClass == VRModuleDeviceClass.Controller) { Refresh(); } }
public static void BindAllCurrentDeviceClassMappings(VRModuleDeviceClass deviceClass) { for (int i = 0, imax = ViveRoleEnum.ValidViveRoleTable.Count; i < imax; ++i) { var roleMap = ViveRole.GetMap(ViveRoleEnum.ValidViveRoleTable.GetValueByIndex(i)); var roleInfo = roleMap.RoleValueInfo; for (int rv = roleInfo.MinValidRoleValue, rvmax = roleInfo.MaxValidRoleValue; rv <= rvmax; ++rv) { if (!roleInfo.IsValidRoleValue(rv)) { continue; } if (roleMap.IsRoleValueBound(rv)) { continue; } var mappedDevice = roleMap.GetMappedDeviceByRoleValue(rv); var mappedDeviceState = VRModule.GetCurrentDeviceState(mappedDevice); if (mappedDeviceState.deviceClass != deviceClass) { continue; } roleMap.BindDeviceToRoleValue(mappedDeviceState.serialNumber, rv); } } }
public void OnConnectedDeviceChanged(uint deviceIndex, VRModuleDeviceClass deviceClass, string deviceSN, bool connected) { if (connected) { if (IsDeviceBound(deviceSN)) { InternalInsertRoleBoundDevice(deviceSN, deviceIndex, GetBoundRoleValueByDevice(deviceSN)); } } else { if (IsDeviceMapped(deviceIndex)) { if (IsDeviceBound(deviceSN)) { InternalRemoveRoleBoundDevice(deviceSN, deviceIndex, GetBoundRoleValueByDevice(deviceSN)); } if (IsDeviceMapped(deviceIndex)) { InternalUnmapping(GetMappedRoleValueByDevice(deviceIndex), deviceIndex); } } } if (m_handler != null) { m_handler.OnConnectedDeviceChanged(deviceIndex, deviceClass, deviceSN, connected); } }
public override void OnConnectedDeviceChanged(uint deviceIndex, VRModuleDeviceClass deviceClass, string deviceSN, bool connected) { if (!RoleMap.IsDeviceBound(deviceSN) && deviceClass != VRModuleDeviceClass.TrackedHand) { return; } Refresh(); }
public override void OnConnectedDeviceChanged(uint deviceIndex, VRModuleDeviceClass deviceClass, string deviceSN, bool connected) { if (!RoleMap.IsDeviceBound(deviceSN) && !IsController(deviceClass) && !IsTracker(deviceClass)) { return; } Refresh(); }
public override void OnConnectedDeviceChanged(uint deviceIndex, VRModuleDeviceClass deviceClass, string deviceSN, bool connected) { if (connected) { if (RoleMap.IsDeviceBound(deviceSN)) { return; } } else { return; } Refresh(); }
public void Update(uint index) { var deviceState = VRModule.GetDeviceState(index); deviceIndex = index; serialNumber = deviceState.serialNumber; modelNumber = deviceState.modelNumber; renderModelName = deviceState.renderModelName; deviceClass = deviceState.deviceClass; deviceModel = deviceState.deviceModel; input2DType = deviceState.input2DType; isConnected = deviceState.isConnected; isPoseValid = deviceState.isPoseValid; isOutOfRange = deviceState.isOutOfRange; isCalibrating = deviceState.isCalibrating; isUninitialized = deviceState.isUninitialized; velocity = deviceState.velocity; angularVelocity = deviceState.angularVelocity; pose = deviceState.pose; UpdateFieldString <VRModuleRawButton>(ref pressedFields, deviceState.buttonPressed, pressed); UpdateFieldString <VRModuleRawButton>(ref touchedFields, deviceState.buttonTouched, touched); foreach (VRModuleRawAxis i in axisValue.Enums) { axisValue[i] = deviceState.GetAxisValue(i); } jointCount = 0; if (deviceState.readOnlyHandJoints != null) { foreach (var p in deviceState.readOnlyHandJoints.EnumValues) { handJoints[p.Key] = p.Value; if (p.Value.isValid) { jointCount++; } } } }
public void CopyFrom(DeviceState state) { m_serialNumber = state.m_serialNumber; m_modelNumber = state.m_modelNumber; m_renderModelName = state.m_renderModelName; m_deviceClass = state.m_deviceClass; m_deviceModel = state.m_deviceModel; m_isPoseValid = state.m_isPoseValid; m_isConnected = state.m_isConnected; m_isOutOfRange = state.m_isOutOfRange; m_isCalibrating = state.m_isCalibrating; m_isUninitialized = state.m_isUninitialized; m_velocity = state.m_velocity; m_angularVelocity = state.m_angularVelocity; m_position = state.m_position; m_rotation = state.m_rotation; m_buttonPressed = state.m_buttonPressed; m_buttonTouched = state.m_buttonTouched; Array.Copy(state.m_axisValue, m_axisValue, m_axisValue.Length); }
public void CopyFrom(DeviceState state) { m_serialNumber = state.m_serialNumber; m_modelNumber = state.m_modelNumber; m_renderModelName = state.m_renderModelName; m_deviceClass = state.m_deviceClass; m_deviceModel = state.m_deviceModel; m_input2DType = state.m_input2DType; m_isPoseValid = state.m_isPoseValid; m_isConnected = state.m_isConnected; m_isOutOfRange = state.m_isOutOfRange; m_isCalibrating = state.m_isCalibrating; m_isUninitialized = state.m_isUninitialized; m_velocity = state.m_velocity; m_angularVelocity = state.m_angularVelocity; m_position = state.m_position; m_rotation = state.m_rotation; m_buttonPressed = state.m_buttonPressed; m_buttonTouched = state.m_buttonTouched; Array.Copy(state.m_axisValue, m_axisValue, m_axisValue.Length); if (state.m_handJoints == null) { m_handJoints = null; } else { if (m_handJoints == null) { m_handJoints = new JointEnumArray(); } m_handJoints.CopyFrom(state.m_handJoints); } }
private bool IsTracker(VRModuleDeviceClass deviceClass) { return(deviceClass == VRModuleDeviceClass.GenericTracker); }
public virtual void OnConnectedDeviceChanged(uint deviceIndex, VRModuleDeviceClass deviceClass, string deviceSN, bool connected) { }
private bool IsTrackingDevice(VRModuleDeviceClass deviceClass) { return(deviceClass == VRModuleDeviceClass.HMD || deviceClass == VRModuleDeviceClass.Controller || deviceClass == VRModuleDeviceClass.GenericTracker); }
private bool IsController(VRModuleDeviceClass deviceClass) { return(deviceClass == VRModuleDeviceClass.Controller); }
private bool IsTrackedHand(VRModuleDeviceClass deviceClass) { return(deviceClass == VRModuleDeviceClass.TrackedHand); }