mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 14:08:51 +02:00
Spacemouse fixes
This commit is contained in:
parent
1ab683643c
commit
ade0862948
4 changed files with 11 additions and 24 deletions
|
@ -45,9 +45,9 @@ function update(deltaTime) {
|
||||||
print("- Controller RZ: " + Controller.getValue(Controller.Standard.LX));
|
print("- Controller RZ: " + Controller.getValue(Controller.Standard.LX));
|
||||||
}
|
}
|
||||||
|
|
||||||
if(Controller.getValue(Controller.Standard.LT) != 0){
|
if(Controller.getValue(Controller.Standard.LB) != 0){
|
||||||
toggleFirstMove();
|
toggleFirstMove();
|
||||||
print("- Controller LEFTB: " + Controller.getValue(Controller.Standard.LT));
|
print("- Controller LEFTB: " + Controller.getValue(Controller.Standard.LB));
|
||||||
}
|
}
|
||||||
|
|
||||||
if(Controller.getValue(Controller.Standard.RY) != 0){
|
if(Controller.getValue(Controller.Standard.RY) != 0){
|
||||||
|
@ -60,9 +60,9 @@ function update(deltaTime) {
|
||||||
print("- Controller TX: " + Controller.getValue(Controller.Standard.RX));
|
print("- Controller TX: " + Controller.getValue(Controller.Standard.RX));
|
||||||
}
|
}
|
||||||
|
|
||||||
if(Controller.getValue(Controller.Standard.RT) != 0){
|
if(Controller.getValue(Controller.Standard.RB) != 0){
|
||||||
toggleFirstMove();
|
toggleFirstMove();
|
||||||
print("- Controller RIGHTB: " + Controller.getValue(Controller.Standard.RT));
|
print("- Controller RIGHTB: " + Controller.getValue(Controller.Standard.RB));
|
||||||
}
|
}
|
||||||
|
|
||||||
firstmove = 1;
|
firstmove = 1;
|
||||||
|
|
|
@ -8,8 +8,8 @@
|
||||||
|
|
||||||
{ "from": "Spacemouse.RotateZ", "to": "Standard.LX" },
|
{ "from": "Spacemouse.RotateZ", "to": "Standard.LX" },
|
||||||
|
|
||||||
{ "from": "Spacemouse.LeftButton", "to": "Standard.LT" },
|
{ "from": "Spacemouse.LeftButton", "to": "Standard.LB" },
|
||||||
{ "from": "Spacemouse.RightButton", "to": "Standard.RT" }
|
{ "from": "Spacemouse.RightButton", "to": "Standard.RB" }
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
|
|
||||||
const float MAX_AXIS = 75.0f; // max forward = 2x speed
|
const float MAX_AXIS = 75.0f; // max forward = 2x speed
|
||||||
|
|
||||||
static std::shared_ptr<SpacemouseDevice> instance = NULL;
|
static std::shared_ptr<SpacemouseDevice> instance;
|
||||||
SpacemouseDevice::SpacemouseDevice() :
|
SpacemouseDevice::SpacemouseDevice() :
|
||||||
InputDevice("Spacemouse")
|
InputDevice("Spacemouse")
|
||||||
{
|
{
|
||||||
|
@ -120,9 +120,9 @@ void SpacemouseDevice::update(float deltaTime, bool jointsCaptured) {
|
||||||
|
|
||||||
SpacemouseManager& SpacemouseManager::getInstance() {
|
SpacemouseManager& SpacemouseManager::getInstance() {
|
||||||
static SpacemouseManager sharedInstance;
|
static SpacemouseManager sharedInstance;
|
||||||
if (instance == NULL){
|
if (instance == nullptr) {
|
||||||
new SpacemouseDevice();
|
new SpacemouseDevice();
|
||||||
}
|
}
|
||||||
return sharedInstance;
|
return sharedInstance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -318,14 +318,12 @@ void SpacemouseManager::Move3d(HANDLE device, std::vector<float>& motionData) {
|
||||||
//Called when a 3D mouse key is pressed
|
//Called when a 3D mouse key is pressed
|
||||||
void SpacemouseManager::On3dmouseKeyDown(HANDLE device, int virtualKeyCode) {
|
void SpacemouseManager::On3dmouseKeyDown(HANDLE device, int virtualKeyCode) {
|
||||||
Q_UNUSED(device);
|
Q_UNUSED(device);
|
||||||
//SpacemouseDevice& spacemousedevice = SpacemouseDevice::getInstance();
|
|
||||||
instance->setButton(virtualKeyCode);
|
instance->setButton(virtualKeyCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Called when a 3D mouse key is released
|
//Called when a 3D mouse key is released
|
||||||
void SpacemouseManager::On3dmouseKeyUp(HANDLE device, int virtualKeyCode) {
|
void SpacemouseManager::On3dmouseKeyUp(HANDLE device, int virtualKeyCode) {
|
||||||
Q_UNUSED(device);
|
Q_UNUSED(device);
|
||||||
//SpacemouseDevice& spacemousedevice = SpacemouseDevice::getInstance();
|
|
||||||
instance->setButton(0);
|
instance->setButton(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -858,8 +856,6 @@ void SpacemouseManager::init() {
|
||||||
|
|
||||||
// ...or use this to take over system-wide
|
// ...or use this to take over system-wide
|
||||||
fConnexionClientID = RegisterConnexionClient(kConnexionClientWildcard, NULL, kConnexionClientModeTakeOver, kConnexionMaskAll);
|
fConnexionClientID = RegisterConnexionClient(kConnexionClientWildcard, NULL, kConnexionClientModeTakeOver, kConnexionMaskAll);
|
||||||
//SpacemouseDevice& spacemousedevice = SpacemouseDevice::getInstance();
|
|
||||||
//memcpy(&spacemousedevice.clientId, &fConnexionClientID, (long)sizeof(int));
|
|
||||||
memcpy(&instance->clientId, &fConnexionClientID, (long)sizeof(int));
|
memcpy(&instance->clientId, &fConnexionClientID, (long)sizeof(int));
|
||||||
|
|
||||||
// A separate API call is required to capture buttons beyond the first 8
|
// A separate API call is required to capture buttons beyond the first 8
|
||||||
|
@ -887,7 +883,6 @@ void SpacemouseManager::destroy() {
|
||||||
}
|
}
|
||||||
CleanupConnexionHandlers();
|
CleanupConnexionHandlers();
|
||||||
fConnexionClientID = 0;
|
fConnexionClientID = 0;
|
||||||
//SpacemouseDevice& spacemousedevice = SpacemouseDevice::getInstance();
|
|
||||||
if (instance->getDeviceID() != controller::Input::INVALID_DEVICE) {
|
if (instance->getDeviceID() != controller::Input::INVALID_DEVICE) {
|
||||||
auto userInputMapper = DependencyManager::get<UserInputMapper>();
|
auto userInputMapper = DependencyManager::get<UserInputMapper>();
|
||||||
userInputMapper->removeDevice(instance->getDeviceID());
|
userInputMapper->removeDevice(instance->getDeviceID());
|
||||||
|
@ -897,7 +892,6 @@ void SpacemouseManager::destroy() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void DeviceAddedHandler(unsigned int connection) {
|
void DeviceAddedHandler(unsigned int connection) {
|
||||||
//SpacemouseDevice& spacemousedevice = SpacemouseDevice::getInstance();
|
|
||||||
if (instance->getDeviceID() == controller::Input::INVALID_DEVICE) {
|
if (instance->getDeviceID() == controller::Input::INVALID_DEVICE) {
|
||||||
qCWarning(interfaceapp) << "Spacemouse device added ";
|
qCWarning(interfaceapp) << "Spacemouse device added ";
|
||||||
auto userInputMapper = DependencyManager::get<UserInputMapper>();
|
auto userInputMapper = DependencyManager::get<UserInputMapper>();
|
||||||
|
@ -907,7 +901,6 @@ void DeviceAddedHandler(unsigned int connection) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void DeviceRemovedHandler(unsigned int connection) {
|
void DeviceRemovedHandler(unsigned int connection) {
|
||||||
//SpacemouseDevice& spacemousedevice = SpacemouseDevice::getInstance();
|
|
||||||
if (instance->getDeviceID() != controller::Input::INVALID_DEVICE) {
|
if (instance->getDeviceID() != controller::Input::INVALID_DEVICE) {
|
||||||
qCWarning(interfaceapp) << "Spacemouse device removed";
|
qCWarning(interfaceapp) << "Spacemouse device removed";
|
||||||
auto userInputMapper = DependencyManager::get<UserInputMapper>();
|
auto userInputMapper = DependencyManager::get<UserInputMapper>();
|
||||||
|
@ -934,7 +927,6 @@ void MessageHandler(unsigned int connection, unsigned int messageType, void *mes
|
||||||
case kConnexionMsgDeviceState:
|
case kConnexionMsgDeviceState:
|
||||||
state = (SpacemouseDeviceState*)messageArgument;
|
state = (SpacemouseDeviceState*)messageArgument;
|
||||||
if (state->client == fConnexionClientID) {
|
if (state->client == fConnexionClientID) {
|
||||||
//SpacemouseDevice& spacemousedevice = SpacemouseDevice::getInstance();
|
|
||||||
instance->cc_position = { state->axis[0], state->axis[1], state->axis[2] };
|
instance->cc_position = { state->axis[0], state->axis[1], state->axis[2] };
|
||||||
instance->cc_rotation = { state->axis[3], state->axis[4], state->axis[5] };
|
instance->cc_rotation = { state->axis[3], state->axis[4], state->axis[5] };
|
||||||
|
|
||||||
|
|
|
@ -89,8 +89,7 @@ private:
|
||||||
};
|
};
|
||||||
|
|
||||||
class SpacemouseManager : public QObject, public QAbstractNativeEventFilter {
|
class SpacemouseManager : public QObject, public QAbstractNativeEventFilter {
|
||||||
//class SpacemouseManager : public InputPlugin, public controller::InputDevice {
|
|
||||||
|
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
SpacemouseManager() {};
|
SpacemouseManager() {};
|
||||||
|
@ -118,10 +117,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void toggleSpacemouse(bool shouldEnable);
|
void toggleSpacemouse(bool shouldEnable);
|
||||||
|
|
||||||
//std::shared_ptr<SpacemouseDevice> getDevice();
|
|
||||||
|
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void Move3d(std::vector<float>& motionData);
|
void Move3d(std::vector<float>& motionData);
|
||||||
|
@ -193,7 +189,6 @@ class SpacemouseDevice : public QObject, public controller::InputDevice {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
//static SpacemouseDevice& getInstance();
|
|
||||||
SpacemouseDevice();
|
SpacemouseDevice();
|
||||||
enum PositionChannel {
|
enum PositionChannel {
|
||||||
TRANSLATE_X,
|
TRANSLATE_X,
|
||||||
|
|
Loading…
Reference in a new issue