MCPcopy Create free account
hub / github.com/ValveSoftware/openvr / Activate

Method Activate

samples/drivers/drivers/tutorial/src/controller_device.cpp:5–33  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3ControllerDevice::ControllerDevice(vr::ETrackedControllerRole role) : role_(role), device_id_(vr::k_unTrackedDeviceIndexInvalid) {};
4
5vr::EVRInitError ControllerDevice::Activate(uint32_t unObjectId) {
6 vr::VRDriverLog()->Log("ControllerDevice::Activate");
7
8 const vr::PropertyContainerHandle_t container = vr::VRProperties()->TrackedDeviceToPropertyContainer(unObjectId);
9 vr::VRProperties()->SetInt32Property(container, vr::Prop_ControllerRoleHint_Int32, role_);
10
11 vr::VRProperties()->SetStringProperty(container, vr::Prop_ModelNumber_String, "MySampleControllerModel_1");
12
13 vr::VRProperties()->SetStringProperty(container, vr::Prop_InputProfilePath_String,
14 "{sample}/resources/input/sample_profile.json");
15
16 vr::VRDriverInput()->CreateBooleanComponent(container, "/input/a/click", &input_handles_[kInputHandle_A_click]);
17 vr::VRDriverInput()->CreateBooleanComponent(container, "/input/a/touch", &input_handles_[kInputHandle_A_touch]);
18
19 vr::VRDriverInput()->CreateScalarComponent(container, "/input/trigger/value", &input_handles_[kInputHandle_trigger_value],
20 vr::VRScalarType_Absolute, vr::VRScalarUnits_NormalizedOneSided);
21 vr::VRDriverInput()->CreateBooleanComponent(container, "/input/trigger/click", &input_handles_[kInputHandle_trigger_click]);
22
23 vr::VRDriverInput()->CreateScalarComponent(container, "/input/joystick/x", &input_handles_[kInputHandle_joystick_x],
24 vr::VRScalarType_Absolute, vr::VRScalarUnits_NormalizedTwoSided);
25 vr::VRDriverInput()->CreateScalarComponent(container, "/input/joystick/y", &input_handles_[kInputHandle_joystick_y],
26 vr::VRScalarType_Absolute, vr::VRScalarUnits_NormalizedTwoSided);
27 vr::VRDriverInput()->CreateBooleanComponent(container, "/input/joystick/click", &input_handles_[kInputHandle_joystick_click]);
28
29 vr::VRDriverInput()->CreateHapticComponent(container, "/output/haptic", &input_handles_[kInputHandle_haptic]);
30
31 device_id_ = unObjectId;
32 return vr::VRInitError_None;
33}
34
35void ControllerDevice::RunFrame() {
36 vr::VRServerDriverHost()->TrackedDevicePoseUpdated(device_id_, GetPose(), sizeof(vr::DriverPose_t));

Callers

nothing calls this directly

Calls 3

SetInt32PropertyMethod · 0.80
SetStringPropertyMethod · 0.80

Tested by

no test coverage detected