mirror of
https://thingvellir.net/git/overte
synced 2025-03-27 23:52:03 +01:00
working on windows crash
This commit is contained in:
parent
e8daee013e
commit
8908c7c141
3 changed files with 27 additions and 32 deletions
|
@ -641,7 +641,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) :
|
|||
applicationUpdater->checkForUpdate();
|
||||
|
||||
// the 3Dconnexion device wants to be initiliazed after a window is displayed.
|
||||
ConnexionClient::init();
|
||||
ConnexionClient::getInstance().init();
|
||||
|
||||
auto& packetReceiver = nodeList->getPacketReceiver();
|
||||
packetReceiver.registerListener(PacketType::DomainConnectionDenied, this, "handleDomainConnectionDeniedPacket");
|
||||
|
@ -754,7 +754,7 @@ Application::~Application() {
|
|||
|
||||
Leapmotion::destroy();
|
||||
RealSense::destroy();
|
||||
ConnexionClient::destroy();
|
||||
ConnexionClient::getInstance().destroy();
|
||||
|
||||
qInstallMessageHandler(NULL); // NOTE: Do this as late as possible so we continue to get our log messages
|
||||
}
|
||||
|
|
|
@ -160,17 +160,14 @@ ConnexionClient& ConnexionClient::getInstance() {
|
|||
|
||||
#ifdef Q_OS_WIN
|
||||
|
||||
static ConnexionClient* gMouseInput = 0;
|
||||
|
||||
void ConnexionClient::toggleConnexion(bool shouldEnable) {
|
||||
ConnexionData& connexiondata = ConnexionData::getInstance();
|
||||
if (shouldEnable && connexiondata.getDeviceID() == 0) {
|
||||
ConnexionClient::init();
|
||||
init();
|
||||
}
|
||||
if (!shouldEnable && connexiondata.getDeviceID() != 0) {
|
||||
ConnexionClient::destroy();
|
||||
destroy();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void ConnexionClient::init() {
|
||||
|
@ -179,14 +176,12 @@ void ConnexionClient::init() {
|
|||
|
||||
InitializeRawInput(GetActiveWindow());
|
||||
|
||||
gMouseInput = &this;
|
||||
|
||||
QAbstractEventDispatcher::instance()->installNativeEventFilter(&cclient);
|
||||
QAbstractEventDispatcher::instance()->installNativeEventFilter(this);
|
||||
}
|
||||
}
|
||||
|
||||
void ConnexionClient::destroy() {
|
||||
QAbstractEventDispatcher::instance()->removeNativeEventFilter(&this);
|
||||
QAbstractEventDispatcher::instance()->removeNativeEventFilter(this);
|
||||
ConnexionData& connexiondata = ConnexionData::getInstance();
|
||||
int deviceid = connexiondata.getDeviceID();
|
||||
connexiondata.setDeviceID(0);
|
||||
|
@ -294,17 +289,17 @@ unsigned short HidToVirtualKey(unsigned long pid, unsigned short hidKeyCode) {
|
|||
|
||||
bool ConnexionClient::RawInputEventFilter(void* msg, long* result) {
|
||||
ConnexionData& connexiondata = ConnexionData::getInstance();
|
||||
if (ConnexionClient::Is3dmouseAttached() && connexiondata.getDeviceID() == 0) {
|
||||
if (Is3dmouseAttached() && connexiondata.getDeviceID() == 0) {
|
||||
connexiondata.registerToUserInputMapper(*Application::getUserInputMapper());
|
||||
connexiondata.assignDefaultInputMapping(*Application::getUserInputMapper());
|
||||
UserActivityLogger::getInstance().connectedDevice("controller", "3Dconnexion");
|
||||
} else if (!ConnexionClient::Is3dmouseAttached() && connexiondata.getDeviceID() != 0) {
|
||||
} else if (!Is3dmouseAttached() && connexiondata.getDeviceID() != 0) {
|
||||
int deviceid = connexiondata.getDeviceID();
|
||||
connexiondata.setDeviceID(0);
|
||||
Application::getUserInputMapper()->removeDevice(deviceid);
|
||||
}
|
||||
|
||||
if (!ConnexionClient::Is3dmouseAttached()) {
|
||||
if (!Is3dmouseAttached()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -312,7 +307,7 @@ bool ConnexionClient::RawInputEventFilter(void* msg, long* result) {
|
|||
|
||||
if (message->message == WM_INPUT) {
|
||||
HRAWINPUT hRawInput = reinterpret_cast<HRAWINPUT>(message->lParam);
|
||||
gMouseInput->OnRawInput(RIM_INPUT, hRawInput);
|
||||
OnRawInput(RIM_INPUT, hRawInput);
|
||||
if (result != 0) {
|
||||
result = 0;
|
||||
}
|
||||
|
@ -326,7 +321,7 @@ ConnexionClient::ConnexionClient() {
|
|||
}
|
||||
|
||||
ConnexionClient::~ConnexionClient() {
|
||||
QAbstractEventDispatcher::instance()->removeNativeEventFilter(&this);
|
||||
|
||||
}
|
||||
|
||||
// Access the mouse parameters structure
|
||||
|
@ -881,11 +876,11 @@ static void DeviceRemovedHandler(unsigned int connection);
|
|||
static void MessageHandler(unsigned int connection, unsigned int messageType, void *messageArgument);
|
||||
|
||||
void ConnexionClient::toggleConnexion(bool shouldEnable) {
|
||||
if (shouldEnable && !ConnexionClient::Is3dmouseAttached()) {
|
||||
ConnexionClient::init();
|
||||
if (shouldEnable && !Is3dmouseAttached()) {
|
||||
init();
|
||||
}
|
||||
if (!shouldEnable && ConnexionClient::Is3dmouseAttached()) {
|
||||
ConnexionClient::destroy();
|
||||
if (!shouldEnable && Is3dmouseAttached()) {
|
||||
destroy();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -908,7 +903,7 @@ void ConnexionClient::init() {
|
|||
// use default switches
|
||||
ConnexionClientControl(fConnexionClientID, kConnexionCtlSetSwitches, kConnexionSwitchesDisabled, NULL);
|
||||
|
||||
if (ConnexionClient::Is3dmouseAttached() && connexiondata.getDeviceID() == 0) {
|
||||
if (Is3dmouseAttached() && connexiondata.getDeviceID() == 0) {
|
||||
connexiondata.registerToUserInputMapper(*Application::getUserInputMapper());
|
||||
connexiondata.assignDefaultInputMapping(*Application::getUserInputMapper());
|
||||
UserActivityLogger::getInstance().connectedDevice("controller", "3Dconnexion");
|
||||
|
|
|
@ -23,9 +23,9 @@ class ConnexionClient : public QObject {
|
|||
Q_OBJECT
|
||||
public:
|
||||
static ConnexionClient& getInstance();
|
||||
static void init() {};
|
||||
static void destroy() {};
|
||||
static bool Is3dmouseAttached() { return false; };
|
||||
void init() {};
|
||||
void destroy() {};
|
||||
bool Is3dmouseAttached() { return false; };
|
||||
public slots:
|
||||
void toggleConnexion(bool shouldEnable) {};
|
||||
};
|
||||
|
@ -90,9 +90,9 @@ public:
|
|||
~ConnexionClient();
|
||||
|
||||
static ConnexionClient& getInstance();
|
||||
static void init();
|
||||
static void destroy();
|
||||
static bool Is3dmouseAttached();
|
||||
void init();
|
||||
void destroy();
|
||||
bool Is3dmouseAttached();
|
||||
|
||||
ConnexionClient* client;
|
||||
|
||||
|
@ -106,7 +106,7 @@ public:
|
|||
virtual bool nativeEventFilter(const QByteArray& eventType, void* message, long* result) Q_DECL_OVERRIDE
|
||||
{
|
||||
MSG* msg = static_cast< MSG * >(message);
|
||||
return ConnexionClient::RawInputEventFilter(message, result);
|
||||
return RawInputEventFilter(message, result);
|
||||
}
|
||||
|
||||
public slots:
|
||||
|
@ -120,7 +120,7 @@ signals:
|
|||
private:
|
||||
bool InitializeRawInput(HWND hwndTarget);
|
||||
|
||||
static bool RawInputEventFilter(void* msg, long* result);
|
||||
bool RawInputEventFilter(void* msg, long* result);
|
||||
|
||||
void OnRawInput(UINT nInputCode, HRAWINPUT hRawInput);
|
||||
UINT GetRawInputBuffer(PRAWINPUT pData, PUINT pcbSize, UINT cbSizeHeader);
|
||||
|
@ -165,9 +165,9 @@ class ConnexionClient : public QObject {
|
|||
Q_OBJECT
|
||||
public:
|
||||
static ConnexionClient& getInstance();
|
||||
static void init();
|
||||
static void destroy();
|
||||
static bool Is3dmouseAttached();
|
||||
void init();
|
||||
void destroy();
|
||||
bool Is3dmouseAttached();
|
||||
public slots:
|
||||
void toggleConnexion(bool shouldEnable);
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue