mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 03:58:07 +02:00
Implement all Sixense methods for OS X
This commit is contained in:
parent
298ac650d8
commit
96aa5be457
1 changed files with 76 additions and 26 deletions
|
@ -24,7 +24,7 @@ using SixenseTakeIntAndSixenseControllerData = int (*)(int, sixenseControllerDat
|
||||||
|
|
||||||
static unique_ptr<QLibrary> SIXENSE;
|
static unique_ptr<QLibrary> SIXENSE;
|
||||||
|
|
||||||
bool loadSixense() {
|
void loadSixense() {
|
||||||
if (!SIXENSE) {
|
if (!SIXENSE) {
|
||||||
static const QString LIBRARY_PATH =
|
static const QString LIBRARY_PATH =
|
||||||
#ifdef SIXENSE_LIB_FILENAME
|
#ifdef SIXENSE_LIB_FILENAME
|
||||||
|
@ -41,57 +41,107 @@ bool loadSixense() {
|
||||||
qDebug() << "Sixense library at" << SIXENSE->fileName() << "failed to load:" << SIXENSE->errorString();
|
qDebug() << "Sixense library at" << SIXENSE->fileName() << "failed to load:" << SIXENSE->errorString();
|
||||||
qDebug() << "Continuing without hydra support.";
|
qDebug() << "Continuing without hydra support.";
|
||||||
}
|
}
|
||||||
return SIXENSE->isLoaded();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void unloadSixense() {
|
void unloadSixense() {
|
||||||
SIXENSE->unload();
|
SIXENSE->unload();
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename Func>
|
template<typename... Args>
|
||||||
Func resolve(const char* name) {
|
int call(const char* name, Args... args) {
|
||||||
Q_ASSERT_X(SIXENSE && SIXENSE->isLoaded(), __FUNCTION__, "Sixense library not loaded");
|
Q_ASSERT_X(SIXENSE && SIXENSE->isLoaded(), __FUNCTION__, "Sixense library not loaded");
|
||||||
auto func = reinterpret_cast<Func>(SIXENSE->resolve(name));
|
auto func = reinterpret_cast<int(*)(Args...)>(SIXENSE->resolve(name));
|
||||||
Q_ASSERT_X(func, __FUNCTION__, string("Could not resolve ").append(name).c_str());
|
Q_ASSERT_X(func, __FUNCTION__, string("Could not resolve ").append(name).c_str());
|
||||||
return func;
|
return func(args...);
|
||||||
}
|
}
|
||||||
|
|
||||||
// sixense.h wrapper for OSX dynamic linking
|
// sixense.h wrapper for OSX dynamic linking
|
||||||
int sixenseInit() {
|
int sixenseInit() {
|
||||||
loadSixense();
|
loadSixense();
|
||||||
auto sixenseInit = resolve<SixenseBaseFunction>("sixenseInit");
|
return call(__FUNCTION__);
|
||||||
return sixenseInit();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int sixenseExit() {
|
int sixenseExit() {
|
||||||
auto sixenseExit = resolve<SixenseBaseFunction>("sixenseExit");
|
auto returnCode = call(__FUNCTION__);
|
||||||
auto returnCode = sixenseExit();
|
|
||||||
unloadSixense();
|
unloadSixense();
|
||||||
return returnCode;
|
return returnCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
int sixenseSetFilterEnabled(int input) {
|
int sixenseGetMaxBases() {
|
||||||
auto sixenseSetFilterEnabled = resolve<SixenseTakeIntFunction>("sixenseSetFilterEnabled");
|
return call(__FUNCTION__);
|
||||||
return sixenseSetFilterEnabled(input);
|
|
||||||
}
|
}
|
||||||
|
int sixenseSetActiveBase(int i) {
|
||||||
int sixenseGetNumActiveControllers() {
|
return call(__FUNCTION__, i);
|
||||||
auto sixenseGetNumActiveControllers = resolve<SixenseBaseFunction>("sixenseGetNumActiveControllers");
|
}
|
||||||
return sixenseGetNumActiveControllers();
|
int sixenseIsBaseConnected(int i) {
|
||||||
|
return call(__FUNCTION__, i);
|
||||||
}
|
}
|
||||||
|
|
||||||
int sixenseGetMaxControllers() {
|
int sixenseGetMaxControllers() {
|
||||||
auto sixenseGetMaxControllers = resolve<SixenseBaseFunction>("sixenseGetMaxControllers");
|
return call(__FUNCTION__);
|
||||||
return sixenseGetMaxControllers();
|
}
|
||||||
|
int sixenseIsControllerEnabled(int which) {
|
||||||
|
return call(__FUNCTION__, which);
|
||||||
|
}
|
||||||
|
int sixenseGetNumActiveControllers() {
|
||||||
|
return call(__FUNCTION__);
|
||||||
}
|
}
|
||||||
|
|
||||||
int sixenseIsControllerEnabled(int input) {
|
int sixenseGetHistorySize() {
|
||||||
auto sixenseIsControllerEnabled = resolve<SixenseTakeIntFunction>("sixenseIsControllerEnabled");
|
return call(__FUNCTION__);
|
||||||
return sixenseIsControllerEnabled(input);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int sixenseGetNewestData(int input1, sixenseControllerData* intput2) {
|
int sixenseGetData(int which, int index_back, sixenseControllerData* data) {
|
||||||
auto sixenseGetNewestData = resolve<SixenseTakeIntAndSixenseControllerData>("sixenseGetNewestData");
|
return call(__FUNCTION__, which, index_back, data);
|
||||||
return sixenseGetNewestData(input1, intput2);
|
}
|
||||||
|
int sixenseGetAllData(int index_back, sixenseAllControllerData* data) {
|
||||||
|
return call(__FUNCTION__, index_back, data);
|
||||||
|
}
|
||||||
|
int sixenseGetNewestData(int which, sixenseControllerData* data) {
|
||||||
|
return call(__FUNCTION__, which, data);
|
||||||
|
}
|
||||||
|
int sixenseGetAllNewestData(sixenseAllControllerData* data) {
|
||||||
|
return call(__FUNCTION__, data);
|
||||||
|
}
|
||||||
|
|
||||||
|
int sixenseSetHemisphereTrackingMode(int which_controller, int state) {
|
||||||
|
return call(__FUNCTION__, which_controller, state);
|
||||||
|
}
|
||||||
|
int sixenseGetHemisphereTrackingMode(int which_controller, int* state) {
|
||||||
|
return call(__FUNCTION__, which_controller, state);
|
||||||
|
}
|
||||||
|
int sixenseAutoEnableHemisphereTracking(int which_controller) {
|
||||||
|
return call(__FUNCTION__, which_controller);
|
||||||
|
}
|
||||||
|
|
||||||
|
int sixenseSetHighPriorityBindingEnabled(int on_or_off) {
|
||||||
|
return call(__FUNCTION__, on_or_off);
|
||||||
|
}
|
||||||
|
int sixenseGetHighPriorityBindingEnabled(int* on_or_off) {
|
||||||
|
return call(__FUNCTION__, on_or_off);
|
||||||
|
}
|
||||||
|
|
||||||
|
int sixenseTriggerVibration(int controller_id, int duration_100ms, int pattern_id) {
|
||||||
|
return call(__FUNCTION__, controller_id, duration_100ms, pattern_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
int sixenseSetFilterEnabled(int on_or_off) {
|
||||||
|
return call(__FUNCTION__, on_or_off);
|
||||||
|
}
|
||||||
|
int sixenseGetFilterEnabled(int* on_or_off) {
|
||||||
|
return call(__FUNCTION__, on_or_off);
|
||||||
|
}
|
||||||
|
|
||||||
|
int sixenseSetFilterParams(float near_range, float near_val, float far_range, float far_val) {
|
||||||
|
return call(__FUNCTION__, near_range, near_val, far_range, far_val);
|
||||||
|
}
|
||||||
|
int sixenseGetFilterParams(float* near_range, float* near_val, float* far_range, float* far_val) {
|
||||||
|
return call(__FUNCTION__, near_range, near_val, far_range, far_val);
|
||||||
|
}
|
||||||
|
|
||||||
|
int sixenseSetBaseColor(unsigned char red, unsigned char green, unsigned char blue) {
|
||||||
|
return call(__FUNCTION__, red, green, blue);
|
||||||
|
}
|
||||||
|
int sixenseGetBaseColor(unsigned char* red, unsigned char* green, unsigned char* blue) {
|
||||||
|
return call(__FUNCTION__, red, green, blue);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue