|
| 1 | +#include "DummyController.h" |
| 2 | + |
| 3 | +DummyController::DummyController() |
| 4 | +{ |
| 5 | +} |
| 6 | + |
| 7 | +DummyController::DummyController(std::string serial, bool side, DriverPose_t initial_pose, VRControllerState_t initial_state) : |
| 8 | + serial_(serial), |
| 9 | + side_(side), |
| 10 | + controller_pose_(initial_pose), |
| 11 | + controller_state_(initial_state) |
| 12 | +{ |
| 13 | +} |
| 14 | + |
| 15 | +DummyController::~DummyController() |
| 16 | +{ |
| 17 | +} |
| 18 | + |
| 19 | +void DummyController::updateControllerState(VRControllerState_t new_state) |
| 20 | +{ |
| 21 | + controller_state_ = new_state; |
| 22 | +} |
| 23 | + |
| 24 | +void DummyController::updateControllerPose(DriverPose_t new_pose) |
| 25 | +{ |
| 26 | + controller_pose_ = new_pose; |
| 27 | +} |
| 28 | + |
| 29 | +uint32_t DummyController::getObjectID() |
| 30 | +{ |
| 31 | + return object_id_; |
| 32 | +} |
| 33 | + |
| 34 | +VRControllerState_t DummyController::GetControllerState() |
| 35 | +{ |
| 36 | + return controller_state_; |
| 37 | +} |
| 38 | + |
| 39 | +bool DummyController::TriggerHapticPulse(uint32_t unAxisId, uint16_t usPulseDurationMicroseconds) |
| 40 | +{ |
| 41 | + return false; |
| 42 | +} |
| 43 | + |
| 44 | +EVRInitError DummyController::Activate(uint32_t unObjectId) |
| 45 | +{ |
| 46 | + object_id_ = unObjectId; |
| 47 | + |
| 48 | + PropertyContainerHandle_t prop_handle = VRProperties()->TrackedDeviceToPropertyContainer(unObjectId); |
| 49 | + |
| 50 | + VRProperties()->SetBoolProperty(prop_handle, vr::Prop_WillDriftInYaw_Bool, false); |
| 51 | + VRProperties()->SetBoolProperty(prop_handle, vr::Prop_DeviceIsWireless_Bool, true); |
| 52 | + VRProperties()->SetBoolProperty(prop_handle, vr::Prop_HasControllerComponent_Bool, true); |
| 53 | + |
| 54 | + if (side_) { |
| 55 | + VRProperties()->SetInt32Property(prop_handle, vr::Prop_ControllerRoleHint_Int32, ETrackedControllerRole::TrackedControllerRole_RightHand); |
| 56 | + }else { |
| 57 | + VRProperties()->SetInt32Property(prop_handle, vr::Prop_ControllerRoleHint_Int32, ETrackedControllerRole::TrackedControllerRole_LeftHand); |
| 58 | + } |
| 59 | + |
| 60 | + VRProperties()->SetInt32Property(prop_handle, vr::Prop_Axis0Type_Int32, vr::k_eControllerAxis_TrackPad); |
| 61 | + VRProperties()->SetInt32Property(prop_handle, vr::Prop_Axis1Type_Int32, vr::k_eControllerAxis_Trigger); |
| 62 | + |
| 63 | + VRProperties()->SetStringProperty(prop_handle, Prop_SerialNumber_String, serial_.c_str()); |
| 64 | + VRProperties()->SetStringProperty(prop_handle, Prop_ModelNumber_String, "Vive Controller MV"); |
| 65 | + VRProperties()->SetStringProperty(prop_handle, Prop_RenderModelName_String, "vr_controller_vive_1_5"); |
| 66 | + VRProperties()->SetStringProperty(prop_handle, Prop_ManufacturerName_String, "HTC"); |
| 67 | + |
| 68 | + uint64_t available_buttons = vr::ButtonMaskFromId(vr::k_EButton_ApplicationMenu) | |
| 69 | + vr::ButtonMaskFromId(vr::k_EButton_SteamVR_Touchpad) | |
| 70 | + vr::ButtonMaskFromId(vr::k_EButton_SteamVR_Trigger) | |
| 71 | + vr::ButtonMaskFromId(vr::k_EButton_System) | |
| 72 | + vr::ButtonMaskFromId(vr::k_EButton_Grip); |
| 73 | + |
| 74 | + vr::VRProperties()->SetUint64Property(prop_handle, Prop_SupportedButtons_Uint64, available_buttons); |
| 75 | + |
| 76 | + return EVRInitError::VRInitError_None; |
| 77 | +} |
| 78 | + |
| 79 | +void DummyController::Deactivate() |
| 80 | +{ |
| 81 | +} |
| 82 | + |
| 83 | +void DummyController::EnterStandby() |
| 84 | +{ |
| 85 | +} |
| 86 | + |
| 87 | +void * DummyController::GetComponent(const char * pchComponentNameAndVersion) |
| 88 | +{ |
| 89 | + if (0 == strcmp(IVRControllerComponent_Version, pchComponentNameAndVersion)) |
| 90 | + { |
| 91 | + return (vr::IVRControllerComponent*)this; |
| 92 | + } |
| 93 | + |
| 94 | + return NULL; |
| 95 | +} |
| 96 | + |
| 97 | +void DummyController::DebugRequest(const char * pchRequest, char * pchResponseBuffer, uint32_t unResponseBufferSize) |
| 98 | +{ |
| 99 | + if (unResponseBufferSize >= 1) |
| 100 | + pchResponseBuffer[0] = 0; |
| 101 | +} |
| 102 | + |
| 103 | +DriverPose_t DummyController::GetPose() |
| 104 | +{ |
| 105 | + return controller_pose_; |
| 106 | +} |
0 commit comments