From b19376ef6eac12652e3d194a9dbf2cdee46bd209 Mon Sep 17 00:00:00 2001 From: Sam Gondelman Date: Thu, 30 Jul 2015 12:17:36 -0700 Subject: [PATCH 1/7] trying to fix connexion linker errors, general style fixes, renamed some files --- cmake/modules/Find3DConnexionClient.cmake | 41 +++++++ cmake/modules/FindconnexionClient.cmake | 38 ------ interface/CMakeLists.txt | 2 +- interface/external/connexionclient/readme.txt | 5 +- interface/src/Application.cpp | 2 +- interface/src/Menu.cpp | 2 +- ...{3Dconnexion.cpp => 3DConnexionClient.cpp} | 115 +++++++++--------- .../{3Dconnexion.h => 3DConnexionClient.h} | 29 +++-- 8 files changed, 116 insertions(+), 118 deletions(-) create mode 100644 cmake/modules/Find3DConnexionClient.cmake delete mode 100644 cmake/modules/FindconnexionClient.cmake rename interface/src/devices/{3Dconnexion.cpp => 3DConnexionClient.cpp} (91%) rename interface/src/devices/{3Dconnexion.h => 3DConnexionClient.h} (93%) diff --git a/cmake/modules/Find3DConnexionClient.cmake b/cmake/modules/Find3DConnexionClient.cmake new file mode 100644 index 0000000000..7f38824a81 --- /dev/null +++ b/cmake/modules/Find3DConnexionClient.cmake @@ -0,0 +1,41 @@ +# +# Find3DConnexionClient.cmake +# +# Once done this will define + +# 3DCONNEXIONCLIENT_FOUND - system found 3DConnexion +# 3DCONNEXIONCLIENT_INCLUDE_DIRS - the 3DConnexion include directory +# 3DCONNEXIONCLIENT_LIBRARY - Link this to use 3DConnexion +# +# Created on 10/06/2015 by Marcel Verhagen +# Copyright 2015 High Fidelity, Inc. +# +# Distributed under the Apache License, Version 2.0. +# See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +# + +include("${MACRO_DIR}/HifiLibrarySearchHints.cmake") +hifi_library_search_hints("connexionclient") + +if (APPLE) + find_library(3DConnexionClient 3DConnexionClient) + if(EXISTS ${3DConnexionClient}) + set(3DCONNEXIONCLIENT_FOUND true) + set(3DCONNEXIONCLIENT_INCLUDE_DIRS ${3DConnexionClient}) + set(3DCONNEXIONCLIENT_LIBRARY ${3DConnexionClient}) + set_target_properties(${TARGET_NAME} PROPERTIES LINK_FLAGS "-weak_framework 3DConnexionClient") + message(STATUS "Found 3DConnexion " + ${3DConnexionClient}) + mark_as_advanced(3DCONNEXIONCLIENT_INCLUDE_DIR CONNEXIONCLIENT_LIBRARY) + else () + message(STATUS "Could NOT find 3DConnexionClient") + endif() +endif() + +if (WIN32) + find_path(3DCONNEXIONCLIENT_INCLUDE_DIRS I3dMouseParams.h PATH_SUFFIXES Inc HINTS ${CONNEXIONCLIENT_SEARCH_DIRS}) + + include(FindPackageHandleStandardArgs) + find_package_handle_standard_args(3DConnexionClient DEFAULT_MSG 3DCONNEXIONCLIENT_INCLUDE_DIRS) + + mark_as_advanced(3DCONNEXIONCLIENT_INCLUDE_DIRS 3DCONNEXIONCLIENT_SEARCH_DIRS) +endif() \ No newline at end of file diff --git a/cmake/modules/FindconnexionClient.cmake b/cmake/modules/FindconnexionClient.cmake deleted file mode 100644 index 1d6d7d4514..0000000000 --- a/cmake/modules/FindconnexionClient.cmake +++ /dev/null @@ -1,38 +0,0 @@ -# -# FindconnexionClient.cmake -# -# Once done this will define -# -# 3DCONNEXIONCLIENT_INCLUDE_DIRS -# -# Created on 10/06/2015 by Marcel Verhagen -# Copyright 2015 High Fidelity, Inc. -# -# Distributed under the Apache License, Version 2.0. -# See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html -# - -# setup hints for 3DCONNEXIONCLIENT search -include("${MACRO_DIR}/HifiLibrarySearchHints.cmake") -hifi_library_search_hints("connexionclient") - -if (APPLE) - find_library(3DconnexionClient 3DconnexionClient) - if(EXISTS ${3DconnexionClient}) - set(CONNEXIONCLIENT_FOUND true) - set(CONNEXIONCLIENT_INCLUDE_DIR ${3DconnexionClient}) - set(CONNEXIONCLIENT_LIBRARY ${3DconnexionClient}) - set_target_properties(${TARGET_NAME} PROPERTIES LINK_FLAGS "-weak_framework 3DconnexionClient") - message(STATUS "Found 3Dconnexion") - mark_as_advanced(CONNEXIONCLIENT_INCLUDE_DIR CONNEXIONCLIENT_LIBRARY) - endif() -endif() - -if (WIN32) - find_path(CONNEXIONCLIENT_INCLUDE_DIRS I3dMouseParams.h PATH_SUFFIXES Inc HINTS ${CONNEXIONCLIENT_SEARCH_DIRS}) - - include(FindPackageHandleStandardArgs) - find_package_handle_standard_args(connexionClient DEFAULT_MSG CONNEXIONCLIENT_INCLUDE_DIRS) - - mark_as_advanced(CONNEXIONCLIENT_INCLUDE_DIRS CONNEXIONCLIENT_SEARCH_DIRS) -endif() diff --git a/interface/CMakeLists.txt b/interface/CMakeLists.txt index 4ee3709f4a..589f6a992f 100644 --- a/interface/CMakeLists.txt +++ b/interface/CMakeLists.txt @@ -2,7 +2,7 @@ set(TARGET_NAME interface) project(${TARGET_NAME}) # set a default root dir for each of our optional externals if it was not passed -set(OPTIONAL_EXTERNALS "Faceshift" "Sixense" "LeapMotion" "RtMidi" "SDL2" "RSSDK" "connexionClient") +set(OPTIONAL_EXTERNALS "Faceshift" "Sixense" "LeapMotion" "RtMidi" "SDL2" "RSSDK" "3DConnexionClient") foreach(EXTERNAL ${OPTIONAL_EXTERNALS}) string(TOUPPER ${EXTERNAL} ${EXTERNAL}_UPPERCASE) if (NOT ${${EXTERNAL}_UPPERCASE}_ROOT_DIR) diff --git a/interface/external/connexionclient/readme.txt b/interface/external/connexionclient/readme.txt index dd67a29449..cbfc5a277a 100644 --- a/interface/external/connexionclient/readme.txt +++ b/interface/external/connexionclient/readme.txt @@ -1,4 +1,3 @@ -The mac version does not require any files here. 3D connexion should be installed from -http://www.3dconnexion.eu/service/drivers.html +The Mac version does not require any files. The 3D Connexion driver should be installed from http://www.3dconnexion.eu/service/drivers.html -For windows a header file is required Inc/I3dMouseParams.h +For Windows the provided header file is required: Inc/I3dMouseParams.h \ No newline at end of file diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 1c91f9282c..74cf701aad 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -115,7 +115,7 @@ #include "devices/MIDIManager.h" #include "devices/OculusManager.h" #include "devices/TV3DManager.h" -#include "devices/3Dconnexion.h" +#include "devices/3DConnexionClient.h" #include "scripting/AccountScriptingInterface.h" #include "scripting/AudioDeviceScriptingInterface.h" diff --git a/interface/src/Menu.cpp b/interface/src/Menu.cpp index 1cbe127857..3cade466e2 100644 --- a/interface/src/Menu.cpp +++ b/interface/src/Menu.cpp @@ -29,7 +29,7 @@ #include "devices/Faceshift.h" #include "devices/RealSense.h" #include "devices/SixenseManager.h" -#include "devices/3Dconnexion.h" +#include "devices/3DConnexionClient.h" #include "MainWindow.h" #include "scripting/MenuScriptingInterface.h" #if defined(Q_OS_MAC) || defined(Q_OS_WIN) diff --git a/interface/src/devices/3Dconnexion.cpp b/interface/src/devices/3DConnexionClient.cpp similarity index 91% rename from interface/src/devices/3Dconnexion.cpp rename to interface/src/devices/3DConnexionClient.cpp index ef66e6660b..6028c4c6de 100755 --- a/interface/src/devices/3Dconnexion.cpp +++ b/interface/src/devices/3DConnexionClient.cpp @@ -1,6 +1,6 @@ // -// 3DConnexion.cpp -// hifi +// 3DConnexionClient.cpp +// interface/src/devices // // Created by MarcelEdward Verhagen on 09-06-15. // Copyright 2015 High Fidelity, Inc. @@ -9,7 +9,7 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#include "3Dconnexion.h" +#include "3DConnexionClient.h" #include "UserActivityLogger.h" const float MAX_AXIS = 75.0f; // max forward = 2x speed @@ -28,7 +28,6 @@ ConnexionData::ConnexionData() { } void ConnexionData::handleAxisEvent() { - //qCWarning(interfaceapp) << "pos state x = " << cc_position.x << " y = " << cc_position.y << " z = " << cc_position.z << " Rotation x = " << cc_rotation.x << " y = " << cc_rotation.y << " z = " << cc_rotation.z; _axisStateMap[makeInput(ROTATION_AXIS_Y_POS).getChannel()] = (cc_rotation.y > 0.0f) ? cc_rotation.y / MAX_AXIS : 0.0f; _axisStateMap[makeInput(ROTATION_AXIS_Y_NEG).getChannel()] = (cc_rotation.y < 0.0f) ? -cc_rotation.y / MAX_AXIS : 0.0f; _axisStateMap[makeInput(POSITION_AXIS_X_POS).getChannel()] = (cc_position.x > 0.0f) ? cc_position.x / MAX_AXIS : 0.0f; @@ -148,7 +147,7 @@ UserInputMapper::Input ConnexionData::makeInput(ConnexionData::PositionChannel a void ConnexionData::update() { // the update is done in the ConnexionClient class. - // for windows in the nativeEventFilter the inputmapper is connected or registed or removed when an 3Dconnnexion device is attached or deteched + // for windows in the nativeEventFilter the inputmapper is connected or registed or removed when an 3Dconnnexion device is attached or detached // for osx the api will call DeviceAddedHandler or DeviceRemoveHandler when a 3Dconnexion device is attached or detached } @@ -157,14 +156,13 @@ ConnexionClient& ConnexionClient::getInstance() { return sharedInstance; } -#ifdef HAVE_CONNEXIONCLIENT +#ifdef HAVE_3DCONNEXIONCLIENT #ifdef _WIN32 static ConnexionClient* gMouseInput = 0; -void ConnexionClient::toggleConnexion(bool shouldEnable) -{ +void ConnexionClient::toggleConnexion(bool shouldEnable) { ConnexionData& connexiondata = ConnexionData::getInstance(); if (shouldEnable && connexiondata.getDeviceID() == 0) { ConnexionClient::init(); @@ -225,15 +223,15 @@ enum ConnexionPid { // e3dmouse_virtual_key enum V3dk { - V3DK_INVALID = 0 - , V3DK_MENU = 1, V3DK_FIT - , V3DK_TOP, V3DK_LEFT, V3DK_RIGHT, V3DK_FRONT, V3DK_BOTTOM, V3DK_BACK - , V3DK_CW, V3DK_CCW - , V3DK_ISO1, V3DK_ISO2 - , V3DK_1, V3DK_2, V3DK_3, V3DK_4, V3DK_5, V3DK_6, V3DK_7, V3DK_8, V3DK_9, V3DK_10 - , V3DK_ESC, V3DK_ALT, V3DK_SHIFT, V3DK_CTRL - , V3DK_ROTATE, V3DK_PANZOOM, V3DK_DOMINANT - , V3DK_PLUS, V3DK_MINUS + V3DK_INVALID = 0, + V3DK_MENU = 1, V3DK_FIT, + V3DK_TOP, V3DK_LEFT, V3DK_RIGHT, V3DK_FRONT, V3DK_BOTTOM, V3DK_BACK, + V3DK_CW, V3DK_CCW, + V3DK_ISO1, V3DK_ISO2, + V3DK_1, V3DK_2, V3DK_3, V3DK_4, V3DK_5, V3DK_6, V3DK_7, V3DK_8, V3DK_9, V3DK_10, + V3DK_ESC, V3DK_ALT, V3DK_SHIFT, V3DK_CTRL, + V3DK_ROTATE, V3DK_PANZOOM, V3DK_DOMINANT, + V3DK_PLUS, V3DK_MINUS }; struct tag_VirtualKeys { @@ -244,33 +242,33 @@ struct tag_VirtualKeys { // e3dmouse_virtual_key static const V3dk SpaceExplorerKeys[] = { - V3DK_INVALID // there is no button 0 - , V3DK_1, V3DK_2 - , V3DK_TOP, V3DK_LEFT, V3DK_RIGHT, V3DK_FRONT - , V3DK_ESC, V3DK_ALT, V3DK_SHIFT, V3DK_CTRL - , V3DK_FIT, V3DK_MENU - , V3DK_PLUS, V3DK_MINUS - , V3DK_ROTATE + V3DK_INVALID, // there is no button 0 + V3DK_1, V3DK_2, + V3DK_TOP, V3DK_LEFT, V3DK_RIGHT, V3DK_FRONT, + V3DK_ESC, V3DK_ALT, V3DK_SHIFT, V3DK_CTRL, + V3DK_FIT, V3DK_MENU, + V3DK_PLUS, V3DK_MINUS, + V3DK_ROTATE }; //e3dmouse_virtual_key static const V3dk SpacePilotKeys[] = { - V3DK_INVALID - , V3DK_1, V3DK_2, V3DK_3, V3DK_4, V3DK_5, V3DK_6 - , V3DK_TOP, V3DK_LEFT, V3DK_RIGHT, V3DK_FRONT - , V3DK_ESC, V3DK_ALT, V3DK_SHIFT, V3DK_CTRL - , V3DK_FIT, V3DK_MENU - , V3DK_PLUS, V3DK_MINUS - , V3DK_DOMINANT, V3DK_ROTATE + V3DK_INVALID, + V3DK_1, V3DK_2, V3DK_3, V3DK_4, V3DK_5, V3DK_6, + V3DK_TOP, V3DK_LEFT, V3DK_RIGHT, V3DK_FRONT, + V3DK_ESC, V3DK_ALT, V3DK_SHIFT, V3DK_CTRL, + V3DK_FIT, V3DK_MENU, + V3DK_PLUS, V3DK_MINUS, + V3DK_DOMINANT, V3DK_ROTATE, }; static const struct tag_VirtualKeys _3dmouseVirtualKeys[] = { - CONNEXIONPID_SPACEPILOT - , sizeof(SpacePilotKeys) / sizeof(SpacePilotKeys[0]) - , const_cast(SpacePilotKeys), - CONNEXIONPID_SPACEEXPLORER - , sizeof(SpaceExplorerKeys) / sizeof(SpaceExplorerKeys[0]) - , const_cast(SpaceExplorerKeys) + CONNEXIONPID_SPACEPILOT, + sizeof(SpacePilotKeys) / sizeof(SpacePilotKeys[0]), + const_cast(SpacePilotKeys), + CONNEXIONPID_SPACEEXPLORER, + sizeof(SpaceExplorerKeys) / sizeof(SpaceExplorerKeys[0]), + const_cast(SpaceExplorerKeys) }; // Converts a hid device keycode (button identifier) of a pre-2009 3Dconnexion USB device to the standard 3d mouse virtual key definition. @@ -282,10 +280,8 @@ static const struct tag_VirtualKeys _3dmouseVirtualKeys[] = { // to the standard 3d mouse virtual key definition. unsigned short HidToVirtualKey(unsigned long pid, unsigned short hidKeyCode) { unsigned short virtualkey = hidKeyCode; - for (size_t i = 0; imessage == WM_INPUT) { HRAWINPUT hRawInput = reinterpret_cast(message->lParam); gMouseInput->OnRawInput(RIM_INPUT, hRawInput); - if (result != 0) { + if (result != 0) { result = 0; } return true; @@ -680,8 +676,6 @@ void ConnexionClient::OnRawInput(UINT nInputCode, HRAWINPUT hRawInput) { bool ConnexionClient::TranslateRawInputData(UINT nInputCode, PRAWINPUT pRawInput) { bool bIsForeground = (nInputCode == RIM_INPUT); - //qDebug("Rawinput.header.dwType=0x%x\n", pRawInput->header.dwType); - // We are not interested in keyboard or mouse data received via raw input if (pRawInput->header.dwType != RIM_TYPEHID) { return false; @@ -689,9 +683,9 @@ bool ConnexionClient::TranslateRawInputData(UINT nInputCode, PRAWINPUT pRawInput if (TRACE_RIDI_DEVICENAME == 1) { UINT dwSize = 0; - if (::GetRawInputDeviceInfo(pRawInput->header.hDevice, RIDI_DEVICENAME, NULL, &dwSize) == 0) { + if (::GetRawInputDeviceInfo(pRawInput->header.hDevice, RIDI_DEVICENAME, NULL, &dwSize) == 0) { std::vector szDeviceName(dwSize + 1); - if (::GetRawInputDeviceInfo(pRawInput->header.hDevice, RIDI_DEVICENAME, &szDeviceName[0], &dwSize) >0) { + if (::GetRawInputDeviceInfo(pRawInput->header.hDevice, RIDI_DEVICENAME, &szDeviceName[0], &dwSize) > 0) { qDebug("Device Name = %s\nDevice handle = 0x%x\n", &szDeviceName[0], pRawInput->header.hDevice); } } @@ -703,7 +697,7 @@ bool ConnexionClient::TranslateRawInputData(UINT nInputCode, PRAWINPUT pRawInput if (::GetRawInputDeviceInfo(pRawInput->header.hDevice, RIDI_DEVICEINFO, &sRidDeviceInfo, &cbSize) == cbSize) { if (TRACE_RIDI_DEVICEINFO == 1) { - switch (sRidDeviceInfo.dwType) { + switch (sRidDeviceInfo.dwType) { case RIM_TYPEMOUSE: qDebug("\tsRidDeviceInfo.dwType=RIM_TYPEMOUSE\n"); break; @@ -806,16 +800,19 @@ bool ConnexionClient::TranslateRawInputData(UINT nInputCode, PRAWINPUT pRawInput return false; } -MouseParameters::MouseParameters() : fNavigation(NAVIGATION_OBJECT_MODE) - , fPivot(PIVOT_AUTO) - , fPivotVisibility(PIVOT_SHOW) - , fIsLockHorizon(true) - , fIsPanZoom(true) - , fIsRotate(true) - , fSpeed(SPEED_LOW) { +MouseParameters::MouseParameters() : + fNavigation(NAVIGATION_OBJECT_MODE), + fPivot(PIVOT_AUTO), + fPivotVisibility(PIVOT_SHOW), + fIsLockHorizon(true), + fIsPanZoom(true), + fIsRotate(true), + fSpeed(SPEED_LOW) +{ } -MouseParameters::~MouseParameters() { +MouseParameters::~MouseParameters() +{ } bool MouseParameters::IsPanZoom() const { @@ -831,15 +828,15 @@ MouseParameters::Speed MouseParameters::GetSpeed() const { } void MouseParameters::SetPanZoom(bool isPanZoom) { - fIsPanZoom=isPanZoom; + fIsPanZoom = isPanZoom; } void MouseParameters::SetRotate(bool isRotate) { - fIsRotate=isRotate; + fIsRotate = isRotate; } void MouseParameters::SetSpeed(Speed speed) { - fSpeed=speed; + fSpeed = speed; } MouseParameters::Navigation MouseParameters::GetNavigationMode() const { @@ -1010,4 +1007,4 @@ void MessageHandler(unsigned int connection, unsigned int messageType, void *mes #endif // __APPLE__ -#endif // HAVE_CONNEXIONCLIENT +#endif // HAVE_3DCONNEXIONCLIENT diff --git a/interface/src/devices/3Dconnexion.h b/interface/src/devices/3DConnexionClient.h similarity index 93% rename from interface/src/devices/3Dconnexion.h rename to interface/src/devices/3DConnexionClient.h index 28b4924e44..454c89f797 100755 --- a/interface/src/devices/3Dconnexion.h +++ b/interface/src/devices/3DConnexionClient.h @@ -1,5 +1,5 @@ -// 3DConnexion.h -// hifi +// 3DConnexionClient.h +// interface/src/devices // // Created by Marcel Verhagen on 09-06-15. // Copyright 2015 High Fidelity, Inc. @@ -8,8 +8,8 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#ifndef hifi_ConnexionClient_h -#define hifi_ConnexionClient_h +#ifndef hifi_3DConnexionClient_h +#define hifi_3DConnexionClient_h #include #include @@ -18,7 +18,7 @@ #include "ui/UserInputMapper.h" -#ifndef HAVE_CONNEXIONCLIENT +#ifndef HAVE_3DCONNEXIONCLIENT class ConnexionClient : public QObject { Q_OBJECT public: @@ -29,9 +29,9 @@ public: public slots: void toggleConnexion(bool shouldEnable) {}; }; -#endif // NOT_HAVE_CONNEXIONCLIENT +#endif // NOT_HAVE_3DCONNEXIONCLIENT -#ifdef HAVE_CONNEXIONCLIENT +#ifdef HAVE_3DCONNEXIONCLIENT // the windows connexion rawinput #ifdef _WIN32 @@ -86,16 +86,15 @@ private: class ConnexionClient : public QObject, public QAbstractNativeEventFilter { Q_OBJECT public: - ConnexionClient(); + ConnexionClient(); ~ConnexionClient(); - static ConnexionClient& getInstance(); - - ConnexionClient* client; + static ConnexionClient& getInstance(); static void init(); static void destroy(); - static bool Is3dmouseAttached(); + + ConnexionClient* client; I3dMouseParam& MouseParams(); const I3dMouseParam& MouseParams() const; @@ -166,16 +165,16 @@ class ConnexionClient : public QObject { Q_OBJECT public: static ConnexionClient& getInstance(); - static bool Is3dmouseAttached(); static void init(); static void destroy(); + static bool Is3dmouseAttached(); public slots: void toggleConnexion(bool shouldEnable); }; #endif // __APPLE__ -#endif // HAVE_CONNEXIONCLIENT +#endif // HAVE_3DCONNEXIONCLIENT // connnects to the userinputmapper @@ -241,4 +240,4 @@ protected: AxisStateMap _axisStateMap; }; -#endif // defined(hifi_ConnexionClient_h) \ No newline at end of file +#endif // defined(hifi_3DConnexionClient_h) \ No newline at end of file From b8f7d4b8c8a25124b0382378bdf00570597dd981 Mon Sep 17 00:00:00 2001 From: Sam Gondelman Date: Thu, 30 Jul 2015 13:19:05 -0700 Subject: [PATCH 2/7] more work on cleaning up connexion --- cmake/modules/Find3DConnexionClient.cmake | 2 +- interface/src/devices/3DConnexionClient.cpp | 13 +++++-------- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/cmake/modules/Find3DConnexionClient.cmake b/cmake/modules/Find3DConnexionClient.cmake index 7f38824a81..2b5508cfcc 100644 --- a/cmake/modules/Find3DConnexionClient.cmake +++ b/cmake/modules/Find3DConnexionClient.cmake @@ -24,7 +24,7 @@ if (APPLE) set(3DCONNEXIONCLIENT_INCLUDE_DIRS ${3DConnexionClient}) set(3DCONNEXIONCLIENT_LIBRARY ${3DConnexionClient}) set_target_properties(${TARGET_NAME} PROPERTIES LINK_FLAGS "-weak_framework 3DConnexionClient") - message(STATUS "Found 3DConnexion " + ${3DConnexionClient}) + message(STATUS "Found 3DConnexion at " ${3DConnexionClient}) mark_as_advanced(3DCONNEXIONCLIENT_INCLUDE_DIR CONNEXIONCLIENT_LIBRARY) else () message(STATUS "Could NOT find 3DConnexionClient") diff --git a/interface/src/devices/3DConnexionClient.cpp b/interface/src/devices/3DConnexionClient.cpp index 6028c4c6de..4743370778 100755 --- a/interface/src/devices/3DConnexionClient.cpp +++ b/interface/src/devices/3DConnexionClient.cpp @@ -175,20 +175,18 @@ void ConnexionClient::toggleConnexion(bool shouldEnable) { void ConnexionClient::init() { if (Menu::getInstance()->isOptionChecked(MenuOption::Connexion)) { - ConnexionClient& cclient = ConnexionClient::getInstance(); - cclient.fLast3dmouseInputTime = 0; + fLast3dmouseInputTime = 0; - cclient.InitializeRawInput(GetActiveWindow()); + InitializeRawInput(GetActiveWindow()); - gMouseInput = &cclient; + gMouseInput = &this; QAbstractEventDispatcher::instance()->installNativeEventFilter(&cclient); } } void ConnexionClient::destroy() { - ConnexionClient& cclient = ConnexionClient::getInstance(); - QAbstractEventDispatcher::instance()->removeNativeEventFilter(&cclient); + QAbstractEventDispatcher::instance()->removeNativeEventFilter(&this); ConnexionData& connexiondata = ConnexionData::getInstance(); int deviceid = connexiondata.getDeviceID(); connexiondata.setDeviceID(0); @@ -328,8 +326,7 @@ ConnexionClient::ConnexionClient() { } ConnexionClient::~ConnexionClient() { - ConnexionClient& cclient = ConnexionClient::getInstance(); - QAbstractEventDispatcher::instance()->removeNativeEventFilter(&cclient); + QAbstractEventDispatcher::instance()->removeNativeEventFilter(&this); } // Access the mouse parameters structure From a01a4f929f50d99e4e45406ce3072991821b3e66 Mon Sep 17 00:00:00 2001 From: Sam Gondelman Date: Thu, 30 Jul 2015 15:14:51 -0700 Subject: [PATCH 3/7] removing unnecessary weak link --- cmake/modules/Find3DConnexionClient.cmake | 1 - interface/src/devices/3DConnexionClient.cpp | 13 ++----------- 2 files changed, 2 insertions(+), 12 deletions(-) diff --git a/cmake/modules/Find3DConnexionClient.cmake b/cmake/modules/Find3DConnexionClient.cmake index 2b5508cfcc..522c25478e 100644 --- a/cmake/modules/Find3DConnexionClient.cmake +++ b/cmake/modules/Find3DConnexionClient.cmake @@ -23,7 +23,6 @@ if (APPLE) set(3DCONNEXIONCLIENT_FOUND true) set(3DCONNEXIONCLIENT_INCLUDE_DIRS ${3DConnexionClient}) set(3DCONNEXIONCLIENT_LIBRARY ${3DConnexionClient}) - set_target_properties(${TARGET_NAME} PROPERTIES LINK_FLAGS "-weak_framework 3DConnexionClient") message(STATUS "Found 3DConnexion at " ${3DConnexionClient}) mark_as_advanced(3DCONNEXIONCLIENT_INCLUDE_DIR CONNEXIONCLIENT_LIBRARY) else () diff --git a/interface/src/devices/3DConnexionClient.cpp b/interface/src/devices/3DConnexionClient.cpp index 4743370778..2e0a30715c 100755 --- a/interface/src/devices/3DConnexionClient.cpp +++ b/interface/src/devices/3DConnexionClient.cpp @@ -872,13 +872,6 @@ void MouseParameters::SetPivotVisibility(PivotVisibility visibility) { #else -#define WITH_SEPARATE_THREAD false // set to true or false - -// Make the linker happy for the framework check (see link below for more info) -// http://developer.apple.com/documentation/MacOSX/Conceptual/BPFrameworks/Concepts/WeakLinking.html - -extern int16_t SetConnexionHandlers(ConnexionMessageHandlerProc messageHandler, ConnexionAddedHandlerProc addedHandler, ConnexionRemovedHandlerProc removedHandler, bool useSeparateThread) __attribute__((weak_import)); - int fConnexionClientID; static ConnexionDeviceState lastState; @@ -887,20 +880,18 @@ static void DeviceAddedHandler(unsigned int connection); static void DeviceRemovedHandler(unsigned int connection); static void MessageHandler(unsigned int connection, unsigned int messageType, void *messageArgument); -void ConnexionClient::toggleConnexion(bool shouldEnable) -{ +void ConnexionClient::toggleConnexion(bool shouldEnable) { if (shouldEnable && !ConnexionClient::Is3dmouseAttached()) { ConnexionClient::init(); } if (!shouldEnable && ConnexionClient::Is3dmouseAttached()) { ConnexionClient::destroy(); } - } void ConnexionClient::init() { // Make sure the framework is installed - if (SetConnexionHandlers != NULL && Menu::getInstance()->isOptionChecked(MenuOption::Connexion)) { + if (Menu::getInstance()->isOptionChecked(MenuOption::Connexion)) { // Install message handler and register our client InstallConnexionHandlers(MessageHandler, DeviceAddedHandler, DeviceRemovedHandler); // Either use this to take over in our application only... does not work From 25e75bcc7938f04203330501cc05c8048c7b7ec8 Mon Sep 17 00:00:00 2001 From: SamGondelman Date: Thu, 30 Jul 2015 18:11:24 -0700 Subject: [PATCH 4/7] WIP: trying to fix windows not finding framework --- cmake/modules/Find3DConnexionClient.cmake | 5 ++--- interface/src/devices/3DConnexionClient.cpp | 2 +- interface/src/devices/3DConnexionClient.h | 2 +- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/cmake/modules/Find3DConnexionClient.cmake b/cmake/modules/Find3DConnexionClient.cmake index 522c25478e..ffd6477ae4 100644 --- a/cmake/modules/Find3DConnexionClient.cmake +++ b/cmake/modules/Find3DConnexionClient.cmake @@ -28,9 +28,8 @@ if (APPLE) else () message(STATUS "Could NOT find 3DConnexionClient") endif() -endif() - -if (WIN32) +elseif (WIN32) + message(STATUS ${CONNEXIONCLIENT_SEARCH_DIRS}) find_path(3DCONNEXIONCLIENT_INCLUDE_DIRS I3dMouseParams.h PATH_SUFFIXES Inc HINTS ${CONNEXIONCLIENT_SEARCH_DIRS}) include(FindPackageHandleStandardArgs) diff --git a/interface/src/devices/3DConnexionClient.cpp b/interface/src/devices/3DConnexionClient.cpp index 2e0a30715c..00a570f66c 100755 --- a/interface/src/devices/3DConnexionClient.cpp +++ b/interface/src/devices/3DConnexionClient.cpp @@ -158,7 +158,7 @@ ConnexionClient& ConnexionClient::getInstance() { #ifdef HAVE_3DCONNEXIONCLIENT -#ifdef _WIN32 +#ifdef Q_OS_WIN static ConnexionClient* gMouseInput = 0; diff --git a/interface/src/devices/3DConnexionClient.h b/interface/src/devices/3DConnexionClient.h index 454c89f797..ea9aa7456f 100755 --- a/interface/src/devices/3DConnexionClient.h +++ b/interface/src/devices/3DConnexionClient.h @@ -33,7 +33,7 @@ public slots: #ifdef HAVE_3DCONNEXIONCLIENT // the windows connexion rawinput -#ifdef _WIN32 +#ifdef Q_OS_WIN #include "I3dMouseParams.h" #include From e8daee013e80178230580754537222f41422c5b6 Mon Sep 17 00:00:00 2001 From: SamGondelman Date: Fri, 31 Jul 2015 16:27:10 -0700 Subject: [PATCH 5/7] windows finds framework --- cmake/modules/Find3DConnexionClient.cmake | 7 +++---- .../Inc => 3dconnexionclient/include}/I3dMouseParams.h | 0 .../{connexionclient => 3dconnexionclient}/readme.txt | 2 +- 3 files changed, 4 insertions(+), 5 deletions(-) rename interface/external/{connexionclient/Inc => 3dconnexionclient/include}/I3dMouseParams.h (100%) rename interface/external/{connexionclient => 3dconnexionclient}/readme.txt (65%) diff --git a/cmake/modules/Find3DConnexionClient.cmake b/cmake/modules/Find3DConnexionClient.cmake index ffd6477ae4..eea16dc619 100644 --- a/cmake/modules/Find3DConnexionClient.cmake +++ b/cmake/modules/Find3DConnexionClient.cmake @@ -15,7 +15,7 @@ # include("${MACRO_DIR}/HifiLibrarySearchHints.cmake") -hifi_library_search_hints("connexionclient") +hifi_library_search_hints("3dconnexionclient") if (APPLE) find_library(3DConnexionClient 3DConnexionClient) @@ -24,13 +24,12 @@ if (APPLE) set(3DCONNEXIONCLIENT_INCLUDE_DIRS ${3DConnexionClient}) set(3DCONNEXIONCLIENT_LIBRARY ${3DConnexionClient}) message(STATUS "Found 3DConnexion at " ${3DConnexionClient}) - mark_as_advanced(3DCONNEXIONCLIENT_INCLUDE_DIR CONNEXIONCLIENT_LIBRARY) + mark_as_advanced(3DCONNEXIONCLIENT_INCLUDE_DIR 3DCONNEXIONCLIENT_LIBRARY) else () message(STATUS "Could NOT find 3DConnexionClient") endif() elseif (WIN32) - message(STATUS ${CONNEXIONCLIENT_SEARCH_DIRS}) - find_path(3DCONNEXIONCLIENT_INCLUDE_DIRS I3dMouseParams.h PATH_SUFFIXES Inc HINTS ${CONNEXIONCLIENT_SEARCH_DIRS}) + find_path(3DCONNEXIONCLIENT_INCLUDE_DIRS I3dMouseParams.h PATH_SUFFIXES include HINTS ${3DCONNEXIONCLIENT_SEARCH_DIRS}) include(FindPackageHandleStandardArgs) find_package_handle_standard_args(3DConnexionClient DEFAULT_MSG 3DCONNEXIONCLIENT_INCLUDE_DIRS) diff --git a/interface/external/connexionclient/Inc/I3dMouseParams.h b/interface/external/3dconnexionclient/include/I3dMouseParams.h similarity index 100% rename from interface/external/connexionclient/Inc/I3dMouseParams.h rename to interface/external/3dconnexionclient/include/I3dMouseParams.h diff --git a/interface/external/connexionclient/readme.txt b/interface/external/3dconnexionclient/readme.txt similarity index 65% rename from interface/external/connexionclient/readme.txt rename to interface/external/3dconnexionclient/readme.txt index cbfc5a277a..a8014b386d 100644 --- a/interface/external/connexionclient/readme.txt +++ b/interface/external/3dconnexionclient/readme.txt @@ -1,3 +1,3 @@ The Mac version does not require any files. The 3D Connexion driver should be installed from http://www.3dconnexion.eu/service/drivers.html -For Windows the provided header file is required: Inc/I3dMouseParams.h \ No newline at end of file +For Windows the provided header file is required: include/I3dMouseParams.h \ No newline at end of file From 8908c7c1417525477a9f9a79b9a5c6375565847f Mon Sep 17 00:00:00 2001 From: SamGondelman Date: Fri, 31 Jul 2015 17:55:59 -0700 Subject: [PATCH 6/7] working on windows crash --- interface/src/Application.cpp | 4 +-- interface/src/devices/3DConnexionClient.cpp | 33 +++++++++------------ interface/src/devices/3DConnexionClient.h | 22 +++++++------- 3 files changed, 27 insertions(+), 32 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 74cf701aad..9b155f8b84 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -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 } diff --git a/interface/src/devices/3DConnexionClient.cpp b/interface/src/devices/3DConnexionClient.cpp index 00a570f66c..5a9cc9e462 100755 --- a/interface/src/devices/3DConnexionClient.cpp +++ b/interface/src/devices/3DConnexionClient.cpp @@ -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(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"); diff --git a/interface/src/devices/3DConnexionClient.h b/interface/src/devices/3DConnexionClient.h index ea9aa7456f..83472a35c0 100755 --- a/interface/src/devices/3DConnexionClient.h +++ b/interface/src/devices/3DConnexionClient.h @@ -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); }; From 95232920f109e0d2fdff0612b87e46100b4eb66a Mon Sep 17 00:00:00 2001 From: Sam Gondelman Date: Mon, 3 Aug 2015 16:35:34 -0700 Subject: [PATCH 7/7] trying to fix mac linking errors --- cmake/modules/Find3DConnexionClient.cmake | 2 +- interface/src/devices/3DConnexionClient.cpp | 12 ------------ interface/src/devices/3DConnexionClient.h | 4 +--- 3 files changed, 2 insertions(+), 16 deletions(-) diff --git a/cmake/modules/Find3DConnexionClient.cmake b/cmake/modules/Find3DConnexionClient.cmake index eea16dc619..51ac1d4f71 100644 --- a/cmake/modules/Find3DConnexionClient.cmake +++ b/cmake/modules/Find3DConnexionClient.cmake @@ -18,7 +18,7 @@ include("${MACRO_DIR}/HifiLibrarySearchHints.cmake") hifi_library_search_hints("3dconnexionclient") if (APPLE) - find_library(3DConnexionClient 3DConnexionClient) + find_library(3DCONNEXIONCLIENT_LIBRARIES NAMES 3DConnexionClient HINTS 3DCONNEXIONCLIENT_SEARCH_DIRS) if(EXISTS ${3DConnexionClient}) set(3DCONNEXIONCLIENT_FOUND true) set(3DCONNEXIONCLIENT_INCLUDE_DIRS ${3DConnexionClient}) diff --git a/interface/src/devices/3DConnexionClient.cpp b/interface/src/devices/3DConnexionClient.cpp index 5a9cc9e462..7459f7da2a 100755 --- a/interface/src/devices/3DConnexionClient.cpp +++ b/interface/src/devices/3DConnexionClient.cpp @@ -316,14 +316,6 @@ bool ConnexionClient::RawInputEventFilter(void* msg, long* result) { return false; } -ConnexionClient::ConnexionClient() { - -} - -ConnexionClient::~ConnexionClient() { - -} - // Access the mouse parameters structure I3dMouseParam& ConnexionClient::MouseParams() { return f3dMouseParams; @@ -803,10 +795,6 @@ MouseParameters::MouseParameters() : { } -MouseParameters::~MouseParameters() -{ -} - bool MouseParameters::IsPanZoom() const { return fIsPanZoom; } diff --git a/interface/src/devices/3DConnexionClient.h b/interface/src/devices/3DConnexionClient.h index 83472a35c0..f0e9f10785 100755 --- a/interface/src/devices/3DConnexionClient.h +++ b/interface/src/devices/3DConnexionClient.h @@ -45,7 +45,6 @@ public slots: class MouseParameters : public I3dMouseParam { public: MouseParameters(); - ~MouseParameters(); // I3dmouseSensor interface bool IsPanZoom() const; @@ -86,8 +85,7 @@ private: class ConnexionClient : public QObject, public QAbstractNativeEventFilter { Q_OBJECT public: - ConnexionClient(); - ~ConnexionClient(); + ConnexionClient() {}; static ConnexionClient& getInstance(); void init();