EVRInitError Activate( vr::TrackedDeviceIndex_t unObjectId ) { m_unObjectId = unObjectId; m_ulPropertyContainer = vr::VRProperties()->TrackedDeviceToPropertyContainer( m_unObjectId ); // set make and model strings vr::VRProperties()->SetStringProperty(m_ulPropertyContainer, Prop_ManufacturerName_String, m_sManufacturer.c_str()); vr::VRProperties()->SetStringProperty( m_ulPropertyContainer, Prop_ModelNumber_String, m_sModelNumber.c_str() ); vr::VRProperties()->SetStringProperty( m_ulPropertyContainer, Prop_RenderModelName_String, m_sModelNumber.c_str() ); vr::VRProperties()->SetStringProperty(m_ulPropertyContainer, Prop_InputProfilePath_String, m_sInputProfile.c_str()); // return a constant that's not 0 (invalid) or 1 (reserved for Oculus) vr::VRProperties()->SetUint64Property( m_ulPropertyContainer, Prop_CurrentUniverseId_Uint64, 2 ); // define which button our driver can use uint64_t ulRetVal; ulRetVal = vr::ButtonMaskFromId(vr::k_EButton_Axis0); //vr::ButtonMaskFromId(vr::k_EButton_System) | //vr::ButtonMaskFromId(vr::k_EButton_Axis1); vr::VRProperties()->SetUint64Property(m_ulPropertyContainer, Prop_SupportedButtons_Uint64, ulRetVal); // enable the analog axis setting vr::VRProperties()->SetInt32Property(m_ulPropertyContainer, Prop_Axis0Type_Int32, vr::k_eControllerAxis_TrackPad); // Icons can be configured in code or automatically configured by an external file "drivername\resources\driver.vrresources". // Icon properties NOT configured in code (post Activate) are then auto-configured by the optional presence of a driver's "drivername\resources\driver.vrresources". // In this manner a driver can configure their icons in a flexible data driven fashion by using an external file. // // The structure of the driver.vrresources file allows a driver to specialize their icons based on their HW. // Keys matching the value in "Prop_ModelNumber_String" are considered first, since the driver may have model specific icons. // An absence of a matching "Prop_ModelNumber_String" then considers the ETrackedDeviceClass ("HMD", "Controller", "GenericTracker", "TrackingReference") // since the driver may have specialized icons based on those device class names. // // An absence of either then falls back to the "system.vrresources" where generic device class icons are then supplied. // // Please refer to "bin\drivers\sample\resources\driver.vrresources" which contains this sample configuration. // // "Alias" is a reserved key and specifies chaining to another json block. // // In this sample configuration file (overly complex FOR EXAMPLE PURPOSES ONLY).... // // "Model-v2.0" chains through the alias to "Model-v1.0" which chains through the alias to "Model-v Defaults". // // Keys NOT found in "Model-v2.0" would then chase through the "Alias" to be resolved in "Model-v1.0" and either resolve their or continue through the alias. // Thus "Prop_NamedIconPathDeviceAlertLow_String" in each model's block represent a specialization specific for that "model". // Keys in "Model-v Defaults" are an example of mapping to the same states, and here all map to "Prop_NamedIconPathDeviceOff_String". // bool bSetupIconUsingExternalResourceFile = false; if ( !bSetupIconUsingExternalResourceFile ) { // Setup properties directly in code. // Path values are of the form {drivername}\icons\some_icon_filename.png vr::VRProperties()->SetStringProperty( m_ulPropertyContainer, vr::Prop_NamedIconPathDeviceOff_String, "{omnideck}/icons/barebones_status_off.png" ); vr::VRProperties()->SetStringProperty( m_ulPropertyContainer, vr::Prop_NamedIconPathDeviceSearching_String, "{omnideck}/icons/barebones_status_searching.gif" ); vr::VRProperties()->SetStringProperty( m_ulPropertyContainer, vr::Prop_NamedIconPathDeviceSearchingAlert_String, "{omnideck}/icons/barebones_status_searching_alert.gif" ); vr::VRProperties()->SetStringProperty( m_ulPropertyContainer, vr::Prop_NamedIconPathDeviceReady_String, "{omnideck}/icons/barebones_status_ready.png" ); vr::VRProperties()->SetStringProperty( m_ulPropertyContainer, vr::Prop_NamedIconPathDeviceReadyAlert_String, "{omnideck}/icons/barebones_status_ready_alert.png" ); vr::VRProperties()->SetStringProperty( m_ulPropertyContainer, vr::Prop_NamedIconPathDeviceNotReady_String, "{omnideck}/icons/barebones_status_error.png" ); vr::VRProperties()->SetStringProperty( m_ulPropertyContainer, vr::Prop_NamedIconPathDeviceStandby_String, "{omnideck}/icons/barebones_status_standby.png" ); vr::VRProperties()->SetStringProperty( m_ulPropertyContainer, vr::Prop_NamedIconPathDeviceAlertLow_String, "{omnideck}/icons/barebones_status_ready_low.png" ); } DriverLog("Set role to treadmill: %d\n", unObjectId); ETrackedPropertyError propertyError = vr::VRProperties()->SetInt32Property(m_ulPropertyContainer, Prop_ControllerRoleHint_Int32, vr::TrackedControllerRole_Treadmill); DriverLog("Result: %d\n", propertyError); DriverLog("Set never tracked pose: %d\n", unObjectId); propertyError = vr::VRProperties()->SetBoolProperty(m_ulPropertyContainer, Prop_NeverTracked_Bool, false); DriverLog("Result: %d\n", propertyError); DriverLog("CreateScalarComponent /input/trackpad/x for: %d\n", unObjectId); EVRInputError inputError = vr::VRDriverInput()->CreateScalarComponent(m_ulPropertyContainer, "/input/trackpad/x", &m_ulInputComponentHandleTouchpadX, EVRScalarType::VRScalarType_Absolute, EVRScalarUnits::VRScalarUnits_NormalizedTwoSided); DriverLog("Result: %d handle: %d\n", inputError, m_ulInputComponentHandleTouchpadX); DriverLog("CreateScalarComponent /input/trackpad/y for: %d\n", unObjectId); inputError = vr::VRDriverInput()->CreateScalarComponent(m_ulPropertyContainer, "/input/trackpad/y", &m_ulInputComponentHandleTouchpadY, EVRScalarType::VRScalarType_Absolute, EVRScalarUnits::VRScalarUnits_NormalizedTwoSided); DriverLog("Result: %d handle: %d\n", inputError, m_ulInputComponentHandleTouchpadY); DriverLog("CreateBooleanComponent /input/trackpad/touch for: %d\n", unObjectId); inputError = vr::VRDriverInput()->CreateBooleanComponent(m_ulPropertyContainer, "/input/trackpad/touch", &m_ulInputComponentHandleTouchpadTouch); DriverLog("Result: %d handle: %d\n", inputError, m_ulInputComponentHandleTouchpadTouch); DriverLog("CreateBooleanComponent /input/trackpad/click for: %d\n", unObjectId); inputError = vr::VRDriverInput()->CreateBooleanComponent(m_ulPropertyContainer, "/input/trackpad/click", &m_ulInputComponentHandleTouchpadPress); DriverLog("Result: %d handle: %d\n", inputError, m_ulInputComponentHandleTouchpadPress); /* DriverLog("CreateBooleanComponent /input/trigger/click for: %d\n", unObjectId); inputError = vr::VRDriverInput()->CreateBooleanComponent(m_ulPropertyContainer, "/input/trigger/click", &m_ulInputComponentHandleTriggerPress); DriverLog("Result: %d handle: %d\n", inputError, m_ulInputComponentHandleTriggerPress); DriverLog("CreateScalarComponent /input/trigger/value for: %d\n", unObjectId); inputError = vr::VRDriverInput()->CreateScalarComponent(m_ulPropertyContainer, "/input/trigger/value", &m_ulInputComponentHandleTriggerX, EVRScalarType::VRScalarType_Absolute, EVRScalarUnits::VRScalarUnits_NormalizedOneSided); DriverLog("Result: %d handle: %d\n", inputError, m_ulInputComponentHandleTriggerX); DriverLog("CreateBooleanComponent /input/grip/click for: %d\n", unObjectId); inputError = vr::VRDriverInput()->CreateBooleanComponent(m_ulPropertyContainer, "/input/grip/click", &m_ulInputComponentHandleGripPress); DriverLog("Result: %d handle: %d\n", inputError, m_ulInputComponentHandleGripPress); */ vr::VRProperties()->SetBoolProperty(m_ulPropertyContainer, vr::Prop_DeviceCanPowerOff_Bool, true); DriverLog("Finished Activate()\n"); return VRInitError_None; }