Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions driver/slimevr/resources/driver.vrresources
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"jsonid" : "vrresources",
"statusicons" : {
"Tracker" : {
"Prop_NamedIconPathDeviceOff_String": "{slimevr}/icons/tracker_status_off.png",
"Prop_NamedIconPathDeviceSearching_String": "{slimevr}/icons/tracker_status_ready.png",
"Prop_NamedIconPathDeviceSearchingAlert_String": "{slimevr}/icons/tracker_status_ready_alert.png",
"Prop_NamedIconPathDeviceReady_String": "{slimevr}/icons/tracker_status_ready.png",
"Prop_NamedIconPathDeviceReadyAlert_String": "{slimevr}/icons/tracker_status_ready_alert.png",
"Prop_NamedIconPathDeviceNotReady_String": "{slimevr}/icons/tracker_status_error.png",
"Prop_NamedIconPathDeviceStandby_String": "{slimevr}/icons/tracker_status_standby.png",
"Prop_NamedIconPathDeviceAlertLow_String": "{slimevr}/icons/tracker_status_ready_low.png"
}
}
}
2 changes: 1 addition & 1 deletion src/IVRDriver.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ namespace SlimeVRDriver {
*
* @return A vector of current frame's OpenVR events.
*/
virtual std::vector<vr::VREvent_t> GetOpenVREvents() = 0;
virtual const std::vector<vr::VREvent_t>& GetOpenVREvents() = 0;

/**
* Returns the milliseconds between last frame and this frame.
Expand Down
32 changes: 6 additions & 26 deletions src/TrackerDevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ void SlimeVRDriver::TrackerDevice::Update() {
if (device_index_ == vr::k_unTrackedDeviceIndexInvalid) return;

// Check if this device was asked to be identified
auto events = GetDriver()->GetOpenVREvents();
for (auto event : events) {
auto& events = GetDriver()->GetOpenVREvents();
for (const auto& event : events) {
// Note here, event.trackedDeviceIndex does not necessarily equal device_index_, not sure why, but the component handle will match so we can just use that instead
//if (event.trackedDeviceIndex == device_index_) {
if (event.eventType == vr::EVREventType::VREvent_Input_HapticVibration) {
Expand Down Expand Up @@ -153,38 +153,18 @@ vr::EVRInitError SlimeVRDriver::TrackerDevice::Activate(uint32_t unObjectId) {

logger_->Log("Activating tracker {}", serial_);

// Get the properties handle
auto props = GetDriver()->GetProperties()->TrackedDeviceToPropertyContainer(device_index_);

// Set some universe ID (Must be 2 or higher)
GetDriver()->GetProperties()->SetUint64Property(props, vr::Prop_CurrentUniverseId_Uint64, 4);

// Set up a model "number" (not needed but good to have)
GetDriver()->GetProperties()->SetStringProperty(props, vr::Prop_ManufacturerName_String, "SlimeVR");
GetDriver()->GetProperties()->SetStringProperty(props, vr::Prop_ModelNumber_String, "SlimeVR Virtual Tracker");

// Opt out of hand selection
GetDriver()->GetProperties()->SetInt32Property(props, vr::Prop_ControllerRoleHint_Int32, vr::ETrackedControllerRole::TrackedControllerRole_OptOut);
vr::VRProperties()->SetInt32Property(props, vr::Prop_DeviceClass_Int32, vr::TrackedDeviceClass_GenericTracker);
vr::VRProperties()->SetInt32Property(props, vr::Prop_ControllerHandSelectionPriority_Int32, -1);

// Set up a render model path
GetDriver()->GetProperties()->SetStringProperty(props, vr::Prop_RenderModelName_String, "{htc}/rendermodels/vr_tracker_vive_1_0");

// Set the icon
GetDriver()->GetProperties()->SetStringProperty(props, vr::Prop_NamedIconPathDeviceReady_String, "{slimevr}/icons/tracker_status_ready.png");

GetDriver()->GetProperties()->SetStringProperty(props, vr::Prop_NamedIconPathDeviceOff_String, "{slimevr}/icons/tracker_status_off.png");
GetDriver()->GetProperties()->SetStringProperty(props, vr::Prop_NamedIconPathDeviceSearching_String, "{slimevr}/icons/tracker_status_ready.png");
GetDriver()->GetProperties()->SetStringProperty(props, vr::Prop_NamedIconPathDeviceSearchingAlert_String, "{slimevr}/icons/tracker_status_ready_alert.png");
GetDriver()->GetProperties()->SetStringProperty(props, vr::Prop_NamedIconPathDeviceReadyAlert_String, "{slimevr}/icons/tracker_status_ready_alert.png");
GetDriver()->GetProperties()->SetStringProperty(props, vr::Prop_NamedIconPathDeviceNotReady_String, "{slimevr}/icons/tracker_status_error.png");
GetDriver()->GetProperties()->SetStringProperty(props, vr::Prop_NamedIconPathDeviceStandby_String, "{slimevr}/icons/tracker_status_standby.png");
GetDriver()->GetProperties()->SetStringProperty(props, vr::Prop_NamedIconPathDeviceAlertLow_String, "{slimevr}/icons/tracker_status_ready_low.png");

// Some device properties will be derived at runtime by SteamVR
// using the profile, such as the device class and controller type
GetDriver()->GetProperties()->SetStringProperty(props, vr::Prop_InputProfilePath_String, "{slimevr}/input/slimevr_tracker_profile.json");

GetDriver()->GetProperties()->SetStringProperty(props, vr::Prop_ControllerType_String, "slimevr_tracker");

// Doesn't apply until restart of SteamVR
auto role = GetViveRole(tracker_role_);
if (role != "") {
vr::VRSettings()->SetString(vr::k_pch_Trackers_Section, ("/devices/slimevr/" + serial_).c_str(), role.c_str());
Expand Down
10 changes: 7 additions & 3 deletions src/TrackerRole.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,14 @@ std::string GetViveRoleHint(TrackerRole role) {

std::string GetViveRole(TrackerRole role) {
switch (role) {
case LEFT_CONTROLLER:
case RIGHT_CONTROLLER:
case GENERIC_CONTROLLER:
return "TrackerRole_Handed";
case LEFT_CONTROLLER:
case LEFT_HAND:
return "TrackerRole_Handed,TrackedControllerRole_LeftHand";
case RIGHT_CONTROLLER:
case RIGHT_HAND:
return "TrackerRole_Handed";
return "TrackerRole_Handed,TrackedControllerRole_RightHand";
case LEFT_FOOT:
return "TrackerRole_LeftFoot";
case RIGHT_FOOT:
Expand Down Expand Up @@ -97,7 +99,9 @@ std::string GetViveRole(TrackerRole role) {
DeviceType GetDeviceType(TrackerRole role) {
switch (role) {
case LEFT_CONTROLLER:
case LEFT_HAND:
case RIGHT_CONTROLLER:
case RIGHT_HAND:
case GENERIC_CONTROLLER:
return DeviceType::CONTROLLER;
case HMD:
Expand Down
7 changes: 3 additions & 4 deletions src/VRDriver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,6 @@ void SlimeVRDriver::VRDriver::RunPoseRequestThread() {
if (result.has_value()) {
current_universe_.emplace(universe, result.value());
logger_->Log("Found current universe");
} else {
logger_->Log("Failed to find current universe!");
}
}
} else if (universe_error != last_universe_error_) {
Expand Down Expand Up @@ -216,6 +214,7 @@ void SlimeVRDriver::VRDriver::OnBridgeMessage(const messages::ProtobufMessage& m
messages::TrackerAdded ta = message.tracker_added();
switch(GetDeviceType(static_cast<TrackerRole>(ta.tracker_role()))) {
case DeviceType::TRACKER:
case DeviceType::CONTROLLER:
AddDevice(std::make_shared<TrackerDevice>(ta.tracker_serial(), ta.tracker_id(), static_cast<TrackerRole>(ta.tracker_role())));
break;
}
Expand Down Expand Up @@ -266,7 +265,7 @@ std::vector<std::shared_ptr<SlimeVRDriver::IVRDevice>> SlimeVRDriver::VRDriver::
return devices;
}

std::vector<vr::VREvent_t> SlimeVRDriver::VRDriver::GetOpenVREvents() {
const std::vector<vr::VREvent_t>& SlimeVRDriver::VRDriver::GetOpenVREvents() {
return openvr_events_;
}

Expand Down Expand Up @@ -455,7 +454,7 @@ std::optional<SlimeVRDriver::UniverseTranslation> SlimeVRDriver::VRDriver::Searc
}
}

if (default_chap_path_.has_value()) {
if (default_chap_path_.has_value() && std::filesystem::exists(default_chap_path_.value())) {
try {
return SearchUniverse(simdjson::padded_string::load(default_chap_path_.value()).take_value(), target);
}
Expand Down
2 changes: 1 addition & 1 deletion src/VRDriver.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ namespace SlimeVRDriver {
public:
// Inherited via IVRDriver
virtual std::vector<std::shared_ptr<IVRDevice>> GetDevices() override;
virtual std::vector<vr::VREvent_t> GetOpenVREvents() override;
virtual const std::vector<vr::VREvent_t>& GetOpenVREvents() override;
virtual std::chrono::milliseconds GetLastFrameTime() override;
virtual bool AddDevice(std::shared_ptr<IVRDevice> device) override;
virtual SettingsValue GetSettingsValue(std::string key) override;
Expand Down