-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bf16b86
commit c1a3608
Showing
6 changed files
with
204 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
src/openxr/extensions/xr_htc_vive_tracker_extension_wrapper.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
#include "xr_htc_vive_tracker_extension_wrapper.h" | ||
|
||
XRHTCViveTrackerExtensionWrapper *XRHTCViveTrackerExtensionWrapper::singleton = nullptr; | ||
|
||
XRHTCViveTrackerExtensionWrapper *XRHTCViveTrackerExtensionWrapper::get_singleton() { | ||
if (!singleton) { | ||
singleton = new XRHTCViveTrackerExtensionWrapper(); | ||
} | ||
|
||
return singleton; | ||
} | ||
|
||
XRHTCViveTrackerExtensionWrapper::XRHTCViveTrackerExtensionWrapper() { | ||
openxr_api = OpenXRApi::openxr_get_api(); | ||
|
||
request_extensions[XR_HTCX_VIVE_TRACKER_INTERACTION_EXTENSION_NAME] = &available; | ||
} | ||
|
||
XRHTCViveTrackerExtensionWrapper::~XRHTCViveTrackerExtensionWrapper() { | ||
OpenXRApi::openxr_release_api(); | ||
} | ||
|
||
bool XRHTCViveTrackerExtensionWrapper::is_available() { | ||
return available; | ||
} | ||
|
||
void XRHTCViveTrackerExtensionWrapper::add_input_maps() { | ||
if (available) { | ||
openxr_api->add_input_map("/user/vive_tracker_htcx/role/left_foot"); | ||
openxr_api->add_input_map("/user/vive_tracker_htcx/role/left_foot"); | ||
openxr_api->add_input_map("/user/vive_tracker_htcx/role/right_foot"); | ||
openxr_api->add_input_map("/user/vive_tracker_htcx/role/left_shoulder"); | ||
openxr_api->add_input_map("/user/vive_tracker_htcx/role/right_shoulder"); | ||
openxr_api->add_input_map("/user/vive_tracker_htcx/role/left_elbow"); | ||
openxr_api->add_input_map("/user/vive_tracker_htcx/role/right_elbow"); | ||
openxr_api->add_input_map("/user/vive_tracker_htcx/role/left_knee"); | ||
openxr_api->add_input_map("/user/vive_tracker_htcx/role/right_knee"); | ||
openxr_api->add_input_map("/user/vive_tracker_htcx/role/waist"); | ||
openxr_api->add_input_map("/user/vive_tracker_htcx/role/chest"); | ||
openxr_api->add_input_map("/user/vive_tracker_htcx/role/camera"); | ||
openxr_api->add_input_map("/user/vive_tracker_htcx/role/keyboard"); | ||
} | ||
} | ||
|
||
bool XRHTCViveTrackerExtensionWrapper::on_event_polled(const XrEventDataBuffer &event) { | ||
switch (event.type) { | ||
case XR_TYPE_EVENT_DATA_VIVE_TRACKER_CONNECTED_HTCX: { | ||
// Investigate if we need to do more here | ||
printf("OpenXR EVENT: VIVE tracker connected"); | ||
|
||
return true; | ||
} break; | ||
default: { | ||
return false; | ||
} break; | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
src/openxr/extensions/xr_htc_vive_tracker_extension_wrapper.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#ifndef XR_HTC_VIVE_TRACKER_EXTENSION_H | ||
#define XR_HTC_VIVE_TRACKER_EXTENSION_H | ||
|
||
#include "openxr/OpenXRApi.h" | ||
#include "xr_extension_wrapper.h" | ||
#include "openxr/include/util.h" | ||
|
||
class XRHTCViveTrackerExtensionWrapper : public XRExtensionWrapper { | ||
public: | ||
static XRHTCViveTrackerExtensionWrapper *get_singleton(); | ||
|
||
XRHTCViveTrackerExtensionWrapper(); | ||
virtual ~XRHTCViveTrackerExtensionWrapper() override; | ||
|
||
bool is_available(); | ||
virtual void add_input_maps() override; | ||
virtual bool on_event_polled(const XrEventDataBuffer &event) override; | ||
|
||
private: | ||
static XRHTCViveTrackerExtensionWrapper *singleton; | ||
|
||
OpenXRApi *openxr_api = nullptr; | ||
bool available = false; | ||
}; | ||
|
||
#endif // !XR_HTC_VIVE_TRACKER_EXTENSION_H |