mirror of
https://github.com/overte-org/overte.git
synced 2025-07-26 07:00:09 +02:00
Merge branch 'master' of https://github.com/highfidelity/hifi into dont-use-other-avatar-sounds
This commit is contained in:
commit
ea2971a24f
93 changed files with 960 additions and 536 deletions
23
BUILD.md
23
BUILD.md
|
@ -5,25 +5,30 @@
|
||||||
* [OpenSSL](https://www.openssl.org/related/binaries.html) ~> 1.0.1m
|
* [OpenSSL](https://www.openssl.org/related/binaries.html) ~> 1.0.1m
|
||||||
* IMPORTANT: Using the recommended version of OpenSSL is critical to avoid security vulnerabilities.
|
* IMPORTANT: Using the recommended version of OpenSSL is critical to avoid security vulnerabilities.
|
||||||
* [VHACD](https://github.com/virneo/v-hacd)(clone this repository)(Optional)
|
* [VHACD](https://github.com/virneo/v-hacd)(clone this repository)(Optional)
|
||||||
* [zlib](http://www.zlib.net/)
|
|
||||||
|
|
||||||
####CMake External Project Dependencies
|
####CMake External Project Dependencies
|
||||||
|
|
||||||
|
* [boostconfig](https://github.com/boostorg/config) ~> 1.58
|
||||||
* [Bullet Physics Engine](https://code.google.com/p/bullet/downloads/list) ~> 2.82
|
* [Bullet Physics Engine](https://code.google.com/p/bullet/downloads/list) ~> 2.82
|
||||||
* [Intel Threading Building Blocks](https://www.threadingbuildingblocks.org/) ~> 4.3
|
* [Faceshift](http://www.faceshift.com/) ~> 4.3
|
||||||
|
* [GLEW](http://glew.sourceforge.net/)
|
||||||
* [glm](http://glm.g-truc.net/0.9.5/index.html) ~> 0.9.5.4
|
* [glm](http://glm.g-truc.net/0.9.5/index.html) ~> 0.9.5.4
|
||||||
* [gverb](https://github.com/highfidelity/gverb)
|
* [gverb](https://github.com/highfidelity/gverb)
|
||||||
|
* [Oculus SDK](https://developer.oculus.com/downloads/) ~> 0.6 (Win32) / 0.5 (Mac / Linux)
|
||||||
The following external projects are optional dependencies. You can indicate to CMake that you would like to include them by passing -DGET_$NAME=1 when running a clean CMake build. For example, to get CMake to download and compile SDL2 you would pass -DGET_SDL2=1.
|
* [oglplus](http://oglplus.org/) ~> 0.63
|
||||||
|
* [OpenVR](https://github.com/ValveSoftware/openvr) ~> 0.91 (Win32 only)
|
||||||
|
* [Polyvox](http://www.volumesoffun.com/) ~> 0.2.1
|
||||||
* [SDL2](https://www.libsdl.org/download-2.0.php) ~> 2.0.3
|
* [SDL2](https://www.libsdl.org/download-2.0.php) ~> 2.0.3
|
||||||
* Enables game controller support in Interface
|
* [soxr](http://soxr.sourceforge.net) ~> 0.1.1
|
||||||
|
* [Intel Threading Building Blocks](https://www.threadingbuildingblocks.org/) ~> 4.3
|
||||||
|
* [Sixense](http://sixense.com/) ~> 071615
|
||||||
|
* [zlib](http://www.zlib.net/) ~> 1.28 (Win32 only)
|
||||||
|
|
||||||
The above dependencies will be downloaded, built, linked and included automatically by CMake where we require them. The CMakeLists files that handle grabbing each of the following external dependencies can be found in the [cmake/externals folder](cmake/externals). The resulting downloads, source files and binaries will be placed in the `build/ext` folder in each of the subfolders for each external project.
|
The above dependencies will be downloaded, built, linked and included automatically by CMake where we require them. The CMakeLists files that handle grabbing each of the following external dependencies can be found in the [cmake/externals folder](cmake/externals). The resulting downloads, source files and binaries will be placed in the `build/ext` folder in each of the subfolders for each external project.
|
||||||
|
|
||||||
These are not placed in your normal build tree when doing an out of source build so that they do not need to be re-downloaded and re-compiled every time the CMake build folder is cleared. Should you want to force a re-download and re-compile of a specific external, you can simply remove that directory from the appropriate subfolder in `build/ext`. Should you want to force a re-download and re-compile of all externals, just remove the `build/ext` folder.
|
These are not placed in your normal build tree when doing an out of source build so that they do not need to be re-downloaded and re-compiled every time the CMake build folder is cleared. Should you want to force a re-download and re-compile of a specific external, you can simply remove that directory from the appropriate subfolder in `build/ext`. Should you want to force a re-download and re-compile of all externals, just remove the `build/ext` folder.
|
||||||
|
|
||||||
If you would like to use a specific install of a dependency instead of the version that would be grabbed as a CMake ExternalProject, you can pass -DGET_$NAME=0 (where $NAME is the name of the subfolder in [cmake/externals](cmake/externals)) when you run CMake to tell it not to get that dependency as an external project.
|
If you would like to use a specific install of a dependency instead of the version that would be grabbed as a CMake ExternalProject, you can pass -DUSE_LOCAL_$NAME=0 (where $NAME is the name of the subfolder in [cmake/externals](cmake/externals)) when you run CMake to tell it not to get that dependency as an external project.
|
||||||
|
|
||||||
###OS Specific Build Guides
|
###OS Specific Build Guides
|
||||||
* [BUILD_OSX.md](BUILD_OSX.md) - additional instructions for OS X.
|
* [BUILD_OSX.md](BUILD_OSX.md) - additional instructions for OS X.
|
||||||
|
@ -63,7 +68,7 @@ For example, to pass the QT_CMAKE_PREFIX_PATH variable during build file generat
|
||||||
|
|
||||||
####Finding Dependencies
|
####Finding Dependencies
|
||||||
|
|
||||||
The following applies for dependencies we do not grab via CMake ExternalProject (OpenSSL is an example), or for dependencies you have opted not to grab as a CMake ExternalProject (via -DGET_$NAME=0). The list of dependencies we grab by default as external projects can be found in [the CMake External Project Dependencies section](#cmake-external-project-dependencies).
|
The following applies for dependencies we do not grab via CMake ExternalProject (OpenSSL is an example), or for dependencies you have opted not to grab as a CMake ExternalProject (via -DUSE_LOCAL_$NAME=0). The list of dependencies we grab by default as external projects can be found in [the CMake External Project Dependencies section](#cmake-external-project-dependencies).
|
||||||
|
|
||||||
You can point our [Cmake find modules](cmake/modules/) to the correct version of dependencies by setting one of the three following variables to the location of the correct version of the dependency.
|
You can point our [Cmake find modules](cmake/modules/) to the correct version of dependencies by setting one of the three following variables to the location of the correct version of the dependency.
|
||||||
|
|
||||||
|
@ -77,5 +82,5 @@ In the examples below the variable $NAME would be replaced by the name of the de
|
||||||
|
|
||||||
####Devices
|
####Devices
|
||||||
|
|
||||||
You can support external input/output devices such as Oculus Rift, Leap Motion, Faceshift, MIDI, Razr Hydra and more by adding each individual SDK in the visible building path. Refer to the readme file available in each device folder in [interface/external/](interface/external) for the detailed explanation of the requirements to use the device.
|
You can support external input/output devices such as Leap Motion, MIDI, and more by adding each individual SDK in the visible building path. Refer to the readme file available in each device folder in [interface/external/](interface/external) for the detailed explanation of the requirements to use the device.
|
||||||
|
|
||||||
|
|
10
BUILD_WIN.md
10
BUILD_WIN.md
|
@ -75,16 +75,6 @@ To prevent these problems, install OpenSSL yourself. Download the following bina
|
||||||
|
|
||||||
Install OpenSSL into the Windows system directory, to make sure that Qt uses the version that you've just installed, and not some other version.
|
Install OpenSSL into the Windows system directory, to make sure that Qt uses the version that you've just installed, and not some other version.
|
||||||
|
|
||||||
####zlib
|
|
||||||
|
|
||||||
Install zlib from
|
|
||||||
|
|
||||||
[Zlib for Windows](http://gnuwin32.sourceforge.net/packages/zlib.htm)
|
|
||||||
|
|
||||||
and fix a header file, as described here:
|
|
||||||
|
|
||||||
[zlib zconf.h bug](http://sourceforge.net/p/gnuwin32/bugs/169/)
|
|
||||||
|
|
||||||
###Build High Fidelity using Visual Studio
|
###Build High Fidelity using Visual Studio
|
||||||
Follow the same build steps from the CMake section of [BUILD.md](BUILD.md), but pass a different generator to CMake.
|
Follow the same build steps from the CMake section of [BUILD.md](BUILD.md), but pass a different generator to CMake.
|
||||||
|
|
||||||
|
|
|
@ -203,6 +203,7 @@ if (NOT ANDROID)
|
||||||
add_subdirectory(interface)
|
add_subdirectory(interface)
|
||||||
set_target_properties(interface PROPERTIES FOLDER "Apps")
|
set_target_properties(interface PROPERTIES FOLDER "Apps")
|
||||||
add_subdirectory(tests)
|
add_subdirectory(tests)
|
||||||
|
add_subdirectory(plugins)
|
||||||
add_subdirectory(tools)
|
add_subdirectory(tools)
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
|
|
5
cmake/externals/glew/CMakeLists.txt
vendored
5
cmake/externals/glew/CMakeLists.txt
vendored
|
@ -7,14 +7,15 @@ endif ()
|
||||||
include(ExternalProject)
|
include(ExternalProject)
|
||||||
ExternalProject_Add(
|
ExternalProject_Add(
|
||||||
${EXTERNAL_NAME}
|
${EXTERNAL_NAME}
|
||||||
URL http://hifi-public.s3.amazonaws.com/dependencies/glew_simple.zip
|
URL http://hifi-public.s3.amazonaws.com/dependencies/glew_simple2.zip
|
||||||
URL_MD5 0507dc08337a82a5e7ecbc5417f92cc1
|
URL_MD5 f05d858e8203c32b689da208ad8b39db
|
||||||
CONFIGURE_COMMAND CMAKE_ARGS ${ANDROID_CMAKE_ARGS} -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} -DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR>
|
CONFIGURE_COMMAND CMAKE_ARGS ${ANDROID_CMAKE_ARGS} -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} -DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR>
|
||||||
LOG_DOWNLOAD 1
|
LOG_DOWNLOAD 1
|
||||||
LOG_CONFIGURE 1
|
LOG_CONFIGURE 1
|
||||||
LOG_BUILD 1
|
LOG_BUILD 1
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
# Hide this external target (for ide users)
|
# Hide this external target (for ide users)
|
||||||
set_target_properties(${EXTERNAL_NAME} PROPERTIES FOLDER "hidden/externals")
|
set_target_properties(${EXTERNAL_NAME} PROPERTIES FOLDER "hidden/externals")
|
||||||
|
|
||||||
|
|
49
cmake/externals/zlib/CMakeLists.txt
vendored
49
cmake/externals/zlib/CMakeLists.txt
vendored
|
@ -1,28 +1,31 @@
|
||||||
|
set(EXTERNAL_NAME zlib)
|
||||||
|
string(TOUPPER ${EXTERNAL_NAME} EXTERNAL_NAME_UPPER)
|
||||||
|
|
||||||
if (WIN32)
|
include(ExternalProject)
|
||||||
set(EXTERNAL_NAME zlib)
|
|
||||||
string(TOUPPER ${EXTERNAL_NAME} EXTERNAL_NAME_UPPER)
|
|
||||||
|
|
||||||
include(ExternalProject)
|
ExternalProject_Add(
|
||||||
ExternalProject_Add(
|
${EXTERNAL_NAME}
|
||||||
${EXTERNAL_NAME}
|
URL http://zlib.net/zlib128.zip
|
||||||
URL http://zlib.net/zlib128.zip
|
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR>
|
||||||
URL_MD5 126f8676442ffbd97884eb4d6f32afb4
|
BINARY_DIR ${EXTERNAL_PROJECT_PREFIX}/build
|
||||||
INSTALL_COMMAND ""
|
LOG_DOWNLOAD 1
|
||||||
LOG_DOWNLOAD 1
|
LOG_CONFIGURE 1
|
||||||
)
|
LOG_BUILD 1
|
||||||
|
)
|
||||||
|
|
||||||
|
# Hide this external target (for ide users)
|
||||||
|
set_target_properties(${EXTERNAL_NAME} PROPERTIES FOLDER "hidden/externals")
|
||||||
|
|
||||||
# Hide this external target (for ide users)
|
ExternalProject_Get_Property(${EXTERNAL_NAME} INSTALL_DIR)
|
||||||
set_target_properties(${EXTERNAL_NAME} PROPERTIES FOLDER "hidden/externals")
|
set(${EXTERNAL_NAME_UPPER}_INCLUDE_DIR ${INSTALL_DIR}/include CACHE PATH "List of zlib include directories")
|
||||||
|
set(${EXTERNAL_NAME_UPPER}_INCLUDE_DIRS ${${EXTERNAL_NAME_UPPER}_INCLUDE_DIR} CACHE PATH "List of zlib include directories")
|
||||||
|
set(${EXTERNAL_NAME_UPPER}_DLL_PATH ${INSTALL_DIR}/bin CACHE FILEPATH "Location of ZLib DLL")
|
||||||
|
set(${EXTERNAL_NAME_UPPER}_LIBRARY_RELEASE ${INSTALL_DIR}/lib/zlib.lib CACHE FILEPATH "Location of zlib release library")
|
||||||
|
set(${EXTERNAL_NAME_UPPER}_LIBRARY_DEBUG ${INSTALL_DIR}/lib/zlibd.lib CACHE FILEPATH "Location of zlib debug library")
|
||||||
|
|
||||||
ExternalProject_Get_Property(${EXTERNAL_NAME} SOURCE_DIR)
|
include(SelectLibraryConfigurations)
|
||||||
|
select_library_configurations(${EXTERNAL_NAME_UPPER})
|
||||||
|
|
||||||
set(${EXTERNAL_NAME_UPPER}_INCLUDE_DIRS ${SOURCE_DIR}/include CACHE PATH "List of zlib include directories")
|
# Force selected libraries into the cache
|
||||||
|
set(${EXTERNAL_NAME_UPPER}_LIBRARY ${${EXTERNAL_NAME_UPPER}_LIBRARY} CACHE FILEPATH "Location of zlib libraries")
|
||||||
ExternalProject_Get_Property(${EXTERNAL_NAME} BINARY_DIR)
|
set(${EXTERNAL_NAME_UPPER}_LIBRARIES ${${EXTERNAL_NAME_UPPER}_LIBRARIES} CACHE FILEPATH "Location of zlib libraries")
|
||||||
|
|
||||||
set(${EXTERNAL_NAME_UPPER}_DLL_PATH ${BINARY_DIR}/Release CACHE FILEPATH "Location of GLEW DLL")
|
|
||||||
set(${EXTERNAL_NAME_UPPER}_LIBRARY_RELEASE ${BINARY_DIR}/Release/zlib.lib CACHE FILEPATH "Location of ZLib release library")
|
|
||||||
set(${EXTERNAL_NAME_UPPER}_LIBRARY_DEBUG "" CACHE FILEPATH "Location of ZLib debug library")
|
|
||||||
|
|
||||||
endif ()
|
|
||||||
|
|
33
cmake/macros/SetupHifiPlugin.cmake
Normal file
33
cmake/macros/SetupHifiPlugin.cmake
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
#
|
||||||
|
# Created by Bradley Austin Davis on 2015/10/25
|
||||||
|
# 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
|
||||||
|
#
|
||||||
|
macro(SETUP_HIFI_PLUGIN)
|
||||||
|
set(${TARGET_NAME}_SHARED 1)
|
||||||
|
setup_hifi_library(${ARGV})
|
||||||
|
add_dependencies(interface ${TARGET_NAME})
|
||||||
|
set_target_properties(${TARGET_NAME} PROPERTIES FOLDER "Plugins")
|
||||||
|
|
||||||
|
if (APPLE)
|
||||||
|
set(PLUGIN_PATH "interface.app/Contents/MacOS/plugins")
|
||||||
|
else()
|
||||||
|
set(PLUGIN_PATH "plugins")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# create the destination for the plugin binaries
|
||||||
|
add_custom_command(
|
||||||
|
TARGET ${TARGET_NAME} POST_BUILD
|
||||||
|
COMMAND "${CMAKE_COMMAND}" -E make_directory
|
||||||
|
"${CMAKE_BINARY_DIR}/interface/$<CONFIGURATION>/${PLUGIN_PATH}/"
|
||||||
|
)
|
||||||
|
|
||||||
|
add_custom_command(TARGET ${DIR} POST_BUILD
|
||||||
|
COMMAND "${CMAKE_COMMAND}" -E copy
|
||||||
|
"$<TARGET_FILE:${TARGET_NAME}>"
|
||||||
|
"${CMAKE_BINARY_DIR}/interface/$<CONFIGURATION>/${PLUGIN_PATH}/"
|
||||||
|
)
|
||||||
|
|
||||||
|
endmacro()
|
22
cmake/macros/TargetZlib.cmake
Normal file
22
cmake/macros/TargetZlib.cmake
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
#
|
||||||
|
# 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_ZLIB)
|
||||||
|
|
||||||
|
if (WIN32)
|
||||||
|
add_dependency_external_projects(zlib)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
find_package(ZLIB REQUIRED)
|
||||||
|
|
||||||
|
if (WIN32)
|
||||||
|
add_paths_to_fixup_libs(${ZLIB_DLL_PATH})
|
||||||
|
endif()
|
||||||
|
|
||||||
|
target_include_directories(${TARGET_NAME} SYSTEM PRIVATE ${ZLIB_INCLUDE_DIRS})
|
||||||
|
target_link_libraries(${TARGET_NAME} ${ZLIB_LIBRARIES})
|
||||||
|
endmacro()
|
|
@ -30,6 +30,4 @@ include(SelectLibraryConfigurations)
|
||||||
select_library_configurations(GLEW)
|
select_library_configurations(GLEW)
|
||||||
|
|
||||||
include(FindPackageHandleStandardArgs)
|
include(FindPackageHandleStandardArgs)
|
||||||
find_package_handle_standard_args(GLEW DEFAULT_MSG GLEW_INCLUDE_DIRS GLEW_LIBRARIES)
|
find_package_handle_standard_args(GLEW DEFAULT_MSG GLEW_INCLUDE_DIRS GLEW_LIBRARIES)
|
||||||
|
|
||||||
message(STATUS "Found GLEW - Assuming that GLEW is static and defining GLEW_STATIC")
|
|
|
@ -10,5 +10,35 @@
|
||||||
#
|
#
|
||||||
|
|
||||||
include(BundleUtilities)
|
include(BundleUtilities)
|
||||||
|
|
||||||
|
|
||||||
|
# replace copy_resolved_item_into_bundle
|
||||||
|
#
|
||||||
|
# The official version of copy_resolved_item_into_bundle will print out a "warning:" when
|
||||||
|
# the resolved item matches the resolved embedded item. This not not really an issue that
|
||||||
|
# should rise to the level of a "warning" so we replace this message with a "status:"
|
||||||
|
#
|
||||||
|
function(copy_resolved_item_into_bundle resolved_item resolved_embedded_item)
|
||||||
|
if(WIN32)
|
||||||
|
# ignore case on Windows
|
||||||
|
string(TOLOWER "${resolved_item}" resolved_item_compare)
|
||||||
|
string(TOLOWER "${resolved_embedded_item}" resolved_embedded_item_compare)
|
||||||
|
else()
|
||||||
|
set(resolved_item_compare "${resolved_item}")
|
||||||
|
set(resolved_embedded_item_compare "${resolved_embedded_item}")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if("${resolved_item_compare}" STREQUAL "${resolved_embedded_item_compare}")
|
||||||
|
# this is our only change from the original version
|
||||||
|
message(STATUS "status: resolved_item == resolved_embedded_item - not copying...")
|
||||||
|
else()
|
||||||
|
#message(STATUS "copying COMMAND ${CMAKE_COMMAND} -E copy ${resolved_item} ${resolved_embedded_item}")
|
||||||
|
execute_process(COMMAND ${CMAKE_COMMAND} -E copy "${resolved_item}" "${resolved_embedded_item}")
|
||||||
|
if(UNIX AND NOT APPLE)
|
||||||
|
file(RPATH_REMOVE FILE "${resolved_embedded_item}")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
endfunction()
|
||||||
|
|
||||||
message(STATUS "FIXUP_LIBS for fixup_bundle called for bundle ${BUNDLE_EXECUTABLE} are @FIXUP_LIBS@")
|
message(STATUS "FIXUP_LIBS for fixup_bundle called for bundle ${BUNDLE_EXECUTABLE} are @FIXUP_LIBS@")
|
||||||
fixup_bundle("${BUNDLE_EXECUTABLE}" "" "@FIXUP_LIBS@")
|
fixup_bundle("${BUNDLE_EXECUTABLE}" "" "@FIXUP_LIBS@")
|
|
@ -910,8 +910,8 @@ var leftController = new MyController(LEFT_HAND);
|
||||||
var MAPPING_NAME = "com.highfidelity.handControllerGrab";
|
var MAPPING_NAME = "com.highfidelity.handControllerGrab";
|
||||||
|
|
||||||
var mapping = Controller.newMapping(MAPPING_NAME);
|
var mapping = Controller.newMapping(MAPPING_NAME);
|
||||||
mapping.from([Controller.Standard.RB, Controller.Standard.RT]).to(rightController.eitherTrigger);
|
mapping.from([Controller.Standard.RB, Controller.Standard.RT]).peek().to(rightController.eitherTrigger);
|
||||||
mapping.from([Controller.Standard.LB, Controller.Standard.LT]).to(leftController.eitherTrigger);
|
mapping.from([Controller.Standard.LB, Controller.Standard.LT]).peek().to(leftController.eitherTrigger);
|
||||||
Controller.enableMapping(MAPPING_NAME);
|
Controller.enableMapping(MAPPING_NAME);
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -81,6 +81,7 @@
|
||||||
|
|
||||||
{ "from": "Keyboard.Space", "to": "Actions.SHIFT" },
|
{ "from": "Keyboard.Space", "to": "Actions.SHIFT" },
|
||||||
{ "from": "Keyboard.R", "to": "Actions.ACTION1" },
|
{ "from": "Keyboard.R", "to": "Actions.ACTION1" },
|
||||||
{ "from": "Keyboard.T", "to": "Actions.ACTION2" }
|
{ "from": "Keyboard.T", "to": "Actions.ACTION2" },
|
||||||
|
{ "from": "Keyboard.RightMouseClick", "to": "Actions.ContextMenu" }
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
|
|
||||||
|
|
||||||
{ "from": "Standard.RX", "to": "Actions.Yaw" },
|
{ "from": "Standard.RX", "to": "Actions.Yaw" },
|
||||||
{ "from": "Standard.RY", "to": "Actions.Pitch" },
|
{ "from": "Standard.RY", "filters": "invert", "to": "Actions.TranslateY" },
|
||||||
|
|
||||||
|
|
||||||
{ "from": [ "Standard.DU", "Standard.DL", "Standard.DR", "Standard.DD" ], "to": "Standard.LeftPrimaryThumb" },
|
{ "from": [ "Standard.DU", "Standard.DL", "Standard.DR", "Standard.DD" ], "to": "Standard.LeftPrimaryThumb" },
|
||||||
|
@ -25,6 +25,9 @@
|
||||||
{ "from": [ "Standard.A", "Standard.B", "Standard.X", "Standard.Y" ], "to": "Standard.RightPrimaryThumb" },
|
{ "from": [ "Standard.A", "Standard.B", "Standard.X", "Standard.Y" ], "to": "Standard.RightPrimaryThumb" },
|
||||||
{ "from": "Standard.Start", "to": "Standard.RightSecondaryThumb" },
|
{ "from": "Standard.Start", "to": "Standard.RightSecondaryThumb" },
|
||||||
|
|
||||||
|
{ "from": "Standard.LeftSecondaryThumb", "to": "Actions.CycleCamera" },
|
||||||
|
{ "from": "Standard.RightSecondaryThumb", "to": "Actions.ContextMenu" },
|
||||||
|
|
||||||
{ "from": "Standard.LT", "to": "Actions.LeftHandClick" },
|
{ "from": "Standard.LT", "to": "Actions.LeftHandClick" },
|
||||||
{ "from": "Standard.RT", "to": "Actions.RightHandClick" },
|
{ "from": "Standard.RT", "to": "Actions.RightHandClick" },
|
||||||
|
|
||||||
|
|
|
@ -392,7 +392,6 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer) :
|
||||||
_entityClipboard->createRootElement();
|
_entityClipboard->createRootElement();
|
||||||
|
|
||||||
_pluginContainer = new PluginContainerProxy();
|
_pluginContainer = new PluginContainerProxy();
|
||||||
Plugin::setContainer(_pluginContainer);
|
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
installNativeEventFilter(&MyNativeEventFilter::getInstance());
|
installNativeEventFilter(&MyNativeEventFilter::getInstance());
|
||||||
#endif
|
#endif
|
||||||
|
@ -630,8 +629,14 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer) :
|
||||||
// Setup the userInputMapper with the actions
|
// Setup the userInputMapper with the actions
|
||||||
auto userInputMapper = DependencyManager::get<UserInputMapper>();
|
auto userInputMapper = DependencyManager::get<UserInputMapper>();
|
||||||
connect(userInputMapper.data(), &UserInputMapper::actionEvent, [this](int action, float state) {
|
connect(userInputMapper.data(), &UserInputMapper::actionEvent, [this](int action, float state) {
|
||||||
if (state && action == toInt(controller::Action::TOGGLE_MUTE)) {
|
if (state) {
|
||||||
DependencyManager::get<AudioClient>()->toggleMute();
|
if (action == controller::toInt(controller::Action::TOGGLE_MUTE)) {
|
||||||
|
DependencyManager::get<AudioClient>()->toggleMute();
|
||||||
|
} else if (action == controller::toInt(controller::Action::CYCLE_CAMERA)) {
|
||||||
|
cycleCamera();
|
||||||
|
} else if (action == controller::toInt(controller::Action::CONTEXT_MENU)) {
|
||||||
|
VrMenu::toggle(); // show context menu even on non-stereo displays
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1785,9 +1790,7 @@ void Application::keyPressEvent(QKeyEvent* event) {
|
||||||
|
|
||||||
void Application::keyReleaseEvent(QKeyEvent* event) {
|
void Application::keyReleaseEvent(QKeyEvent* event) {
|
||||||
if (event->key() == Qt::Key_Alt && _altPressed && hasFocus()) {
|
if (event->key() == Qt::Key_Alt && _altPressed && hasFocus()) {
|
||||||
if (getActiveDisplayPlugin()->isStereo()) {
|
VrMenu::toggle(); // show context menu even on non-stereo displays
|
||||||
VrMenu::toggle();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_keysPressed.remove(event->key());
|
_keysPressed.remove(event->key());
|
||||||
|
@ -2620,6 +2623,30 @@ void Application::updateThreads(float deltaTime) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Application::cycleCamera() {
|
||||||
|
auto menu = Menu::getInstance();
|
||||||
|
if (menu->isOptionChecked(MenuOption::FullscreenMirror)) {
|
||||||
|
|
||||||
|
menu->setIsOptionChecked(MenuOption::FullscreenMirror, false);
|
||||||
|
menu->setIsOptionChecked(MenuOption::FirstPerson, true);
|
||||||
|
|
||||||
|
} else if (menu->isOptionChecked(MenuOption::FirstPerson)) {
|
||||||
|
|
||||||
|
menu->setIsOptionChecked(MenuOption::FirstPerson, false);
|
||||||
|
menu->setIsOptionChecked(MenuOption::ThirdPerson, true);
|
||||||
|
|
||||||
|
} else if (menu->isOptionChecked(MenuOption::ThirdPerson)) {
|
||||||
|
|
||||||
|
menu->setIsOptionChecked(MenuOption::ThirdPerson, false);
|
||||||
|
menu->setIsOptionChecked(MenuOption::FullscreenMirror, true);
|
||||||
|
|
||||||
|
} else if (menu->isOptionChecked(MenuOption::IndependentMode)) {
|
||||||
|
// do nothing if in independe mode
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
cameraMenuChanged(); // handle the menu change
|
||||||
|
}
|
||||||
|
|
||||||
void Application::cameraMenuChanged() {
|
void Application::cameraMenuChanged() {
|
||||||
if (Menu::getInstance()->isOptionChecked(MenuOption::FullscreenMirror)) {
|
if (Menu::getInstance()->isOptionChecked(MenuOption::FullscreenMirror)) {
|
||||||
if (_myCamera.getMode() != CAMERA_MODE_MIRROR) {
|
if (_myCamera.getMode() != CAMERA_MODE_MIRROR) {
|
||||||
|
|
|
@ -293,8 +293,9 @@ public slots:
|
||||||
void aboutApp();
|
void aboutApp();
|
||||||
void showEditEntitiesHelp();
|
void showEditEntitiesHelp();
|
||||||
|
|
||||||
|
void cycleCamera();
|
||||||
void cameraMenuChanged();
|
void cameraMenuChanged();
|
||||||
|
|
||||||
void reloadResourceCaches();
|
void reloadResourceCaches();
|
||||||
|
|
||||||
void crashApplication();
|
void crashApplication();
|
||||||
|
|
|
@ -13,7 +13,6 @@
|
||||||
#include "ui/DialogsManager.h"
|
#include "ui/DialogsManager.h"
|
||||||
|
|
||||||
PluginContainerProxy::PluginContainerProxy() {
|
PluginContainerProxy::PluginContainerProxy() {
|
||||||
Plugin::setContainer(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PluginContainerProxy::~PluginContainerProxy() {
|
PluginContainerProxy::~PluginContainerProxy() {
|
||||||
|
|
|
@ -60,6 +60,7 @@ namespace controller {
|
||||||
makeButtonPair(Action::ACTION2, "SecondaryAction"),
|
makeButtonPair(Action::ACTION2, "SecondaryAction"),
|
||||||
makeButtonPair(Action::CONTEXT_MENU, "ContextMenu"),
|
makeButtonPair(Action::CONTEXT_MENU, "ContextMenu"),
|
||||||
makeButtonPair(Action::TOGGLE_MUTE, "ToggleMute"),
|
makeButtonPair(Action::TOGGLE_MUTE, "ToggleMute"),
|
||||||
|
makeButtonPair(Action::CYCLE_CAMERA, "CycleCamera"),
|
||||||
|
|
||||||
// Aliases and bisected versions
|
// Aliases and bisected versions
|
||||||
makeAxisPair(Action::LONGITUDINAL_BACKWARD, "Backward"),
|
makeAxisPair(Action::LONGITUDINAL_BACKWARD, "Backward"),
|
||||||
|
|
|
@ -51,6 +51,7 @@ enum class Action {
|
||||||
|
|
||||||
CONTEXT_MENU,
|
CONTEXT_MENU,
|
||||||
TOGGLE_MUTE,
|
TOGGLE_MUTE,
|
||||||
|
CYCLE_CAMERA,
|
||||||
|
|
||||||
SHIFT,
|
SHIFT,
|
||||||
|
|
||||||
|
|
|
@ -7,8 +7,11 @@
|
||||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
//
|
//
|
||||||
|
|
||||||
#include "DeviceProxy.h"
|
// NOTE: we don't need to include this header unless/until we add additional symbols.
|
||||||
|
// By removing this header we prevent these warnings on windows:
|
||||||
namespace controller {
|
//
|
||||||
}
|
// warning LNK4221: This object file does not define any previously undefined public symbols,
|
||||||
|
// so it will not be used by any link operation that consumes this library
|
||||||
|
//
|
||||||
|
//#include "DeviceProxy.h"
|
||||||
|
|
||||||
|
|
|
@ -118,41 +118,5 @@ QString StandardController::getDefaultMappingConfig() const {
|
||||||
return DEFAULT_MAPPING_JSON;
|
return DEFAULT_MAPPING_JSON;
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME figure out how to move the shifted version to JSON
|
|
||||||
//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;
|
|
||||||
//
|
|
||||||
// // Hold front right shoulder button for precision controls
|
|
||||||
// // Left Joystick: Movement, strafing
|
|
||||||
// mapper.addInputChannel(UserInputMapper::TRANSLATE_Z, makeInput(controller::LY), makeInput(controller::RB), JOYSTICK_MOVE_SPEED / 2.0f);
|
|
||||||
// mapper.addInputChannel(UserInputMapper::TRANSLATE_X, makeInput(controller::LY), makeInput(controller::RB), JOYSTICK_MOVE_SPEED / 2.0f);
|
|
||||||
//
|
|
||||||
// // Right Joystick: Camera orientation
|
|
||||||
// mapper.addInputChannel(UserInputMapper::YAW, makeInput(controller::RX), makeInput(controller::RB), JOYSTICK_YAW_SPEED / 2.0f);
|
|
||||||
// mapper.addInputChannel(UserInputMapper::PITCH, makeInput(controller::RY), makeInput(controller::RB), JOYSTICK_PITCH_SPEED / 2.0f);
|
|
||||||
//
|
|
||||||
// // Dpad movement
|
|
||||||
// mapper.addInputChannel(UserInputMapper::LONGITUDINAL_FORWARD, makeInput(controller::DU), makeInput(controller::RB), DPAD_MOVE_SPEED / 2.0f);
|
|
||||||
// mapper.addInputChannel(UserInputMapper::LONGITUDINAL_BACKWARD, makeInput(controller::DD), makeInput(controller::RB), DPAD_MOVE_SPEED / 2.0f);
|
|
||||||
// mapper.addInputChannel(UserInputMapper::LATERAL_RIGHT, makeInput(controller::DR), makeInput(controller::RB), DPAD_MOVE_SPEED / 2.0f);
|
|
||||||
// mapper.addInputChannel(UserInputMapper::LATERAL_LEFT, makeInput(controller::DL), makeInput(controller::RB), DPAD_MOVE_SPEED / 2.0f);
|
|
||||||
//
|
|
||||||
// // Button controls
|
|
||||||
// mapper.addInputChannel(UserInputMapper::VERTICAL_UP, makeInput(controller::Y), makeInput(controller::RB), DPAD_MOVE_SPEED / 2.0f);
|
|
||||||
// mapper.addInputChannel(UserInputMapper::VERTICAL_DOWN, makeInput(controller::X), makeInput(controller::RB), DPAD_MOVE_SPEED / 2.0f);
|
|
||||||
//
|
|
||||||
// // Zoom
|
|
||||||
// mapper.addInputChannel(UserInputMapper::BOOM_IN, makeInput(controller::RT), makeInput(controller::RB), BOOM_SPEED / 2.0f);
|
|
||||||
// mapper.addInputChannel(UserInputMapper::BOOM_OUT, makeInput(controller::LT), makeInput(controller::RB), BOOM_SPEED / 2.0f);
|
|
||||||
//
|
|
||||||
// mapper.addInputChannel(UserInputMapper::SHIFT, makeInput(controller::RB));
|
|
||||||
//
|
|
||||||
// mapper.addInputChannel(UserInputMapper::ACTION1, makeInput(controller::B));
|
|
||||||
// mapper.addInputChannel(UserInputMapper::ACTION2, makeInput(controller::A));
|
|
||||||
//}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -513,7 +513,7 @@ bool UserInputMapper::applyRoute(const Route::Pointer& route, bool force) {
|
||||||
// and someone else wires it to CONTEXT_MENU, I don't want both to occur when
|
// and someone else wires it to CONTEXT_MENU, I don't want both to occur when
|
||||||
// I press the button. The exception is if I'm wiring a control back to itself
|
// I press the button. The exception is if I'm wiring a control back to itself
|
||||||
// in order to adjust my interface, like inverting the Y axis on an analog stick
|
// in order to adjust my interface, like inverting the Y axis on an analog stick
|
||||||
if (!source->readable()) {
|
if (!route->peek && !source->readable()) {
|
||||||
if (debugRoutes && route->debug) {
|
if (debugRoutes && route->debug) {
|
||||||
qCDebug(controllers) << "Source unreadable";
|
qCDebug(controllers) << "Source unreadable";
|
||||||
}
|
}
|
||||||
|
@ -539,7 +539,7 @@ bool UserInputMapper::applyRoute(const Route::Pointer& route, bool force) {
|
||||||
|
|
||||||
// Fetch the value, may have been overriden by previous loopback routes
|
// Fetch the value, may have been overriden by previous loopback routes
|
||||||
if (source->isPose()) {
|
if (source->isPose()) {
|
||||||
Pose value = getPose(source);
|
Pose value = getPose(source, route->peek);
|
||||||
static const Pose IDENTITY_POSE { vec3(), quat() };
|
static const Pose IDENTITY_POSE { vec3(), quat() };
|
||||||
if (debugRoutes && route->debug) {
|
if (debugRoutes && route->debug) {
|
||||||
if (!value.valid) {
|
if (!value.valid) {
|
||||||
|
@ -554,7 +554,7 @@ bool UserInputMapper::applyRoute(const Route::Pointer& route, bool force) {
|
||||||
destination->apply(value, source);
|
destination->apply(value, source);
|
||||||
} else {
|
} else {
|
||||||
// Fetch the value, may have been overriden by previous loopback routes
|
// Fetch the value, may have been overriden by previous loopback routes
|
||||||
float value = getValue(source);
|
float value = getValue(source, route->peek);
|
||||||
|
|
||||||
if (debugRoutes && route->debug) {
|
if (debugRoutes && route->debug) {
|
||||||
qCDebug(controllers) << "Value was " << value;
|
qCDebug(controllers) << "Value was " << value;
|
||||||
|
@ -691,8 +691,8 @@ void UserInputMapper::enableMapping(const QString& mappingName, bool enable) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
float UserInputMapper::getValue(const Endpoint::Pointer& endpoint) {
|
float UserInputMapper::getValue(const Endpoint::Pointer& endpoint, bool peek) {
|
||||||
return endpoint->value();
|
return peek ? endpoint->peek() : endpoint->value();
|
||||||
}
|
}
|
||||||
|
|
||||||
float UserInputMapper::getValue(const Input& input) const {
|
float UserInputMapper::getValue(const Input& input) const {
|
||||||
|
@ -704,11 +704,11 @@ float UserInputMapper::getValue(const Input& input) const {
|
||||||
return endpoint->value();
|
return endpoint->value();
|
||||||
}
|
}
|
||||||
|
|
||||||
Pose UserInputMapper::getPose(const Endpoint::Pointer& endpoint) {
|
Pose UserInputMapper::getPose(const Endpoint::Pointer& endpoint, bool peek) {
|
||||||
if (!endpoint->isPose()) {
|
if (!endpoint->isPose()) {
|
||||||
return Pose();
|
return Pose();
|
||||||
}
|
}
|
||||||
return endpoint->pose();
|
return peek ? endpoint->peekPose() : endpoint->pose();
|
||||||
}
|
}
|
||||||
|
|
||||||
Pose UserInputMapper::getPose(const Input& input) const {
|
Pose UserInputMapper::getPose(const Input& input) const {
|
||||||
|
@ -742,6 +742,7 @@ static const QString JSON_NAME = QStringLiteral("name");
|
||||||
static const QString JSON_CHANNELS = QStringLiteral("channels");
|
static const QString JSON_CHANNELS = QStringLiteral("channels");
|
||||||
static const QString JSON_CHANNEL_FROM = QStringLiteral("from");
|
static const QString JSON_CHANNEL_FROM = QStringLiteral("from");
|
||||||
static const QString JSON_CHANNEL_DEBUG = QStringLiteral("debug");
|
static const QString JSON_CHANNEL_DEBUG = QStringLiteral("debug");
|
||||||
|
static const QString JSON_CHANNEL_PEEK = QStringLiteral("peek");
|
||||||
static const QString JSON_CHANNEL_WHEN = QStringLiteral("when");
|
static const QString JSON_CHANNEL_WHEN = QStringLiteral("when");
|
||||||
static const QString JSON_CHANNEL_TO = QStringLiteral("to");
|
static const QString JSON_CHANNEL_TO = QStringLiteral("to");
|
||||||
static const QString JSON_CHANNEL_FILTERS = QStringLiteral("filters");
|
static const QString JSON_CHANNEL_FILTERS = QStringLiteral("filters");
|
||||||
|
@ -953,6 +954,7 @@ Route::Pointer UserInputMapper::parseRoute(const QJsonValue& value) {
|
||||||
result->json = QString(QJsonDocument(obj).toJson());
|
result->json = QString(QJsonDocument(obj).toJson());
|
||||||
result->source = parseSource(obj[JSON_CHANNEL_FROM]);
|
result->source = parseSource(obj[JSON_CHANNEL_FROM]);
|
||||||
result->debug = obj[JSON_CHANNEL_DEBUG].toBool();
|
result->debug = obj[JSON_CHANNEL_DEBUG].toBool();
|
||||||
|
result->debug = obj[JSON_CHANNEL_PEEK].toBool();
|
||||||
if (!result->source) {
|
if (!result->source) {
|
||||||
qWarning() << "Invalid route source " << obj[JSON_CHANNEL_FROM];
|
qWarning() << "Invalid route source " << obj[JSON_CHANNEL_FROM];
|
||||||
return Route::Pointer();
|
return Route::Pointer();
|
||||||
|
|
|
@ -38,8 +38,8 @@ namespace controller {
|
||||||
|
|
||||||
class UserInputMapper : public QObject, public Dependency {
|
class UserInputMapper : public QObject, public Dependency {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
SINGLETON_DEPENDENCY
|
SINGLETON_DEPENDENCY
|
||||||
Q_ENUMS(Action)
|
Q_ENUMS(Action)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// FIXME move to unordered set / map
|
// FIXME move to unordered set / map
|
||||||
|
@ -135,8 +135,8 @@ namespace controller {
|
||||||
int recordDeviceOfType(const QString& deviceName);
|
int recordDeviceOfType(const QString& deviceName);
|
||||||
QHash<const QString&, int> _deviceCounts;
|
QHash<const QString&, int> _deviceCounts;
|
||||||
|
|
||||||
static float getValue(const EndpointPointer& endpoint);
|
static float getValue(const EndpointPointer& endpoint, bool peek = false);
|
||||||
static Pose getPose(const EndpointPointer& endpoint);
|
static Pose getPose(const EndpointPointer& endpoint, bool peek = false);
|
||||||
|
|
||||||
friend class RouteBuilderProxy;
|
friend class RouteBuilderProxy;
|
||||||
friend class MappingBuilderProxy;
|
friend class MappingBuilderProxy;
|
||||||
|
|
|
@ -6,9 +6,11 @@
|
||||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
//
|
//
|
||||||
|
|
||||||
#include "Endpoint.h"
|
// NOTE: we don't need to include this header unless/until we add additional symbols.
|
||||||
|
// By removing this header we prevent these warnings on windows:
|
||||||
namespace controller {
|
//
|
||||||
|
// warning LNK4221: This object file does not define any previously undefined public symbols,
|
||||||
}
|
// so it will not be used by any link operation that consumes this library
|
||||||
|
//
|
||||||
|
//#include "Endpoint.h"
|
||||||
|
|
||||||
|
|
|
@ -36,12 +36,13 @@ namespace controller {
|
||||||
using WriteLambda = std::function<void(float)>;
|
using WriteLambda = std::function<void(float)>;
|
||||||
|
|
||||||
Endpoint(const Input& input) : _input(input) {}
|
Endpoint(const Input& input) : _input(input) {}
|
||||||
virtual float value() = 0;
|
virtual float value() { return peek(); }
|
||||||
|
virtual float peek() const = 0;
|
||||||
virtual void apply(float value, const Pointer& source) = 0;
|
virtual void apply(float value, const Pointer& source) = 0;
|
||||||
virtual Pose pose() { return Pose(); }
|
virtual Pose peekPose() const { return Pose(); };
|
||||||
|
virtual Pose pose() { return peekPose(); }
|
||||||
virtual void apply(const Pose& value, const Pointer& source) {}
|
virtual void apply(const Pose& value, const Pointer& source) {}
|
||||||
virtual bool isPose() { return _input.isPose(); }
|
virtual bool isPose() const { return _input.isPose(); }
|
||||||
|
|
||||||
virtual bool writeable() const { return true; }
|
virtual bool writeable() const { return true; }
|
||||||
virtual bool readable() const { return true; }
|
virtual bool readable() const { return true; }
|
||||||
virtual void reset() { }
|
virtual void reset() { }
|
||||||
|
@ -58,7 +59,7 @@ namespace controller {
|
||||||
LambdaEndpoint(ReadLambda readLambda, WriteLambda writeLambda = [](float) {})
|
LambdaEndpoint(ReadLambda readLambda, WriteLambda writeLambda = [](float) {})
|
||||||
: Endpoint(Input::INVALID_INPUT), _readLambda(readLambda), _writeLambda(writeLambda) { }
|
: Endpoint(Input::INVALID_INPUT), _readLambda(readLambda), _writeLambda(writeLambda) { }
|
||||||
|
|
||||||
virtual float value() override { return _readLambda(); }
|
virtual float peek() const override { return _readLambda(); }
|
||||||
virtual void apply(float value, const Pointer& source) override { _writeLambda(value); }
|
virtual void apply(float value, const Pointer& source) override { _writeLambda(value); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -73,10 +74,10 @@ namespace controller {
|
||||||
: Endpoint(id) {
|
: Endpoint(id) {
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual float value() override { return _currentValue; }
|
virtual float peek() const override { return _currentValue; }
|
||||||
virtual void apply(float value, const Pointer& source) override { _currentValue = value; }
|
virtual void apply(float value, const Pointer& source) override { _currentValue = value; }
|
||||||
|
|
||||||
virtual Pose pose() override { return _currentPose; }
|
virtual Pose peekPose() const override { return _currentPose; }
|
||||||
virtual void apply(const Pose& value, const Pointer& source) override {
|
virtual void apply(const Pose& value, const Pointer& source) override {
|
||||||
_currentPose = value;
|
_currentPose = value;
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,4 +5,11 @@
|
||||||
// Distributed under the Apache License, Version 2.0.
|
// Distributed under the Apache License, Version 2.0.
|
||||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
//
|
//
|
||||||
#include "Mapping.h"
|
|
||||||
|
// NOTE: we don't need to include this header unless/until we add additional symbols.
|
||||||
|
// By removing this header we prevent these warnings on windows:
|
||||||
|
//
|
||||||
|
// warning LNK4221: This object file does not define any previously undefined public symbols,
|
||||||
|
// so it will not be used by any link operation that consumes this library
|
||||||
|
//
|
||||||
|
//#include "Mapping.h"
|
||||||
|
|
|
@ -6,4 +6,10 @@
|
||||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
//
|
//
|
||||||
|
|
||||||
#include "Route.h"
|
// NOTE: we don't need to include this header unless/until we add additional symbols.
|
||||||
|
// By removing this header we prevent these warnings on windows:
|
||||||
|
//
|
||||||
|
// warning LNK4221: This object file does not define any previously undefined public symbols,
|
||||||
|
// so it will not be used by any link operation that consumes this library
|
||||||
|
//
|
||||||
|
//#include "Route.h"
|
||||||
|
|
|
@ -26,6 +26,7 @@ namespace controller {
|
||||||
Filter::List filters;
|
Filter::List filters;
|
||||||
QString json;
|
QString json;
|
||||||
bool debug { false };
|
bool debug { false };
|
||||||
|
bool peek { false };
|
||||||
|
|
||||||
using Pointer = std::shared_ptr<Route>;
|
using Pointer = std::shared_ptr<Route>;
|
||||||
using List = std::list<Pointer>;
|
using List = std::list<Pointer>;
|
||||||
|
|
|
@ -52,6 +52,11 @@ QObject* RouteBuilderProxy::debug(bool enable) {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QObject* RouteBuilderProxy::peek(bool enable) {
|
||||||
|
_route->peek = enable;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
QObject* RouteBuilderProxy::when(const QScriptValue& expression) {
|
QObject* RouteBuilderProxy::when(const QScriptValue& expression) {
|
||||||
_route->conditional = _parent.conditionalFor(expression);
|
_route->conditional = _parent.conditionalFor(expression);
|
||||||
return this;
|
return this;
|
||||||
|
|
|
@ -38,6 +38,7 @@ class RouteBuilderProxy : public QObject {
|
||||||
|
|
||||||
Q_INVOKABLE void to(const QScriptValue& destination);
|
Q_INVOKABLE void to(const QScriptValue& destination);
|
||||||
Q_INVOKABLE QObject* debug(bool enable = true);
|
Q_INVOKABLE QObject* debug(bool enable = true);
|
||||||
|
Q_INVOKABLE QObject* peek(bool enable = true);
|
||||||
Q_INVOKABLE QObject* when(const QScriptValue& expression);
|
Q_INVOKABLE QObject* when(const QScriptValue& expression);
|
||||||
Q_INVOKABLE QObject* clamp(float min, float max);
|
Q_INVOKABLE QObject* clamp(float min, float max);
|
||||||
Q_INVOKABLE QObject* hysteresis(float min, float max);
|
Q_INVOKABLE QObject* hysteresis(float min, float max);
|
||||||
|
@ -48,7 +49,7 @@ class RouteBuilderProxy : public QObject {
|
||||||
Q_INVOKABLE QObject* constrainToInteger();
|
Q_INVOKABLE QObject* constrainToInteger();
|
||||||
Q_INVOKABLE QObject* constrainToPositiveInteger();
|
Q_INVOKABLE QObject* constrainToPositiveInteger();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void to(const Endpoint::Pointer& destination);
|
void to(const Endpoint::Pointer& destination);
|
||||||
void conditional(const Conditional::Pointer& conditional);
|
void conditional(const Conditional::Pointer& conditional);
|
||||||
void addFilter(Filter::Pointer filter);
|
void addFilter(Filter::Pointer filter);
|
||||||
|
|
|
@ -6,4 +6,10 @@
|
||||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
//
|
//
|
||||||
|
|
||||||
#include "EndpointConditional.h"
|
// NOTE: we don't need to include this header unless/until we add additional symbols.
|
||||||
|
// By removing this header we prevent these warnings on windows:
|
||||||
|
//
|
||||||
|
// warning LNK4221: This object file does not define any previously undefined public symbols,
|
||||||
|
// so it will not be used by any link operation that consumes this library
|
||||||
|
//
|
||||||
|
//#include "EndpointConditional.h"
|
|
@ -18,7 +18,7 @@ namespace controller {
|
||||||
class EndpointConditional : public Conditional {
|
class EndpointConditional : public Conditional {
|
||||||
public:
|
public:
|
||||||
EndpointConditional(Endpoint::Pointer endpoint) : _endpoint(endpoint) {}
|
EndpointConditional(Endpoint::Pointer endpoint) : _endpoint(endpoint) {}
|
||||||
virtual bool satisfied() override { return _endpoint && _endpoint->value() != 0.0f; }
|
virtual bool satisfied() override { return _endpoint && _endpoint->peek() != 0.0f; }
|
||||||
private:
|
private:
|
||||||
Endpoint::Pointer _endpoint;
|
Endpoint::Pointer _endpoint;
|
||||||
};
|
};
|
||||||
|
|
|
@ -6,4 +6,10 @@
|
||||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
//
|
//
|
||||||
|
|
||||||
#include "NotConditional.h"
|
// NOTE: we don't need to include this header unless/until we add additional symbols.
|
||||||
|
// By removing this header we prevent these warnings on windows:
|
||||||
|
//
|
||||||
|
// warning LNK4221: This object file does not define any previously undefined public symbols,
|
||||||
|
// so it will not be used by any link operation that consumes this library
|
||||||
|
//
|
||||||
|
//#include "NotConditional.h"
|
||||||
|
|
|
@ -23,10 +23,10 @@ class ActionEndpoint : public Endpoint {
|
||||||
public:
|
public:
|
||||||
ActionEndpoint(const Input& id = Input::INVALID_INPUT) : Endpoint(id) { }
|
ActionEndpoint(const Input& id = Input::INVALID_INPUT) : Endpoint(id) { }
|
||||||
|
|
||||||
virtual float value() override { return _currentValue; }
|
virtual float peek() const { return _currentValue; }
|
||||||
virtual void apply(float newValue, const Pointer& source) override;
|
virtual void apply(float newValue, const Pointer& source) override;
|
||||||
|
|
||||||
virtual Pose pose() override { return _currentPose; }
|
virtual Pose peekPose() const { return _currentPose; }
|
||||||
virtual void apply(const Pose& value, const Pointer& source) override;
|
virtual void apply(const Pose& value, const Pointer& source) override;
|
||||||
|
|
||||||
virtual void reset() override;
|
virtual void reset() override;
|
||||||
|
|
|
@ -27,13 +27,19 @@ AnyEndpoint::AnyEndpoint(Endpoint::List children) : Endpoint(Input::INVALID_INPU
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float AnyEndpoint::peek() const {
|
||||||
|
float result = 0;
|
||||||
|
for (auto& child : _children) {
|
||||||
|
result = std::max(result, child->peek());
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fetching the value must trigger any necessary side effects of value() on ALL the children.
|
||||||
float AnyEndpoint::value() {
|
float AnyEndpoint::value() {
|
||||||
float result = 0;
|
float result = 0;
|
||||||
for (auto& child : _children) {
|
for (auto& child : _children) {
|
||||||
float childResult = child->value();
|
result = std::max(result, child->value());
|
||||||
if (childResult != 0.0f) {
|
|
||||||
result = childResult;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,6 +19,7 @@ class AnyEndpoint : public Endpoint {
|
||||||
public:
|
public:
|
||||||
using Endpoint::apply;
|
using Endpoint::apply;
|
||||||
AnyEndpoint(Endpoint::List children);
|
AnyEndpoint(Endpoint::List children);
|
||||||
|
virtual float peek() const override;
|
||||||
virtual float value() override;
|
virtual float value() override;
|
||||||
virtual void apply(float newValue, const Endpoint::Pointer& source) override;
|
virtual void apply(float newValue, const Endpoint::Pointer& source) override;
|
||||||
virtual bool writeable() const override;
|
virtual bool writeable() const override;
|
||||||
|
|
|
@ -6,4 +6,10 @@
|
||||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
//
|
//
|
||||||
|
|
||||||
#include "ArrayEndpoint.h"
|
// NOTE: we don't need to include this header unless/until we add additional symbols.
|
||||||
|
// By removing this header we prevent these warnings on windows:
|
||||||
|
//
|
||||||
|
// warning LNK4221: This object file does not define any previously undefined public symbols,
|
||||||
|
// so it will not be used by any link operation that consumes this library
|
||||||
|
//
|
||||||
|
//#include "ArrayEndpoint.h"
|
|
@ -21,9 +21,7 @@ public:
|
||||||
using Pointer = std::shared_ptr<ArrayEndpoint>;
|
using Pointer = std::shared_ptr<ArrayEndpoint>;
|
||||||
ArrayEndpoint() : Endpoint(Input::INVALID_INPUT) { }
|
ArrayEndpoint() : Endpoint(Input::INVALID_INPUT) { }
|
||||||
|
|
||||||
virtual float value() override {
|
virtual float peek() const override { return 0.0f; }
|
||||||
return 0.0;
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual void apply(float value, const Endpoint::Pointer& source) override {
|
virtual void apply(float value, const Endpoint::Pointer& source) override {
|
||||||
for (auto& child : _children) {
|
for (auto& child : _children) {
|
||||||
|
|
|
@ -24,6 +24,12 @@ bool CompositeEndpoint::readable() const {
|
||||||
return first->readable() && second->readable();
|
return first->readable() && second->readable();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float CompositeEndpoint::peek() const {
|
||||||
|
float result = first->peek() * -1.0f + second->peek();
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fetching via value() must trigger any side effects of value() on the children
|
||||||
float CompositeEndpoint::value() {
|
float CompositeEndpoint::value() {
|
||||||
float result = first->value() * -1.0f + second->value();
|
float result = first->value() * -1.0f + second->value();
|
||||||
return result;
|
return result;
|
||||||
|
|
|
@ -18,6 +18,7 @@ namespace controller {
|
||||||
using Endpoint::apply;
|
using Endpoint::apply;
|
||||||
CompositeEndpoint(Endpoint::Pointer first, Endpoint::Pointer second);
|
CompositeEndpoint(Endpoint::Pointer first, Endpoint::Pointer second);
|
||||||
|
|
||||||
|
virtual float peek() const override;
|
||||||
virtual float value() override;
|
virtual float value() override;
|
||||||
virtual void apply(float newValue, const Pointer& source) override;
|
virtual void apply(float newValue, const Pointer& source) override;
|
||||||
virtual bool readable() const override;
|
virtual bool readable() const override;
|
||||||
|
|
|
@ -13,10 +13,10 @@
|
||||||
#include "../../UserInputMapper.h"
|
#include "../../UserInputMapper.h"
|
||||||
|
|
||||||
using namespace controller;
|
using namespace controller;
|
||||||
float InputEndpoint::value(){
|
|
||||||
_read = true;
|
float InputEndpoint::peek() const {
|
||||||
if (isPose()) {
|
if (isPose()) {
|
||||||
return pose().valid ? 1.0f : 0.0f;
|
return peekPose().valid ? 1.0f : 0.0f;
|
||||||
}
|
}
|
||||||
auto userInputMapper = DependencyManager::get<UserInputMapper>();
|
auto userInputMapper = DependencyManager::get<UserInputMapper>();
|
||||||
auto deviceProxy = userInputMapper->getDevice(_input);
|
auto deviceProxy = userInputMapper->getDevice(_input);
|
||||||
|
@ -26,8 +26,12 @@ float InputEndpoint::value(){
|
||||||
return deviceProxy->getValue(_input);
|
return deviceProxy->getValue(_input);
|
||||||
}
|
}
|
||||||
|
|
||||||
Pose InputEndpoint::pose() {
|
float InputEndpoint::value(){
|
||||||
_read = true;
|
_read = true;
|
||||||
|
return peek();
|
||||||
|
}
|
||||||
|
|
||||||
|
Pose InputEndpoint::peekPose() const {
|
||||||
if (!isPose()) {
|
if (!isPose()) {
|
||||||
return Pose();
|
return Pose();
|
||||||
}
|
}
|
||||||
|
@ -39,3 +43,8 @@ Pose InputEndpoint::pose() {
|
||||||
return deviceProxy->getPose(_input.channel);
|
return deviceProxy->getPose(_input.channel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Pose InputEndpoint::pose() {
|
||||||
|
_read = true;
|
||||||
|
return peekPose();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,9 +20,11 @@ public:
|
||||||
: Endpoint(id) {
|
: Endpoint(id) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
virtual float peek() const override;
|
||||||
virtual float value() override;
|
virtual float value() override;
|
||||||
// FIXME need support for writing back to vibration / force feedback effects
|
// FIXME need support for writing back to vibration / force feedback effects
|
||||||
virtual void apply(float newValue, const Pointer& source) override {}
|
virtual void apply(float newValue, const Pointer& source) override {}
|
||||||
|
virtual Pose peekPose() const override;
|
||||||
virtual Pose pose() override;
|
virtual Pose pose() override;
|
||||||
virtual void apply(const Pose& value, const Pointer& source) override { }
|
virtual void apply(const Pose& value, const Pointer& source) override { }
|
||||||
|
|
||||||
|
|
|
@ -6,4 +6,10 @@
|
||||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
//
|
//
|
||||||
|
|
||||||
#include "JSEndpoint.h"
|
// NOTE: we don't need to include this header unless/until we add additional symbols.
|
||||||
|
// By removing this header we prevent these warnings on windows:
|
||||||
|
//
|
||||||
|
// warning LNK4221: This object file does not define any previously undefined public symbols,
|
||||||
|
// so it will not be used by any link operation that consumes this library
|
||||||
|
//
|
||||||
|
//#include "JSEndpoint.h"
|
|
@ -24,9 +24,8 @@ public:
|
||||||
: Endpoint(Input::INVALID_INPUT), _callable(callable) {
|
: Endpoint(Input::INVALID_INPUT), _callable(callable) {
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual float value() {
|
virtual float peek() const {
|
||||||
float result = (float)_callable.call().toNumber();
|
return (float)const_cast<JSEndpoint*>(this)->_callable.call().toNumber();
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void apply(float newValue, const Pointer& source) {
|
virtual void apply(float newValue, const Pointer& source) {
|
||||||
|
|
|
@ -12,8 +12,8 @@
|
||||||
|
|
||||||
using namespace controller;
|
using namespace controller;
|
||||||
|
|
||||||
float ScriptEndpoint::value() {
|
float ScriptEndpoint::peek() const {
|
||||||
updateValue();
|
const_cast<ScriptEndpoint*>(this)->updateValue();
|
||||||
return _lastValueRead;
|
return _lastValueRead;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,8 +24,8 @@ public:
|
||||||
: Endpoint(Input::INVALID_INPUT), _callable(callable) {
|
: Endpoint(Input::INVALID_INPUT), _callable(callable) {
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual float value();
|
virtual float peek() const override;
|
||||||
virtual void apply(float newValue, const Pointer& source);
|
virtual void apply(float newValue, const Pointer& source) override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Q_INVOKABLE void updateValue();
|
Q_INVOKABLE void updateValue();
|
||||||
|
|
|
@ -6,4 +6,10 @@
|
||||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
//
|
//
|
||||||
|
|
||||||
#include "StandardEndpoint.h"
|
// NOTE: we don't need to include this header unless/until we add additional symbols.
|
||||||
|
// By removing this header we prevent these warnings on windows:
|
||||||
|
//
|
||||||
|
// warning LNK4221: This object file does not define any previously undefined public symbols,
|
||||||
|
// so it will not be used by any link operation that consumes this library
|
||||||
|
//
|
||||||
|
//#include "StandardEndpoint.h"
|
|
@ -6,4 +6,10 @@
|
||||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
//
|
//
|
||||||
|
|
||||||
#include "ConstrainToIntegerFilter.h"
|
// NOTE: we don't need to include this header unless/until we add additional symbols.
|
||||||
|
// By removing this header we prevent these warnings on windows:
|
||||||
|
//
|
||||||
|
// warning LNK4221: This object file does not define any previously undefined public symbols,
|
||||||
|
// so it will not be used by any link operation that consumes this library
|
||||||
|
//
|
||||||
|
//#include "ConstrainToIntegerFilter.h"
|
||||||
|
|
|
@ -6,4 +6,10 @@
|
||||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
//
|
//
|
||||||
|
|
||||||
#include "ConstrainToPositiveIntegerFilter.h"
|
// NOTE: we don't need to include this header unless/until we add additional symbols.
|
||||||
|
// By removing this header we prevent these warnings on windows:
|
||||||
|
//
|
||||||
|
// warning LNK4221: This object file does not define any previously undefined public symbols,
|
||||||
|
// so it will not be used by any link operation that consumes this library
|
||||||
|
//
|
||||||
|
//#include "ConstrainToPositiveIntegerFilter.h"
|
||||||
|
|
|
@ -6,4 +6,10 @@
|
||||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
//
|
//
|
||||||
|
|
||||||
#include "InvertFilter.h"
|
// NOTE: we don't need to include this header unless/until we add additional symbols.
|
||||||
|
// By removing this header we prevent these warnings on windows:
|
||||||
|
//
|
||||||
|
// warning LNK4221: This object file does not define any previously undefined public symbols,
|
||||||
|
// so it will not be used by any link operation that consumes this library
|
||||||
|
//
|
||||||
|
//#include "InvertFilter.h"
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
set(TARGET_NAME display-plugins)
|
set(TARGET_NAME display-plugins)
|
||||||
setup_hifi_library(OpenGL)
|
setup_hifi_library(OpenGL)
|
||||||
link_hifi_libraries(shared plugins gpu gl)
|
link_hifi_libraries(shared plugins gl)
|
||||||
|
|
||||||
target_opengl()
|
target_opengl()
|
||||||
|
|
||||||
|
@ -8,11 +8,6 @@ GroupSources("src/display-plugins")
|
||||||
|
|
||||||
target_oglplus()
|
target_oglplus()
|
||||||
|
|
||||||
add_dependency_external_projects(LibOVR)
|
|
||||||
find_package(LibOVR REQUIRED)
|
|
||||||
target_include_directories(${TARGET_NAME} PRIVATE ${LIBOVR_INCLUDE_DIRS})
|
|
||||||
target_link_libraries(${TARGET_NAME} ${LIBOVR_LIBRARIES})
|
|
||||||
|
|
||||||
if (WIN32)
|
if (WIN32)
|
||||||
add_dependency_external_projects(OpenVR)
|
add_dependency_external_projects(OpenVR)
|
||||||
find_package(OpenVR REQUIRED)
|
find_package(OpenVR REQUIRED)
|
||||||
|
|
|
@ -12,7 +12,6 @@
|
||||||
|
|
||||||
#include "DisplayPlugin.h"
|
#include "DisplayPlugin.h"
|
||||||
#include <plugins/PluginContainer.h>
|
#include <plugins/PluginContainer.h>
|
||||||
#include <OVR_CAPI_Keys.h>
|
|
||||||
|
|
||||||
static Setting::Handle<float> IPD_SCALE_HANDLE("hmd.ipdScale", 1.0f);
|
static Setting::Handle<float> IPD_SCALE_HANDLE("hmd.ipdScale", 1.0f);
|
||||||
|
|
||||||
|
@ -26,12 +25,12 @@ float AbstractHMDScriptingInterface::getIPD() const {
|
||||||
|
|
||||||
float AbstractHMDScriptingInterface::getEyeHeight() const {
|
float AbstractHMDScriptingInterface::getEyeHeight() const {
|
||||||
// FIXME update the display plugin interface to expose per-plugin settings
|
// FIXME update the display plugin interface to expose per-plugin settings
|
||||||
return OVR_DEFAULT_EYE_HEIGHT;
|
return getPlayerHeight() - 0.10f;
|
||||||
}
|
}
|
||||||
|
|
||||||
float AbstractHMDScriptingInterface::getPlayerHeight() const {
|
float AbstractHMDScriptingInterface::getPlayerHeight() const {
|
||||||
// FIXME update the display plugin interface to expose per-plugin settings
|
// FIXME update the display plugin interface to expose per-plugin settings
|
||||||
return OVR_DEFAULT_PLAYER_HEIGHT;
|
return 1.755f;
|
||||||
}
|
}
|
||||||
|
|
||||||
float AbstractHMDScriptingInterface::getIPDScale() const {
|
float AbstractHMDScriptingInterface::getIPDScale() const {
|
||||||
|
|
|
@ -35,36 +35,36 @@ QAction* _vsyncAction{ nullptr };
|
||||||
|
|
||||||
void Basic2DWindowOpenGLDisplayPlugin::activate() {
|
void Basic2DWindowOpenGLDisplayPlugin::activate() {
|
||||||
_framerateActions.clear();
|
_framerateActions.clear();
|
||||||
CONTAINER->addMenuItem(MENU_PATH(), FULLSCREEN,
|
_container->addMenuItem(MENU_PATH(), FULLSCREEN,
|
||||||
[this](bool clicked) {
|
[this](bool clicked) {
|
||||||
if (clicked) {
|
if (clicked) {
|
||||||
CONTAINER->setFullscreen(getFullscreenTarget());
|
_container->setFullscreen(getFullscreenTarget());
|
||||||
} else {
|
} else {
|
||||||
CONTAINER->unsetFullscreen();
|
_container->unsetFullscreen();
|
||||||
}
|
}
|
||||||
}, true, false);
|
}, true, false);
|
||||||
CONTAINER->addMenu(FRAMERATE);
|
_container->addMenu(FRAMERATE);
|
||||||
_framerateActions.push_back(
|
_framerateActions.push_back(
|
||||||
CONTAINER->addMenuItem(FRAMERATE, FRAMERATE_UNLIMITED,
|
_container->addMenuItem(FRAMERATE, FRAMERATE_UNLIMITED,
|
||||||
[this](bool) { updateFramerate(); }, true, true, FRAMERATE));
|
[this](bool) { updateFramerate(); }, true, true, FRAMERATE));
|
||||||
_framerateActions.push_back(
|
_framerateActions.push_back(
|
||||||
CONTAINER->addMenuItem(FRAMERATE, FRAMERATE_60,
|
_container->addMenuItem(FRAMERATE, FRAMERATE_60,
|
||||||
[this](bool) { updateFramerate(); }, true, false, FRAMERATE));
|
[this](bool) { updateFramerate(); }, true, false, FRAMERATE));
|
||||||
_framerateActions.push_back(
|
_framerateActions.push_back(
|
||||||
CONTAINER->addMenuItem(FRAMERATE, FRAMERATE_50,
|
_container->addMenuItem(FRAMERATE, FRAMERATE_50,
|
||||||
[this](bool) { updateFramerate(); }, true, false, FRAMERATE));
|
[this](bool) { updateFramerate(); }, true, false, FRAMERATE));
|
||||||
_framerateActions.push_back(
|
_framerateActions.push_back(
|
||||||
CONTAINER->addMenuItem(FRAMERATE, FRAMERATE_40,
|
_container->addMenuItem(FRAMERATE, FRAMERATE_40,
|
||||||
[this](bool) { updateFramerate(); }, true, false, FRAMERATE));
|
[this](bool) { updateFramerate(); }, true, false, FRAMERATE));
|
||||||
_framerateActions.push_back(
|
_framerateActions.push_back(
|
||||||
CONTAINER->addMenuItem(FRAMERATE, FRAMERATE_30,
|
_container->addMenuItem(FRAMERATE, FRAMERATE_30,
|
||||||
[this](bool) { updateFramerate(); }, true, false, FRAMERATE));
|
[this](bool) { updateFramerate(); }, true, false, FRAMERATE));
|
||||||
|
|
||||||
WindowOpenGLDisplayPlugin::activate();
|
WindowOpenGLDisplayPlugin::activate();
|
||||||
|
|
||||||
// Vsync detection happens in the parent class activate, so we need to check after that
|
// Vsync detection happens in the parent class activate, so we need to check after that
|
||||||
if (_vsyncSupported) {
|
if (_vsyncSupported) {
|
||||||
_vsyncAction = CONTAINER->addMenuItem(MENU_PATH(), VSYNC_ON, [this](bool) {}, true, true);
|
_vsyncAction = _container->addMenuItem(MENU_PATH(), VSYNC_ON, [this](bool) {}, true, true);
|
||||||
} else {
|
} else {
|
||||||
_vsyncAction = nullptr;
|
_vsyncAction = nullptr;
|
||||||
}
|
}
|
||||||
|
@ -107,7 +107,7 @@ int Basic2DWindowOpenGLDisplayPlugin::getDesiredInterval() const {
|
||||||
bool Basic2DWindowOpenGLDisplayPlugin::isThrottled() const {
|
bool Basic2DWindowOpenGLDisplayPlugin::isThrottled() const {
|
||||||
static const QString ThrottleFPSIfNotFocus = "Throttle FPS If Not Focus"; // FIXME - this value duplicated in Menu.h
|
static const QString ThrottleFPSIfNotFocus = "Throttle FPS If Not Focus"; // FIXME - this value duplicated in Menu.h
|
||||||
|
|
||||||
bool shouldThrottle = (!CONTAINER->isForeground() && CONTAINER->isOptionChecked(ThrottleFPSIfNotFocus));
|
bool shouldThrottle = (!_container->isForeground() && _container->isOptionChecked(ThrottleFPSIfNotFocus));
|
||||||
|
|
||||||
if (_isThrottled != shouldThrottle) {
|
if (_isThrottled != shouldThrottle) {
|
||||||
_isThrottled = shouldThrottle;
|
_isThrottled = shouldThrottle;
|
||||||
|
|
|
@ -15,9 +15,6 @@
|
||||||
#include "Basic2DWindowOpenGLDisplayPlugin.h"
|
#include "Basic2DWindowOpenGLDisplayPlugin.h"
|
||||||
|
|
||||||
#include "openvr/OpenVrDisplayPlugin.h"
|
#include "openvr/OpenVrDisplayPlugin.h"
|
||||||
#include "oculus/OculusDisplayPlugin.h"
|
|
||||||
#include "oculus/OculusDebugDisplayPlugin.h"
|
|
||||||
#include "oculus/OculusLegacyDisplayPlugin.h"
|
|
||||||
|
|
||||||
const QString& DisplayPlugin::MENU_PATH() {
|
const QString& DisplayPlugin::MENU_PATH() {
|
||||||
static const QString value = "Display";
|
static const QString value = "Display";
|
||||||
|
@ -40,15 +37,6 @@ DisplayPluginList getDisplayPlugins() {
|
||||||
new InterleavedStereoDisplayPlugin(),
|
new InterleavedStereoDisplayPlugin(),
|
||||||
|
|
||||||
// HMDs
|
// HMDs
|
||||||
|
|
||||||
// Windows Oculus SDK
|
|
||||||
new OculusDisplayPlugin(),
|
|
||||||
// Windows Oculus Simulator... uses head tracking and the same rendering
|
|
||||||
// as the connected hardware, but without using the SDK to display to the
|
|
||||||
// Rift. Useful for debugging Rift performance with nSight.
|
|
||||||
new OculusDebugDisplayPlugin(),
|
|
||||||
// Mac/Linux Oculus SDK (0.5)
|
|
||||||
new OculusLegacyDisplayPlugin(),
|
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
// SteamVR SDK
|
// SteamVR SDK
|
||||||
new OpenVrDisplayPlugin(),
|
new OpenVrDisplayPlugin(),
|
||||||
|
|
|
@ -5,135 +5,6 @@
|
||||||
// Distributed under the Apache License, Version 2.0.
|
// Distributed under the Apache License, Version 2.0.
|
||||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
//
|
//
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include "plugins/Plugin.h"
|
#include <plugins/DisplayPlugin.h>
|
||||||
#include <QSize>
|
|
||||||
#include <QPoint>
|
|
||||||
#include <functional>
|
|
||||||
|
|
||||||
#include <gl/Config.h>
|
|
||||||
#include <GLMHelpers.h>
|
|
||||||
|
|
||||||
#include <glm/glm.hpp>
|
|
||||||
#include <glm/gtc/quaternion.hpp>
|
|
||||||
#include <RegisteredMetaTypes.h>
|
|
||||||
|
|
||||||
enum Eye {
|
|
||||||
Left,
|
|
||||||
Right,
|
|
||||||
Mono
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Helper method to iterate over each eye
|
|
||||||
*/
|
|
||||||
template <typename F>
|
|
||||||
void for_each_eye(F f) {
|
|
||||||
f(Left);
|
|
||||||
f(Right);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Helper method to iterate over each eye, with an additional lambda to take action between the eyes
|
|
||||||
*/
|
|
||||||
template <typename F, typename FF>
|
|
||||||
void for_each_eye(F f, FF ff) {
|
|
||||||
f(Eye::Left);
|
|
||||||
ff();
|
|
||||||
f(Eye::Right);
|
|
||||||
}
|
|
||||||
|
|
||||||
class QWindow;
|
|
||||||
|
|
||||||
#define AVERAGE_HUMAN_IPD 0.064f
|
|
||||||
|
|
||||||
class DisplayPlugin : public Plugin {
|
|
||||||
Q_OBJECT
|
|
||||||
public:
|
|
||||||
virtual bool isHmd() const { return false; }
|
|
||||||
virtual int getHmdScreen() const { return -1; }
|
|
||||||
/// By default, all HMDs are stereo
|
|
||||||
virtual bool isStereo() const { return isHmd(); }
|
|
||||||
virtual bool isThrottled() const { return false; }
|
|
||||||
|
|
||||||
// Rendering support
|
|
||||||
|
|
||||||
// Stop requesting renders, but don't do full deactivation
|
|
||||||
// needed to work around the issues caused by Oculus
|
|
||||||
// processing messages in the middle of submitFrame
|
|
||||||
virtual void stop() = 0;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Called by the application before the frame rendering. Can be used for
|
|
||||||
* render timing related calls (for instance, the Oculus begin frame timing
|
|
||||||
* call)
|
|
||||||
*/
|
|
||||||
virtual void preRender() = 0;
|
|
||||||
/**
|
|
||||||
* Called by the application immediately before calling the display function.
|
|
||||||
* For OpenGL based plugins, this is the best place to put activate the output
|
|
||||||
* OpenGL context
|
|
||||||
*/
|
|
||||||
virtual void preDisplay() = 0;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sends the scene texture to the display plugin.
|
|
||||||
*/
|
|
||||||
virtual void display(GLuint sceneTexture, const glm::uvec2& sceneSize) = 0;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Called by the application immeidately after display. For OpenGL based
|
|
||||||
* displays, this is the best place to put the buffer swap
|
|
||||||
*/
|
|
||||||
virtual void finishFrame() = 0;
|
|
||||||
|
|
||||||
// Does the rendering surface have current focus?
|
|
||||||
virtual bool hasFocus() const = 0;
|
|
||||||
|
|
||||||
// The size of the rendering target (may be larger than the device size due to distortion)
|
|
||||||
virtual glm::uvec2 getRecommendedRenderSize() const = 0;
|
|
||||||
|
|
||||||
// The size of the UI
|
|
||||||
virtual glm::uvec2 getRecommendedUiSize() const {
|
|
||||||
return getRecommendedRenderSize();
|
|
||||||
}
|
|
||||||
|
|
||||||
// By default the aspect ratio is just the render size
|
|
||||||
virtual float getRecommendedAspectRatio() const {
|
|
||||||
return aspect(getRecommendedRenderSize());
|
|
||||||
}
|
|
||||||
|
|
||||||
// Stereo specific methods
|
|
||||||
virtual glm::mat4 getProjection(Eye eye, const glm::mat4& baseProjection) const {
|
|
||||||
return baseProjection;
|
|
||||||
}
|
|
||||||
|
|
||||||
// HMD specific methods
|
|
||||||
// TODO move these into another class?
|
|
||||||
virtual glm::mat4 getEyeToHeadTransform(Eye eye) const {
|
|
||||||
static const glm::mat4 transform; return transform;
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual glm::mat4 getHeadPose() const {
|
|
||||||
static const glm::mat4 pose; return pose;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Needed for timewarp style features
|
|
||||||
virtual void setEyeRenderPose(Eye eye, const glm::mat4& pose) {
|
|
||||||
// NOOP
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual float getIPD() const { return AVERAGE_HUMAN_IPD; }
|
|
||||||
|
|
||||||
virtual void abandonCalibration() {}
|
|
||||||
virtual void resetSensors() {}
|
|
||||||
virtual float devicePixelRatio() { return 1.0; }
|
|
||||||
|
|
||||||
|
|
||||||
static const QString& MENU_PATH();
|
|
||||||
signals:
|
|
||||||
void recommendedFramebufferSizeChanged(const QSize & size);
|
|
||||||
void requestRender();
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
|
@ -25,6 +25,6 @@ bool NullDisplayPlugin::hasFocus() const {
|
||||||
|
|
||||||
void NullDisplayPlugin::preRender() {}
|
void NullDisplayPlugin::preRender() {}
|
||||||
void NullDisplayPlugin::preDisplay() {}
|
void NullDisplayPlugin::preDisplay() {}
|
||||||
void NullDisplayPlugin::display(GLuint sceneTexture, const glm::uvec2& sceneSize) {}
|
void NullDisplayPlugin::display(uint32_t sceneTexture, const glm::uvec2& sceneSize) {}
|
||||||
void NullDisplayPlugin::finishFrame() {}
|
void NullDisplayPlugin::finishFrame() {}
|
||||||
void NullDisplayPlugin::stop() {}
|
void NullDisplayPlugin::stop() {}
|
||||||
|
|
|
@ -21,7 +21,7 @@ public:
|
||||||
virtual bool hasFocus() const override;
|
virtual bool hasFocus() const override;
|
||||||
virtual void preRender() override;
|
virtual void preRender() override;
|
||||||
virtual void preDisplay() override;
|
virtual void preDisplay() override;
|
||||||
virtual void display(GLuint sceneTexture, const glm::uvec2& sceneSize) override;
|
virtual void display(uint32_t sceneTexture, const glm::uvec2& sceneSize) override;
|
||||||
virtual void finishFrame() override;
|
virtual void finishFrame() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
#include <QOpenGLContext>
|
#include <QOpenGLContext>
|
||||||
#include <QCoreApplication>
|
#include <QCoreApplication>
|
||||||
|
|
||||||
|
#include <gl/Config.h>
|
||||||
#include <gl/GlWindow.h>
|
#include <gl/GlWindow.h>
|
||||||
#include <GLMHelpers.h>
|
#include <GLMHelpers.h>
|
||||||
|
|
||||||
|
|
|
@ -42,7 +42,7 @@ bool WindowOpenGLDisplayPlugin::hasFocus() const {
|
||||||
|
|
||||||
void WindowOpenGLDisplayPlugin::activate() {
|
void WindowOpenGLDisplayPlugin::activate() {
|
||||||
OpenGLDisplayPlugin::activate();
|
OpenGLDisplayPlugin::activate();
|
||||||
_window = CONTAINER->getPrimarySurface();
|
_window = _container->getPrimarySurface();
|
||||||
_window->makeCurrent();
|
_window->makeCurrent();
|
||||||
customizeContext();
|
customizeContext();
|
||||||
_window->doneCurrent();
|
_window->doneCurrent();
|
||||||
|
|
|
@ -89,7 +89,7 @@ bool OpenVrDisplayPlugin::isSupported() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
void OpenVrDisplayPlugin::activate() {
|
void OpenVrDisplayPlugin::activate() {
|
||||||
CONTAINER->setIsOptionChecked(StandingHMDSensorMode, true);
|
_container->setIsOptionChecked(StandingHMDSensorMode, true);
|
||||||
|
|
||||||
hmdRefCount++;
|
hmdRefCount++;
|
||||||
vr::HmdError eError = vr::HmdError_None;
|
vr::HmdError eError = vr::HmdError_None;
|
||||||
|
@ -132,7 +132,7 @@ void OpenVrDisplayPlugin::activate() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void OpenVrDisplayPlugin::deactivate() {
|
void OpenVrDisplayPlugin::deactivate() {
|
||||||
CONTAINER->setIsOptionChecked(StandingHMDSensorMode, false);
|
_container->setIsOptionChecked(StandingHMDSensorMode, false);
|
||||||
|
|
||||||
hmdRefCount--;
|
hmdRefCount--;
|
||||||
|
|
||||||
|
|
|
@ -74,21 +74,21 @@ void StereoDisplayPlugin::activate() {
|
||||||
if (screen == qApp->primaryScreen()) {
|
if (screen == qApp->primaryScreen()) {
|
||||||
checked = true;
|
checked = true;
|
||||||
}
|
}
|
||||||
auto action = CONTAINER->addMenuItem(MENU_PATH(), name,
|
auto action = _container->addMenuItem(MENU_PATH(), name,
|
||||||
[this](bool clicked) { updateScreen(); }, true, checked, "Screens");
|
[this](bool clicked) { updateScreen(); }, true, checked, "Screens");
|
||||||
_screenActions[i] = action;
|
_screenActions[i] = action;
|
||||||
}
|
}
|
||||||
|
|
||||||
CONTAINER->removeMenu(FRAMERATE);
|
_container->removeMenu(FRAMERATE);
|
||||||
|
|
||||||
CONTAINER->setFullscreen(qApp->primaryScreen());
|
_container->setFullscreen(qApp->primaryScreen());
|
||||||
WindowOpenGLDisplayPlugin::activate();
|
WindowOpenGLDisplayPlugin::activate();
|
||||||
}
|
}
|
||||||
|
|
||||||
void StereoDisplayPlugin::updateScreen() {
|
void StereoDisplayPlugin::updateScreen() {
|
||||||
for (uint32_t i = 0; i < _screenActions.size(); ++i) {
|
for (uint32_t i = 0; i < _screenActions.size(); ++i) {
|
||||||
if (_screenActions[i]->isChecked()) {
|
if (_screenActions[i]->isChecked()) {
|
||||||
CONTAINER->setFullscreen(qApp->screens().at(i));
|
_container->setFullscreen(qApp->screens().at(i));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -96,7 +96,7 @@ void StereoDisplayPlugin::updateScreen() {
|
||||||
|
|
||||||
void StereoDisplayPlugin::deactivate() {
|
void StereoDisplayPlugin::deactivate() {
|
||||||
_screenActions.clear();
|
_screenActions.clear();
|
||||||
CONTAINER->unsetFullscreen();
|
_container->unsetFullscreen();
|
||||||
WindowOpenGLDisplayPlugin::deactivate();
|
WindowOpenGLDisplayPlugin::deactivate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,14 +10,4 @@
|
||||||
//
|
//
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <plugins/Plugin.h>
|
#include <plugins/InputPlugin.h>
|
||||||
|
|
||||||
class InputPlugin : public Plugin {
|
|
||||||
public:
|
|
||||||
virtual bool isJointController() const = 0;
|
|
||||||
|
|
||||||
virtual void pluginFocusOutEvent() = 0;
|
|
||||||
|
|
||||||
virtual void pluginUpdate(float deltaTime, bool jointsCaptured) = 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
|
@ -209,72 +209,3 @@ QString KeyboardMouseDevice::getDefaultMappingConfig() const {
|
||||||
return MAPPING_JSON;
|
return MAPPING_JSON;
|
||||||
}
|
}
|
||||||
|
|
||||||
//void KeyboardMouseDevice::assignDefaultInputMapping(UserInputMapper& mapper) {
|
|
||||||
// const float BUTTON_MOVE_SPEED = 1.0f;
|
|
||||||
// const float BUTTON_YAW_SPEED = 0.75f;
|
|
||||||
// const float BUTTON_PITCH_SPEED = 0.5f;
|
|
||||||
// const float MOUSE_YAW_SPEED = 0.5f;
|
|
||||||
// const float MOUSE_PITCH_SPEED = 0.25f;
|
|
||||||
// const float TOUCH_YAW_SPEED = 0.5f;
|
|
||||||
// const float TOUCH_PITCH_SPEED = 0.25f;
|
|
||||||
// const float BUTTON_BOOM_SPEED = 0.1f;
|
|
||||||
//
|
|
||||||
// // AWSD keys mapping
|
|
||||||
//
|
|
||||||
// mapper.addInputChannel(controller::BOOM_IN, makeInput(Qt::Key_E), makeInput(Qt::Key_Shift), BUTTON_BOOM_SPEED);
|
|
||||||
// mapper.addInputChannel(controller::BOOM_OUT, makeInput(Qt::Key_C), makeInput(Qt::Key_Shift), BUTTON_BOOM_SPEED);
|
|
||||||
// mapper.addInputChannel(controller::LATERAL_LEFT, makeInput(Qt::Key_A), makeInput(Qt::RightButton), BUTTON_YAW_SPEED);
|
|
||||||
// mapper.addInputChannel(controller::LATERAL_RIGHT, makeInput(Qt::Key_D), makeInput(Qt::RightButton), BUTTON_YAW_SPEED);
|
|
||||||
// mapper.addInputChannel(controller::LATERAL_LEFT, makeInput(Qt::Key_A), makeInput(Qt::Key_Shift), BUTTON_YAW_SPEED);
|
|
||||||
// mapper.addInputChannel(controller::LATERAL_RIGHT, makeInput(Qt::Key_D), makeInput(Qt::Key_Shift), BUTTON_YAW_SPEED);
|
|
||||||
// mapper.addInputChannel(controller::PITCH_DOWN, makeInput(Qt::Key_S), makeInput(Qt::Key_Shift), BUTTON_PITCH_SPEED);
|
|
||||||
// mapper.addInputChannel(controller::PITCH_UP, makeInput(Qt::Key_W), makeInput(Qt::Key_Shift), BUTTON_PITCH_SPEED);
|
|
||||||
//
|
|
||||||
// // Arrow keys mapping
|
|
||||||
// mapper.addInputChannel(controller::LONGITUDINAL_BACKWARD, makeInput(Qt::Key_Down), BUTTON_MOVE_SPEED);
|
|
||||||
// mapper.addInputChannel(controller::LONGITUDINAL_FORWARD, makeInput(Qt::Key_Up), BUTTON_MOVE_SPEED);
|
|
||||||
// mapper.addInputChannel(controller::YAW_LEFT, makeInput(Qt::Key_Left), BUTTON_MOVE_SPEED);
|
|
||||||
// mapper.addInputChannel(controller::YAW_RIGHT, makeInput(Qt::Key_Right), BUTTON_MOVE_SPEED);
|
|
||||||
// mapper.addInputChannel(controller::VERTICAL_DOWN, makeInput(Qt::Key_PageDown), BUTTON_MOVE_SPEED);
|
|
||||||
// mapper.addInputChannel(controller::VERTICAL_UP, makeInput(Qt::Key_PageUp), BUTTON_MOVE_SPEED);
|
|
||||||
//
|
|
||||||
// mapper.addInputChannel(controller::LATERAL_LEFT, makeInput(Qt::Key_Left), makeInput(Qt::RightButton), BUTTON_YAW_SPEED);
|
|
||||||
// mapper.addInputChannel(controller::LATERAL_RIGHT, makeInput(Qt::Key_Right), makeInput(Qt::RightButton), BUTTON_YAW_SPEED);
|
|
||||||
// mapper.addInputChannel(controller::LATERAL_LEFT, makeInput(Qt::Key_Left), makeInput(Qt::Key_Shift), BUTTON_YAW_SPEED);
|
|
||||||
// mapper.addInputChannel(controller::LATERAL_RIGHT, makeInput(Qt::Key_Right), makeInput(Qt::Key_Shift), BUTTON_YAW_SPEED);
|
|
||||||
// mapper.addInputChannel(controller::PITCH_DOWN, makeInput(Qt::Key_Down), makeInput(Qt::Key_Shift), BUTTON_PITCH_SPEED);
|
|
||||||
// mapper.addInputChannel(controller::PITCH_UP, makeInput(Qt::Key_Up), makeInput(Qt::Key_Shift), BUTTON_PITCH_SPEED);
|
|
||||||
//
|
|
||||||
// // Mouse move
|
|
||||||
// mapper.addInputChannel(controller::PITCH_DOWN, makeInput(MOUSE_AXIS_Y_NEG), makeInput(Qt::RightButton), MOUSE_PITCH_SPEED);
|
|
||||||
// mapper.addInputChannel(controller::PITCH_UP, makeInput(MOUSE_AXIS_Y_POS), makeInput(Qt::RightButton), MOUSE_PITCH_SPEED);
|
|
||||||
// mapper.addInputChannel(controller::YAW_LEFT, makeInput(MOUSE_AXIS_X_NEG), makeInput(Qt::RightButton), MOUSE_YAW_SPEED);
|
|
||||||
// mapper.addInputChannel(controller::YAW_RIGHT, makeInput(MOUSE_AXIS_X_POS), makeInput(Qt::RightButton), MOUSE_YAW_SPEED);
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//#ifdef Q_OS_MAC
|
|
||||||
// // wheel event modifier on Mac collide with the touchpad scroll event
|
|
||||||
// mapper.addInputChannel(controller::PITCH_DOWN, makeInput(TOUCH_AXIS_Y_NEG), TOUCH_PITCH_SPEED);
|
|
||||||
// mapper.addInputChannel(controller::PITCH_UP, makeInput(TOUCH_AXIS_Y_POS), TOUCH_PITCH_SPEED);
|
|
||||||
// mapper.addInputChannel(controller::YAW_LEFT, makeInput(TOUCH_AXIS_X_NEG), TOUCH_YAW_SPEED);
|
|
||||||
// mapper.addInputChannel(controller::YAW_RIGHT, makeInput(TOUCH_AXIS_X_POS), TOUCH_YAW_SPEED);
|
|
||||||
//#else
|
|
||||||
// // Touch pad yaw pitch
|
|
||||||
// mapper.addInputChannel(controller::PITCH_DOWN, makeInput(TOUCH_AXIS_Y_NEG), TOUCH_PITCH_SPEED);
|
|
||||||
// mapper.addInputChannel(controller::PITCH_UP, makeInput(TOUCH_AXIS_Y_POS), TOUCH_PITCH_SPEED);
|
|
||||||
// mapper.addInputChannel(controller::YAW_LEFT, makeInput(TOUCH_AXIS_X_NEG), TOUCH_YAW_SPEED);
|
|
||||||
// mapper.addInputChannel(controller::YAW_RIGHT, makeInput(TOUCH_AXIS_X_POS), TOUCH_YAW_SPEED);
|
|
||||||
//
|
|
||||||
// // Wheel move
|
|
||||||
// mapper.addInputChannel(controller::BOOM_IN, makeInput(MOUSE_AXIS_WHEEL_Y_POS), BUTTON_BOOM_SPEED);
|
|
||||||
// mapper.addInputChannel(controller::BOOM_OUT, makeInput(MOUSE_AXIS_WHEEL_Y_NEG), BUTTON_BOOM_SPEED);
|
|
||||||
// mapper.addInputChannel(controller::LATERAL_LEFT, makeInput(MOUSE_AXIS_WHEEL_X_NEG), BUTTON_YAW_SPEED);
|
|
||||||
// mapper.addInputChannel(controller::LATERAL_RIGHT, makeInput(MOUSE_AXIS_WHEEL_X_POS), BUTTON_YAW_SPEED);
|
|
||||||
//
|
|
||||||
//#endif
|
|
||||||
//
|
|
||||||
// mapper.addInputChannel(controller::SHIFT, makeInput(Qt::Key_Space));
|
|
||||||
// mapper.addInputChannel(controller::ACTION1, makeInput(Qt::Key_R));
|
|
||||||
// mapper.addInputChannel(controller::ACTION2, makeInput(Qt::Key_T));
|
|
||||||
//}
|
|
||||||
|
|
||||||
|
|
|
@ -20,27 +20,27 @@
|
||||||
|
|
||||||
#ifdef HAVE_SDL2
|
#ifdef HAVE_SDL2
|
||||||
static_assert(
|
static_assert(
|
||||||
controller::A == SDL_CONTROLLER_BUTTON_A &&
|
(int)controller::A == (int)SDL_CONTROLLER_BUTTON_A &&
|
||||||
controller::B == SDL_CONTROLLER_BUTTON_B &&
|
(int)controller::B == (int)SDL_CONTROLLER_BUTTON_B &&
|
||||||
controller::X == SDL_CONTROLLER_BUTTON_X &&
|
(int)controller::X == (int)SDL_CONTROLLER_BUTTON_X &&
|
||||||
controller::Y == SDL_CONTROLLER_BUTTON_Y &&
|
(int)controller::Y == (int)SDL_CONTROLLER_BUTTON_Y &&
|
||||||
controller::BACK == SDL_CONTROLLER_BUTTON_BACK &&
|
(int)controller::BACK == (int)SDL_CONTROLLER_BUTTON_BACK &&
|
||||||
controller::GUIDE == SDL_CONTROLLER_BUTTON_GUIDE &&
|
(int)controller::GUIDE == (int)SDL_CONTROLLER_BUTTON_GUIDE &&
|
||||||
controller::START == SDL_CONTROLLER_BUTTON_START &&
|
(int)controller::START == (int)SDL_CONTROLLER_BUTTON_START &&
|
||||||
controller::LS == SDL_CONTROLLER_BUTTON_LEFTSTICK &&
|
(int)controller::LS == (int)SDL_CONTROLLER_BUTTON_LEFTSTICK &&
|
||||||
controller::RS == SDL_CONTROLLER_BUTTON_RIGHTSTICK &&
|
(int)controller::RS == (int)SDL_CONTROLLER_BUTTON_RIGHTSTICK &&
|
||||||
controller::LB == SDL_CONTROLLER_BUTTON_LEFTSHOULDER &&
|
(int)controller::LB == (int)SDL_CONTROLLER_BUTTON_LEFTSHOULDER &&
|
||||||
controller::RB == SDL_CONTROLLER_BUTTON_RIGHTSHOULDER &&
|
(int)controller::RB == (int)SDL_CONTROLLER_BUTTON_RIGHTSHOULDER &&
|
||||||
controller::DU == SDL_CONTROLLER_BUTTON_DPAD_UP &&
|
(int)controller::DU == (int)SDL_CONTROLLER_BUTTON_DPAD_UP &&
|
||||||
controller::DD == SDL_CONTROLLER_BUTTON_DPAD_DOWN &&
|
(int)controller::DD == (int)SDL_CONTROLLER_BUTTON_DPAD_DOWN &&
|
||||||
controller::DL == SDL_CONTROLLER_BUTTON_DPAD_LEFT &&
|
(int)controller::DL == (int)SDL_CONTROLLER_BUTTON_DPAD_LEFT &&
|
||||||
controller::DR == SDL_CONTROLLER_BUTTON_DPAD_RIGHT &&
|
(int)controller::DR == (int)SDL_CONTROLLER_BUTTON_DPAD_RIGHT &&
|
||||||
controller::LX == SDL_CONTROLLER_AXIS_LEFTX &&
|
(int)controller::LX == (int)SDL_CONTROLLER_AXIS_LEFTX &&
|
||||||
controller::LY == SDL_CONTROLLER_AXIS_LEFTY &&
|
(int)controller::LY == (int)SDL_CONTROLLER_AXIS_LEFTY &&
|
||||||
controller::RX == SDL_CONTROLLER_AXIS_RIGHTX &&
|
(int)controller::RX == (int)SDL_CONTROLLER_AXIS_RIGHTX &&
|
||||||
controller::RY == SDL_CONTROLLER_AXIS_RIGHTY &&
|
(int)controller::RY == (int)SDL_CONTROLLER_AXIS_RIGHTY &&
|
||||||
controller::LT == SDL_CONTROLLER_AXIS_TRIGGERLEFT &&
|
(int)controller::LT == (int)SDL_CONTROLLER_AXIS_TRIGGERLEFT &&
|
||||||
controller::RT == SDL_CONTROLLER_AXIS_TRIGGERRIGHT,
|
(int)controller::RT == (int)SDL_CONTROLLER_AXIS_TRIGGERRIGHT,
|
||||||
"SDL2 equvalence: Enums and values from StandardControls.h are assumed to match enums from SDL_gamecontroller.h");
|
"SDL2 equvalence: Enums and values from StandardControls.h are assumed to match enums from SDL_gamecontroller.h");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -94,8 +94,8 @@ void SixenseManager::activate() {
|
||||||
_calibrationState = CALIBRATION_STATE_IDLE;
|
_calibrationState = CALIBRATION_STATE_IDLE;
|
||||||
_avatarPosition = DEFAULT_AVATAR_POSITION;
|
_avatarPosition = DEFAULT_AVATAR_POSITION;
|
||||||
|
|
||||||
CONTAINER->addMenu(MENU_PATH);
|
_container->addMenu(MENU_PATH);
|
||||||
CONTAINER->addMenuItem(MENU_PATH, TOGGLE_SMOOTH,
|
_container->addMenuItem(MENU_PATH, TOGGLE_SMOOTH,
|
||||||
[this] (bool clicked) { this->setSixenseFilter(clicked); },
|
[this] (bool clicked) { this->setSixenseFilter(clicked); },
|
||||||
true, true);
|
true, true);
|
||||||
|
|
||||||
|
@ -136,8 +136,8 @@ void SixenseManager::deactivate() {
|
||||||
InputPlugin::deactivate();
|
InputPlugin::deactivate();
|
||||||
|
|
||||||
#ifdef HAVE_SIXENSE
|
#ifdef HAVE_SIXENSE
|
||||||
CONTAINER->removeMenuItem(MENU_NAME, TOGGLE_SMOOTH);
|
_container->removeMenuItem(MENU_NAME, TOGGLE_SMOOTH);
|
||||||
CONTAINER->removeMenu(MENU_PATH);
|
_container->removeMenu(MENU_PATH);
|
||||||
|
|
||||||
_poseStateMap.clear();
|
_poseStateMap.clear();
|
||||||
_collectedSamples.clear();
|
_collectedSamples.clear();
|
||||||
|
@ -319,7 +319,7 @@ void SixenseManager::updateCalibration(void* controllersX) {
|
||||||
_avatarRotation = glm::inverse(glm::quat_cast(glm::mat3(xAxis, Vectors::UNIT_Y, zAxis)));
|
_avatarRotation = glm::inverse(glm::quat_cast(glm::mat3(xAxis, Vectors::UNIT_Y, zAxis)));
|
||||||
const float Y_OFFSET_CALIBRATED_HANDS_TO_AVATAR = -0.3f;
|
const float Y_OFFSET_CALIBRATED_HANDS_TO_AVATAR = -0.3f;
|
||||||
_avatarPosition.y += Y_OFFSET_CALIBRATED_HANDS_TO_AVATAR;
|
_avatarPosition.y += Y_OFFSET_CALIBRATED_HANDS_TO_AVATAR;
|
||||||
CONTAINER->requestReset();
|
_container->requestReset();
|
||||||
qCDebug(inputplugins, "succeess: sixense calibration");
|
qCDebug(inputplugins, "succeess: sixense calibration");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -556,49 +556,6 @@ QString SixenseManager::getDefaultMappingConfig() const {
|
||||||
return MAPPING_JSON;
|
return MAPPING_JSON;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
|
||||||
//void SixenseManager::assignDefaultInputMapping(UserInputMapper& mapper) {
|
|
||||||
// const float JOYSTICK_MOVE_SPEED = 1.0f;
|
|
||||||
// const float JOYSTICK_YAW_SPEED = 0.5f;
|
|
||||||
// const float JOYSTICK_PITCH_SPEED = 0.25f;
|
|
||||||
// const float BUTTON_MOVE_SPEED = 1.0f;
|
|
||||||
// const float BOOM_SPEED = 0.1f;
|
|
||||||
// using namespace controller;
|
|
||||||
//
|
|
||||||
// // Left Joystick: Movement, strafing
|
|
||||||
// mapper.addInputChannel(UserInputMapper::TRANSLATE_Z, makeInput(LY), JOYSTICK_MOVE_SPEED);
|
|
||||||
// mapper.addInputChannel(UserInputMapper::TRANSLATE_X, makeInput(LX), JOYSTICK_MOVE_SPEED);
|
|
||||||
//
|
|
||||||
// // Right Joystick: Camera orientation
|
|
||||||
// mapper.addInputChannel(UserInputMapper::YAW, makeInput(RX), JOYSTICK_YAW_SPEED);
|
|
||||||
// mapper.addInputChannel(UserInputMapper::PITCH, makeInput(RY), JOYSTICK_PITCH_SPEED);
|
|
||||||
//
|
|
||||||
// // Buttons
|
|
||||||
// mapper.addInputChannel(UserInputMapper::BOOM_IN, makeInput(L3), BOOM_SPEED);
|
|
||||||
// mapper.addInputChannel(UserInputMapper::BOOM_OUT, makeInput(L1), BOOM_SPEED);
|
|
||||||
//
|
|
||||||
// mapper.addInputChannel(UserInputMapper::VERTICAL_UP, makeInput(R3), BUTTON_MOVE_SPEED);
|
|
||||||
// mapper.addInputChannel(UserInputMapper::VERTICAL_DOWN, makeInput(R1), BUTTON_MOVE_SPEED);
|
|
||||||
//
|
|
||||||
// mapper.addInputChannel(UserInputMapper::SHIFT, makeInput(L2));
|
|
||||||
// mapper.addInputChannel(UserInputMapper::SHIFT, makeInput(R2));
|
|
||||||
//
|
|
||||||
// mapper.addInputChannel(UserInputMapper::ACTION1, makeInput(L4));
|
|
||||||
// mapper.addInputChannel(UserInputMapper::ACTION2, makeInput(R4));
|
|
||||||
//
|
|
||||||
// // FIXME
|
|
||||||
//// mapper.addInputChannel(UserInputMapper::LEFT_HAND, makeInput(LEFT_HAND));
|
|
||||||
//// mapper.addInputChannel(UserInputMapper::RIGHT_HAND, makeInput(RIGHT_HAND));
|
|
||||||
//
|
|
||||||
// mapper.addInputChannel(UserInputMapper::LEFT_HAND_CLICK, makeInput(LT));
|
|
||||||
// mapper.addInputChannel(UserInputMapper::RIGHT_HAND_CLICK, makeInput(RT));
|
|
||||||
//
|
|
||||||
// // TODO find a mechanism to allow users to navigate the context menu via
|
|
||||||
// mapper.addInputChannel(UserInputMapper::CONTEXT_MENU, makeInput(L0));
|
|
||||||
// mapper.addInputChannel(UserInputMapper::TOGGLE_MUTE, makeInput(R0));
|
|
||||||
//
|
|
||||||
//}
|
|
||||||
|
|
||||||
// virtual
|
// virtual
|
||||||
void SixenseManager::saveSettings() const {
|
void SixenseManager::saveSettings() const {
|
||||||
Settings settings;
|
Settings settings;
|
||||||
|
|
|
@ -75,8 +75,8 @@ bool ViveControllerManager::isSupported() const {
|
||||||
void ViveControllerManager::activate() {
|
void ViveControllerManager::activate() {
|
||||||
InputPlugin::activate();
|
InputPlugin::activate();
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
CONTAINER->addMenu(MENU_PATH);
|
_container->addMenu(MENU_PATH);
|
||||||
CONTAINER->addMenuItem(MENU_PATH, RENDER_CONTROLLERS,
|
_container->addMenuItem(MENU_PATH, RENDER_CONTROLLERS,
|
||||||
[this] (bool clicked) { this->setRenderControllers(clicked); },
|
[this] (bool clicked) { this->setRenderControllers(clicked); },
|
||||||
true, true);
|
true, true);
|
||||||
|
|
||||||
|
@ -146,8 +146,8 @@ void ViveControllerManager::deactivate() {
|
||||||
InputPlugin::deactivate();
|
InputPlugin::deactivate();
|
||||||
|
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
CONTAINER->removeMenuItem(MENU_NAME, RENDER_CONTROLLERS);
|
_container->removeMenuItem(MENU_NAME, RENDER_CONTROLLERS);
|
||||||
CONTAINER->removeMenu(MENU_PATH);
|
_container->removeMenu(MENU_PATH);
|
||||||
|
|
||||||
hmdRefCount--;
|
hmdRefCount--;
|
||||||
|
|
||||||
|
|
140
libraries/plugins/src/plugins/DisplayPlugin.h
Normal file
140
libraries/plugins/src/plugins/DisplayPlugin.h
Normal file
|
@ -0,0 +1,140 @@
|
||||||
|
//
|
||||||
|
// Created by Bradley Austin Davis on 2015/05/29
|
||||||
|
// 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
|
||||||
|
//
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <functional>
|
||||||
|
|
||||||
|
#include <glm/glm.hpp>
|
||||||
|
#include <glm/gtc/quaternion.hpp>
|
||||||
|
|
||||||
|
#include <QtCore/QSize>
|
||||||
|
#include <QtCore/QPoint>
|
||||||
|
|
||||||
|
#include <GLMHelpers.h>
|
||||||
|
#include <RegisteredMetaTypes.h>
|
||||||
|
|
||||||
|
#include "Plugin.h"
|
||||||
|
|
||||||
|
enum Eye {
|
||||||
|
Left,
|
||||||
|
Right,
|
||||||
|
Mono
|
||||||
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Helper method to iterate over each eye
|
||||||
|
*/
|
||||||
|
template <typename F>
|
||||||
|
void for_each_eye(F f) {
|
||||||
|
f(Left);
|
||||||
|
f(Right);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Helper method to iterate over each eye, with an additional lambda to take action between the eyes
|
||||||
|
*/
|
||||||
|
template <typename F, typename FF>
|
||||||
|
void for_each_eye(F f, FF ff) {
|
||||||
|
f(Eye::Left);
|
||||||
|
ff();
|
||||||
|
f(Eye::Right);
|
||||||
|
}
|
||||||
|
|
||||||
|
class QWindow;
|
||||||
|
|
||||||
|
#define AVERAGE_HUMAN_IPD 0.064f
|
||||||
|
|
||||||
|
class DisplayPlugin : public Plugin {
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
virtual bool isHmd() const { return false; }
|
||||||
|
virtual int getHmdScreen() const { return -1; }
|
||||||
|
/// By default, all HMDs are stereo
|
||||||
|
virtual bool isStereo() const { return isHmd(); }
|
||||||
|
virtual bool isThrottled() const { return false; }
|
||||||
|
|
||||||
|
// Rendering support
|
||||||
|
|
||||||
|
// Stop requesting renders, but don't do full deactivation
|
||||||
|
// needed to work around the issues caused by Oculus
|
||||||
|
// processing messages in the middle of submitFrame
|
||||||
|
virtual void stop() = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called by the application before the frame rendering. Can be used for
|
||||||
|
* render timing related calls (for instance, the Oculus begin frame timing
|
||||||
|
* call)
|
||||||
|
*/
|
||||||
|
virtual void preRender() = 0;
|
||||||
|
/**
|
||||||
|
* Called by the application immediately before calling the display function.
|
||||||
|
* For OpenGL based plugins, this is the best place to put activate the output
|
||||||
|
* OpenGL context
|
||||||
|
*/
|
||||||
|
virtual void preDisplay() = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sends the scene texture to the display plugin.
|
||||||
|
*/
|
||||||
|
virtual void display(uint32_t sceneTexture, const glm::uvec2& sceneSize) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called by the application immeidately after display. For OpenGL based
|
||||||
|
* displays, this is the best place to put the buffer swap
|
||||||
|
*/
|
||||||
|
virtual void finishFrame() = 0;
|
||||||
|
|
||||||
|
// Does the rendering surface have current focus?
|
||||||
|
virtual bool hasFocus() const = 0;
|
||||||
|
|
||||||
|
// The size of the rendering target (may be larger than the device size due to distortion)
|
||||||
|
virtual glm::uvec2 getRecommendedRenderSize() const = 0;
|
||||||
|
|
||||||
|
// The size of the UI
|
||||||
|
virtual glm::uvec2 getRecommendedUiSize() const {
|
||||||
|
return getRecommendedRenderSize();
|
||||||
|
}
|
||||||
|
|
||||||
|
// By default the aspect ratio is just the render size
|
||||||
|
virtual float getRecommendedAspectRatio() const {
|
||||||
|
return aspect(getRecommendedRenderSize());
|
||||||
|
}
|
||||||
|
|
||||||
|
// Stereo specific methods
|
||||||
|
virtual glm::mat4 getProjection(Eye eye, const glm::mat4& baseProjection) const {
|
||||||
|
return baseProjection;
|
||||||
|
}
|
||||||
|
|
||||||
|
// HMD specific methods
|
||||||
|
// TODO move these into another class?
|
||||||
|
virtual glm::mat4 getEyeToHeadTransform(Eye eye) const {
|
||||||
|
static const glm::mat4 transform; return transform;
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual glm::mat4 getHeadPose() const {
|
||||||
|
static const glm::mat4 pose; return pose;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Needed for timewarp style features
|
||||||
|
virtual void setEyeRenderPose(Eye eye, const glm::mat4& pose) {
|
||||||
|
// NOOP
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual float getIPD() const { return AVERAGE_HUMAN_IPD; }
|
||||||
|
|
||||||
|
virtual void abandonCalibration() {}
|
||||||
|
virtual void resetSensors() {}
|
||||||
|
virtual float devicePixelRatio() { return 1.0; }
|
||||||
|
|
||||||
|
|
||||||
|
static const QString& MENU_PATH();
|
||||||
|
signals:
|
||||||
|
void recommendedFramebufferSizeChanged(const QSize & size);
|
||||||
|
void requestRender();
|
||||||
|
};
|
||||||
|
|
|
@ -21,3 +21,4 @@ using DisplayPluginPointer = QSharedPointer<DisplayPlugin>;
|
||||||
using DisplayPluginList = QVector<DisplayPluginPointer>;
|
using DisplayPluginList = QVector<DisplayPluginPointer>;
|
||||||
using InputPluginPointer = QSharedPointer<InputPlugin>;
|
using InputPluginPointer = QSharedPointer<InputPlugin>;
|
||||||
using InputPluginList = QVector<InputPluginPointer>;
|
using InputPluginList = QVector<InputPluginPointer>;
|
||||||
|
|
||||||
|
|
23
libraries/plugins/src/plugins/InputPlugin.h
Normal file
23
libraries/plugins/src/plugins/InputPlugin.h
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
//
|
||||||
|
// InputPlugin.h
|
||||||
|
// input-plugins/src/input-plugins
|
||||||
|
//
|
||||||
|
// Created by Sam Gondelman on 7/13/2015
|
||||||
|
// 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
|
||||||
|
//
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "Plugin.h"
|
||||||
|
|
||||||
|
class InputPlugin : public Plugin {
|
||||||
|
public:
|
||||||
|
virtual bool isJointController() const = 0;
|
||||||
|
|
||||||
|
virtual void pluginFocusOutEvent() = 0;
|
||||||
|
|
||||||
|
virtual void pluginUpdate(float deltaTime, bool jointsCaptured) = 0;
|
||||||
|
};
|
||||||
|
|
|
@ -7,12 +7,10 @@
|
||||||
//
|
//
|
||||||
#include "Plugin.h"
|
#include "Plugin.h"
|
||||||
|
|
||||||
PluginContainer* Plugin::CONTAINER{ nullptr };
|
|
||||||
|
|
||||||
QString Plugin::UNKNOWN_PLUGIN_ID("unknown");
|
QString Plugin::UNKNOWN_PLUGIN_ID("unknown");
|
||||||
|
|
||||||
void Plugin::setContainer(PluginContainer* container) {
|
void Plugin::setContainer(PluginContainer* container) {
|
||||||
CONTAINER = container;
|
_container = container;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Plugin::isSupported() const { return true; }
|
bool Plugin::isSupported() const { return true; }
|
||||||
|
|
|
@ -24,7 +24,7 @@ public:
|
||||||
|
|
||||||
virtual bool isSupported() const;
|
virtual bool isSupported() const;
|
||||||
|
|
||||||
static void setContainer(PluginContainer* container);
|
void setContainer(PluginContainer* container);
|
||||||
|
|
||||||
/// Called when plugin is initially loaded, typically at application start
|
/// Called when plugin is initially loaded, typically at application start
|
||||||
virtual void init();
|
virtual void init();
|
||||||
|
@ -57,8 +57,8 @@ public:
|
||||||
virtual void loadSettings() {}
|
virtual void loadSettings() {}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool _active{ false };
|
bool _active { false };
|
||||||
static PluginContainer* CONTAINER;
|
PluginContainer* _container { nullptr };
|
||||||
static QString UNKNOWN_PLUGIN_ID;
|
static QString UNKNOWN_PLUGIN_ID;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -6,15 +6,54 @@
|
||||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
//
|
//
|
||||||
#include "PluginManager.h"
|
#include "PluginManager.h"
|
||||||
|
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
|
|
||||||
#include "Forward.h"
|
#include <QtCore/QCoreApplication>
|
||||||
|
#include <QtCore/QDir>
|
||||||
|
#include <QtCore/QDebug>
|
||||||
|
#include <QtCore/QPluginLoader>
|
||||||
|
|
||||||
|
#include "RuntimePlugin.h"
|
||||||
|
#include "DisplayPlugin.h"
|
||||||
|
#include "InputPlugin.h"
|
||||||
|
#include "PluginContainer.h"
|
||||||
|
|
||||||
|
|
||||||
PluginManager* PluginManager::getInstance() {
|
PluginManager* PluginManager::getInstance() {
|
||||||
static PluginManager _manager;
|
static PluginManager _manager;
|
||||||
return &_manager;
|
return &_manager;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
using Loader = QSharedPointer<QPluginLoader>;
|
||||||
|
using LoaderList = QList<Loader>;
|
||||||
|
|
||||||
|
const LoaderList& getLoadedPlugins() {
|
||||||
|
static std::once_flag once;
|
||||||
|
static LoaderList loadedPlugins;
|
||||||
|
std::call_once(once, [&] {
|
||||||
|
QString pluginPath = QCoreApplication::applicationDirPath() + "/plugins/";
|
||||||
|
QDir pluginDir(pluginPath);
|
||||||
|
pluginDir.setFilter(QDir::Files);
|
||||||
|
if (pluginDir.exists()) {
|
||||||
|
qDebug() << "Loading runtime plugins from " << pluginPath;
|
||||||
|
auto candidates = pluginDir.entryList();
|
||||||
|
for (auto plugin : candidates) {
|
||||||
|
qDebug() << "Attempting plugins " << plugin;
|
||||||
|
QSharedPointer<QPluginLoader> loader(new QPluginLoader(pluginPath + plugin));
|
||||||
|
if (loader->load()) {
|
||||||
|
qDebug() << "Plugins " << plugin << " success";
|
||||||
|
loadedPlugins.push_back(loader);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return loadedPlugins;
|
||||||
|
}
|
||||||
|
|
||||||
|
PluginManager::PluginManager() {
|
||||||
|
}
|
||||||
|
|
||||||
// TODO migrate to a DLL model where plugins are discovered and loaded at runtime by the PluginManager class
|
// TODO migrate to a DLL model where plugins are discovered and loaded at runtime by the PluginManager class
|
||||||
extern DisplayPluginList getDisplayPlugins();
|
extern DisplayPluginList getDisplayPlugins();
|
||||||
extern InputPluginList getInputPlugins();
|
extern InputPluginList getInputPlugins();
|
||||||
|
@ -23,8 +62,25 @@ extern void saveInputPluginSettings(const InputPluginList& plugins);
|
||||||
const DisplayPluginList& PluginManager::getDisplayPlugins() {
|
const DisplayPluginList& PluginManager::getDisplayPlugins() {
|
||||||
static DisplayPluginList displayPlugins;
|
static DisplayPluginList displayPlugins;
|
||||||
static std::once_flag once;
|
static std::once_flag once;
|
||||||
|
|
||||||
std::call_once(once, [&] {
|
std::call_once(once, [&] {
|
||||||
|
// Grab the built in plugins
|
||||||
displayPlugins = ::getDisplayPlugins();
|
displayPlugins = ::getDisplayPlugins();
|
||||||
|
|
||||||
|
// Now grab the dynamic plugins
|
||||||
|
for (auto loader : getLoadedPlugins()) {
|
||||||
|
DisplayProvider* displayProvider = qobject_cast<DisplayProvider*>(loader->instance());
|
||||||
|
if (displayProvider) {
|
||||||
|
for (auto displayPlugin : displayProvider->getDisplayPlugins()) {
|
||||||
|
displayPlugins.push_back(displayPlugin);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
auto& container = PluginContainer::getInstance();
|
||||||
|
for (auto plugin : displayPlugins) {
|
||||||
|
plugin->setContainer(&container);
|
||||||
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
return displayPlugins;
|
return displayPlugins;
|
||||||
}
|
}
|
||||||
|
@ -34,6 +90,21 @@ const InputPluginList& PluginManager::getInputPlugins() {
|
||||||
static std::once_flag once;
|
static std::once_flag once;
|
||||||
std::call_once(once, [&] {
|
std::call_once(once, [&] {
|
||||||
inputPlugins = ::getInputPlugins();
|
inputPlugins = ::getInputPlugins();
|
||||||
|
|
||||||
|
// Now grab the dynamic plugins
|
||||||
|
for (auto loader : getLoadedPlugins()) {
|
||||||
|
InputProvider* inputProvider = qobject_cast<InputProvider*>(loader->instance());
|
||||||
|
if (inputProvider) {
|
||||||
|
for (auto inputPlugin : inputProvider->getInputPlugins()) {
|
||||||
|
inputPlugins.push_back(inputPlugin);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
auto& container = PluginContainer::getInstance();
|
||||||
|
for (auto plugin : inputPlugins) {
|
||||||
|
plugin->setContainer(&container);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
return inputPlugins;
|
return inputPlugins;
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
class PluginManager : public QObject {
|
class PluginManager : public QObject {
|
||||||
public:
|
public:
|
||||||
static PluginManager* getInstance();
|
static PluginManager* getInstance();
|
||||||
|
PluginManager();
|
||||||
|
|
||||||
const DisplayPluginList& getDisplayPlugins();
|
const DisplayPluginList& getDisplayPlugins();
|
||||||
const InputPluginList& getInputPlugins();
|
const InputPluginList& getInputPlugins();
|
||||||
|
|
36
libraries/plugins/src/plugins/RuntimePlugin.h
Normal file
36
libraries/plugins/src/plugins/RuntimePlugin.h
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
//
|
||||||
|
// Created by Bradley Austin Davis on 2015/10/24
|
||||||
|
// 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
|
||||||
|
//
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <assert.h>
|
||||||
|
|
||||||
|
#include <QString>
|
||||||
|
#include <QObject>
|
||||||
|
|
||||||
|
#include "Forward.h"
|
||||||
|
|
||||||
|
class DisplayProvider {
|
||||||
|
public:
|
||||||
|
virtual ~DisplayProvider() {}
|
||||||
|
|
||||||
|
virtual DisplayPluginList getDisplayPlugins() = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
#define DisplayProvider_iid "com.highfidelity.plugins.display"
|
||||||
|
Q_DECLARE_INTERFACE(DisplayProvider, DisplayProvider_iid)
|
||||||
|
|
||||||
|
|
||||||
|
class InputProvider {
|
||||||
|
public:
|
||||||
|
virtual ~InputProvider() {}
|
||||||
|
virtual InputPluginList getInputPlugins() = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
#define InputProvider_iid "com.highfidelity.plugins.input"
|
||||||
|
Q_DECLARE_INTERFACE(InputProvider, InputProvider_iid)
|
||||||
|
|
|
@ -3,14 +3,4 @@ set(TARGET_NAME shared)
|
||||||
# TODO: there isn't really a good reason to have Script linked here - let's get what is requiring it out (RegisteredMetaTypes.cpp)
|
# 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)
|
setup_hifi_library(Gui Network Script Widgets)
|
||||||
|
|
||||||
find_package(ZLIB REQUIRED)
|
target_zlib()
|
||||||
target_link_libraries(${TARGET_NAME} ${ZLIB_LIBRARIES})
|
|
||||||
target_include_directories(${TARGET_NAME} PUBLIC ${ZLIB_INCLUDE_DIRS})
|
|
||||||
|
|
||||||
if (WIN32)
|
|
||||||
# Birarda will fix this when he finds it.
|
|
||||||
get_filename_component(ZLIB_LIB_DIR "${ZLIB_LIBRARIES}" DIRECTORY)
|
|
||||||
get_filename_component(ZLIB_DIR "${ZLIB_LIB_DIR}" DIRECTORY)
|
|
||||||
set(ZLIB_BIN_DIR "${ZLIB_DIR}/bin")
|
|
||||||
add_paths_to_fixup_libs(${ZLIB_BIN_DIR})
|
|
||||||
endif ()
|
|
||||||
|
|
18
plugins/CMakeLists.txt
Normal file
18
plugins/CMakeLists.txt
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
#
|
||||||
|
# Created by Bradley Austin Davis on 2015/10/25
|
||||||
|
# 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
|
||||||
|
#
|
||||||
|
|
||||||
|
# add the plugin directories
|
||||||
|
file(GLOB PLUGIN_SUBDIRS RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}/*")
|
||||||
|
list(REMOVE_ITEM PLUGIN_SUBDIRS "CMakeFiles")
|
||||||
|
|
||||||
|
foreach(DIR ${PLUGIN_SUBDIRS})
|
||||||
|
if(IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/${DIR}")
|
||||||
|
add_subdirectory(${DIR})
|
||||||
|
endif()
|
||||||
|
endforeach()
|
||||||
|
|
25
plugins/oculus/CMakeLists.txt
Normal file
25
plugins/oculus/CMakeLists.txt
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
#
|
||||||
|
# Created by Bradley Austin Davis on 2015/10/25
|
||||||
|
# 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
|
||||||
|
#
|
||||||
|
|
||||||
|
if (WIN32)
|
||||||
|
|
||||||
|
# we're using static GLEW, so define GLEW_STATIC
|
||||||
|
add_definitions(-DGLEW_STATIC)
|
||||||
|
|
||||||
|
set(TARGET_NAME oculus)
|
||||||
|
setup_hifi_plugin()
|
||||||
|
link_hifi_libraries(shared gl plugins display-plugins)
|
||||||
|
|
||||||
|
include_hifi_library_headers(octree)
|
||||||
|
|
||||||
|
add_dependency_external_projects(LibOVR)
|
||||||
|
find_package(LibOVR REQUIRED)
|
||||||
|
target_include_directories(${TARGET_NAME} PRIVATE ${LIBOVR_INCLUDE_DIRS})
|
||||||
|
target_link_libraries(${TARGET_NAME} ${LIBOVR_LIBRARIES})
|
||||||
|
|
||||||
|
endif()
|
|
@ -61,6 +61,14 @@ bool OculusBaseDisplayPlugin::isSupported() const {
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// DLL based display plugins MUST initialize GLEW inside the DLL code.
|
||||||
|
void OculusBaseDisplayPlugin::customizeContext() {
|
||||||
|
glewExperimental = true;
|
||||||
|
GLenum err = glewInit();
|
||||||
|
glGetError();
|
||||||
|
WindowOpenGLDisplayPlugin::customizeContext();
|
||||||
|
}
|
||||||
|
|
||||||
void OculusBaseDisplayPlugin::init() {
|
void OculusBaseDisplayPlugin::init() {
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
//
|
//
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "../WindowOpenGLDisplayPlugin.h"
|
#include <display-plugins/WindowOpenGLDisplayPlugin.h>
|
||||||
|
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
|
|
||||||
|
@ -35,6 +35,7 @@ public:
|
||||||
virtual float getIPD() const override final;
|
virtual float getIPD() const override final;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
virtual void customizeContext() override;
|
||||||
virtual void preRender() override final;
|
virtual void preRender() override final;
|
||||||
virtual void display(GLuint finalTexture, const glm::uvec2& sceneSize) override;
|
virtual void display(GLuint finalTexture, const glm::uvec2& sceneSize) override;
|
||||||
|
|
|
@ -7,11 +7,14 @@
|
||||||
//
|
//
|
||||||
#include "OculusDisplayPlugin.h"
|
#include "OculusDisplayPlugin.h"
|
||||||
|
|
||||||
#include <QGLWidget>
|
#include <QtOpenGL/QGLWidget>
|
||||||
|
|
||||||
|
// FIXME get rid of this
|
||||||
|
#include <gl/Config.h>
|
||||||
|
#include <plugins/PluginContainer.h>
|
||||||
|
|
||||||
#include "OculusHelpers.h"
|
#include "OculusHelpers.h"
|
||||||
|
|
||||||
#include <plugins/PluginContainer.h>
|
|
||||||
|
|
||||||
#if (OVR_MAJOR_VERSION >= 6)
|
#if (OVR_MAJOR_VERSION >= 6)
|
||||||
|
|
||||||
|
@ -142,16 +145,16 @@ static const QString FRAMERATE = DisplayPlugin::MENU_PATH() + ">Framerate";
|
||||||
|
|
||||||
void OculusDisplayPlugin::activate() {
|
void OculusDisplayPlugin::activate() {
|
||||||
|
|
||||||
CONTAINER->addMenuItem(MENU_PATH(), MONO_PREVIEW,
|
_container->addMenuItem(MENU_PATH(), MONO_PREVIEW,
|
||||||
[this](bool clicked) {
|
[this](bool clicked) {
|
||||||
_monoPreview = clicked;
|
_monoPreview = clicked;
|
||||||
}, true, true);
|
}, true, true);
|
||||||
CONTAINER->removeMenu(FRAMERATE);
|
_container->removeMenu(FRAMERATE);
|
||||||
OculusBaseDisplayPlugin::activate();
|
OculusBaseDisplayPlugin::activate();
|
||||||
}
|
}
|
||||||
|
|
||||||
void OculusDisplayPlugin::customizeContext() {
|
void OculusDisplayPlugin::customizeContext() {
|
||||||
WindowOpenGLDisplayPlugin::customizeContext();
|
OculusBaseDisplayPlugin::customizeContext();
|
||||||
#if (OVR_MAJOR_VERSION >= 6)
|
#if (OVR_MAJOR_VERSION >= 6)
|
||||||
_sceneFbo = SwapFboPtr(new SwapFramebufferWrapper(_hmd));
|
_sceneFbo = SwapFboPtr(new SwapFramebufferWrapper(_hmd));
|
||||||
_sceneFbo->Init(getRecommendedRenderSize());
|
_sceneFbo->Init(getRecommendedRenderSize());
|
54
plugins/oculus/src/OculusProvider.cpp
Normal file
54
plugins/oculus/src/OculusProvider.cpp
Normal file
|
@ -0,0 +1,54 @@
|
||||||
|
//
|
||||||
|
// Created by Bradley Austin Davis on 2015/10/25
|
||||||
|
// 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 <mutex>
|
||||||
|
|
||||||
|
#include <QtCore/QObject>
|
||||||
|
#include <QtCore/QtPlugin>
|
||||||
|
#include <QtCore/QStringList>
|
||||||
|
|
||||||
|
#include <plugins/RuntimePlugin.h>
|
||||||
|
#include <plugins/DisplayPlugin.h>
|
||||||
|
|
||||||
|
#include "OculusDisplayPlugin.h"
|
||||||
|
#include "OculusDebugDisplayPlugin.h"
|
||||||
|
|
||||||
|
class OculusProvider : public QObject, public DisplayProvider
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
Q_PLUGIN_METADATA(IID DisplayProvider_iid FILE "oculus.json")
|
||||||
|
Q_INTERFACES(DisplayProvider)
|
||||||
|
|
||||||
|
public:
|
||||||
|
OculusProvider(QObject* parent = nullptr) : QObject(parent) {}
|
||||||
|
virtual ~OculusProvider() {}
|
||||||
|
|
||||||
|
virtual DisplayPluginList getDisplayPlugins() override {
|
||||||
|
static std::once_flag once;
|
||||||
|
std::call_once(once, [&] {
|
||||||
|
DisplayPluginPointer plugin(new OculusDisplayPlugin());
|
||||||
|
if (plugin->isSupported()) {
|
||||||
|
_displayPlugins.push_back(plugin);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Windows Oculus Simulator... uses head tracking and the same rendering
|
||||||
|
// as the connected hardware, but without using the SDK to display to the
|
||||||
|
// Rift. Useful for debugging Rift performance with nSight.
|
||||||
|
plugin = DisplayPluginPointer(new OculusDebugDisplayPlugin());
|
||||||
|
if (plugin->isSupported()) {
|
||||||
|
_displayPlugins.push_back(plugin);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return _displayPlugins;
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
DisplayPluginList _displayPlugins;
|
||||||
|
};
|
||||||
|
|
||||||
|
#include "OculusProvider.moc"
|
1
plugins/oculus/src/oculus.json
Normal file
1
plugins/oculus/src/oculus.json
Normal file
|
@ -0,0 +1 @@
|
||||||
|
{}
|
22
plugins/oculusLegacy/CMakeLists.txt
Normal file
22
plugins/oculusLegacy/CMakeLists.txt
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
#
|
||||||
|
# Created by Bradley Austin Davis on 2015/10/25
|
||||||
|
# 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
|
||||||
|
#
|
||||||
|
|
||||||
|
if (NOT WIN32)
|
||||||
|
|
||||||
|
set(TARGET_NAME oculusLegacy)
|
||||||
|
setup_hifi_plugin()
|
||||||
|
link_hifi_libraries(shared gl plugins display-plugins)
|
||||||
|
|
||||||
|
include_hifi_library_headers(octree)
|
||||||
|
|
||||||
|
add_dependency_external_projects(LibOVR)
|
||||||
|
find_package(LibOVR REQUIRED)
|
||||||
|
target_include_directories(${TARGET_NAME} PRIVATE ${LIBOVR_INCLUDE_DIRS})
|
||||||
|
target_link_libraries(${TARGET_NAME} ${LIBOVR_LIBRARIES})
|
||||||
|
|
||||||
|
endif()
|
9
plugins/oculusLegacy/src/OculusHelpers.cpp
Normal file
9
plugins/oculusLegacy/src/OculusHelpers.cpp
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
//
|
||||||
|
// Created by Bradley Austin Davis on 2015/08/08
|
||||||
|
// 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 "OculusHelpers.h"
|
85
plugins/oculusLegacy/src/OculusHelpers.h
Normal file
85
plugins/oculusLegacy/src/OculusHelpers.h
Normal file
|
@ -0,0 +1,85 @@
|
||||||
|
//
|
||||||
|
// Created by Bradley Austin Davis on 2015/05/26
|
||||||
|
// 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
|
||||||
|
//
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <OVR_CAPI_GL.h>
|
||||||
|
#include <GLMHelpers.h>
|
||||||
|
#include <glm/gtc/type_ptr.hpp>
|
||||||
|
#include <glm/gtc/matrix_transform.hpp>
|
||||||
|
|
||||||
|
// Convenience method for looping over each eye with a lambda
|
||||||
|
template <typename Function>
|
||||||
|
inline void ovr_for_each_eye(Function function) {
|
||||||
|
for (ovrEyeType eye = ovrEyeType::ovrEye_Left;
|
||||||
|
eye < ovrEyeType::ovrEye_Count;
|
||||||
|
eye = static_cast<ovrEyeType>(eye + 1)) {
|
||||||
|
function(eye);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
inline glm::mat4 toGlm(const ovrMatrix4f & om) {
|
||||||
|
return glm::transpose(glm::make_mat4(&om.M[0][0]));
|
||||||
|
}
|
||||||
|
|
||||||
|
inline glm::mat4 toGlm(const ovrFovPort & fovport, float nearPlane = 0.01f, float farPlane = 10000.0f) {
|
||||||
|
return toGlm(ovrMatrix4f_Projection(fovport, nearPlane, farPlane, true));
|
||||||
|
}
|
||||||
|
|
||||||
|
inline glm::vec3 toGlm(const ovrVector3f & ov) {
|
||||||
|
return glm::make_vec3(&ov.x);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline glm::vec2 toGlm(const ovrVector2f & ov) {
|
||||||
|
return glm::make_vec2(&ov.x);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline glm::uvec2 toGlm(const ovrSizei & ov) {
|
||||||
|
return glm::uvec2(ov.w, ov.h);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline glm::quat toGlm(const ovrQuatf & oq) {
|
||||||
|
return glm::make_quat(&oq.x);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline glm::mat4 toGlm(const ovrPosef & op) {
|
||||||
|
glm::mat4 orientation = glm::mat4_cast(toGlm(op.Orientation));
|
||||||
|
glm::mat4 translation = glm::translate(glm::mat4(), toGlm(op.Position));
|
||||||
|
return translation * orientation;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline ovrMatrix4f ovrFromGlm(const glm::mat4 & m) {
|
||||||
|
ovrMatrix4f result;
|
||||||
|
glm::mat4 transposed(glm::transpose(m));
|
||||||
|
memcpy(result.M, &(transposed[0][0]), sizeof(float) * 16);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline ovrVector3f ovrFromGlm(const glm::vec3 & v) {
|
||||||
|
return{ v.x, v.y, v.z };
|
||||||
|
}
|
||||||
|
|
||||||
|
inline ovrVector2f ovrFromGlm(const glm::vec2 & v) {
|
||||||
|
return{ v.x, v.y };
|
||||||
|
}
|
||||||
|
|
||||||
|
inline ovrSizei ovrFromGlm(const glm::uvec2 & v) {
|
||||||
|
return{ (int)v.x, (int)v.y };
|
||||||
|
}
|
||||||
|
|
||||||
|
inline ovrQuatf ovrFromGlm(const glm::quat & q) {
|
||||||
|
return{ q.x, q.y, q.z, q.w };
|
||||||
|
}
|
||||||
|
|
||||||
|
inline ovrPosef ovrPoseFromGlm(const glm::mat4 & m) {
|
||||||
|
glm::vec3 translation = glm::vec3(m[3]) / m[3].w;
|
||||||
|
glm::quat orientation = glm::quat_cast(m);
|
||||||
|
ovrPosef result;
|
||||||
|
result.Orientation = ovrFromGlm(orientation);
|
||||||
|
result.Position = ovrFromGlm(translation);
|
||||||
|
return result;
|
||||||
|
}
|
|
@ -42,10 +42,8 @@ uvec2 OculusLegacyDisplayPlugin::getRecommendedRenderSize() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
void OculusLegacyDisplayPlugin::preRender() {
|
void OculusLegacyDisplayPlugin::preRender() {
|
||||||
#if (OVR_MAJOR_VERSION == 5)
|
|
||||||
ovrHmd_GetEyePoses(_hmd, _frameIndex, _eyeOffsets, _eyePoses, &_trackingState);
|
ovrHmd_GetEyePoses(_hmd, _frameIndex, _eyeOffsets, _eyePoses, &_trackingState);
|
||||||
ovrHmd_BeginFrame(_hmd, _frameIndex);
|
ovrHmd_BeginFrame(_hmd, _frameIndex);
|
||||||
#endif
|
|
||||||
WindowOpenGLDisplayPlugin::preRender();
|
WindowOpenGLDisplayPlugin::preRender();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -54,32 +52,21 @@ glm::mat4 OculusLegacyDisplayPlugin::getProjection(Eye eye, const glm::mat4& bas
|
||||||
}
|
}
|
||||||
|
|
||||||
void OculusLegacyDisplayPlugin::resetSensors() {
|
void OculusLegacyDisplayPlugin::resetSensors() {
|
||||||
#if (OVR_MAJOR_VERSION == 5)
|
|
||||||
ovrHmd_RecenterPose(_hmd);
|
ovrHmd_RecenterPose(_hmd);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
glm::mat4 OculusLegacyDisplayPlugin::getEyeToHeadTransform(Eye eye) const {
|
glm::mat4 OculusLegacyDisplayPlugin::getEyeToHeadTransform(Eye eye) const {
|
||||||
#if (OVR_MAJOR_VERSION == 5)
|
|
||||||
return toGlm(_eyePoses[eye]);
|
return toGlm(_eyePoses[eye]);
|
||||||
#else
|
|
||||||
return WindowOpenGLDisplayPlugin::getEyeToHeadTransform(eye);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Should NOT be used for rendering as this will mess up timewarp. Use the getModelview() method above for
|
// Should NOT be used for rendering as this will mess up timewarp. Use the getModelview() method above for
|
||||||
// any use of head poses for rendering, ensuring you use the correct eye
|
// any use of head poses for rendering, ensuring you use the correct eye
|
||||||
glm::mat4 OculusLegacyDisplayPlugin::getHeadPose() const {
|
glm::mat4 OculusLegacyDisplayPlugin::getHeadPose() const {
|
||||||
#if (OVR_MAJOR_VERSION == 5)
|
|
||||||
return toGlm(_trackingState.HeadPose.ThePose);
|
return toGlm(_trackingState.HeadPose.ThePose);
|
||||||
#else
|
|
||||||
return WindowOpenGLDisplayPlugin::getHeadPose();
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool OculusLegacyDisplayPlugin::isSupported() const {
|
bool OculusLegacyDisplayPlugin::isSupported() const {
|
||||||
#if (OVR_MAJOR_VERSION == 5)
|
|
||||||
if (!ovr_Initialize(nullptr)) {
|
if (!ovr_Initialize(nullptr)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -104,14 +91,10 @@ bool OculusLegacyDisplayPlugin::isSupported() const {
|
||||||
|
|
||||||
ovr_Shutdown();
|
ovr_Shutdown();
|
||||||
return result;
|
return result;
|
||||||
#else
|
|
||||||
return false;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void OculusLegacyDisplayPlugin::activate() {
|
void OculusLegacyDisplayPlugin::activate() {
|
||||||
#if (OVR_MAJOR_VERSION == 5)
|
if (!(ovr_Initialize(nullptr))) {
|
||||||
if (!OVR_SUCCESS(ovr_Initialize(nullptr))) {
|
|
||||||
Q_ASSERT(false);
|
Q_ASSERT(false);
|
||||||
qFatal("Failed to Initialize SDK");
|
qFatal("Failed to Initialize SDK");
|
||||||
}
|
}
|
||||||
|
@ -149,8 +132,8 @@ void OculusLegacyDisplayPlugin::activate() {
|
||||||
|
|
||||||
_frameIndex = 0;
|
_frameIndex = 0;
|
||||||
|
|
||||||
if (!OVR_SUCCESS(ovrHmd_ConfigureTracking(_hmd,
|
if (!ovrHmd_ConfigureTracking(_hmd,
|
||||||
ovrTrackingCap_Orientation | ovrTrackingCap_Position | ovrTrackingCap_MagYawCorrection, 0))) {
|
ovrTrackingCap_Orientation | ovrTrackingCap_Position | ovrTrackingCap_MagYawCorrection, 0)) {
|
||||||
qFatal("Could not attach to sensor device");
|
qFatal("Could not attach to sensor device");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -158,7 +141,7 @@ void OculusLegacyDisplayPlugin::activate() {
|
||||||
|
|
||||||
int screen = getHmdScreen();
|
int screen = getHmdScreen();
|
||||||
if (screen != -1) {
|
if (screen != -1) {
|
||||||
CONTAINER->setFullscreen(qApp->screens()[screen]);
|
_container->setFullscreen(qApp->screens()[screen]);
|
||||||
}
|
}
|
||||||
|
|
||||||
_window->installEventFilter(this);
|
_window->installEventFilter(this);
|
||||||
|
@ -189,11 +172,9 @@ void OculusLegacyDisplayPlugin::activate() {
|
||||||
#endif
|
#endif
|
||||||
ovrHmd_ConfigureRendering(_hmd, &config.Config, distortionCaps, _eyeFovs, _eyeRenderDescs);
|
ovrHmd_ConfigureRendering(_hmd, &config.Config, distortionCaps, _eyeFovs, _eyeRenderDescs);
|
||||||
Q_ASSERT(result);
|
Q_ASSERT(result);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void OculusLegacyDisplayPlugin::deactivate() {
|
void OculusLegacyDisplayPlugin::deactivate() {
|
||||||
#if (OVR_MAJOR_VERSION == 5)
|
|
||||||
_window->removeEventFilter(this);
|
_window->removeEventFilter(this);
|
||||||
|
|
||||||
WindowOpenGLDisplayPlugin::deactivate();
|
WindowOpenGLDisplayPlugin::deactivate();
|
||||||
|
@ -202,12 +183,19 @@ void OculusLegacyDisplayPlugin::deactivate() {
|
||||||
if (_hmdScreen >= 0) {
|
if (_hmdScreen >= 0) {
|
||||||
riftScreen = qApp->screens()[_hmdScreen];
|
riftScreen = qApp->screens()[_hmdScreen];
|
||||||
}
|
}
|
||||||
CONTAINER->unsetFullscreen(riftScreen);
|
_container->unsetFullscreen(riftScreen);
|
||||||
|
|
||||||
ovrHmd_Destroy(_hmd);
|
ovrHmd_Destroy(_hmd);
|
||||||
_hmd = nullptr;
|
_hmd = nullptr;
|
||||||
ovr_Shutdown();
|
ovr_Shutdown();
|
||||||
#endif
|
}
|
||||||
|
|
||||||
|
// DLL based display plugins MUST initialize GLEW inside the DLL code.
|
||||||
|
void OculusLegacyDisplayPlugin::customizeContext() {
|
||||||
|
glewExperimental = true;
|
||||||
|
glewInit();
|
||||||
|
glGetError();
|
||||||
|
WindowOpenGLDisplayPlugin::customizeContext();
|
||||||
}
|
}
|
||||||
|
|
||||||
void OculusLegacyDisplayPlugin::preDisplay() {
|
void OculusLegacyDisplayPlugin::preDisplay() {
|
||||||
|
@ -216,17 +204,14 @@ void OculusLegacyDisplayPlugin::preDisplay() {
|
||||||
|
|
||||||
void OculusLegacyDisplayPlugin::display(GLuint finalTexture, const glm::uvec2& sceneSize) {
|
void OculusLegacyDisplayPlugin::display(GLuint finalTexture, const glm::uvec2& sceneSize) {
|
||||||
++_frameIndex;
|
++_frameIndex;
|
||||||
#if (OVR_MAJOR_VERSION == 5)
|
|
||||||
ovr_for_each_eye([&](ovrEyeType eye) {
|
ovr_for_each_eye([&](ovrEyeType eye) {
|
||||||
reinterpret_cast<ovrGLTexture&>(_eyeTextures[eye]).OGL.TexId = finalTexture;
|
reinterpret_cast<ovrGLTexture&>(_eyeTextures[eye]).OGL.TexId = finalTexture;
|
||||||
});
|
});
|
||||||
ovrHmd_EndFrame(_hmd, _eyePoses, _eyeTextures);
|
ovrHmd_EndFrame(_hmd, _eyePoses, _eyeTextures);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Pass input events on to the application
|
// Pass input events on to the application
|
||||||
bool OculusLegacyDisplayPlugin::eventFilter(QObject* receiver, QEvent* event) {
|
bool OculusLegacyDisplayPlugin::eventFilter(QObject* receiver, QEvent* event) {
|
||||||
#if (OVR_MAJOR_VERSION == 5)
|
|
||||||
if (!_hswDismissed && (event->type() == QEvent::KeyPress)) {
|
if (!_hswDismissed && (event->type() == QEvent::KeyPress)) {
|
||||||
static ovrHSWDisplayState hswState;
|
static ovrHSWDisplayState hswState;
|
||||||
ovrHmd_GetHSWDisplayState(_hmd, &hswState);
|
ovrHmd_GetHSWDisplayState(_hmd, &hswState);
|
||||||
|
@ -236,7 +221,6 @@ bool OculusLegacyDisplayPlugin::eventFilter(QObject* receiver, QEvent* event) {
|
||||||
_hswDismissed = true;
|
_hswDismissed = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
return WindowOpenGLDisplayPlugin::eventFilter(receiver, event);
|
return WindowOpenGLDisplayPlugin::eventFilter(receiver, event);
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
//
|
//
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "../WindowOpenGLDisplayPlugin.h"
|
#include <display-plugins/WindowOpenGLDisplayPlugin.h>
|
||||||
|
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
|
|
||||||
|
@ -35,6 +35,7 @@ public:
|
||||||
virtual glm::mat4 getHeadPose() const override;
|
virtual glm::mat4 getHeadPose() const override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
virtual void customizeContext() override;
|
||||||
virtual void preRender() override;
|
virtual void preRender() override;
|
||||||
virtual void preDisplay() override;
|
virtual void preDisplay() override;
|
||||||
virtual void display(GLuint finalTexture, const glm::uvec2& sceneSize) override;
|
virtual void display(GLuint finalTexture, const glm::uvec2& sceneSize) override;
|
45
plugins/oculusLegacy/src/OculusProvider.cpp
Normal file
45
plugins/oculusLegacy/src/OculusProvider.cpp
Normal file
|
@ -0,0 +1,45 @@
|
||||||
|
//
|
||||||
|
// Created by Bradley Austin Davis on 2015/10/25
|
||||||
|
// 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 <mutex>
|
||||||
|
|
||||||
|
#include <QtCore/QObject>
|
||||||
|
#include <QtCore/QtPlugin>
|
||||||
|
#include <QtCore/QStringList>
|
||||||
|
|
||||||
|
#include <plugins/RuntimePlugin.h>
|
||||||
|
#include <plugins/DisplayPlugin.h>
|
||||||
|
|
||||||
|
#include "OculusLegacyDisplayPlugin.h"
|
||||||
|
|
||||||
|
class OculusProvider : public QObject, public DisplayProvider
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
Q_PLUGIN_METADATA(IID DisplayProvider_iid FILE "oculus.json")
|
||||||
|
Q_INTERFACES(DisplayProvider)
|
||||||
|
|
||||||
|
public:
|
||||||
|
OculusProvider(QObject* parent = nullptr) : QObject(parent) {}
|
||||||
|
virtual ~OculusProvider() {}
|
||||||
|
|
||||||
|
virtual DisplayPluginList getDisplayPlugins() override {
|
||||||
|
static std::once_flag once;
|
||||||
|
std::call_once(once, [&] {
|
||||||
|
DisplayPluginPointer plugin(new OculusLegacyDisplayPlugin());
|
||||||
|
if (plugin->isSupported()) {
|
||||||
|
_displayPlugins.push_back(plugin);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return _displayPlugins;
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
DisplayPluginList _displayPlugins;
|
||||||
|
};
|
||||||
|
|
||||||
|
#include "OculusProvider.moc"
|
1
plugins/oculusLegacy/src/oculus.json
Normal file
1
plugins/oculusLegacy/src/oculus.json
Normal file
|
@ -0,0 +1 @@
|
||||||
|
{}
|
|
@ -80,9 +80,6 @@ using namespace controller;
|
||||||
class PluginContainerProxy : public QObject, PluginContainer {
|
class PluginContainerProxy : public QObject, PluginContainer {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
PluginContainerProxy() {
|
|
||||||
Plugin::setContainer(this);
|
|
||||||
}
|
|
||||||
virtual ~PluginContainerProxy() {}
|
virtual ~PluginContainerProxy() {}
|
||||||
virtual void addMenu(const QString& menuName) override {}
|
virtual void addMenu(const QString& menuName) override {}
|
||||||
virtual void removeMenu(const QString& menuName) override {}
|
virtual void removeMenu(const QString& menuName) override {}
|
||||||
|
|
Loading…
Reference in a new issue