mirror of
https://github.com/overte-org/overte.git
synced 2025-08-11 08:18:56 +02:00
Cleanup
This commit is contained in:
parent
503e03d4a8
commit
e3b54f0272
1 changed files with 45 additions and 36 deletions
|
@ -1,6 +1,6 @@
|
||||||
//
|
//
|
||||||
// SixenseSupportOSX.cpp
|
// SixenseSupportOSX.cpp
|
||||||
//
|
// libraries/input-plugins/src/input-plugins
|
||||||
//
|
//
|
||||||
// Created by Clement on 10/20/15.
|
// Created by Clement on 10/20/15.
|
||||||
// Copyright 2015 High Fidelity, Inc.
|
// Copyright 2015 High Fidelity, Inc.
|
||||||
|
@ -9,14 +9,31 @@
|
||||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
//
|
//
|
||||||
|
|
||||||
#ifdef __APPLE__
|
#if defined(__APPLE__) && defined(HAVE_SIXENSE)
|
||||||
#include "sixense.h"
|
#include "sixense.h"
|
||||||
|
|
||||||
#include <QtCore/QCoreApplication>
|
#include <QtCore/QCoreApplication>
|
||||||
#include <QtCore/QDebug>
|
#include <QtCore/QDebug>
|
||||||
#include <QtCore/QLibrary>
|
#include <QtCore/QLibrary>
|
||||||
|
|
||||||
static std::unique_ptr<QLibrary> SIXENSE;
|
using Library = std::unique_ptr<QLibrary>;
|
||||||
|
static Library SIXENSE;
|
||||||
|
|
||||||
|
struct Callable {
|
||||||
|
template<typename... Args> int operator() (Args... args){
|
||||||
|
return reinterpret_cast<int(*)(Args...)>(function)(args...);
|
||||||
|
}
|
||||||
|
QFunctionPointer function;
|
||||||
|
};
|
||||||
|
|
||||||
|
Callable resolve(const Library& library, const char* name) {
|
||||||
|
Q_ASSERT_X(library && library->isLoaded(), __FUNCTION__, "Sixense library not loaded");
|
||||||
|
auto function = library->resolve(name);
|
||||||
|
Q_ASSERT_X(function, __FUNCTION__, std::string("Could not resolve ").append(name).c_str());
|
||||||
|
return Callable { function };
|
||||||
|
}
|
||||||
|
#define FOREWARD resolve(SIXENSE, __FUNCTION__)
|
||||||
|
|
||||||
|
|
||||||
void loadSixense() {
|
void loadSixense() {
|
||||||
if (!SIXENSE) {
|
if (!SIXENSE) {
|
||||||
|
@ -36,106 +53,98 @@ void loadSixense() {
|
||||||
qDebug() << "Continuing without hydra support.";
|
qDebug() << "Continuing without hydra support.";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void unloadSixense() {
|
void unloadSixense() {
|
||||||
SIXENSE->unload();
|
SIXENSE->unload();
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename... Args>
|
|
||||||
int call(const char* name, Args... args) {
|
|
||||||
Q_ASSERT_X(SIXENSE && SIXENSE->isLoaded(), __FUNCTION__, "Sixense library not loaded");
|
|
||||||
auto func = reinterpret_cast<int(*)(Args...)>(SIXENSE->resolve(name));
|
|
||||||
Q_ASSERT_X(func, __FUNCTION__, std::string("Could not resolve ").append(name).c_str());
|
|
||||||
return func(args...);
|
|
||||||
}
|
|
||||||
|
|
||||||
// sixense.h wrapper for OSX dynamic linking
|
// sixense.h wrapper for OSX dynamic linking
|
||||||
int sixenseInit() {
|
int sixenseInit() {
|
||||||
loadSixense();
|
loadSixense();
|
||||||
return call(__FUNCTION__);
|
return FOREWARD();
|
||||||
}
|
}
|
||||||
int sixenseExit() {
|
int sixenseExit() {
|
||||||
auto returnCode = call(__FUNCTION__);
|
auto returnCode = FOREWARD();
|
||||||
unloadSixense();
|
unloadSixense();
|
||||||
return returnCode;
|
return returnCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
int sixenseGetMaxBases() {
|
int sixenseGetMaxBases() {
|
||||||
return call(__FUNCTION__);
|
return FOREWARD();
|
||||||
}
|
}
|
||||||
int sixenseSetActiveBase(int i) {
|
int sixenseSetActiveBase(int i) {
|
||||||
return call(__FUNCTION__, i);
|
return FOREWARD(i);
|
||||||
}
|
}
|
||||||
int sixenseIsBaseConnected(int i) {
|
int sixenseIsBaseConnected(int i) {
|
||||||
return call(__FUNCTION__, i);
|
return FOREWARD(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
int sixenseGetMaxControllers() {
|
int sixenseGetMaxControllers() {
|
||||||
return call(__FUNCTION__);
|
return FOREWARD();
|
||||||
}
|
}
|
||||||
int sixenseIsControllerEnabled(int which) {
|
int sixenseIsControllerEnabled(int which) {
|
||||||
return call(__FUNCTION__, which);
|
return FOREWARD(which);
|
||||||
}
|
}
|
||||||
int sixenseGetNumActiveControllers() {
|
int sixenseGetNumActiveControllers() {
|
||||||
return call(__FUNCTION__);
|
return FOREWARD();
|
||||||
}
|
}
|
||||||
|
|
||||||
int sixenseGetHistorySize() {
|
int sixenseGetHistorySize() {
|
||||||
return call(__FUNCTION__);
|
return FOREWARD();
|
||||||
}
|
}
|
||||||
|
|
||||||
int sixenseGetData(int which, int index_back, sixenseControllerData* data) {
|
int sixenseGetData(int which, int index_back, sixenseControllerData* data) {
|
||||||
return call(__FUNCTION__, which, index_back, data);
|
return FOREWARD(which, index_back, data);
|
||||||
}
|
}
|
||||||
int sixenseGetAllData(int index_back, sixenseAllControllerData* data) {
|
int sixenseGetAllData(int index_back, sixenseAllControllerData* data) {
|
||||||
return call(__FUNCTION__, index_back, data);
|
return FOREWARD(index_back, data);
|
||||||
}
|
}
|
||||||
int sixenseGetNewestData(int which, sixenseControllerData* data) {
|
int sixenseGetNewestData(int which, sixenseControllerData* data) {
|
||||||
return call(__FUNCTION__, which, data);
|
return FOREWARD(which, data);
|
||||||
}
|
}
|
||||||
int sixenseGetAllNewestData(sixenseAllControllerData* data) {
|
int sixenseGetAllNewestData(sixenseAllControllerData* data) {
|
||||||
return call(__FUNCTION__, data);
|
return FOREWARD(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
int sixenseSetHemisphereTrackingMode(int which_controller, int state) {
|
int sixenseSetHemisphereTrackingMode(int which_controller, int state) {
|
||||||
return call(__FUNCTION__, which_controller, state);
|
return FOREWARD(which_controller, state);
|
||||||
}
|
}
|
||||||
int sixenseGetHemisphereTrackingMode(int which_controller, int* state) {
|
int sixenseGetHemisphereTrackingMode(int which_controller, int* state) {
|
||||||
return call(__FUNCTION__, which_controller, state);
|
return FOREWARD(which_controller, state);
|
||||||
}
|
}
|
||||||
int sixenseAutoEnableHemisphereTracking(int which_controller) {
|
int sixenseAutoEnableHemisphereTracking(int which_controller) {
|
||||||
return call(__FUNCTION__, which_controller);
|
return FOREWARD(which_controller);
|
||||||
}
|
}
|
||||||
|
|
||||||
int sixenseSetHighPriorityBindingEnabled(int on_or_off) {
|
int sixenseSetHighPriorityBindingEnabled(int on_or_off) {
|
||||||
return call(__FUNCTION__, on_or_off);
|
return FOREWARD(on_or_off);
|
||||||
}
|
}
|
||||||
int sixenseGetHighPriorityBindingEnabled(int* on_or_off) {
|
int sixenseGetHighPriorityBindingEnabled(int* on_or_off) {
|
||||||
return call(__FUNCTION__, on_or_off);
|
return FOREWARD(on_or_off);
|
||||||
}
|
}
|
||||||
|
|
||||||
int sixenseTriggerVibration(int controller_id, int duration_100ms, int pattern_id) {
|
int sixenseTriggerVibration(int controller_id, int duration_100ms, int pattern_id) {
|
||||||
return call(__FUNCTION__, controller_id, duration_100ms, pattern_id);
|
return FOREWARD(controller_id, duration_100ms, pattern_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
int sixenseSetFilterEnabled(int on_or_off) {
|
int sixenseSetFilterEnabled(int on_or_off) {
|
||||||
return call(__FUNCTION__, on_or_off);
|
return FOREWARD(on_or_off);
|
||||||
}
|
}
|
||||||
int sixenseGetFilterEnabled(int* on_or_off) {
|
int sixenseGetFilterEnabled(int* on_or_off) {
|
||||||
return call(__FUNCTION__, on_or_off);
|
return FOREWARD(on_or_off);
|
||||||
}
|
}
|
||||||
|
|
||||||
int sixenseSetFilterParams(float near_range, float near_val, float far_range, float far_val) {
|
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);
|
return FOREWARD(near_range, near_val, far_range, far_val);
|
||||||
}
|
}
|
||||||
int sixenseGetFilterParams(float* near_range, float* near_val, float* far_range, float* 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);
|
return FOREWARD(near_range, near_val, far_range, far_val);
|
||||||
}
|
}
|
||||||
|
|
||||||
int sixenseSetBaseColor(unsigned char red, unsigned char green, unsigned char blue) {
|
int sixenseSetBaseColor(unsigned char red, unsigned char green, unsigned char blue) {
|
||||||
return call(__FUNCTION__, red, green, blue);
|
return FOREWARD(red, green, blue);
|
||||||
}
|
}
|
||||||
int sixenseGetBaseColor(unsigned char* red, unsigned char* green, unsigned char* blue) {
|
int sixenseGetBaseColor(unsigned char* red, unsigned char* green, unsigned char* blue) {
|
||||||
return call(__FUNCTION__, red, green, blue);
|
return FOREWARD(red, green, blue);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue