diff --git a/assignment-client/CMakeLists.txt b/assignment-client/CMakeLists.txt index 84a36c6c51..e543b3aa21 100644 --- a/assignment-client/CMakeLists.txt +++ b/assignment-client/CMakeLists.txt @@ -2,10 +2,6 @@ set(TARGET_NAME assignment-client) setup_hifi_project(Core Gui Network Script Widgets WebSockets) -add_dependency_external_projects(glm) -find_package(GLM REQUIRED) -target_include_directories(${TARGET_NAME} PRIVATE ${GLM_INCLUDE_DIRS}) - # link in the shared libraries link_hifi_libraries( audio avatars octree environment gpu model fbx entities diff --git a/cmake/macros/LinkHifiLibraries.cmake b/cmake/macros/LinkHifiLibraries.cmake index d0a12f3bea..70399bedb4 100644 --- a/cmake/macros/LinkHifiLibraries.cmake +++ b/cmake/macros/LinkHifiLibraries.cmake @@ -16,7 +16,6 @@ macro(LINK_HIFI_LIBRARIES) foreach(HIFI_LIBRARY ${LIBRARIES_TO_LINK}) if (NOT TARGET ${HIFI_LIBRARY}) add_subdirectory("${RELATIVE_LIBRARY_DIR_PATH}/${HIFI_LIBRARY}" "${RELATIVE_LIBRARY_DIR_PATH}/${HIFI_LIBRARY}") - set_target_properties(${HIFI_LIBRARY} PROPERTIES FOLDER "Libraries") endif () include_directories("${HIFI_LIBRARY_DIR}/${HIFI_LIBRARY}/src") diff --git a/cmake/macros/SetupHifiLibrary.cmake b/cmake/macros/SetupHifiLibrary.cmake index ccb5ca2484..9c6cbf6831 100644 --- a/cmake/macros/SetupHifiLibrary.cmake +++ b/cmake/macros/SetupHifiLibrary.cmake @@ -36,5 +36,9 @@ macro(SETUP_HIFI_LIBRARY) # Don't make scribed shaders cumulative set(AUTOSCRIBE_SHADER_LIB_SRC "") + + target_glm() + + set_target_properties(${TARGET_NAME} PROPERTIES FOLDER "Libraries") endmacro(SETUP_HIFI_LIBRARY) \ No newline at end of file diff --git a/cmake/macros/SetupHifiProject.cmake b/cmake/macros/SetupHifiProject.cmake index bd6cbef9dc..166a3fd4b9 100644 --- a/cmake/macros/SetupHifiProject.cmake +++ b/cmake/macros/SetupHifiProject.cmake @@ -34,4 +34,7 @@ macro(SETUP_HIFI_PROJECT) foreach(QT_MODULE ${${TARGET_NAME}_DEPENDENCY_QT_MODULES}) target_link_libraries(${TARGET_NAME} Qt5::${QT_MODULE}) endforeach() + + target_glm() + endmacro() diff --git a/cmake/macros/SetupHifiTestCase.cmake b/cmake/macros/SetupHifiTestCase.cmake index 2507a30f5e..38239d6e97 100644 --- a/cmake/macros/SetupHifiTestCase.cmake +++ b/cmake/macros/SetupHifiTestCase.cmake @@ -94,6 +94,7 @@ macro(SETUP_HIFI_TESTCASE) EXCLUDE_FROM_DEFAULT_BUILD TRUE EXCLUDE_FROM_ALL TRUE) + list (APPEND ${TEST_PROJ_NAME}_TARGETS ${TARGET_NAME}) #list (APPEND ALL_TEST_TARGETS ${TARGET_NAME}) @@ -111,8 +112,9 @@ macro(SETUP_HIFI_TESTCASE) set_target_properties(${TARGET_NAME} PROPERTIES FOLDER "hidden/test-executables") # handle testcase-specific dependencies (this a macro that should be defined in the cmakelists.txt file in each tests subdir) - - SETUP_TESTCASE_DEPENDENCIES () + SETUP_TESTCASE_DEPENDENCIES() + target_glm() + endforeach () set(TEST_TARGET ${TEST_PROJ_NAME}-tests) diff --git a/cmake/macros/TargetBullet.cmake b/cmake/macros/TargetBullet.cmake new file mode 100644 index 0000000000..600ae9e63b --- /dev/null +++ b/cmake/macros/TargetBullet.cmake @@ -0,0 +1,18 @@ +# +# Copyright 2015 High Fidelity, Inc. +# Created by Bradley Austin Davis on 2015/10/10 +# +# Distributed under the Apache License, Version 2.0. +# See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +# +macro(TARGET_BULLET) + add_dependency_external_projects(bullet) + find_package(Bullet REQUIRED) + # perform the system include hack for OS X to ignore warnings + if (APPLE) + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -isystem ${BULLET_INCLUDE_DIRS}") + else() + target_include_directories(${TARGET_NAME} SYSTEM PRIVATE ${BULLET_INCLUDE_DIRS}) + endif() + target_link_libraries(${TARGET_NAME} ${BULLET_LIBRARIES}) +endmacro() \ No newline at end of file diff --git a/cmake/macros/TargetGlew.cmake b/cmake/macros/TargetGlew.cmake new file mode 100644 index 0000000000..5f71f021ec --- /dev/null +++ b/cmake/macros/TargetGlew.cmake @@ -0,0 +1,14 @@ +# +# Copyright 2015 High Fidelity, Inc. +# Created by Bradley Austin Davis on 2015/10/10 +# +# Distributed under the Apache License, Version 2.0. +# See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +# +macro(TARGET_GLEW) + add_dependency_external_projects(glew) + find_package(GLEW REQUIRED) + add_definitions(-DGLEW_STATIC) + target_include_directories(${TARGET_NAME} PUBLIC ${GLEW_INCLUDE_DIRS}) + target_link_libraries(${TARGET_NAME} ${GLEW_LIBRARY}) +endmacro() \ No newline at end of file diff --git a/cmake/macros/TargetGlm.cmake b/cmake/macros/TargetGlm.cmake new file mode 100644 index 0000000000..324cb1c17a --- /dev/null +++ b/cmake/macros/TargetGlm.cmake @@ -0,0 +1,12 @@ +# +# Copyright 2015 High Fidelity, Inc. +# Created by Bradley Austin Davis on 2015/10/10 +# +# Distributed under the Apache License, Version 2.0. +# See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +# +macro(TARGET_GLM) + add_dependency_external_projects(glm) + find_package(GLM REQUIRED) + target_include_directories(${TARGET_NAME} PUBLIC ${GLM_INCLUDE_DIRS}) +endmacro() \ No newline at end of file diff --git a/cmake/macros/TargetNsight.cmake b/cmake/macros/TargetNsight.cmake new file mode 100644 index 0000000000..4b7e87e9d3 --- /dev/null +++ b/cmake/macros/TargetNsight.cmake @@ -0,0 +1,20 @@ +# +# Copyright 2015 High Fidelity, Inc. +# Created by Bradley Austin Davis on 2015/10/10 +# +# Distributed under the Apache License, Version 2.0. +# See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +# +macro(TARGET_NSIGHT) + if (WIN32) + if (USE_NSIGHT) + # try to find the Nsight package and add it to the build if we find it + find_package(NSIGHT) + if (NSIGHT_FOUND) + include_directories(${NSIGHT_INCLUDE_DIRS}) + add_definitions(-DNSIGHT_FOUND) + target_link_libraries(${TARGET_NAME} "${NSIGHT_LIBRARIES}") + endif () + endif() + endif (WIN32) +endmacro() \ No newline at end of file diff --git a/cmake/macros/TargetOglplus.cmake b/cmake/macros/TargetOglplus.cmake new file mode 100644 index 0000000000..16a50f3dd7 --- /dev/null +++ b/cmake/macros/TargetOglplus.cmake @@ -0,0 +1,21 @@ +# +# Copyright 2015 High Fidelity, Inc. +# Created by Bradley Austin Davis on 2015/10/10 +# +# Distributed under the Apache License, Version 2.0. +# See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +# +macro(TARGET_OGLPLUS) + # our OGL plus setup requires glew + target_glew() + + # our OGL plus setup requires boostconfig + add_dependency_external_projects(boostconfig) + find_package(BoostConfig REQUIRED) + target_include_directories(${TARGET_NAME} PUBLIC ${BOOSTCONFIG_INCLUDE_DIRS}) + + + add_dependency_external_projects(oglplus) + find_package(OGLPLUS REQUIRED) + target_include_directories(${TARGET_NAME} PUBLIC ${OGLPLUS_INCLUDE_DIRS}) +endmacro() \ No newline at end of file diff --git a/cmake/macros/SetupHifiOpenGL.cmake b/cmake/macros/TargetOpenGL.cmake similarity index 58% rename from cmake/macros/SetupHifiOpenGL.cmake rename to cmake/macros/TargetOpenGL.cmake index 2b1858fd4b..7b3178d579 100644 --- a/cmake/macros/SetupHifiOpenGL.cmake +++ b/cmake/macros/TargetOpenGL.cmake @@ -1,38 +1,24 @@ - - -macro(SETUP_HIFI_OPENGL) - +# +# Copyright 2015 High Fidelity, Inc. +# Created by Bradley Austin Davis on 2015/10/10 +# +# Distributed under the Apache License, Version 2.0. +# See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +# +macro(TARGET_OPENGL) if (APPLE) - # link in required OS X frameworks and include the right GL headers find_library(OpenGL OpenGL) target_link_libraries(${TARGET_NAME} ${OpenGL}) - - elseif (WIN32) - - if (USE_NSIGHT) - # try to find the Nsight package and add it to the build if we find it - find_package(NSIGHT) - if (NSIGHT_FOUND) - include_directories(${NSIGHT_INCLUDE_DIRS}) - add_definitions(-DNSIGHT_FOUND) - target_link_libraries(${TARGET_NAME} "${NSIGHT_LIBRARIES}") - endif() - endif() - elseif(ANDROID) - target_link_libraries(${TARGET_NAME} "-lGLESv3" "-lEGL") - else() - + target_nsight() find_package(OpenGL REQUIRED) if (${OPENGL_INCLUDE_DIR}) include_directories(SYSTEM "${OPENGL_INCLUDE_DIR}") endif() target_link_libraries(${TARGET_NAME} "${OPENGL_LIBRARY}") target_include_directories(${TARGET_NAME} PUBLIC ${OPENGL_INCLUDE_DIR}) - endif() - endmacro() diff --git a/examples/example/scripts/controllerScriptingExamples.js b/examples/example/scripts/controllerScriptingExamples.js index 88c4ae2daa..6db7b38705 100644 --- a/examples/example/scripts/controllerScriptingExamples.js +++ b/examples/example/scripts/controllerScriptingExamples.js @@ -11,14 +11,19 @@ // Assumes you only have the default keyboard connected + +Object.keys(Controller.Standard).forEach(function (input) { + print("Controller.Standard." + input + ":" + Controller.Standard[input]); +}); + Object.keys(Controller.Hardware).forEach(function (deviceName) { Object.keys(Controller.Hardware[deviceName]).forEach(function (input) { - print(deviceName + "." + input + ":" + Controller.Hardware[deviceName][input]); + print("Controller.Hardware." + deviceName + "." + input + ":" + Controller.Hardware[deviceName][input]); }); }); Object.keys(Controller.Actions).forEach(function (actionName) { - print(actionName + ":" + Controller.Actions[actionName]); + print("Controller.Actions." + actionName + ":" + Controller.Actions[actionName]); }); // Resets every device to its default key bindings: diff --git a/examples/libraries/entitySelectionTool.js b/examples/libraries/entitySelectionTool.js index c49408fef6..61aa5b0394 100644 --- a/examples/libraries/entitySelectionTool.js +++ b/examples/libraries/entitySelectionTool.js @@ -2326,7 +2326,9 @@ SelectionDisplay = (function () { that.checkMove = function() { if (SelectionManager.hasSelection()) { - SelectionManager._update(); + + // FIXME - this cause problems with editing in the entity properties window + //SelectionManager._update(); if (!Vec3.equal(Camera.getPosition(), lastCameraPosition) || !Quat.equal(Camera.getOrientation(), lastCameraOrientation)) { diff --git a/gvr-interface/CMakeLists.txt b/gvr-interface/CMakeLists.txt index 2c1e87c8b4..175706a3ff 100644 --- a/gvr-interface/CMakeLists.txt +++ b/gvr-interface/CMakeLists.txt @@ -24,10 +24,6 @@ endif () include_directories(${Qt5Gui_PRIVATE_INCLUDE_DIRS}) -add_dependency_external_projects(glm) -find_package(GLM REQUIRED) -target_include_directories(${TARGET_NAME} PRIVATE ${GLM_INCLUDE_DIRS}) - link_hifi_libraries(shared networking audio-client avatars) if (ANDROID) diff --git a/interface/CMakeLists.txt b/interface/CMakeLists.txt index 63d1445496..00f6d2ecea 100644 --- a/interface/CMakeLists.txt +++ b/interface/CMakeLists.txt @@ -1,8 +1,6 @@ set(TARGET_NAME interface) project(${TARGET_NAME}) -add_definitions(-DGLEW_STATIC) - # set a default root dir for each of our optional externals if it was not passed set(OPTIONAL_EXTERNALS "Faceshift" "LeapMotion" "RtMidi" "RSSDK" "3DConnexionClient" "iViewHMD") foreach(EXTERNAL ${OPTIONAL_EXTERNALS}) @@ -97,29 +95,17 @@ else() add_executable(${TARGET_NAME} ${INTERFACE_SRCS} ${QM}) endif() -add_dependency_external_projects(glm bullet) - -# set up the external glm library -find_package(GLM REQUIRED) -target_include_directories(${TARGET_NAME} PRIVATE ${GLM_INCLUDE_DIRS}) - -find_package(Bullet REQUIRED) - -# perform the system include hack for OS X to ignore warnings -if (APPLE) - SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -isystem ${BULLET_INCLUDE_DIRS}") -else() - target_include_directories(${TARGET_NAME} SYSTEM PRIVATE ${BULLET_INCLUDE_DIRS}) -endif() - -target_link_libraries(${TARGET_NAME} ${BULLET_LIBRARIES}) - # link required hifi libraries link_hifi_libraries(shared octree environment gpu procedural model render fbx networking model-networking entities avatars audio audio-client animation script-engine physics render-utils entities-renderer ui auto-updater plugins display-plugins input-plugins) +target_bullet() +target_glew() +target_opengl() + + add_dependency_external_projects(sdl2) # perform standard include and linking for found externals diff --git a/interface/src/scripting/ControllerScriptingInterface.cpp b/interface/src/scripting/ControllerScriptingInterface.cpp index 4db482b6d4..9bdf8d1a4a 100644 --- a/interface/src/scripting/ControllerScriptingInterface.cpp +++ b/interface/src/scripting/ControllerScriptingInterface.cpp @@ -391,6 +391,19 @@ QString ControllerScriptingInterface::sanatizeName(const QString& name) { void ControllerScriptingInterface::wireUpControllers(ScriptEngine* engine) { + // Controller.Standard.* + auto standardDevice = DependencyManager::get()->getStandardDevice(); + if (standardDevice) { + auto deviceName = sanatizeName(standardDevice->getName()); + auto deviceInputs = standardDevice->getAvailabeInputs(); + for (const auto& inputMapping : deviceInputs) { + auto input = inputMapping.first; + auto inputName = sanatizeName(inputMapping.second); + QString deviceInputName{ "Controller." + deviceName + "." + inputName }; + engine->registerValue(deviceInputName, input.getID()); + } + } + // Controller.Hardware.* auto devices = DependencyManager::get()->getDevices(); for(const auto& deviceMapping : devices) { diff --git a/libraries/animation/CMakeLists.txt b/libraries/animation/CMakeLists.txt index 115a2e360c..3cf7bfa295 100644 --- a/libraries/animation/CMakeLists.txt +++ b/libraries/animation/CMakeLists.txt @@ -1,6 +1,3 @@ set(TARGET_NAME animation) - -# use setup_hifi_library macro to setup our project and link appropriate Qt modules setup_hifi_library(Network Script) - link_hifi_libraries(shared gpu model fbx) diff --git a/libraries/audio-client/CMakeLists.txt b/libraries/audio-client/CMakeLists.txt index f631ec6387..90937edc5d 100644 --- a/libraries/audio-client/CMakeLists.txt +++ b/libraries/audio-client/CMakeLists.txt @@ -1,8 +1,5 @@ set(TARGET_NAME audio-client) - -# use setup_hifi_library macro to setup our project and link appropriate Qt modules setup_hifi_library(Network Multimedia) - link_hifi_libraries(audio) # append audio includes to our list of includes to bubble @@ -10,9 +7,7 @@ target_include_directories(${TARGET_NAME} PUBLIC "${HIFI_LIBRARY_DIR}/audio/src" # have CMake grab externals for us add_dependency_external_projects(gverb) - find_package(Gverb REQUIRED) - target_link_libraries(${TARGET_NAME} ${GVERB_LIBRARIES}) target_include_directories(${TARGET_NAME} PRIVATE ${GVERB_INCLUDE_DIRS}) diff --git a/libraries/audio/CMakeLists.txt b/libraries/audio/CMakeLists.txt index 5134ccda36..c49c9547a5 100644 --- a/libraries/audio/CMakeLists.txt +++ b/libraries/audio/CMakeLists.txt @@ -1,10 +1,3 @@ set(TARGET_NAME audio) - -# use setup_hifi_library macro to setup our project and link appropriate Qt modules setup_hifi_library(Network) - -add_dependency_external_projects(glm) -find_package(GLM REQUIRED) -target_include_directories(${TARGET_NAME} PUBLIC ${GLM_INCLUDE_DIRS}) - link_hifi_libraries(networking shared) diff --git a/libraries/auto-updater/CMakeLists.txt b/libraries/auto-updater/CMakeLists.txt index c3d6e74a6f..b3665af2cb 100644 --- a/libraries/auto-updater/CMakeLists.txt +++ b/libraries/auto-updater/CMakeLists.txt @@ -1,4 +1,3 @@ set(TARGET_NAME auto-updater) - setup_hifi_library(Network) link_hifi_libraries(shared networking) diff --git a/libraries/avatars/CMakeLists.txt b/libraries/avatars/CMakeLists.txt index acc939b25c..849828bbf6 100644 --- a/libraries/avatars/CMakeLists.txt +++ b/libraries/avatars/CMakeLists.txt @@ -1,10 +1,3 @@ set(TARGET_NAME avatars) - -# use setup_hifi_library macro to setup our project and link appropriate Qt modules setup_hifi_library(Network Script) - -add_dependency_external_projects(glm) -find_package(GLM REQUIRED) -target_include_directories(${TARGET_NAME} PUBLIC ${GLM_INCLUDE_DIRS}) - link_hifi_libraries(audio shared networking) diff --git a/libraries/display-plugins/CMakeLists.txt b/libraries/display-plugins/CMakeLists.txt index b602327f4c..504370796a 100644 --- a/libraries/display-plugins/CMakeLists.txt +++ b/libraries/display-plugins/CMakeLists.txt @@ -1,27 +1,12 @@ set(TARGET_NAME display-plugins) - -add_definitions(-DGLEW_STATIC) - -# use setup_hifi_library macro to setup our project and link appropriate Qt modules setup_hifi_library(OpenGL) - -setup_hifi_opengl() - link_hifi_libraries(shared plugins gpu render-utils) +target_opengl() + GroupSources("src/display-plugins") -add_dependency_external_projects(glm) -find_package(GLM REQUIRED) -target_include_directories(${TARGET_NAME} PUBLIC ${GLM_INCLUDE_DIRS}) - -add_dependency_external_projects(boostconfig) -find_package(BoostConfig REQUIRED) -target_include_directories(${TARGET_NAME} PUBLIC ${BOOSTCONFIG_INCLUDE_DIRS}) - -add_dependency_external_projects(oglplus) -find_package(OGLPLUS REQUIRED) -target_include_directories(${TARGET_NAME} PUBLIC ${OGLPLUS_INCLUDE_DIRS}) +target_oglplus() add_dependency_external_projects(LibOVR) find_package(LibOVR REQUIRED) diff --git a/libraries/embedded-webserver/CMakeLists.txt b/libraries/embedded-webserver/CMakeLists.txt index 45d9827d42..b23be3a7a2 100644 --- a/libraries/embedded-webserver/CMakeLists.txt +++ b/libraries/embedded-webserver/CMakeLists.txt @@ -1,4 +1,2 @@ set(TARGET_NAME embedded-webserver) - -# use setup_hifi_library macro to setup our project and link appropriate Qt modules setup_hifi_library(Network) diff --git a/libraries/entities-renderer/CMakeLists.txt b/libraries/entities-renderer/CMakeLists.txt index d092f188e1..bb90c04c95 100644 --- a/libraries/entities-renderer/CMakeLists.txt +++ b/libraries/entities-renderer/CMakeLists.txt @@ -1,29 +1,12 @@ set(TARGET_NAME entities-renderer) - AUTOSCRIBE_SHADER_LIB(gpu model render render-utils) - -# use setup_hifi_library macro to setup our project and link appropriate Qt modules setup_hifi_library(Widgets Network Script) +link_hifi_libraries(shared gpu procedural model model-networking script-engine render render-utils) -add_dependency_external_projects(glm) -find_package(GLM REQUIRED) -target_include_directories(${TARGET_NAME} PUBLIC ${GLM_INCLUDE_DIRS}) - -add_dependency_external_projects(bullet) -find_package(Bullet REQUIRED) - -# perform the system include hack for OS X to ignore warnings -if (APPLE) - SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -isystem ${BULLET_INCLUDE_DIRS}") -else() - target_include_directories(${TARGET_NAME} SYSTEM PRIVATE ${BULLET_INCLUDE_DIRS}) -endif() - -target_link_libraries(${TARGET_NAME} ${BULLET_LIBRARIES}) +target_bullet() add_dependency_external_projects(polyvox) find_package(PolyVox REQUIRED) target_include_directories(${TARGET_NAME} SYSTEM PUBLIC ${POLYVOX_INCLUDE_DIRS}) target_link_libraries(${TARGET_NAME} ${POLYVOX_LIBRARIES}) -link_hifi_libraries(shared gpu procedural model model-networking script-engine render render-utils) diff --git a/libraries/entities-renderer/src/EntityTreeRenderer.cpp b/libraries/entities-renderer/src/EntityTreeRenderer.cpp index 7dea243145..fb9ab6563b 100644 --- a/libraries/entities-renderer/src/EntityTreeRenderer.cpp +++ b/libraries/entities-renderer/src/EntityTreeRenderer.cpp @@ -704,7 +704,9 @@ void EntityTreeRenderer::checkAndCallPreload(const EntityItemID& entityID, const if (_tree && !_shuttingDown) { EntityItemPointer entity = getTree()->findEntityByEntityItemID(entityID); if (entity && !entity->getScript().isEmpty()) { - _entitiesScriptEngine->loadEntityScript(entityID, entity->getScript(), reload); + QString scriptUrl = entity->getScript(); + scriptUrl = ResourceManager::normalizeURL(scriptUrl); + _entitiesScriptEngine->loadEntityScript(entityID, scriptUrl, reload); } } } diff --git a/libraries/entities/CMakeLists.txt b/libraries/entities/CMakeLists.txt index f7936ff125..f6b2e0e280 100644 --- a/libraries/entities/CMakeLists.txt +++ b/libraries/entities/CMakeLists.txt @@ -1,24 +1,7 @@ set(TARGET_NAME entities) - -# use setup_hifi_library macro to setup our project and link appropriate Qt modules setup_hifi_library(Network Script) - -add_dependency_external_projects(glm) -find_package(GLM REQUIRED) -target_include_directories(${TARGET_NAME} PUBLIC ${GLM_INCLUDE_DIRS}) - -add_dependency_external_projects(bullet) - -find_package(Bullet REQUIRED) - -# perform the system include hack for OS X to ignore warnings -if (APPLE) - SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -isystem ${BULLET_INCLUDE_DIRS}") -else() - target_include_directories(${TARGET_NAME} SYSTEM PRIVATE ${BULLET_INCLUDE_DIRS}) -endif() - -target_link_libraries(${TARGET_NAME} ${BULLET_LIBRARIES}) - link_hifi_libraries(avatars shared octree gpu model fbx networking animation environment) + +target_bullet() + include_hifi_library_headers(render) diff --git a/libraries/environment/CMakeLists.txt b/libraries/environment/CMakeLists.txt index e3fc143c14..11538a8f2b 100644 --- a/libraries/environment/CMakeLists.txt +++ b/libraries/environment/CMakeLists.txt @@ -1,10 +1,3 @@ set(TARGET_NAME environment) - -# use setup_hifi_library macro to setup our project and link appropriate Qt modules setup_hifi_library() - -add_dependency_external_projects(glm) -find_package(GLM REQUIRED) -target_include_directories(${TARGET_NAME} PUBLIC ${GLM_INCLUDE_DIRS}) - link_hifi_libraries(shared networking) diff --git a/libraries/fbx/CMakeLists.txt b/libraries/fbx/CMakeLists.txt index 9d9f57ad20..e10b6bcfd5 100644 --- a/libraries/fbx/CMakeLists.txt +++ b/libraries/fbx/CMakeLists.txt @@ -1,10 +1,3 @@ set(TARGET_NAME fbx) - -# use setup_hifi_library macro to setup our project and link appropriate Qt modules setup_hifi_library() - -add_dependency_external_projects(glm) -find_package(GLM REQUIRED) -target_include_directories(${TARGET_NAME} PUBLIC ${GLM_INCLUDE_DIRS}) - link_hifi_libraries(shared gpu model networking octree) diff --git a/libraries/gpu/CMakeLists.txt b/libraries/gpu/CMakeLists.txt index 38fe5cb22f..63da1d8f8a 100644 --- a/libraries/gpu/CMakeLists.txt +++ b/libraries/gpu/CMakeLists.txt @@ -1,48 +1,7 @@ set(TARGET_NAME gpu) - AUTOSCRIBE_SHADER_LIB(gpu) - -# use setup_hifi_library macro to setup our project and link appropriate Qt modules setup_hifi_library() - link_hifi_libraries(shared) -add_dependency_external_projects(glm) -find_package(GLM REQUIRED) -target_include_directories(${TARGET_NAME} PUBLIC ${GLM_INCLUDE_DIRS}) - -add_dependency_external_projects(glew) -find_package(GLEW REQUIRED) -add_definitions(-DGLEW_STATIC) -target_include_directories(${TARGET_NAME} PUBLIC ${GLEW_INCLUDE_DIRS}) -target_link_libraries(${TARGET_NAME} ${GLEW_LIBRARY}) - -if (APPLE) - # link in required OS X frameworks and include the right GL headers - find_library(OpenGL OpenGL) - target_link_libraries(${TARGET_NAME} ${OpenGL}) -elseif (WIN32) - target_link_libraries(${TARGET_NAME} ${GLEW_LIBRARY} opengl32.lib) - - if (USE_NSIGHT) - # try to find the Nsight package and add it to the build if we find it - # note that this will also enable NSIGHT profilers in all the projects linking gpu - find_package(NSIGHT) - if (NSIGHT_FOUND) - target_include_directories(${TARGET_NAME} PUBLIC ${NSIGHT_INCLUDE_DIRS}) - target_compile_definitions(${TARGET_NAME} PUBLIC NSIGHT_FOUND) - target_link_libraries(${TARGET_NAME} "${NSIGHT_LIBRARIES}") - endif () - endif() -elseif (ANDROID) - target_link_libraries(${TARGET_NAME} "-lGLESv3" "-lEGL") -else () - - find_package(OpenGL REQUIRED) - - if (${OPENGL_INCLUDE_DIR}) - include_directories(SYSTEM "${OPENGL_INCLUDE_DIR}") - endif () - - target_link_libraries(${TARGET_NAME} "${OPENGL_LIBRARY}") -endif (APPLE) +target_glew() +target_opengl() \ No newline at end of file diff --git a/libraries/input-plugins/CMakeLists.txt b/libraries/input-plugins/CMakeLists.txt index 1ac8047edc..094a697012 100644 --- a/libraries/input-plugins/CMakeLists.txt +++ b/libraries/input-plugins/CMakeLists.txt @@ -1,26 +1,9 @@ set(TARGET_NAME input-plugins) - -# set a default root dir for each of our optional externals if it was not passed -set(OPTIONAL_EXTERNALS "SDL2" "Sixense") -foreach(EXTERNAL ${OPTIONAL_EXTERNALS}) - string(TOUPPER ${EXTERNAL} ${EXTERNAL}_UPPERCASE) - if (NOT ${${EXTERNAL}_UPPERCASE}_ROOT_DIR) - string(TOLOWER ${EXTERNAL} ${EXTERNAL}_LOWERCASE) - set(${${EXTERNAL}_UPPERCASE}_ROOT_DIR "${CMAKE_SOURCE_DIR}/interface/external/${${EXTERNAL}_LOWERCASE}") - endif () -endforeach() - setup_hifi_library() - -# use setup_hifi_library macro to setup our project and link appropriate Qt modules link_hifi_libraries(shared plugins gpu render-utils) GroupSources("src/input-plugins") -add_dependency_external_projects(glm) -find_package(GLM REQUIRED) -target_include_directories(${TARGET_NAME} PUBLIC ${GLM_INCLUDE_DIRS}) - if (WIN32) add_dependency_external_projects(OpenVR) find_package(OpenVR REQUIRED) @@ -33,6 +16,16 @@ endif() #target_include_directories(${TARGET_NAME} PRIVATE ${SIXENSE_INCLUDE_DIRS}) #target_link_libraries(${TARGET_NAME} ${SIXENSE_LIBRARIES}) +# set a default root dir for each of our optional externals if it was not passed +set(OPTIONAL_EXTERNALS "SDL2" "Sixense") +foreach(EXTERNAL ${OPTIONAL_EXTERNALS}) + string(TOUPPER ${EXTERNAL} ${EXTERNAL}_UPPERCASE) + if (NOT ${${EXTERNAL}_UPPERCASE}_ROOT_DIR) + string(TOLOWER ${EXTERNAL} ${EXTERNAL}_LOWERCASE) + set(${${EXTERNAL}_UPPERCASE}_ROOT_DIR "${CMAKE_SOURCE_DIR}/interface/external/${${EXTERNAL}_LOWERCASE}") + endif () +endforeach() + # perform standard include and linking for found externals foreach(EXTERNAL ${OPTIONAL_EXTERNALS}) diff --git a/libraries/input-plugins/src/input-plugins/StandardController.cpp b/libraries/input-plugins/src/input-plugins/StandardController.cpp new file mode 100644 index 0000000000..4fb4a23654 --- /dev/null +++ b/libraries/input-plugins/src/input-plugins/StandardController.cpp @@ -0,0 +1,162 @@ +// +// StandardController.cpp +// input-plugins/src/input-plugins +// +// Created by Brad Hefta-Gaub on 2015-10-11. +// 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 + +#include + +#include "StandardController.h" + +const float CONTROLLER_THRESHOLD = 0.3f; + +const float MAX_AXIS = 32768.0f; + +StandardController::~StandardController() { +} + +void StandardController::update(float deltaTime, bool jointsCaptured) { + for (auto axisState : _axisStateMap) { + if (fabsf(axisState.second) < CONTROLLER_THRESHOLD) { + _axisStateMap[axisState.first] = 0.0f; + } + } +} + +void StandardController::focusOutEvent() { + _axisStateMap.clear(); + _buttonPressedMap.clear(); +}; + +void StandardController::registerToUserInputMapper(UserInputMapper& mapper) { + // Grab the current free device ID + _deviceID = mapper.getStandardDeviceID(); + + auto proxy = std::make_shared(_name); + proxy->getButton = [this] (const UserInputMapper::Input& input, int timestamp) -> bool { return this->getButton(input.getChannel()); }; + proxy->getAxis = [this] (const UserInputMapper::Input& input, int timestamp) -> float { return this->getAxis(input.getChannel()); }; + proxy->getAvailabeInputs = [this] () -> QVector { + QVector availableInputs; + availableInputs.append(UserInputMapper::InputPair(makeInput(STANDARD_CONTROLLER_BUTTON_A), "Bottom Button")); + availableInputs.append(UserInputMapper::InputPair(makeInput(STANDARD_CONTROLLER_BUTTON_B), "Right Button")); + availableInputs.append(UserInputMapper::InputPair(makeInput(STANDARD_CONTROLLER_BUTTON_X), "Left Button")); + availableInputs.append(UserInputMapper::InputPair(makeInput(STANDARD_CONTROLLER_BUTTON_Y), "Top Button")); + + availableInputs.append(UserInputMapper::InputPair(makeInput(STANDARD_CONTROLLER_BUTTON_DPAD_UP), "DPad Up")); + availableInputs.append(UserInputMapper::InputPair(makeInput(STANDARD_CONTROLLER_BUTTON_DPAD_DOWN), "DPad Down")); + availableInputs.append(UserInputMapper::InputPair(makeInput(STANDARD_CONTROLLER_BUTTON_DPAD_LEFT), "DPad Left")); + availableInputs.append(UserInputMapper::InputPair(makeInput(STANDARD_CONTROLLER_BUTTON_DPAD_RIGHT), "DPad Right")); + + availableInputs.append(UserInputMapper::InputPair(makeInput(STANDARD_CONTROLLER_BUTTON_LEFTSHOULDER), "L1")); + availableInputs.append(UserInputMapper::InputPair(makeInput(STANDARD_CONTROLLER_BUTTON_RIGHTSHOULDER), "R1")); + availableInputs.append(UserInputMapper::InputPair(makeInput(RIGHT_SHOULDER), "L2")); + availableInputs.append(UserInputMapper::InputPair(makeInput(LEFT_SHOULDER), "R2")); + + availableInputs.append(UserInputMapper::InputPair(makeInput(LEFT_AXIS_Y_NEG), "Left Stick Up")); + availableInputs.append(UserInputMapper::InputPair(makeInput(LEFT_AXIS_Y_POS), "Left Stick Down")); + availableInputs.append(UserInputMapper::InputPair(makeInput(LEFT_AXIS_X_POS), "Left Stick Right")); + availableInputs.append(UserInputMapper::InputPair(makeInput(LEFT_AXIS_X_NEG), "Left Stick Left")); + availableInputs.append(UserInputMapper::InputPair(makeInput(RIGHT_AXIS_Y_NEG), "Right Stick Up")); + availableInputs.append(UserInputMapper::InputPair(makeInput(RIGHT_AXIS_Y_POS), "Right Stick Down")); + availableInputs.append(UserInputMapper::InputPair(makeInput(RIGHT_AXIS_X_POS), "Right Stick Right")); + availableInputs.append(UserInputMapper::InputPair(makeInput(RIGHT_AXIS_X_NEG), "Right Stick Left")); + + availableInputs.append(UserInputMapper::InputPair(makeInput(LEFT_HAND), "Left Hand")); + availableInputs.append(UserInputMapper::InputPair(makeInput(RIGHT_HAND), "Right Hand")); + + return availableInputs; + }; + proxy->resetDeviceBindings = [this, &mapper] () -> bool { + mapper.removeAllInputChannelsForDevice(_deviceID); + this->assignDefaultInputMapping(mapper); + return true; + }; + mapper.registerStandardDevice(proxy); +} + +void StandardController::assignDefaultInputMapping(UserInputMapper& mapper) { + const float JOYSTICK_MOVE_SPEED = 1.0f; + const float DPAD_MOVE_SPEED = 0.5f; + const float JOYSTICK_YAW_SPEED = 0.5f; + const float JOYSTICK_PITCH_SPEED = 0.25f; + const float BOOM_SPEED = 0.1f; + + // Y axes are flipped (up is negative) + // Left StandardController: Movement, strafing + mapper.addInputChannel(UserInputMapper::LONGITUDINAL_FORWARD, makeInput(LEFT_AXIS_Y_NEG), JOYSTICK_MOVE_SPEED); + mapper.addInputChannel(UserInputMapper::LONGITUDINAL_BACKWARD, makeInput(LEFT_AXIS_Y_POS), JOYSTICK_MOVE_SPEED); + mapper.addInputChannel(UserInputMapper::LATERAL_RIGHT, makeInput(LEFT_AXIS_X_POS), JOYSTICK_MOVE_SPEED); + mapper.addInputChannel(UserInputMapper::LATERAL_LEFT, makeInput(LEFT_AXIS_X_NEG), JOYSTICK_MOVE_SPEED); + + // Right StandardController: Camera orientation + mapper.addInputChannel(UserInputMapper::YAW_RIGHT, makeInput(RIGHT_AXIS_X_POS), JOYSTICK_YAW_SPEED); + mapper.addInputChannel(UserInputMapper::YAW_LEFT, makeInput(RIGHT_AXIS_X_NEG), JOYSTICK_YAW_SPEED); + mapper.addInputChannel(UserInputMapper::PITCH_UP, makeInput(RIGHT_AXIS_Y_NEG), JOYSTICK_PITCH_SPEED); + mapper.addInputChannel(UserInputMapper::PITCH_DOWN, makeInput(RIGHT_AXIS_Y_POS), JOYSTICK_PITCH_SPEED); + + // Dpad movement + mapper.addInputChannel(UserInputMapper::LONGITUDINAL_FORWARD, makeInput(STANDARD_CONTROLLER_BUTTON_DPAD_UP), DPAD_MOVE_SPEED); + mapper.addInputChannel(UserInputMapper::LONGITUDINAL_BACKWARD, makeInput(STANDARD_CONTROLLER_BUTTON_DPAD_DOWN), DPAD_MOVE_SPEED); + mapper.addInputChannel(UserInputMapper::LATERAL_RIGHT, makeInput(STANDARD_CONTROLLER_BUTTON_DPAD_RIGHT), DPAD_MOVE_SPEED); + mapper.addInputChannel(UserInputMapper::LATERAL_LEFT, makeInput(STANDARD_CONTROLLER_BUTTON_DPAD_LEFT), DPAD_MOVE_SPEED); + + // Button controls + mapper.addInputChannel(UserInputMapper::VERTICAL_UP, makeInput(STANDARD_CONTROLLER_BUTTON_Y), DPAD_MOVE_SPEED); + mapper.addInputChannel(UserInputMapper::VERTICAL_DOWN, makeInput(STANDARD_CONTROLLER_BUTTON_X), DPAD_MOVE_SPEED); + + // Zoom + mapper.addInputChannel(UserInputMapper::BOOM_IN, makeInput(RIGHT_SHOULDER), BOOM_SPEED); + mapper.addInputChannel(UserInputMapper::BOOM_OUT, makeInput(LEFT_SHOULDER), BOOM_SPEED); + + + // Hold front right shoulder button for precision controls + // Left StandardController: Movement, strafing + mapper.addInputChannel(UserInputMapper::LONGITUDINAL_FORWARD, makeInput(LEFT_AXIS_Y_NEG), makeInput(STANDARD_CONTROLLER_BUTTON_RIGHTSHOULDER), JOYSTICK_MOVE_SPEED/2.0f); + mapper.addInputChannel(UserInputMapper::LONGITUDINAL_BACKWARD, makeInput(LEFT_AXIS_Y_POS), makeInput(STANDARD_CONTROLLER_BUTTON_RIGHTSHOULDER), JOYSTICK_MOVE_SPEED/2.0f); + mapper.addInputChannel(UserInputMapper::LATERAL_RIGHT, makeInput(LEFT_AXIS_X_POS), makeInput(STANDARD_CONTROLLER_BUTTON_RIGHTSHOULDER), JOYSTICK_MOVE_SPEED/2.0f); + mapper.addInputChannel(UserInputMapper::LATERAL_LEFT, makeInput(LEFT_AXIS_X_NEG), makeInput(STANDARD_CONTROLLER_BUTTON_RIGHTSHOULDER), JOYSTICK_MOVE_SPEED/2.0f); + + // Right StandardController: Camera orientation + mapper.addInputChannel(UserInputMapper::YAW_RIGHT, makeInput(RIGHT_AXIS_X_POS), makeInput(STANDARD_CONTROLLER_BUTTON_RIGHTSHOULDER), JOYSTICK_YAW_SPEED/2.0f); + mapper.addInputChannel(UserInputMapper::YAW_LEFT, makeInput(RIGHT_AXIS_X_NEG), makeInput(STANDARD_CONTROLLER_BUTTON_RIGHTSHOULDER), JOYSTICK_YAW_SPEED/2.0f); + mapper.addInputChannel(UserInputMapper::PITCH_UP, makeInput(RIGHT_AXIS_Y_NEG), makeInput(STANDARD_CONTROLLER_BUTTON_RIGHTSHOULDER), JOYSTICK_PITCH_SPEED/2.0f); + mapper.addInputChannel(UserInputMapper::PITCH_DOWN, makeInput(RIGHT_AXIS_Y_POS), makeInput(STANDARD_CONTROLLER_BUTTON_RIGHTSHOULDER), JOYSTICK_PITCH_SPEED/2.0f); + + // Dpad movement + mapper.addInputChannel(UserInputMapper::LONGITUDINAL_FORWARD, makeInput(STANDARD_CONTROLLER_BUTTON_DPAD_UP), makeInput(STANDARD_CONTROLLER_BUTTON_RIGHTSHOULDER), DPAD_MOVE_SPEED/2.0f); + mapper.addInputChannel(UserInputMapper::LONGITUDINAL_BACKWARD, makeInput(STANDARD_CONTROLLER_BUTTON_DPAD_DOWN), makeInput(STANDARD_CONTROLLER_BUTTON_RIGHTSHOULDER), DPAD_MOVE_SPEED/2.0f); + mapper.addInputChannel(UserInputMapper::LATERAL_RIGHT, makeInput(STANDARD_CONTROLLER_BUTTON_DPAD_RIGHT), makeInput(STANDARD_CONTROLLER_BUTTON_RIGHTSHOULDER), DPAD_MOVE_SPEED/2.0f); + mapper.addInputChannel(UserInputMapper::LATERAL_LEFT, makeInput(STANDARD_CONTROLLER_BUTTON_DPAD_LEFT), makeInput(STANDARD_CONTROLLER_BUTTON_RIGHTSHOULDER), DPAD_MOVE_SPEED/2.0f); + + // Button controls + mapper.addInputChannel(UserInputMapper::VERTICAL_UP, makeInput(STANDARD_CONTROLLER_BUTTON_Y), makeInput(STANDARD_CONTROLLER_BUTTON_RIGHTSHOULDER), DPAD_MOVE_SPEED/2.0f); + mapper.addInputChannel(UserInputMapper::VERTICAL_DOWN, makeInput(STANDARD_CONTROLLER_BUTTON_X), makeInput(STANDARD_CONTROLLER_BUTTON_RIGHTSHOULDER), DPAD_MOVE_SPEED/2.0f); + + // Zoom + mapper.addInputChannel(UserInputMapper::BOOM_IN, makeInput(RIGHT_SHOULDER), makeInput(STANDARD_CONTROLLER_BUTTON_RIGHTSHOULDER), BOOM_SPEED/2.0f); + mapper.addInputChannel(UserInputMapper::BOOM_OUT, makeInput(LEFT_SHOULDER), makeInput(STANDARD_CONTROLLER_BUTTON_RIGHTSHOULDER), BOOM_SPEED/2.0f); + + mapper.addInputChannel(UserInputMapper::SHIFT, makeInput(STANDARD_CONTROLLER_BUTTON_LEFTSHOULDER)); + + mapper.addInputChannel(UserInputMapper::ACTION1, makeInput(STANDARD_CONTROLLER_BUTTON_B)); + mapper.addInputChannel(UserInputMapper::ACTION2, makeInput(STANDARD_CONTROLLER_BUTTON_A)); +} + +UserInputMapper::Input StandardController::makeInput(StandardController::StandardControllerButtonChannel button) { + return UserInputMapper::Input(_deviceID, button, UserInputMapper::ChannelType::BUTTON); +} + +UserInputMapper::Input StandardController::makeInput(StandardController::StandardControllerAxisChannel axis) { + return UserInputMapper::Input(_deviceID, axis, UserInputMapper::ChannelType::AXIS); +} + +UserInputMapper::Input StandardController::makeInput(StandardController::StandardControllerPoseChannel pose) { + return UserInputMapper::Input(_deviceID, pose, UserInputMapper::ChannelType::POSE); +} diff --git a/libraries/input-plugins/src/input-plugins/StandardController.h b/libraries/input-plugins/src/input-plugins/StandardController.h new file mode 100644 index 0000000000..f7a4215242 --- /dev/null +++ b/libraries/input-plugins/src/input-plugins/StandardController.h @@ -0,0 +1,77 @@ +// +// StandardController.h +// input-plugins/src/input-plugins +// +// Created by Brad Hefta-Gaub on 2015-10-11. +// 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 +// + +#ifndef hifi_StandardController_h +#define hifi_StandardController_h + +#include +#include + +#include "InputDevice.h" + +typedef std::shared_ptr StandardControllerPointer; + +class StandardController : public QObject, public InputDevice { + Q_OBJECT + Q_PROPERTY(QString name READ getName) + +public: + enum StandardControllerAxisChannel { + LEFT_AXIS_X_POS = 0, + LEFT_AXIS_X_NEG, + LEFT_AXIS_Y_POS, + LEFT_AXIS_Y_NEG, + RIGHT_AXIS_X_POS, + RIGHT_AXIS_X_NEG, + RIGHT_AXIS_Y_POS, + RIGHT_AXIS_Y_NEG, + RIGHT_SHOULDER, + LEFT_SHOULDER, + }; + enum StandardControllerButtonChannel { + STANDARD_CONTROLLER_BUTTON_A = 0, + STANDARD_CONTROLLER_BUTTON_B, + STANDARD_CONTROLLER_BUTTON_X, + STANDARD_CONTROLLER_BUTTON_Y, + + STANDARD_CONTROLLER_BUTTON_DPAD_UP, + STANDARD_CONTROLLER_BUTTON_DPAD_DOWN, + STANDARD_CONTROLLER_BUTTON_DPAD_LEFT, + STANDARD_CONTROLLER_BUTTON_DPAD_RIGHT, + + STANDARD_CONTROLLER_BUTTON_LEFTSHOULDER, + STANDARD_CONTROLLER_BUTTON_RIGHTSHOULDER, + }; + + enum StandardControllerPoseChannel { + LEFT_HAND = 0, + RIGHT_HAND, + }; + + const QString& getName() const { return _name; } + + // Device functions + virtual void registerToUserInputMapper(UserInputMapper& mapper) override; + virtual void assignDefaultInputMapping(UserInputMapper& mapper) override; + virtual void update(float deltaTime, bool jointsCaptured) override; + virtual void focusOutEvent() override; + + StandardController() : InputDevice("Standard") {} + ~StandardController(); + + UserInputMapper::Input makeInput(StandardController::StandardControllerButtonChannel button); + UserInputMapper::Input makeInput(StandardController::StandardControllerAxisChannel axis); + UserInputMapper::Input makeInput(StandardController::StandardControllerPoseChannel pose); + +private: +}; + +#endif // hifi_StandardController_h diff --git a/libraries/input-plugins/src/input-plugins/UserInputMapper.cpp b/libraries/input-plugins/src/input-plugins/UserInputMapper.cpp index 5c51db9410..fad962345c 100755 --- a/libraries/input-plugins/src/input-plugins/UserInputMapper.cpp +++ b/libraries/input-plugins/src/input-plugins/UserInputMapper.cpp @@ -10,13 +10,19 @@ // #include "UserInputMapper.h" +#include "StandardController.h" // Default contruct allocate the poutput size with the current hardcoded action channels UserInputMapper::UserInputMapper() { + registerStandardDevice(); assignDefaulActionScales(); createActionNames(); } +UserInputMapper::~UserInputMapper() { +} + + bool UserInputMapper::registerDevice(uint16 deviceID, const DeviceProxy::Pointer& proxy){ proxy->_name += " (" + QString::number(deviceID) + ")"; _registeredDevices[deviceID] = proxy; @@ -322,3 +328,8 @@ void UserInputMapper::createActionNames() { _actionNames[CONTEXT_MENU] = "CONTEXT_MENU"; _actionNames[TOGGLE_MUTE] = "TOGGLE_MUTE"; } + +void UserInputMapper::registerStandardDevice() { + _standardController = std::make_shared(); + _standardController->registerToUserInputMapper(*this); +} \ No newline at end of file diff --git a/libraries/input-plugins/src/input-plugins/UserInputMapper.h b/libraries/input-plugins/src/input-plugins/UserInputMapper.h index 1ad4294e0c..1d64638ee1 100755 --- a/libraries/input-plugins/src/input-plugins/UserInputMapper.h +++ b/libraries/input-plugins/src/input-plugins/UserInputMapper.h @@ -19,13 +19,17 @@ #include #include #include - + +class StandardController; +typedef std::shared_ptr StandardControllerPointer; class UserInputMapper : public QObject, public Dependency { Q_OBJECT SINGLETON_DEPENDENCY Q_ENUMS(Action) public: + ~UserInputMapper(); + typedef unsigned short uint16; typedef unsigned int uint32; @@ -123,6 +127,7 @@ public: // GetFreeDeviceID should be called before registering a device to use an ID not used by a different device. uint16 getFreeDeviceID() { return _nextFreeDeviceID++; } bool registerDevice(uint16 deviceID, const DeviceProxy::Pointer& device); + bool registerStandardDevice(const DeviceProxy::Pointer& device) { _standardDevice = device; return true; } DeviceProxy::Pointer getDeviceProxy(const Input& input); QString getDeviceName(uint16 deviceID); QVector getAvailableInputs(uint16 deviceID) { return _registeredDevices[deviceID]->getAvailabeInputs(); } @@ -238,11 +243,19 @@ public: typedef std::map DevicesMap; DevicesMap getDevices() { return _registeredDevices; } + uint16 getStandardDeviceID() const { return _standardDeviceID; } + DeviceProxy::Pointer getStandardDevice() { return _standardDevice; } + signals: void actionEvent(int action, float state); protected: + void registerStandardDevice(); + uint16 _standardDeviceID = 0; + DeviceProxy::Pointer _standardDevice; + StandardControllerPointer _standardController; + DevicesMap _registeredDevices; uint16 _nextFreeDeviceID = 1; diff --git a/libraries/model-networking/CMakeLists.txt b/libraries/model-networking/CMakeLists.txt index f014885794..29ab17f2ec 100644 --- a/libraries/model-networking/CMakeLists.txt +++ b/libraries/model-networking/CMakeLists.txt @@ -1,11 +1,4 @@ set(TARGET_NAME model-networking) - -# use setup_hifi_library macro to setup our project and link appropriate Qt modules setup_hifi_library() - -add_dependency_external_projects(glm) -find_package(GLM REQUIRED) -target_include_directories(${TARGET_NAME} PUBLIC ${GLM_INCLUDE_DIRS}) - link_hifi_libraries(shared networking gpu model fbx) diff --git a/libraries/model/CMakeLists.txt b/libraries/model/CMakeLists.txt index c30ffb7238..63f632e484 100755 --- a/libraries/model/CMakeLists.txt +++ b/libraries/model/CMakeLists.txt @@ -1,12 +1,5 @@ set(TARGET_NAME model) - AUTOSCRIBE_SHADER_LIB(gpu model) - -# use setup_hifi_library macro to setup our project and link appropriate Qt modules setup_hifi_library() - -add_dependency_external_projects(glm) -find_package(GLM REQUIRED) -target_include_directories(${TARGET_NAME} PUBLIC ${GLM_INCLUDE_DIRS}) - link_hifi_libraries(shared gpu) + diff --git a/libraries/networking/CMakeLists.txt b/libraries/networking/CMakeLists.txt index 274dae7420..470c9145df 100644 --- a/libraries/networking/CMakeLists.txt +++ b/libraries/networking/CMakeLists.txt @@ -1,8 +1,5 @@ set(TARGET_NAME networking) - -# use setup_hifi_library macro to setup our project and link appropriate Qt modules setup_hifi_library(Network) - link_hifi_libraries(shared) if (WIN32) diff --git a/libraries/networking/src/ResourceManager.cpp b/libraries/networking/src/ResourceManager.cpp index 774664f2c8..fd465a0aed 100644 --- a/libraries/networking/src/ResourceManager.cpp +++ b/libraries/networking/src/ResourceManager.cpp @@ -17,7 +17,30 @@ #include -QUrl ResourceManager::normalizeURL(const QUrl& url) { +ResourceManager::PrefixMap ResourceManager::_prefixMap; +QMutex ResourceManager::_prefixMapLock; + + +void ResourceManager::setUrlPrefixOverride(const QString& prefix, const QString& replacement) { + QMutexLocker locker(&_prefixMapLock); + _prefixMap[prefix] = replacement; +} + +QString ResourceManager::normalizeURL(const QString& urlString) { + QString result = urlString; + QMutexLocker locker(&_prefixMapLock); + foreach(const auto& entry, _prefixMap) { + const auto& prefix = entry.first; + const auto& replacement = entry.second; + if (result.startsWith(prefix)) { + result.replace(0, prefix.size(), replacement); + } + } + return result; +} + +QUrl ResourceManager::normalizeURL(const QUrl& originalUrl) { + QUrl url = QUrl(normalizeURL(originalUrl.toString())); auto scheme = url.scheme(); if (!(scheme == URL_SCHEME_FILE || scheme == URL_SCHEME_HTTP || scheme == URL_SCHEME_HTTPS || scheme == URL_SCHEME_FTP || @@ -37,11 +60,11 @@ ResourceRequest* ResourceManager::createResourceRequest(QObject* parent, const Q auto normalizedURL = normalizeURL(url); auto scheme = normalizedURL.scheme(); if (scheme == URL_SCHEME_FILE) { - return new FileResourceRequest(parent, url); + return new FileResourceRequest(parent, normalizedURL); } else if (scheme == URL_SCHEME_HTTP || scheme == URL_SCHEME_HTTPS || scheme == URL_SCHEME_FTP) { - return new HTTPResourceRequest(parent, url); + return new HTTPResourceRequest(parent, normalizedURL); } else if (scheme == URL_SCHEME_ATP) { - return new AssetResourceRequest(parent, url); + return new AssetResourceRequest(parent, normalizedURL); } qDebug() << "Unknown scheme (" << scheme << ") for URL: " << url.url(); diff --git a/libraries/networking/src/ResourceManager.h b/libraries/networking/src/ResourceManager.h index 40b67b1cd1..c010c67f9b 100644 --- a/libraries/networking/src/ResourceManager.h +++ b/libraries/networking/src/ResourceManager.h @@ -14,6 +14,8 @@ #include +#include + #include "ResourceRequest.h" const QString URL_SCHEME_FILE = "file"; @@ -24,8 +26,15 @@ const QString URL_SCHEME_ATP = "atp"; class ResourceManager { public: + static void setUrlPrefixOverride(const QString& prefix, const QString& replacement); + static QString normalizeURL(const QString& urlString); static QUrl normalizeURL(const QUrl& url); static ResourceRequest* createResourceRequest(QObject* parent, const QUrl& url); +private: + using PrefixMap = std::map; + + static PrefixMap _prefixMap; + static QMutex _prefixMapLock; }; #endif diff --git a/libraries/octree/CMakeLists.txt b/libraries/octree/CMakeLists.txt index cc36aead15..bea036add3 100644 --- a/libraries/octree/CMakeLists.txt +++ b/libraries/octree/CMakeLists.txt @@ -1,10 +1,3 @@ set(TARGET_NAME octree) - -# use setup_hifi_library macro to setup our project and link appropriate Qt modules setup_hifi_library() - -add_dependency_external_projects(glm) -find_package(GLM REQUIRED) -target_include_directories(${TARGET_NAME} PUBLIC ${GLM_INCLUDE_DIRS}) - link_hifi_libraries(shared networking) diff --git a/libraries/physics/CMakeLists.txt b/libraries/physics/CMakeLists.txt index b1f9fbb79c..b734c9ac2e 100644 --- a/libraries/physics/CMakeLists.txt +++ b/libraries/physics/CMakeLists.txt @@ -1,24 +1,5 @@ set(TARGET_NAME physics) - -# use setup_hifi_library macro to setup our project and link appropriate Qt modules setup_hifi_library() - -add_dependency_external_projects(glm) -find_package(GLM REQUIRED) -target_include_directories(${TARGET_NAME} PUBLIC ${GLM_INCLUDE_DIRS}) - -add_dependency_external_projects(bullet) - -find_package(Bullet REQUIRED) - -# perform the system include hack for OS X to ignore warnings -if (APPLE) - SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -isystem ${BULLET_INCLUDE_DIRS}") -else() - target_include_directories(${TARGET_NAME} SYSTEM PRIVATE ${BULLET_INCLUDE_DIRS}) -endif() - -target_link_libraries(${TARGET_NAME} ${BULLET_LIBRARIES}) - link_hifi_libraries(shared fbx entities) -include_hifi_library_headers(fbx) + +target_bullet() diff --git a/libraries/plugins/CMakeLists.txt b/libraries/plugins/CMakeLists.txt index 42b8cb1625..f32650df94 100644 --- a/libraries/plugins/CMakeLists.txt +++ b/libraries/plugins/CMakeLists.txt @@ -1,11 +1,3 @@ set(TARGET_NAME plugins) - -# use setup_hifi_library macro to setup our project and link appropriate Qt modules setup_hifi_library(OpenGL) - link_hifi_libraries(shared) - -add_dependency_external_projects(glm) -find_package(GLM REQUIRED) - -target_include_directories(${TARGET_NAME} PUBLIC ${GLM_INCLUDE_DIRS}) diff --git a/libraries/procedural/CMakeLists.txt b/libraries/procedural/CMakeLists.txt index 9595ef5f7a..0483b8d3a8 100644 --- a/libraries/procedural/CMakeLists.txt +++ b/libraries/procedural/CMakeLists.txt @@ -1,12 +1,5 @@ set(TARGET_NAME procedural) - AUTOSCRIBE_SHADER_LIB(gpu model) - -# use setup_hifi_library macro to setup our project and link appropriate Qt modules setup_hifi_library() - -add_dependency_external_projects(glm) -find_package(GLM REQUIRED) -target_include_directories(${TARGET_NAME} PUBLIC ${GLM_INCLUDE_DIRS}) - link_hifi_libraries(shared gpu model model-networking) + diff --git a/libraries/procedural/src/procedural/Procedural.cpp b/libraries/procedural/src/procedural/Procedural.cpp index f5448bda5c..a0020d21f3 100644 --- a/libraries/procedural/src/procedural/Procedural.cpp +++ b/libraries/procedural/src/procedural/Procedural.cpp @@ -88,6 +88,7 @@ void Procedural::parse(const QJsonObject& proceduralData) { // Get the path to the shader { QString shaderUrl = proceduralData[URL_KEY].toString(); + shaderUrl = ResourceManager::normalizeURL(shaderUrl); _shaderUrl = QUrl(shaderUrl); if (!_shaderUrl.isValid()) { qWarning() << "Invalid shader URL: " << shaderUrl; diff --git a/libraries/render-utils/CMakeLists.txt b/libraries/render-utils/CMakeLists.txt index fa6cc6fe77..c74089a238 100644 --- a/libraries/render-utils/CMakeLists.txt +++ b/libraries/render-utils/CMakeLists.txt @@ -1,45 +1,9 @@ set(TARGET_NAME render-utils) - AUTOSCRIBE_SHADER_LIB(gpu model render) - # pull in the resources.qrc file qt5_add_resources(QT_RESOURCES_FILE "${CMAKE_CURRENT_SOURCE_DIR}/res/fonts/fonts.qrc") - -# use setup_hifi_library macro to setup our project and link appropriate Qt modules setup_hifi_library(Widgets OpenGL Network Qml Quick Script) - -add_dependency_external_projects(glm) -find_package(GLM REQUIRED) -target_include_directories(${TARGET_NAME} PUBLIC ${GLM_INCLUDE_DIRS}) - -add_dependency_external_projects(boostconfig) -find_package(BoostConfig REQUIRED) -target_include_directories(${TARGET_NAME} PUBLIC ${BOOSTCONFIG_INCLUDE_DIRS}) - -add_dependency_external_projects(oglplus) -find_package(OGLPLUS REQUIRED) -target_include_directories(${TARGET_NAME} PUBLIC ${OGLPLUS_INCLUDE_DIRS}) - -add_definitions(-DGLEW_STATIC) - -if (WIN32) - if (USE_NSIGHT) - # try to find the Nsight package and add it to the build if we find it - find_package(NSIGHT) - if (NSIGHT_FOUND) - include_directories(${NSIGHT_INCLUDE_DIRS}) - add_definitions(-DNSIGHT_FOUND) - target_link_libraries(${TARGET_NAME} "${NSIGHT_LIBRARIES}") - endif () - endif() -endif (WIN32) - -add_dependency_external_projects(boostconfig) -find_package(BoostConfig REQUIRED) -target_include_directories(${TARGET_NAME} PUBLIC ${BOOSTCONFIG_INCLUDE_DIRS}) - -add_dependency_external_projects(oglplus) -find_package(OGLPLUS REQUIRED) -target_include_directories(${TARGET_NAME} PUBLIC ${OGLPLUS_INCLUDE_DIRS}) - link_hifi_libraries(shared gpu procedural model model-networking render environment animation fbx) + +target_nsight() +target_oglplus() diff --git a/libraries/render/CMakeLists.txt b/libraries/render/CMakeLists.txt index f2bcb7c47c..76fc8303ce 100644 --- a/libraries/render/CMakeLists.txt +++ b/libraries/render/CMakeLists.txt @@ -1,24 +1,7 @@ set(TARGET_NAME render) - AUTOSCRIBE_SHADER_LIB(gpu model) - -# use setup_hifi_library macro to setup our project and link appropriate Qt modules setup_hifi_library() - -add_dependency_external_projects(glm) -find_package(GLM REQUIRED) -target_include_directories(${TARGET_NAME} PUBLIC ${GLM_INCLUDE_DIRS}) - link_hifi_libraries(shared gpu model) -if (WIN32) - if (USE_NSIGHT) - # try to find the Nsight package and add it to the build if we find it - find_package(NSIGHT) - if (NSIGHT_FOUND) - include_directories(${NSIGHT_INCLUDE_DIRS}) - add_definitions(-DNSIGHT_FOUND) - target_link_libraries(${TARGET_NAME} "${NSIGHT_LIBRARIES}") - endif () - endif() -endif (WIN32) + +target_nsight() diff --git a/libraries/script-engine/CMakeLists.txt b/libraries/script-engine/CMakeLists.txt index a458d4de51..cfe0afd220 100644 --- a/libraries/script-engine/CMakeLists.txt +++ b/libraries/script-engine/CMakeLists.txt @@ -1,10 +1,3 @@ set(TARGET_NAME script-engine) - -# use setup_hifi_library macro to setup our project and link appropriate Qt modules setup_hifi_library(Gui Network Script WebSockets Widgets) - -add_dependency_external_projects(glm) -find_package(GLM REQUIRED) -target_include_directories(${TARGET_NAME} PUBLIC ${GLM_INCLUDE_DIRS}) - link_hifi_libraries(shared networking octree gpu procedural model model-networking fbx entities animation audio physics) diff --git a/libraries/shared/CMakeLists.txt b/libraries/shared/CMakeLists.txt index 00a80619bc..d9df5eba7f 100644 --- a/libraries/shared/CMakeLists.txt +++ b/libraries/shared/CMakeLists.txt @@ -1,15 +1,11 @@ set(TARGET_NAME shared) -# use setup_hifi_library macro to setup our project and link appropriate Qt modules # TODO: there isn't really a good reason to have Script linked here - let's get what is requiring it out (RegisteredMetaTypes.cpp) setup_hifi_library(Gui Network Script Widgets) find_package(ZLIB REQUIRED) target_link_libraries(${TARGET_NAME} ${ZLIB_LIBRARIES}) - -add_dependency_external_projects(glm) -find_package(GLM REQUIRED) -target_include_directories(${TARGET_NAME} PUBLIC ${GLM_INCLUDE_DIRS} ${ZLIB_INCLUDE_DIRS}) +target_include_directories(${TARGET_NAME} PUBLIC ${ZLIB_INCLUDE_DIRS}) if (WIN32) # Birarda will fix this when he finds it. diff --git a/libraries/ui/CMakeLists.txt b/libraries/ui/CMakeLists.txt index b07651f7d4..d4cd1fc2bb 100644 --- a/libraries/ui/CMakeLists.txt +++ b/libraries/ui/CMakeLists.txt @@ -1,11 +1,3 @@ set(TARGET_NAME ui) - -# use setup_hifi_library macro to setup our project and link appropriate Qt modules setup_hifi_library(OpenGL Network Qml Quick Script XmlPatterns) - link_hifi_libraries(render-utils shared) - -add_dependency_external_projects(glm) -find_package(GLM REQUIRED) - -target_include_directories(${TARGET_NAME} PUBLIC ${GLM_INCLUDE_DIRS}) diff --git a/tests/gpu-test/CMakeLists.txt b/tests/gpu-test/CMakeLists.txt index 1cb9e9f78e..0c183fc2f0 100644 --- a/tests/gpu-test/CMakeLists.txt +++ b/tests/gpu-test/CMakeLists.txt @@ -1,15 +1,7 @@ - set(TARGET_NAME gpu-test) - AUTOSCRIBE_SHADER_LIB(gpu model render-utils) - # This is not a testcase -- just set it up as a regular hifi project setup_hifi_project(Quick Gui OpenGL Script Widgets) set_target_properties(${TARGET_NAME} PROPERTIES FOLDER "Tests/manual-tests/") - -#include_oglplus() - -# link in the shared libraries link_hifi_libraries(networking gpu procedural shared fbx model model-networking animation script-engine render-utils ) - copy_dlls_beside_windows_executable() \ No newline at end of file diff --git a/tests/physics/CMakeLists.txt b/tests/physics/CMakeLists.txt index 36cf21c681..f789a7b2ba 100644 --- a/tests/physics/CMakeLists.txt +++ b/tests/physics/CMakeLists.txt @@ -1,22 +1,7 @@ # Declare dependencies macro (SETUP_TESTCASE_DEPENDENCIES) - add_dependency_external_projects(glm) - find_package(GLM REQUIRED) - target_include_directories(${TARGET_NAME} PUBLIC ${GLM_INCLUDE_DIRS}) - - add_dependency_external_projects(bullet) - - find_package(Bullet REQUIRED) - target_link_libraries(${TARGET_NAME} ${BULLET_LIBRARIES}) - - # perform the system include hack for OS X to ignore warnings - if (APPLE) - SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -isystem ${BULLET_INCLUDE_DIRS}") - else() - target_include_directories(${TARGET_NAME} SYSTEM PRIVATE ${BULLET_INCLUDE_DIRS}) - endif() - + target_bullet() link_hifi_libraries(shared physics) copy_dlls_beside_windows_executable() endmacro ()