From 5f8de423f190bbb79a62f804151bc24824fa32d8 Mon Sep 17 00:00:00 2001 From: "Matt A. Tobin" Date: Fri, 2 Feb 2018 04:16:08 -0500 Subject: Add m-esr52 at 52.6.0 --- gfx/vr/osvr/ClientKit/ClientKitC.h | 37 ++ gfx/vr/osvr/ClientKit/ContextC.h | 96 +++++ gfx/vr/osvr/ClientKit/DisplayC.h | 506 +++++++++++++++++++++++++ gfx/vr/osvr/ClientKit/Export.h | 138 +++++++ gfx/vr/osvr/ClientKit/InterfaceC.h | 75 ++++ gfx/vr/osvr/ClientKit/InterfaceCallbackC.h | 77 ++++ gfx/vr/osvr/ClientKit/InterfaceStateC.h | 79 ++++ gfx/vr/osvr/ClientKit/SystemCallbackC.h | 47 +++ gfx/vr/osvr/ClientKit/TransformsC.h | 75 ++++ gfx/vr/osvr/Util/APIBaseC.h | 50 +++ gfx/vr/osvr/Util/AnnotationMacrosC.h | 232 ++++++++++++ gfx/vr/osvr/Util/BoolC.h | 59 +++ gfx/vr/osvr/Util/ChannelCountC.h | 57 +++ gfx/vr/osvr/Util/ClientCallbackTypesC.h | 140 +++++++ gfx/vr/osvr/Util/ClientOpaqueTypesC.h | 69 ++++ gfx/vr/osvr/Util/ClientReportTypesC.h | 348 +++++++++++++++++ gfx/vr/osvr/Util/Export.h | 138 +++++++ gfx/vr/osvr/Util/ImagingReportTypesC.h | 91 +++++ gfx/vr/osvr/Util/MatrixConventionsC.h | 190 ++++++++++ gfx/vr/osvr/Util/PlatformConfig.h | 88 +++++ gfx/vr/osvr/Util/Pose3C.h | 70 ++++ gfx/vr/osvr/Util/QuaternionC.h | 92 +++++ gfx/vr/osvr/Util/QuatlibInteropC.h | 84 ++++ gfx/vr/osvr/Util/RadialDistortionParametersC.h | 62 +++ gfx/vr/osvr/Util/RenderingTypesC.h | 134 +++++++ gfx/vr/osvr/Util/ReturnCodesC.h | 57 +++ gfx/vr/osvr/Util/StdInt.h | 42 ++ gfx/vr/osvr/Util/TimeValueC.h | 271 +++++++++++++ gfx/vr/osvr/Util/Vec2C.h | 86 +++++ gfx/vr/osvr/Util/Vec3C.h | 89 +++++ 30 files changed, 3579 insertions(+) create mode 100644 gfx/vr/osvr/ClientKit/ClientKitC.h create mode 100644 gfx/vr/osvr/ClientKit/ContextC.h create mode 100644 gfx/vr/osvr/ClientKit/DisplayC.h create mode 100644 gfx/vr/osvr/ClientKit/Export.h create mode 100644 gfx/vr/osvr/ClientKit/InterfaceC.h create mode 100644 gfx/vr/osvr/ClientKit/InterfaceCallbackC.h create mode 100644 gfx/vr/osvr/ClientKit/InterfaceStateC.h create mode 100644 gfx/vr/osvr/ClientKit/SystemCallbackC.h create mode 100644 gfx/vr/osvr/ClientKit/TransformsC.h create mode 100644 gfx/vr/osvr/Util/APIBaseC.h create mode 100644 gfx/vr/osvr/Util/AnnotationMacrosC.h create mode 100644 gfx/vr/osvr/Util/BoolC.h create mode 100644 gfx/vr/osvr/Util/ChannelCountC.h create mode 100644 gfx/vr/osvr/Util/ClientCallbackTypesC.h create mode 100644 gfx/vr/osvr/Util/ClientOpaqueTypesC.h create mode 100644 gfx/vr/osvr/Util/ClientReportTypesC.h create mode 100644 gfx/vr/osvr/Util/Export.h create mode 100644 gfx/vr/osvr/Util/ImagingReportTypesC.h create mode 100644 gfx/vr/osvr/Util/MatrixConventionsC.h create mode 100644 gfx/vr/osvr/Util/PlatformConfig.h create mode 100644 gfx/vr/osvr/Util/Pose3C.h create mode 100644 gfx/vr/osvr/Util/QuaternionC.h create mode 100644 gfx/vr/osvr/Util/QuatlibInteropC.h create mode 100644 gfx/vr/osvr/Util/RadialDistortionParametersC.h create mode 100644 gfx/vr/osvr/Util/RenderingTypesC.h create mode 100644 gfx/vr/osvr/Util/ReturnCodesC.h create mode 100644 gfx/vr/osvr/Util/StdInt.h create mode 100644 gfx/vr/osvr/Util/TimeValueC.h create mode 100644 gfx/vr/osvr/Util/Vec2C.h create mode 100644 gfx/vr/osvr/Util/Vec3C.h (limited to 'gfx/vr/osvr') diff --git a/gfx/vr/osvr/ClientKit/ClientKitC.h b/gfx/vr/osvr/ClientKit/ClientKitC.h new file mode 100644 index 000000000..8309e890d --- /dev/null +++ b/gfx/vr/osvr/ClientKit/ClientKitC.h @@ -0,0 +1,37 @@ +/** @file + @brief Header + + Must be c-safe! + + @date 2014 + + @author + Sensics, Inc. + +*/ + +/* +// Copyright 2014 Sensics, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +*/ + +#ifndef INCLUDED_ClientKitC_h_GUID_8D7DF104_892D_4CB5_2302_7C6BB5BC985C +#define INCLUDED_ClientKitC_h_GUID_8D7DF104_892D_4CB5_2302_7C6BB5BC985C + +#include +#include +#include +#include + +#endif diff --git a/gfx/vr/osvr/ClientKit/ContextC.h b/gfx/vr/osvr/ClientKit/ContextC.h new file mode 100644 index 000000000..e07e1b4a7 --- /dev/null +++ b/gfx/vr/osvr/ClientKit/ContextC.h @@ -0,0 +1,96 @@ +/** @file + @brief Header + + Must be c-safe! + + @todo Apply annotation macros + + @date 2014 + + @author + Sensics, Inc. + +*/ + +/* +// Copyright 2014 Sensics, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +*/ + +#ifndef INCLUDED_ContextC_h_GUID_3790F330_2425_4486_4C9F_20C300D7DED3 +#define INCLUDED_ContextC_h_GUID_3790F330_2425_4486_4C9F_20C300D7DED3 + +/* Internal Includes */ +#include +#include +#include +#include +#include +#include + +/* Library/third-party includes */ +/* none */ + +/* Standard includes */ +/* none */ + +OSVR_EXTERN_C_BEGIN + +/** @addtogroup ClientKit + @{ +*/ + +/** @brief Initialize the library. + + @param applicationIdentifier A null terminated string identifying your + application. Reverse DNS format strongly suggested. + @param flags initialization options (reserved) - pass 0 for now. + + @returns Client context - will be needed for subsequent calls +*/ +OSVR_CLIENTKIT_EXPORT OSVR_ClientContext osvrClientInit( + const char applicationIdentifier[], uint32_t flags OSVR_CPP_ONLY(= 0)); + +/** @brief Updates the state of the context - call regularly in your mainloop. + + @param ctx Client context +*/ +OSVR_CLIENTKIT_EXPORT OSVR_ReturnCode osvrClientUpdate(OSVR_ClientContext ctx); + +/** @brief Checks to see if the client context is fully started up and connected + properly to a server. + + If this reports that the client context is not OK, there may not be a server + running, or you may just have to call osvrClientUpdate() a few times to + permit startup to finish. The return value of this call will not change from + failure to success without calling osvrClientUpdate(). + + @param ctx Client context + + @return OSVR_RETURN_FAILURE if not yet fully connected/initialized, or if + some other error (null context) occurs. +*/ +OSVR_CLIENTKIT_EXPORT OSVR_ReturnCode +osvrClientCheckStatus(OSVR_ClientContext ctx); + +/** @brief Shutdown the library. + @param ctx Client context +*/ +OSVR_CLIENTKIT_EXPORT OSVR_ReturnCode +osvrClientShutdown(OSVR_ClientContext ctx); + +/** @} */ +OSVR_EXTERN_C_END + +#endif diff --git a/gfx/vr/osvr/ClientKit/DisplayC.h b/gfx/vr/osvr/ClientKit/DisplayC.h new file mode 100644 index 000000000..75155e6b3 --- /dev/null +++ b/gfx/vr/osvr/ClientKit/DisplayC.h @@ -0,0 +1,506 @@ +/** @file + @brief Header + + Must be c-safe! + + @date 2015 + + @author + Sensics, Inc. + +*/ + +/* +// Copyright 2015 Sensics, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +*/ + +#ifndef INCLUDED_DisplayC_h_GUID_8658EDC9_32A2_49A2_5F5C_10F67852AE74 +#define INCLUDED_DisplayC_h_GUID_8658EDC9_32A2_49A2_5F5C_10F67852AE74 + +/* Internal Includes */ +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/* Library/third-party includes */ +/* none */ + +/* Standard includes */ +/* none */ + +OSVR_EXTERN_C_BEGIN +/** @addtogroup ClientKit + @{ + @name Display API + @{ +*/ + +/** @brief Opaque type of a display configuration. */ +typedef struct OSVR_DisplayConfigObject *OSVR_DisplayConfig; + +/** @brief Allocates a display configuration object populated with data from the + OSVR system. + + Before this call will succeed, your application will need to be correctly + and fully connected to an OSVR server. You may consider putting this call in + a loop alternating with osvrClientUpdate() until this call succeeds. + + Data provided by a display configuration object: + + - The logical display topology (number and relationship of viewers, eyes, + and surfaces), which remains constant throughout the life of the + configuration object. (A method of notification of change here is TBD). + - Pose data for viewers (not required for rendering) and pose/view data for + eyes (used for rendering) which is based on tracker data: if used, these + should be queried every frame. + - Projection matrix data for surfaces, which while in current practice may + be relatively unchanging, we are not guaranteeing them to be constant: + these should be queried every frame. + - Video-input-relative viewport size/location for a surface: would like this + to be variable, but probably not feasible. If you have input, please + comment on the dev mailing list. + - Per-surface distortion strategy priorities/availabilities: constant. Note + the following, though... + - Per-surface distortion strategy parameters: variable, request each frame. + (Could make constant with a notification if needed?) + + Important note: While most of this data is immediately available if you are + successful in getting a display config object, the pose-based data (viewer + pose, eye pose, eye view matrix) needs tracker state, so at least one (and in + practice, typically more) osvrClientUpdate() must be performed before a new + tracker report is available to populate that state. See + osvrClientCheckDisplayStartup() to query if all startup data is available. + + @todo Decide if relative viewport should be constant in a display config, + and update docs accordingly. + + @todo Decide if distortion params should be constant in a display config, + and update docs accordingly. + + @return OSVR_RETURN_FAILURE if invalid parameters were passed or some other + error occurred, in which case the output argument is unmodified. +*/ +OSVR_CLIENTKIT_EXPORT OSVR_ReturnCode +osvrClientGetDisplay(OSVR_ClientContext ctx, OSVR_DisplayConfig *disp); + +/** @brief Frees a display configuration object. The corresponding context must + still be open. + + If you fail to call this, it will be automatically called as part of + clean-up when the corresponding context is closed. + + @return OSVR_RETURN_FAILURE if a null config was passed, or if the given + display object was already freed. +*/ +OSVR_CLIENTKIT_EXPORT OSVR_ReturnCode +osvrClientFreeDisplay(OSVR_DisplayConfig disp); + +/** @brief Checks to see if a display is fully configured and ready, including + having received its first pose update. + + Once this first succeeds, it will continue to succeed for the lifetime of + the display config object, so it is not necessary to keep calling once you + get a successful result. + + @return OSVR_RETURN_FAILURE if a null config was passed, or if the given + display config object was otherwise not ready for full use. +*/ +OSVR_CLIENTKIT_EXPORT OSVR_ReturnCode +osvrClientCheckDisplayStartup(OSVR_DisplayConfig disp); + +/** @brief A display config can have one or more display inputs to pass pixels + over (HDMI/DVI connections, etc): retrieve the number of display inputs in + the current configuration. + + @param disp Display config object. + @param[out] numDisplayInputs Number of display inputs in the logical display + topology, **constant** throughout the active, valid lifetime of a display + config object. + + @sa OSVR_DisplayInputCount + + @return OSVR_RETURN_FAILURE if invalid parameters were passed, in + which case the output argument is unmodified. +*/ +OSVR_CLIENTKIT_EXPORT OSVR_ReturnCode osvrClientGetNumDisplayInputs( + OSVR_DisplayConfig disp, OSVR_DisplayInputCount *numDisplayInputs); + +/** @brief Retrieve the pixel dimensions of a given display input for a display + config + + @param disp Display config object. + @param displayInputIndex The zero-based index of the display input. + @param[out] width Width (in pixels) of the display input. + @param[out] height Height (in pixels) of the display input. + + The out parameters are **constant** throughout the active, valid lifetime of + a display config object. + + @sa OSVR_DisplayDimension + + @return OSVR_RETURN_FAILURE if invalid parameters were passed, in + which case the output arguments are unmodified. +*/ +OSVR_CLIENTKIT_EXPORT OSVR_ReturnCode osvrClientGetDisplayDimensions( + OSVR_DisplayConfig disp, OSVR_DisplayInputCount displayInputIndex, + OSVR_DisplayDimension *width, OSVR_DisplayDimension *height); + +/** @brief A display config can have one (or theoretically more) viewers: + retrieve the viewer count. + + @param disp Display config object. + @param[out] viewers Number of viewers in the logical display topology, + **constant** throughout the active, valid lifetime of a display config + object. + + @sa OSVR_ViewerCount + + @return OSVR_RETURN_FAILURE if invalid parameters were passed, in which case + the output argument is unmodified. +*/ +OSVR_CLIENTKIT_EXPORT OSVR_ReturnCode +osvrClientGetNumViewers(OSVR_DisplayConfig disp, OSVR_ViewerCount *viewers); + +/** @brief Get the pose of a viewer in a display config. + + Note that there may not necessarily be any surfaces rendered from this pose + (it's the unused "center" eye in a stereo configuration, for instance) so + only use this if it makes integration into your engine or existing + applications (not originally designed for stereo) easier. + + Will only succeed if osvrClientCheckDisplayStartup() succeeds. + + @return OSVR_RETURN_FAILURE if invalid parameters were passed or no pose was + yet available, in which case the pose argument is unmodified. +*/ +OSVR_CLIENTKIT_EXPORT OSVR_ReturnCode osvrClientGetViewerPose( + OSVR_DisplayConfig disp, OSVR_ViewerCount viewer, OSVR_Pose3 *pose); + +/** @brief Each viewer in a display config can have one or more "eyes" which + have a substantially similar pose: get the count. + + @param disp Display config object. + @param viewer Viewer ID + @param[out] eyes Number of eyes for this viewer in the logical display + topology, **constant** throughout the active, valid lifetime of a display + config object + + @sa OSVR_EyeCount + + @return OSVR_RETURN_FAILURE if invalid parameters were passed, in which case + the output argument is unmodified. +*/ +OSVR_CLIENTKIT_EXPORT OSVR_ReturnCode osvrClientGetNumEyesForViewer( + OSVR_DisplayConfig disp, OSVR_ViewerCount viewer, OSVR_EyeCount *eyes); + +/** @brief Get the "viewpoint" for the given eye of a viewer in a display + config. + + Will only succeed if osvrClientCheckDisplayStartup() succeeds. + + @param disp Display config object + @param viewer Viewer ID + @param eye Eye ID + @param[out] pose Room-space pose (not relative to pose of the viewer) + + @return OSVR_RETURN_FAILURE if invalid parameters were passed or no pose was + yet available, in which case the pose argument is unmodified. +*/ +OSVR_CLIENTKIT_EXPORT OSVR_ReturnCode +osvrClientGetViewerEyePose(OSVR_DisplayConfig disp, OSVR_ViewerCount viewer, + OSVR_EyeCount eye, OSVR_Pose3 *pose); + +/** @brief Get the view matrix (inverse of pose) for the given eye of a + viewer in a display config - matrix of **doubles**. + + Will only succeed if osvrClientCheckDisplayStartup() succeeds. + + @param disp Display config object + @param viewer Viewer ID + @param eye Eye ID + @param flags Bitwise OR of matrix convention flags (see @ref MatrixFlags) + @param[out] mat Pass a double[::OSVR_MATRIX_SIZE] to get the transformation + matrix from room space to eye space (not relative to pose of the viewer) + + @return OSVR_RETURN_FAILURE if invalid parameters were passed or no pose was + yet available, in which case the output argument is unmodified. +*/ +OSVR_CLIENTKIT_EXPORT OSVR_ReturnCode osvrClientGetViewerEyeViewMatrixd( + OSVR_DisplayConfig disp, OSVR_ViewerCount viewer, OSVR_EyeCount eye, + OSVR_MatrixConventions flags, double *mat); + +/** @brief Get the view matrix (inverse of pose) for the given eye of a + viewer in a display config - matrix of **floats**. + + Will only succeed if osvrClientCheckDisplayStartup() succeeds. + + @param disp Display config object + @param viewer Viewer ID + @param eye Eye ID + @param flags Bitwise OR of matrix convention flags (see @ref MatrixFlags) + @param[out] mat Pass a float[::OSVR_MATRIX_SIZE] to get the transformation + matrix from room space to eye space (not relative to pose of the viewer) + + @return OSVR_RETURN_FAILURE if invalid parameters were passed or no pose was + yet available, in which case the output argument is unmodified. +*/ +OSVR_CLIENTKIT_EXPORT OSVR_ReturnCode osvrClientGetViewerEyeViewMatrixf( + OSVR_DisplayConfig disp, OSVR_ViewerCount viewer, OSVR_EyeCount eye, + OSVR_MatrixConventions flags, float *mat); + +/** @brief Each eye of each viewer in a display config has one or more surfaces + (aka "screens") on which content should be rendered. + + @param disp Display config object + @param viewer Viewer ID + @param eye Eye ID + @param[out] surfaces Number of surfaces (numbered [0, surfaces - 1]) for the + given viewer and eye. **Constant** throughout the active, valid lifetime of + a display config object. + + @sa OSVR_SurfaceCount + + @return OSVR_RETURN_FAILURE if invalid parameters were passed, in which case + the output argument is unmodified. +*/ +OSVR_CLIENTKIT_EXPORT OSVR_ReturnCode osvrClientGetNumSurfacesForViewerEye( + OSVR_DisplayConfig disp, OSVR_ViewerCount viewer, OSVR_EyeCount eye, + OSVR_SurfaceCount *surfaces); + +/** @brief Get the dimensions/location of the viewport **within the display + input** for a surface seen by an eye of a viewer in a display config. (This + does not include other video inputs that may be on a single virtual desktop, + etc. or explicitly account for display configurations that use multiple + video inputs. It does not necessarily indicate that a viewport in the sense + of glViewport must be created with these parameters, though the parameter + order matches for convenience.) + + @param disp Display config object + @param viewer Viewer ID + @param eye Eye ID + @param surface Surface ID + @param[out] left Output: Distance in pixels from the left of the video input + to the left of the viewport. + @param[out] bottom Output: Distance in pixels from the bottom of the video + input to the bottom of the viewport. + @param[out] width Output: Width of viewport in pixels. + @param[out] height Output: Height of viewport in pixels. + + + @return OSVR_RETURN_FAILURE if invalid parameters were passed, in which case + the output arguments are unmodified. +*/ +OSVR_CLIENTKIT_EXPORT OSVR_ReturnCode +osvrClientGetRelativeViewportForViewerEyeSurface( + OSVR_DisplayConfig disp, OSVR_ViewerCount viewer, OSVR_EyeCount eye, + OSVR_SurfaceCount surface, OSVR_ViewportDimension *left, + OSVR_ViewportDimension *bottom, OSVR_ViewportDimension *width, + OSVR_ViewportDimension *height); + +/** @brief Get the index of the display input for a surface seen by an eye of a + viewer in a display config. + + This is the OSVR-assigned display input: it may not (and in practice, + usually will not) match any platform-specific display indices. This function + exists to associate surfaces with video inputs as enumerated by + osvrClientGetNumDisplayInputs(). + + @param disp Display config object + @param viewer Viewer ID + @param eye Eye ID + @param surface Surface ID + @param[out] displayInput Zero-based index of the display input pixels for + this surface are tranmitted over. + + This association is **constant** throughout the active, valid lifetime of a + display config object. + + @sa osvrClientGetNumDisplayInputs(), + osvrClientGetRelativeViewportForViewerEyeSurface() + + @return OSVR_RETURN_FAILURE if invalid parameters were passed, in which + case the output argument is unmodified. + */ +OSVR_CLIENTKIT_EXPORT OSVR_ReturnCode +osvrClientGetViewerEyeSurfaceDisplayInputIndex( + OSVR_DisplayConfig disp, OSVR_ViewerCount viewer, OSVR_EyeCount eye, + OSVR_SurfaceCount surface, OSVR_DisplayInputCount *displayInput); + +/** @brief Get the projection matrix for a surface seen by an eye of a viewer + in a display config. (double version) + + @param disp Display config object + @param viewer Viewer ID + @param eye Eye ID + @param surface Surface ID + @param near Distance from viewpoint to near clipping plane - must be + positive. + @param far Distance from viewpoint to far clipping plane - must be positive + and not equal to near, typically greater than near. + @param flags Bitwise OR of matrix convention flags (see @ref MatrixFlags) + @param[out] matrix Output projection matrix: supply an array of 16 + (::OSVR_MATRIX_SIZE) doubles. + + @return OSVR_RETURN_FAILURE if invalid parameters were passed, in which case + the output argument is unmodified. +*/ +OSVR_CLIENTKIT_EXPORT OSVR_ReturnCode +osvrClientGetViewerEyeSurfaceProjectionMatrixd( + OSVR_DisplayConfig disp, OSVR_ViewerCount viewer, OSVR_EyeCount eye, + OSVR_SurfaceCount surface, double near, double far, + OSVR_MatrixConventions flags, double *matrix); + +/** @brief Get the projection matrix for a surface seen by an eye of a viewer + in a display config. (float version) + + @param disp Display config object + @param viewer Viewer ID + @param eye Eye ID + @param surface Surface ID + @param near Distance to near clipping plane - must be nonzero, typically + positive. + @param far Distance to far clipping plane - must be nonzero, typically + positive and greater than near. + @param flags Bitwise OR of matrix convention flags (see @ref MatrixFlags) + @param[out] matrix Output projection matrix: supply an array of 16 + (::OSVR_MATRIX_SIZE) floats. + + @return OSVR_RETURN_FAILURE if invalid parameters were passed, in which case + the output argument is unmodified. +*/ +OSVR_CLIENTKIT_EXPORT OSVR_ReturnCode +osvrClientGetViewerEyeSurfaceProjectionMatrixf( + OSVR_DisplayConfig disp, OSVR_ViewerCount viewer, OSVR_EyeCount eye, + OSVR_SurfaceCount surface, float near, float far, + OSVR_MatrixConventions flags, float *matrix); + +/** @brief Get the clipping planes (positions at unit distance) for a surface + seen by an eye of a viewer + in a display config. + + This is only for use in integrations that cannot accept a fully-formulated + projection matrix as returned by + osvrClientGetViewerEyeSurfaceProjectionMatrixf() or + osvrClientGetViewerEyeSurfaceProjectionMatrixd(), and may not necessarily + provide the same optimizations. + + As all the planes are given at unit (1) distance, before passing these + planes to a consuming function in your application/engine, you will typically + divide them by your near clipping plane distance. + + @param disp Display config object + @param viewer Viewer ID + @param eye Eye ID + @param surface Surface ID + @param[out] left Distance to left clipping plane + @param[out] right Distance to right clipping plane + @param[out] bottom Distance to bottom clipping plane + @param[out] top Distance to top clipping plane + + @return OSVR_RETURN_FAILURE if invalid parameters were passed, in which case + the output arguments are unmodified. +*/ +OSVR_CLIENTKIT_EXPORT OSVR_ReturnCode +osvrClientGetViewerEyeSurfaceProjectionClippingPlanes( + OSVR_DisplayConfig disp, OSVR_ViewerCount viewer, OSVR_EyeCount eye, + OSVR_SurfaceCount surface, double *left, double *right, double *bottom, + double *top); + +/** @brief Determines if a surface seen by an eye of a viewer in a display + config requests some distortion to be performed. + + This simply reports true or false, and does not specify which kind of + distortion implementations have been parameterized for this display. For + each distortion implementation your application supports, you'll want to + call the corresponding priority function to find out if it is available. + + @param disp Display config object + @param viewer Viewer ID + @param eye Eye ID + @param surface Surface ID + @param[out] distortionRequested Output parameter: whether distortion is + requested. **Constant** throughout the active, valid lifetime of a display + config object. + + @return OSVR_RETURN_FAILURE if invalid parameters were passed, in which case + the output argument is unmodified. +*/ +OSVR_CLIENTKIT_EXPORT OSVR_ReturnCode +osvrClientDoesViewerEyeSurfaceWantDistortion(OSVR_DisplayConfig disp, + OSVR_ViewerCount viewer, + OSVR_EyeCount eye, + OSVR_SurfaceCount surface, + OSVR_CBool *distortionRequested); + +/** @brief Returns the priority/availability of radial distortion parameters for + a surface seen by an eye of a viewer in a display config. + + If osvrClientDoesViewerEyeSurfaceWantDistortion() reports false, then the + display does not request distortion of any sort, and thus neither this nor + any other distortion strategy priority function will report an "available" + priority. + + @param disp Display config object + @param viewer Viewer ID + @param eye Eye ID + @param surface Surface ID + @param[out] priority Output: the priority level. Negative values + (canonically OSVR_DISTORTION_PRIORITY_UNAVAILABLE) indicate this technique + not available, higher values indicate higher preference for the given + technique based on the device's description. **Constant** throughout the + active, valid lifetime of a display config object. + + @return OSVR_RETURN_FAILURE if invalid parameters were passed, in which case + the output argument is unmodified. +*/ +OSVR_CLIENTKIT_EXPORT OSVR_ReturnCode +osvrClientGetViewerEyeSurfaceRadialDistortionPriority( + OSVR_DisplayConfig disp, OSVR_ViewerCount viewer, OSVR_EyeCount eye, + OSVR_SurfaceCount surface, OSVR_DistortionPriority *priority); + +/** @brief Returns the radial distortion parameters, if known/requested, for a + surface seen by an eye of a viewer in a display config. + + Will only succeed if osvrClientGetViewerEyeSurfaceRadialDistortionPriority() + reports a non-negative priority. + + @param disp Display config object + @param viewer Viewer ID + @param eye Eye ID + @param surface Surface ID + @param[out] params Output: the parameters for radial distortion + + @return OSVR_RETURN_FAILURE if this surface does not have these parameters + described, or if invalid parameters were passed, in which case the output + argument is unmodified. +*/ +OSVR_CLIENTKIT_EXPORT OSVR_ReturnCode +osvrClientGetViewerEyeSurfaceRadialDistortion( + OSVR_DisplayConfig disp, OSVR_ViewerCount viewer, OSVR_EyeCount eye, + OSVR_SurfaceCount surface, OSVR_RadialDistortionParameters *params); + +/** @} + @} +*/ + +OSVR_EXTERN_C_END + +#endif diff --git a/gfx/vr/osvr/ClientKit/Export.h b/gfx/vr/osvr/ClientKit/Export.h new file mode 100644 index 000000000..94d5f44f4 --- /dev/null +++ b/gfx/vr/osvr/ClientKit/Export.h @@ -0,0 +1,138 @@ +/** @file + @brief Automatically-generated export header - do not edit! + + @date 2016 + + @author + Sensics, Inc. + +*/ + +// Copyright 2016 Sensics, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef OSVR_CLIENTKIT_EXPORT_H +#define OSVR_CLIENTKIT_EXPORT_H + +#ifdef OSVR_CLIENTKIT_STATIC_DEFINE +# define OSVR_CLIENTKIT_EXPORT +# define OSVR_CLIENTKIT_NO_EXPORT +#endif + +/* Per-compiler advance preventative definition */ +#if defined(__BORLANDC__) || defined(__CODEGEARC__) || defined(__HP_aCC) || \ + defined(__PGI) || defined(__WATCOMC__) +/* Compilers that don't support deprecated, according to CMake. */ +# ifndef OSVR_CLIENTKIT_DEPRECATED +# define OSVR_CLIENTKIT_DEPRECATED +# endif +#endif + +/* Check for attribute support */ +#if defined(__INTEL_COMPILER) +/* Checking before GNUC because Intel implements GNU extensions, + * so it chooses to define __GNUC__ as well. */ +# if __INTEL_COMPILER >= 1200 +/* Intel compiler 12.0 or newer can handle these attributes per CMake */ +# define OSVR_CLIENTKIT_EXPORT_HEADER_SUPPORTS_ATTRIBUTES +# endif + +#elif defined(__GNUC__) +# if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 2)) +/* GCC 4.2+ */ +# define OSVR_CLIENTKIT_EXPORT_HEADER_SUPPORTS_ATTRIBUTES +# endif +#endif + +/* Per-platform defines */ +#if defined(_MSC_VER) +/* MSVC on Windows */ + +#ifndef OSVR_CLIENTKIT_EXPORT +# ifdef osvrClientKit_EXPORTS + /* We are building this library */ +# define OSVR_CLIENTKIT_EXPORT __declspec(dllexport) +# else + /* We are using this library */ +# define OSVR_CLIENTKIT_EXPORT __declspec(dllimport) +# endif +#endif + +#ifndef OSVR_CLIENTKIT_DEPRECATED +# define OSVR_CLIENTKIT_DEPRECATED __declspec(deprecated) +#endif + +#elif defined(_WIN32) && defined(__GNUC__) +/* GCC-compatible on Windows */ + +#ifndef OSVR_CLIENTKIT_EXPORT +# ifdef osvrClientKit_EXPORTS + /* We are building this library */ +# define OSVR_CLIENTKIT_EXPORT __attribute__((dllexport)) +# else + /* We are using this library */ +# define OSVR_CLIENTKIT_EXPORT __attribute__((dllimport)) +# endif +#endif + +#ifndef OSVR_CLIENTKIT_DEPRECATED +# define OSVR_CLIENTKIT_DEPRECATED __attribute__((__deprecated__)) +#endif + +#elif defined(OSVR_CLIENTKIT_EXPORT_HEADER_SUPPORTS_ATTRIBUTES) || \ + (defined(__APPLE__) && defined(__MACH__)) +/* GCC4.2+ compatible (assuming something *nix-like) and Mac OS X */ +/* (The first macro is defined at the top of the file, if applicable) */ +/* see https://gcc.gnu.org/wiki/Visibility */ + +#ifndef OSVR_CLIENTKIT_EXPORT + /* We are building/using this library */ +# define OSVR_CLIENTKIT_EXPORT __attribute__((visibility("default"))) +#endif + +#ifndef OSVR_CLIENTKIT_NO_EXPORT +# define OSVR_CLIENTKIT_NO_EXPORT __attribute__((visibility("hidden"))) +#endif + +#ifndef OSVR_CLIENTKIT_DEPRECATED +# define OSVR_CLIENTKIT_DEPRECATED __attribute__((__deprecated__)) +#endif + +#endif +/* End of platform ifdefs */ + +/* fallback def */ +#ifndef OSVR_CLIENTKIT_EXPORT +# define OSVR_CLIENTKIT_EXPORT +#endif + +/* fallback def */ +#ifndef OSVR_CLIENTKIT_NO_EXPORT +# define OSVR_CLIENTKIT_NO_EXPORT +#endif + +/* fallback def */ +#ifndef OSVR_CLIENTKIT_DEPRECATED_EXPORT +# define OSVR_CLIENTKIT_DEPRECATED_EXPORT OSVR_CLIENTKIT_EXPORT OSVR_CLIENTKIT_DEPRECATED +#endif + +/* fallback def */ +#ifndef OSVR_CLIENTKIT_DEPRECATED_NO_EXPORT +# define OSVR_CLIENTKIT_DEPRECATED_NO_EXPORT OSVR_CLIENTKIT_NO_EXPORT OSVR_CLIENTKIT_DEPRECATED +#endif + +/* Clean up after ourselves */ +#undef OSVR_CLIENTKIT_EXPORT_HEADER_SUPPORTS_ATTRIBUTES + +#endif diff --git a/gfx/vr/osvr/ClientKit/InterfaceC.h b/gfx/vr/osvr/ClientKit/InterfaceC.h new file mode 100644 index 000000000..728350536 --- /dev/null +++ b/gfx/vr/osvr/ClientKit/InterfaceC.h @@ -0,0 +1,75 @@ +/** @file + @brief Header + + Must be c-safe! + + @date 2014 + + @author + Sensics, Inc. + +*/ + +/* +// Copyright 2014 Sensics, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +*/ + +#ifndef INCLUDED_InterfaceC_h_GUID_D90BBAA6_AD62_499D_C023_2F6ED8987C17 +#define INCLUDED_InterfaceC_h_GUID_D90BBAA6_AD62_499D_C023_2F6ED8987C17 + +/* Internal Includes */ +#include +#include +#include +#include +#include + +/* Library/third-party includes */ +/* none */ + +/* Standard includes */ +/* none */ + +OSVR_EXTERN_C_BEGIN +/** @addtogroup ClientKit +@{ +*/ + +/** @brief Get the interface associated with the given path. + @param ctx Client context + @param path A resource path (null-terminated string) + @param[out] iface The interface object. May be freed when no longer needed, + otherwise it will be freed when the context is closed. +*/ +OSVR_CLIENTKIT_EXPORT OSVR_ReturnCode +osvrClientGetInterface(OSVR_ClientContext ctx, const char path[], + OSVR_ClientInterface *iface); + +/** @brief Free an interface object before context closure. + + @param ctx Client context + @param iface The interface object + + @returns OSVR_RETURN_SUCCESS unless a null context or interface was passed + or the given interface was not found in the context (i.e. had already been + freed) +*/ +OSVR_CLIENTKIT_EXPORT OSVR_ReturnCode +osvrClientFreeInterface(OSVR_ClientContext ctx, OSVR_ClientInterface iface); + +/** @} */ +OSVR_EXTERN_C_END + +#endif diff --git a/gfx/vr/osvr/ClientKit/InterfaceCallbackC.h b/gfx/vr/osvr/ClientKit/InterfaceCallbackC.h new file mode 100644 index 000000000..dde1cef97 --- /dev/null +++ b/gfx/vr/osvr/ClientKit/InterfaceCallbackC.h @@ -0,0 +1,77 @@ +/** @file + @brief Header + + Must be c-safe! + + @date 2014 + + @author + Sensics, Inc. + +*/ + +/* +// Copyright 2014 Sensics, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +*/ + +#ifndef INCLUDED_InterfaceCallbacksC_h_GUID_8F16E6CB_F998_4ABC_5B6B_4FC1E4B71BC9 +#define INCLUDED_InterfaceCallbacksC_h_GUID_8F16E6CB_F998_4ABC_5B6B_4FC1E4B71BC9 + +/* Internal Includes */ +#include +#include +#include +#include +#include +#include + +/* Library/third-party includes */ +/* none */ + +/* Standard includes */ +/* none */ + +OSVR_EXTERN_C_BEGIN + +#define OSVR_INTERFACE_CALLBACK_METHOD(TYPE) \ + /** @brief Register a callback for TYPE reports on an interface */ \ + OSVR_CLIENTKIT_EXPORT OSVR_ReturnCode osvrRegister##TYPE##Callback( \ + OSVR_ClientInterface iface, OSVR_##TYPE##Callback cb, void *userdata); + +OSVR_INTERFACE_CALLBACK_METHOD(Pose) +OSVR_INTERFACE_CALLBACK_METHOD(Position) +OSVR_INTERFACE_CALLBACK_METHOD(Orientation) +OSVR_INTERFACE_CALLBACK_METHOD(Velocity) +OSVR_INTERFACE_CALLBACK_METHOD(LinearVelocity) +OSVR_INTERFACE_CALLBACK_METHOD(AngularVelocity) +OSVR_INTERFACE_CALLBACK_METHOD(Acceleration) +OSVR_INTERFACE_CALLBACK_METHOD(LinearAcceleration) +OSVR_INTERFACE_CALLBACK_METHOD(AngularAcceleration) +OSVR_INTERFACE_CALLBACK_METHOD(Button) +OSVR_INTERFACE_CALLBACK_METHOD(Analog) +OSVR_INTERFACE_CALLBACK_METHOD(Imaging) +OSVR_INTERFACE_CALLBACK_METHOD(Location2D) +OSVR_INTERFACE_CALLBACK_METHOD(Direction) +OSVR_INTERFACE_CALLBACK_METHOD(EyeTracker2D) +OSVR_INTERFACE_CALLBACK_METHOD(EyeTracker3D) +OSVR_INTERFACE_CALLBACK_METHOD(EyeTrackerBlink) +OSVR_INTERFACE_CALLBACK_METHOD(NaviVelocity) +OSVR_INTERFACE_CALLBACK_METHOD(NaviPosition) + +#undef OSVR_INTERFACE_CALLBACK_METHOD + +OSVR_EXTERN_C_END + +#endif diff --git a/gfx/vr/osvr/ClientKit/InterfaceStateC.h b/gfx/vr/osvr/ClientKit/InterfaceStateC.h new file mode 100644 index 000000000..edf9f085c --- /dev/null +++ b/gfx/vr/osvr/ClientKit/InterfaceStateC.h @@ -0,0 +1,79 @@ +/** @file + @brief Header + + Must be c-safe! + + @date 2014 + + @author + Sensics, Inc. + +*/ + +/* +// Copyright 2014 Sensics, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +*/ + +#ifndef INCLUDED_InterfaceStateC_h_GUID_8F85D178_74B9_4AA9_4E9E_243089411408 +#define INCLUDED_InterfaceStateC_h_GUID_8F85D178_74B9_4AA9_4E9E_243089411408 + +/* Internal Includes */ +#include +#include +#include +#include +#include +#include +#include + +/* Library/third-party includes */ +/* none */ + +/* Standard includes */ +/* none */ + +OSVR_EXTERN_C_BEGIN + +#define OSVR_CALLBACK_METHODS(TYPE) \ + /** @brief Get TYPE state from an interface, returning failure if none \ + * exists */ \ + OSVR_CLIENTKIT_EXPORT OSVR_ReturnCode osvrGet##TYPE##State( \ + OSVR_ClientInterface iface, struct OSVR_TimeValue *timestamp, \ + OSVR_##TYPE##State *state); + +OSVR_CALLBACK_METHODS(Pose) +OSVR_CALLBACK_METHODS(Position) +OSVR_CALLBACK_METHODS(Orientation) +OSVR_CALLBACK_METHODS(Velocity) +OSVR_CALLBACK_METHODS(LinearVelocity) +OSVR_CALLBACK_METHODS(AngularVelocity) +OSVR_CALLBACK_METHODS(Acceleration) +OSVR_CALLBACK_METHODS(LinearAcceleration) +OSVR_CALLBACK_METHODS(AngularAcceleration) +OSVR_CALLBACK_METHODS(Button) +OSVR_CALLBACK_METHODS(Analog) +OSVR_CALLBACK_METHODS(Location2D) +OSVR_CALLBACK_METHODS(Direction) +OSVR_CALLBACK_METHODS(EyeTracker2D) +OSVR_CALLBACK_METHODS(EyeTracker3D) +OSVR_CALLBACK_METHODS(EyeTrackerBlink) +OSVR_CALLBACK_METHODS(NaviVelocity) +OSVR_CALLBACK_METHODS(NaviPosition) + +#undef OSVR_CALLBACK_METHODS + +OSVR_EXTERN_C_END + +#endif diff --git a/gfx/vr/osvr/ClientKit/SystemCallbackC.h b/gfx/vr/osvr/ClientKit/SystemCallbackC.h new file mode 100644 index 000000000..2476d5f21 --- /dev/null +++ b/gfx/vr/osvr/ClientKit/SystemCallbackC.h @@ -0,0 +1,47 @@ +/** @file + @brief Header + + Must be c-safe! + + @date 2014 + + @author + Sensics, Inc. + +*/ + +/* +// Copyright 2014 Sensics, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +*/ + +#ifndef INCLUDED_SystemCallbackC_h_GUID_543F3F04_343E_4389_08A0_DEA988EC23F7 +#define INCLUDED_SystemCallbackC_h_GUID_543F3F04_343E_4389_08A0_DEA988EC23F7 + +/* Internal Includes */ +#include +#include +#include +#include + +/* Library/third-party includes */ +/* none */ + +/* Standard includes */ +/* none */ + +OSVR_EXTERN_C_BEGIN +OSVR_EXTERN_C_END + +#endif diff --git a/gfx/vr/osvr/ClientKit/TransformsC.h b/gfx/vr/osvr/ClientKit/TransformsC.h new file mode 100644 index 000000000..183497dfd --- /dev/null +++ b/gfx/vr/osvr/ClientKit/TransformsC.h @@ -0,0 +1,75 @@ +/** @file + @brief Header controlling the OSVR transformation hierarchy + + Must be c-safe! + + @date 2015 + + @author + Sensics, Inc. + +*/ + +/* +// Copyright 2015 Sensics, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +*/ + +#ifndef INCLUDED_TransformsC_h_GUID_5B5B7438_42D4_4095_E48A_90E2CC13498E +#define INCLUDED_TransformsC_h_GUID_5B5B7438_42D4_4095_E48A_90E2CC13498E + +/* Internal Includes */ +#include +#include +#include +#include + +/* Library/third-party includes */ +/* none */ + +/* Standard includes */ +/* none */ + +OSVR_EXTERN_C_BEGIN + +/** @addtogroup ClientKit + @{ +*/ + +/** @brief Updates the internal "room to world" transformation (applied to all + tracker data for this client context instance) based on the user's head + orientation, so that the direction the user is facing becomes -Z to your + application. Only rotates about the Y axis (yaw). + + Note that this method internally calls osvrClientUpdate() to get a head pose + so your callbacks may be called during its execution! + + @param ctx Client context +*/ +OSVR_CLIENTKIT_EXPORT OSVR_ReturnCode +osvrClientSetRoomRotationUsingHead(OSVR_ClientContext ctx); + +/** @brief Clears/resets the internal "room to world" transformation back to an + identity transformation - that is, clears the effect of any other + manipulation of the room to world transform. + + @param ctx Client context +*/ +OSVR_CLIENTKIT_EXPORT OSVR_ReturnCode +osvrClientClearRoomToWorldTransform(OSVR_ClientContext ctx); + +/** @} */ +OSVR_EXTERN_C_END + +#endif diff --git a/gfx/vr/osvr/Util/APIBaseC.h b/gfx/vr/osvr/Util/APIBaseC.h new file mode 100644 index 000000000..4abe38550 --- /dev/null +++ b/gfx/vr/osvr/Util/APIBaseC.h @@ -0,0 +1,50 @@ +/** @file + @brief Header providing basic C macros for defining API headers. + + Must be c-safe! + + @date 2014 + + @author + Sensics, Inc. + +*/ + +/* +// Copyright 2014 Sensics, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +*/ + +#ifndef INCLUDED_APIBaseC_h_GUID_C5A2E769_2ADC_429E_D250_DF0883E6E5DB +#define INCLUDED_APIBaseC_h_GUID_C5A2E769_2ADC_429E_D250_DF0883E6E5DB + +#ifdef __cplusplus +#define OSVR_C_ONLY(X) +#define OSVR_CPP_ONLY(X) X +#define OSVR_EXTERN_C_BEGIN extern "C" { +#define OSVR_EXTERN_C_END } +#define OSVR_INLINE inline +#else +#define OSVR_C_ONLY(X) X +#define OSVR_CPP_ONLY(X) +#define OSVR_EXTERN_C_BEGIN +#define OSVR_EXTERN_C_END +#ifdef _MSC_VER +#define OSVR_INLINE static __inline +#else +#define OSVR_INLINE static inline +#endif +#endif + +#endif diff --git a/gfx/vr/osvr/Util/AnnotationMacrosC.h b/gfx/vr/osvr/Util/AnnotationMacrosC.h new file mode 100644 index 000000000..e086608c1 --- /dev/null +++ b/gfx/vr/osvr/Util/AnnotationMacrosC.h @@ -0,0 +1,232 @@ +/** @file + @brief Header containing macros for source-level annotation. + + In theory, supporting MSVC SAL, as well as compatible GCC and + Clang attributes. In practice, expanded as time allows and requires. + + Must be c-safe! + + @date 2014 + + @author + Sensics, Inc. + +*/ + +/* +// Copyright 2014 Sensics, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +*/ + +#ifndef INCLUDED_AnnotationMacrosC_h_GUID_48538D9B_35E3_4E9A_D2B0_D83D51DD5900 +#define INCLUDED_AnnotationMacrosC_h_GUID_48538D9B_35E3_4E9A_D2B0_D83D51DD5900 + +#ifndef OSVR_DISABLE_ANALYSIS + +#if defined(_MSC_VER) && (_MSC_VER >= 1700) +/* Visual C++ (2012 and newer) */ +/* Using SAL attribute format: + * http://msdn.microsoft.com/en-us/library/ms182032(v=vs.120).aspx */ + +#include + +#define OSVR_IN _In_ +#define OSVR_IN_PTR _In_ +#define OSVR_IN_OPT _In_opt_ +#define OSVR_IN_STRZ _In_z_ +#define OSVR_IN_READS(NUM_ELEMENTS) _In_reads_(NUM_ELEMENTS) + +#define OSVR_OUT _Out_ +#define OSVR_OUT_PTR _Outptr_ +#define OSVR_OUT_OPT _Out_opt_ + +#define OSVR_INOUT _Inout_ +#define OSVR_INOUT_PTR _Inout_ + +#define OSVR_RETURN_WARN_UNUSED _Must_inspect_result_ +#define OSVR_RETURN_SUCCESS_CONDITION(X) _Return_type_success_(X) + +/* end of msvc section */ +#elif defined(__GNUC__) && (__GNUC__ >= 4) +/* section for GCC and GCC-alikes */ + +#if defined(__clang__) +/* clang-specific section */ +#endif + +#define OSVR_FUNC_NONNULL(X) __attribute__((__nonnull__ X)) +#define OSVR_RETURN_WARN_UNUSED __attribute__((warn_unused_result)) + +/* end of gcc section and compiler detection */ +#endif + +/* end of ndef disable analysis */ +#endif + +/* Fallback declarations */ +/** +@defgroup annotation_macros Static analysis annotation macros +@brief Wrappers for Microsoft's SAL annotations and others +@ingroup Util + +Use of these is optional, but recommended particularly for C APIs, +as well as any methods handling a buffer with a length. +@{ +*/ +/** @name Parameter annotations + + These indicate the role and valid values for parameters to functions. + + At most one of these should be placed before a parameter's type name in the + function parameter list, in both the declaration and definition. (They must + match!) + @{ +*/ +/** @def OSVR_IN + @brief Indicates a required function parameter that serves only as input. +*/ +#ifndef OSVR_IN +#define OSVR_IN +#endif + +/** @def OSVR_IN_PTR + @brief Indicates a required pointer (non-null) function parameter that + serves only as input. +*/ +#ifndef OSVR_IN_PTR +#define OSVR_IN_PTR +#endif + +/** @def OSVR_IN_OPT + @brief Indicates a function parameter (pointer) that serves only as input, + but is optional and might be NULL. +*/ +#ifndef OSVR_IN_OPT +#define OSVR_IN_OPT +#endif + +/** @def OSVR_IN_STRZ + @brief Indicates a null-terminated string function parameter that serves + only as input. +*/ +#ifndef OSVR_IN_STRZ +#define OSVR_IN_STRZ +#endif + +/** @def OSVR_IN_READS(NUM_ELEMENTS) + @brief Indicates a buffer containing input with the specified number of + elements. + + The specified number of elements is typically the name of another parameter. +*/ +#ifndef OSVR_IN_READS +#define OSVR_IN_READS(NUM_ELEMENTS) +#endif + +/** @def OSVR_OUT + @brief Indicates a required function parameter that serves only as output. + In C code, since this usually means "pointer", you probably want + OSVR_OUT_PTR instead. +*/ +#ifndef OSVR_OUT +#define OSVR_OUT +#endif + +/** @def OSVR_OUT_PTR + @brief Indicates a required pointer (non-null) function parameter that + serves only as output. +*/ +#ifndef OSVR_OUT_PTR +#define OSVR_OUT_PTR +#endif + +/** @def OSVR_OUT_OPT + @brief Indicates a function parameter (pointer) that serves only as output, + but is optional and might be NULL +*/ +#ifndef OSVR_OUT_OPT +#define OSVR_OUT_OPT +#endif + +/** @def OSVR_INOUT + @brief Indicates a required function parameter that is both read and written + to. + + In C code, since this usually means "pointer", you probably want + OSVR_INOUT_PTR instead. +*/ +#ifndef OSVR_INOUT +#define OSVR_INOUT +#endif + +/** @def OSVR_INOUT_PTR + @brief Indicates a required pointer (non-null) function parameter that is + both read and written to. +*/ +#ifndef OSVR_INOUT_PTR +#define OSVR_INOUT_PTR +#endif + +/* End of parameter annotations. */ +/** @} */ + +/** @name Function annotations + + These indicate particular relevant aspects about a function. Some + duplicate the effective meaning of parameter annotations: applying both + allows the fullest extent of static analysis tools to analyze the code, + and in some compilers, generate warnings. + + @{ +*/ +/** @def OSVR_FUNC_NONNULL(X) + @brief Indicates the parameter(s) that must be non-null. + + @param X A parenthesized list of parameters by number (1-based index) + + Should be placed after a function declaration (but before the + semicolon). Repeating in the definition is not needed. +*/ +#ifndef OSVR_FUNC_NONNULL +#define OSVR_FUNC_NONNULL(X) +#endif + +/** @def OSVR_RETURN_WARN_UNUSED + @brief Indicates the function has a return value that must be used (either a + security problem or an obvious bug if not). + + Should be placed before the return value (and virtual keyword, if + applicable) in both declaration and definition. +*/ +#ifndef OSVR_RETURN_WARN_UNUSED +#define OSVR_RETURN_WARN_UNUSED +#endif +/* End of function annotations. */ +/** @} */ + +/** @def OSVR_RETURN_SUCCESS_CONDITION + @brief Applied to a typedef, indicates the condition for `return` under + which a function returning it should be considered to have succeeded (thus + holding certain specifications). + + Should be placed before the typename in a typedef, with the parameter + including the keyword `return` to substitute for the return value. +*/ +#ifndef OSVR_RETURN_SUCCESS_CONDITION +#define OSVR_RETURN_SUCCESS_CONDITION(X) +#endif + +/* End of annotation group. */ +/** @} */ +#endif diff --git a/gfx/vr/osvr/Util/BoolC.h b/gfx/vr/osvr/Util/BoolC.h new file mode 100644 index 000000000..b50ec7cfd --- /dev/null +++ b/gfx/vr/osvr/Util/BoolC.h @@ -0,0 +1,59 @@ +/** @file + @brief Header providing a C-safe "bool" type, because we can't depend on + Visual Studio providing proper C99 support in external-facing APIs. + + Must be c-safe! + + @date 2015 + + @author + Sensics, Inc. + +*/ + +/* +// Copyright 2015 Sensics, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +*/ + +#ifndef INCLUDED_BoolC_h_GUID_4F97BE90_2758_4BA5_B0FC_0CA92DEBA210 +#define INCLUDED_BoolC_h_GUID_4F97BE90_2758_4BA5_B0FC_0CA92DEBA210 + +/* Internal Includes */ +#include +#include + +/* Library/third-party includes */ +/* none */ + +/* Standard includes */ +/* none */ + +OSVR_EXTERN_C_BEGIN +/** @addtogroup Util +@{ +*/ + +/** @brief A pre-C99-safe bool type. Canonical values for true and false are + * provided. Interpretation of other values is not defined. */ +typedef uint8_t OSVR_CBool; +/** @brief Canonical "true" value for OSVR_CBool */ +#define OSVR_TRUE (1) +/** @brief Canonical "false" value for OSVR_CBool */ +#define OSVR_FALSE (0) + +/** @} */ +OSVR_EXTERN_C_END + +#endif diff --git a/gfx/vr/osvr/Util/ChannelCountC.h b/gfx/vr/osvr/Util/ChannelCountC.h new file mode 100644 index 000000000..dc49b3b17 --- /dev/null +++ b/gfx/vr/osvr/Util/ChannelCountC.h @@ -0,0 +1,57 @@ +/** @file + @brief Header + + Must be c-safe! + + @date 2015 + + @author + Sensics, Inc. + +*/ + +/* +// Copyright 2015 Sensics, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +*/ + +#ifndef INCLUDED_ChannelCountC_h_GUID_CF7E5EE7_28B0_4B99_E823_DD701904B5D1 +#define INCLUDED_ChannelCountC_h_GUID_CF7E5EE7_28B0_4B99_E823_DD701904B5D1 + +/* Internal Includes */ +#include +#include + +/* Library/third-party includes */ +/* none */ + +/* Standard includes */ +/* none */ + +OSVR_EXTERN_C_BEGIN + +/** @addtogroup PluginKit +@{ +*/ + +/** @brief The integer type specifying a number of channels/sensors or a +channel/sensor index. +*/ +typedef uint32_t OSVR_ChannelCount; + +/** @} */ + +OSVR_EXTERN_C_END + +#endif diff --git a/gfx/vr/osvr/Util/ClientCallbackTypesC.h b/gfx/vr/osvr/Util/ClientCallbackTypesC.h new file mode 100644 index 000000000..ae17381dc --- /dev/null +++ b/gfx/vr/osvr/Util/ClientCallbackTypesC.h @@ -0,0 +1,140 @@ +/** @file + @brief Header + + Must be c-safe! + + GENERATED - do not edit by hand! + + @date 2014 + + @author + Sensics, Inc. + +*/ + +/* +// Copyright 2014 Sensics, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +*/ + +#ifndef INCLUDED_ClientCallbackTypesC_h_GUID_4D43A675_C8A4_4BBF_516F_59E6C785E4EF +#define INCLUDED_ClientCallbackTypesC_h_GUID_4D43A675_C8A4_4BBF_516F_59E6C785E4EF + +/* Internal Includes */ +#include +#include +#include +#include + +/* Library/third-party includes */ +/* none */ + +/* Standard includes */ +/* none */ + +OSVR_EXTERN_C_BEGIN + +/** @addtogroup ClientKit + @{ +*/ + +/** @name Report callback types + @{ +*/ + +/* generated file - do not edit! */ +/** @brief C function type for a Pose callback */ +typedef void (*OSVR_PoseCallback)(void *userdata, + const struct OSVR_TimeValue *timestamp, + const struct OSVR_PoseReport *report); +/** @brief C function type for a Position callback */ +typedef void (*OSVR_PositionCallback)(void *userdata, + const struct OSVR_TimeValue *timestamp, + const struct OSVR_PositionReport *report); +/** @brief C function type for a Orientation callback */ +typedef void (*OSVR_OrientationCallback)(void *userdata, + const struct OSVR_TimeValue *timestamp, + const struct OSVR_OrientationReport *report); +/** @brief C function type for a Velocity callback */ +typedef void (*OSVR_VelocityCallback)(void *userdata, + const struct OSVR_TimeValue *timestamp, + const struct OSVR_VelocityReport *report); +/** @brief C function type for a LinearVelocity callback */ +typedef void (*OSVR_LinearVelocityCallback)(void *userdata, + const struct OSVR_TimeValue *timestamp, + const struct OSVR_LinearVelocityReport *report); +/** @brief C function type for a AngularVelocity callback */ +typedef void (*OSVR_AngularVelocityCallback)(void *userdata, + const struct OSVR_TimeValue *timestamp, + const struct OSVR_AngularVelocityReport *report); +/** @brief C function type for a Acceleration callback */ +typedef void (*OSVR_AccelerationCallback)(void *userdata, + const struct OSVR_TimeValue *timestamp, + const struct OSVR_AccelerationReport *report); +/** @brief C function type for a LinearAcceleration callback */ +typedef void (*OSVR_LinearAccelerationCallback)(void *userdata, + const struct OSVR_TimeValue *timestamp, + const struct OSVR_LinearAccelerationReport *report); +/** @brief C function type for a AngularAcceleration callback */ +typedef void (*OSVR_AngularAccelerationCallback)(void *userdata, + const struct OSVR_TimeValue *timestamp, + const struct OSVR_AngularAccelerationReport *report); +/** @brief C function type for a Button callback */ +typedef void (*OSVR_ButtonCallback)(void *userdata, + const struct OSVR_TimeValue *timestamp, + const struct OSVR_ButtonReport *report); +/** @brief C function type for a Analog callback */ +typedef void (*OSVR_AnalogCallback)(void *userdata, + const struct OSVR_TimeValue *timestamp, + const struct OSVR_AnalogReport *report); +/** @brief C function type for a Imaging callback */ +typedef void (*OSVR_ImagingCallback)(void *userdata, + const struct OSVR_TimeValue *timestamp, + const struct OSVR_ImagingReport *report); +/** @brief C function type for a Location2D callback */ +typedef void (*OSVR_Location2DCallback)(void *userdata, + const struct OSVR_TimeValue *timestamp, + const struct OSVR_Location2DReport *report); +/** @brief C function type for a Direction callback */ +typedef void (*OSVR_DirectionCallback)(void *userdata, + const struct OSVR_TimeValue *timestamp, + const struct OSVR_DirectionReport *report); +/** @brief C function type for a EyeTracker2D callback */ +typedef void (*OSVR_EyeTracker2DCallback)(void *userdata, + const struct OSVR_TimeValue *timestamp, + const struct OSVR_EyeTracker2DReport *report); +/** @brief C function type for a EyeTracker3D callback */ +typedef void (*OSVR_EyeTracker3DCallback)(void *userdata, + const struct OSVR_TimeValue *timestamp, + const struct OSVR_EyeTracker3DReport *report); +/** @brief C function type for a EyeTrackerBlink callback */ +typedef void (*OSVR_EyeTrackerBlinkCallback)(void *userdata, + const struct OSVR_TimeValue *timestamp, + const struct OSVR_EyeTrackerBlinkReport *report); +/** @brief C function type for a NaviVelocity callback */ +typedef void (*OSVR_NaviVelocityCallback)(void *userdata, + const struct OSVR_TimeValue *timestamp, + const struct OSVR_NaviVelocityReport *report); +/** @brief C function type for a NaviPosition callback */ +typedef void (*OSVR_NaviPositionCallback)(void *userdata, + const struct OSVR_TimeValue *timestamp, + const struct OSVR_NaviPositionReport *report); + +/** @} */ + +/** @} */ + +OSVR_EXTERN_C_END + +#endif diff --git a/gfx/vr/osvr/Util/ClientOpaqueTypesC.h b/gfx/vr/osvr/Util/ClientOpaqueTypesC.h new file mode 100644 index 000000000..64eba6d61 --- /dev/null +++ b/gfx/vr/osvr/Util/ClientOpaqueTypesC.h @@ -0,0 +1,69 @@ +/** @file + @brief Header declaring opaque types used by @ref Client and @ref ClientKit + + Must be c-safe! + + @date 2014 + + @author + Sensics, Inc. + +*/ + +/* +// Copyright 2014 Sensics, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +*/ + +#ifndef INCLUDED_ClientOpaqueTypesC_h_GUID_24B79ED2_5751_4BA2_1690_BBD250EBC0C1 +#define INCLUDED_ClientOpaqueTypesC_h_GUID_24B79ED2_5751_4BA2_1690_BBD250EBC0C1 + +/* Internal Includes */ +#include + +/* Library/third-party includes */ +/* none */ + +/* Standard includes */ +/* none */ + +OSVR_EXTERN_C_BEGIN + +/** @addtogroup ClientKit + @{ +*/ +/** @brief Opaque handle that should be retained by your application. You need + only and exactly one. + + Created by osvrClientInit() at application start. + + You are required to clean up this handle with osvrClientShutdown(). +*/ +typedef struct OSVR_ClientContextObject *OSVR_ClientContext; + +/** @brief Opaque handle to an interface used for registering callbacks and + getting status. + + You are not required to clean up this handle (it will be automatically + cleaned up when the context is), but you can if you are no longer using it, + using osvrClientFreeInterface() to inform the context that you no longer need + this interface. +*/ +typedef struct OSVR_ClientInterfaceObject *OSVR_ClientInterface; + +/** @} */ + +OSVR_EXTERN_C_END + +#endif diff --git a/gfx/vr/osvr/Util/ClientReportTypesC.h b/gfx/vr/osvr/Util/ClientReportTypesC.h new file mode 100644 index 000000000..85fa5a5a1 --- /dev/null +++ b/gfx/vr/osvr/Util/ClientReportTypesC.h @@ -0,0 +1,348 @@ +/** @file + @brief Header + + Must be c-safe! + + @date 2014 + + @author + Sensics, Inc. + +*/ + +/* +// Copyright 2014 Sensics, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +*/ + +#ifndef INCLUDED_ClientReportTypesC_h_GUID_E79DAB07_78B7_4795_1EB9_CA6EEB274AEE +#define INCLUDED_ClientReportTypesC_h_GUID_E79DAB07_78B7_4795_1EB9_CA6EEB274AEE + +/* Internal Includes */ +#include +#include +#include + +#include +#include +#include +#include + +/* Library/third-party includes */ +/* none */ + +/* Standard includes */ +/* none */ + +OSVR_EXTERN_C_BEGIN + +/** @addtogroup ClientKit + @{ +*/ + +/** @name State types +@{ +*/ +/** @brief Type of position state */ +typedef OSVR_Vec3 OSVR_PositionState; + +/** @brief Type of orientation state */ +typedef OSVR_Quaternion OSVR_OrientationState; + +/** @brief Type of pose state */ +typedef OSVR_Pose3 OSVR_PoseState; + +/** @brief Type of linear velocity state */ +typedef OSVR_Vec3 OSVR_LinearVelocityState; + +/** @brief The quaternion represents the incremental rotation taking place over + a period of dt seconds. Use of dt (which does not necessarily + have to be 1, as other velocity/acceleration representations imply) and an + incremental quaternion allows device reports to be scaled to avoid aliasing +*/ +typedef struct OSVR_IncrementalQuaternion { + OSVR_Quaternion incrementalRotation; + double dt; +} OSVR_IncrementalQuaternion; + +/** @brief Type of angular velocity state: an incremental quaternion, providing + the incremental rotation taking place due to velocity over a period of dt + seconds. +*/ +typedef OSVR_IncrementalQuaternion OSVR_AngularVelocityState; + +/** @brief Struct for combined velocity state */ +typedef struct OSVR_VelocityState { + OSVR_LinearVelocityState linearVelocity; + /** @brief Whether the data source reports valid data for + #OSVR_VelocityState::linearVelocity */ + OSVR_CBool linearVelocityValid; + + OSVR_AngularVelocityState angularVelocity; + /** @brief Whether the data source reports valid data for + #OSVR_VelocityState::angularVelocity */ + OSVR_CBool angularVelocityValid; +} OSVR_VelocityState; + +/** @brief Type of linear acceleration state */ +typedef OSVR_Vec3 OSVR_LinearAccelerationState; + +/** @brief Type of angular acceleration state +*/ +typedef OSVR_IncrementalQuaternion OSVR_AngularAccelerationState; + +/** @brief Struct for combined acceleration state */ +typedef struct OSVR_AccelerationState { + OSVR_LinearAccelerationState linearAcceleration; + /** @brief Whether the data source reports valid data for + #OSVR_AccelerationState::linearAcceleration */ + OSVR_CBool linearAccelerationValid; + + OSVR_AngularAccelerationState angularAcceleration; + /** @brief Whether the data source reports valid data for + #OSVR_AccelerationState::angularAcceleration */ + OSVR_CBool angularAccelerationValid; +} OSVR_AccelerationState; + +/** @brief Type of button state */ +typedef uint8_t OSVR_ButtonState; + +/** @brief OSVR_ButtonState value indicating "button down" */ +#define OSVR_BUTTON_PRESSED (1) + +/** @brief OSVR_ButtonState value indicating "button up" */ +#define OSVR_BUTTON_NOT_PRESSED (0) + +/** @brief Type of analog channel state */ +typedef double OSVR_AnalogState; + +/** @} */ + +/** @name Report types + @{ +*/ +/** @brief Report type for a position callback on a tracker interface */ +typedef struct OSVR_PositionReport { + /** @brief Identifies the sensor that the report comes from */ + int32_t sensor; + /** @brief The position vector */ + OSVR_PositionState xyz; +} OSVR_PositionReport; + +/** @brief Report type for an orientation callback on a tracker interface */ +typedef struct OSVR_OrientationReport { + /** @brief Identifies the sensor that the report comes from */ + int32_t sensor; + /** @brief The rotation unit quaternion */ + OSVR_OrientationState rotation; +} OSVR_OrientationReport; + +/** @brief Report type for a pose (position and orientation) callback on a + tracker interface +*/ +typedef struct OSVR_PoseReport { + /** @brief Identifies the sensor that the report comes from */ + int32_t sensor; + /** @brief The pose structure, containing a position vector and a rotation + quaternion + */ + OSVR_PoseState pose; +} OSVR_PoseReport; + +/** @brief Report type for a velocity (linear and angular) callback on a + tracker interface +*/ +typedef struct OSVR_VelocityReport { + /** @brief Identifies the sensor that the report comes from */ + int32_t sensor; + /** @brief The data state - note that not all fields are neccesarily valid, + use the `Valid` members to check the status of the other fields. + */ + OSVR_VelocityState state; +} OSVR_VelocityReport; + +/** @brief Report type for a linear velocity callback on a tracker interface +*/ +typedef struct OSVR_LinearVelocityReport { + /** @brief Identifies the sensor that the report comes from */ + int32_t sensor; + /** @brief The state itself */ + OSVR_LinearVelocityState state; +} OSVR_LinearVelocityReport; + +/** @brief Report type for an angular velocity callback on a tracker interface +*/ +typedef struct OSVR_AngularVelocityReport { + /** @brief Identifies the sensor that the report comes from */ + int32_t sensor; + /** @brief The state itself */ + OSVR_AngularVelocityState state; +} OSVR_AngularVelocityReport; + +/** @brief Report type for an acceleration (linear and angular) callback on a + tracker interface +*/ +typedef struct OSVR_AccelerationReport { + /** @brief Identifies the sensor that the report comes from */ + int32_t sensor; + /** @brief The data state - note that not all fields are neccesarily valid, + use the `Valid` members to check the status of the other fields. + */ + OSVR_AccelerationState state; +} OSVR_AccelerationReport; + +/** @brief Report type for a linear acceleration callback on a tracker interface +*/ +typedef struct OSVR_LinearAccelerationReport { + /** @brief Identifies the sensor that the report comes from */ + int32_t sensor; + /** @brief The state itself */ + OSVR_LinearAccelerationState state; +} OSVR_LinearAccelerationReport; + +/** @brief Report type for an angular acceleration callback on a tracker + interface +*/ +typedef struct OSVR_AngularAccelerationReport { + /** @brief Identifies the sensor that the report comes from */ + int32_t sensor; + /** @brief The state itself */ + OSVR_AngularAccelerationState state; +} OSVR_AngularAccelerationReport; + +/** @brief Report type for a callback on a button interface */ +typedef struct OSVR_ButtonReport { + /** @brief Identifies the sensor that the report comes from */ + int32_t sensor; + /** @brief The button state: 1 is pressed, 0 is not pressed. */ + OSVR_ButtonState state; +} OSVR_ButtonReport; + +/** @brief Report type for a callback on an analog interface */ +typedef struct OSVR_AnalogReport { + /** @brief Identifies the sensor/channel that the report comes from */ + int32_t sensor; + /** @brief The analog state. */ + OSVR_AnalogState state; +} OSVR_AnalogReport; + +/** @brief Type of location within a 2D region/surface, in normalized + coordinates (in range [0, 1] in standard OSVR coordinate system) +*/ +typedef OSVR_Vec2 OSVR_Location2DState; + +/** @brief Report type for 2D location */ +typedef struct OSVR_Location2DReport { + OSVR_ChannelCount sensor; + OSVR_Location2DState location; +} OSVR_Location2DReport; + +/** @brief Type of unit directional vector in 3D with no particular origin */ +typedef OSVR_Vec3 OSVR_DirectionState; + +/** @brief Report type for 3D Direction vector */ +typedef struct OSVR_DirectionReport { + OSVR_ChannelCount sensor; + OSVR_DirectionState direction; +} OSVR_DirectionReport; + +/** @brief Type of eye gaze direction in 3D which contains 3D vector (position) + containing gaze base point of the user's respective eye in 3D device + coordinates. +*/ +typedef OSVR_PositionState OSVR_EyeGazeBasePoint3DState; + +/** @brief Type of eye gaze position in 2D which contains users's gaze/point of + regard in normalized display coordinates (in range [0, 1] in standard OSVR + coordinate system) +*/ +typedef OSVR_Location2DState OSVR_EyeGazePosition2DState; + +// typedef OSVR_DirectionState OSVR_EyeGazeBasePoint3DState; + +/** @brief Type of 3D vector (direction vector) containing the normalized gaze + direction of user's respective eye */ +typedef OSVR_DirectionState OSVR_EyeGazeDirectionState; + +/** @brief State for 3D gaze report */ +typedef struct OSVR_EyeTracker3DState { + OSVR_CBool directionValid; + OSVR_DirectionState direction; + OSVR_CBool basePointValid; + OSVR_PositionState basePoint; +} OSVR_EyeTracker3DState; + +/** @brief Report type for 3D gaze report */ +typedef struct OSVR_EyeTracker3DReport { + OSVR_ChannelCount sensor; + OSVR_EyeTracker3DState state; +} OSVR_EyeTracker3DReport; + +/** @brief State for 2D location report */ +typedef OSVR_Location2DState OSVR_EyeTracker2DState; + +/** @brief Report type for 2D location report */ +typedef struct OSVR_EyeTracker2DReport { + OSVR_ChannelCount sensor; + OSVR_EyeTracker2DState state; +} OSVR_EyeTracker2DReport; + +/** @brief State for a blink event */ +typedef OSVR_ButtonState OSVR_EyeTrackerBlinkState; + +/** @brief OSVR_EyeTrackerBlinkState value indicating an eyes blink had occurred + */ +#define OSVR_EYE_BLINK (1) + +/** @brief OSVR_EyeTrackerBlinkState value indicating eyes are not blinking */ +#define OSVR_EYE_NO_BLINK (0) + +/** @brief Report type for a blink event */ +typedef struct OSVR_EyeTrackerBlinkReport { + OSVR_ChannelCount sensor; + OSVR_EyeTrackerBlinkState state; +} OSVR_EyeTrackerBlinkReport; + +/** @brief Report type for an Imaging callback (forward declaration) */ +struct OSVR_ImagingReport; + +/** @brief Type of Navigation Velocity state */ +typedef OSVR_Vec2 OSVR_NaviVelocityState; + +/** @brief Type of Navigation Position state */ +typedef OSVR_Vec2 OSVR_NaviPositionState; + +/** @brief Report type for an navigation velocity callback on a tracker + * interface */ +typedef struct OSVR_NaviVelocityReport { + OSVR_ChannelCount sensor; + /** @brief The 2D vector in world coordinate system, in meters/second */ + OSVR_NaviVelocityState state; +} OSVR_NaviVelocityReport; + +/** @brief Report type for an navigation position callback on a tracker + * interface */ +typedef struct OSVR_NaviPositionReport { + OSVR_ChannelCount sensor; + /** @brief The 2D vector in world coordinate system, in meters, relative to + * starting position */ + OSVR_NaviPositionState state; +} OSVR_NaviPositionReport; + +/** @} */ + +/** @} */ +OSVR_EXTERN_C_END + +#endif diff --git a/gfx/vr/osvr/Util/Export.h b/gfx/vr/osvr/Util/Export.h new file mode 100644 index 000000000..f3e26b89f --- /dev/null +++ b/gfx/vr/osvr/Util/Export.h @@ -0,0 +1,138 @@ +/** @file + @brief Automatically-generated export header - do not edit! + + @date 2016 + + @author + Sensics, Inc. + +*/ + +// Copyright 2016 Sensics, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef OSVR_UTIL_EXPORT_H +#define OSVR_UTIL_EXPORT_H + +#ifdef OSVR_UTIL_STATIC_DEFINE +# define OSVR_UTIL_EXPORT +# define OSVR_UTIL_NO_EXPORT +#endif + +/* Per-compiler advance preventative definition */ +#if defined(__BORLANDC__) || defined(__CODEGEARC__) || defined(__HP_aCC) || \ + defined(__PGI) || defined(__WATCOMC__) +/* Compilers that don't support deprecated, according to CMake. */ +# ifndef OSVR_UTIL_DEPRECATED +# define OSVR_UTIL_DEPRECATED +# endif +#endif + +/* Check for attribute support */ +#if defined(__INTEL_COMPILER) +/* Checking before GNUC because Intel implements GNU extensions, + * so it chooses to define __GNUC__ as well. */ +# if __INTEL_COMPILER >= 1200 +/* Intel compiler 12.0 or newer can handle these attributes per CMake */ +# define OSVR_UTIL_EXPORT_HEADER_SUPPORTS_ATTRIBUTES +# endif + +#elif defined(__GNUC__) +# if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 2)) +/* GCC 4.2+ */ +# define OSVR_UTIL_EXPORT_HEADER_SUPPORTS_ATTRIBUTES +# endif +#endif + +/* Per-platform defines */ +#if defined(_MSC_VER) +/* MSVC on Windows */ + +#ifndef OSVR_UTIL_EXPORT +# ifdef osvrUtil_EXPORTS + /* We are building this library */ +# define OSVR_UTIL_EXPORT __declspec(dllexport) +# else + /* We are using this library */ +# define OSVR_UTIL_EXPORT __declspec(dllimport) +# endif +#endif + +#ifndef OSVR_UTIL_DEPRECATED +# define OSVR_UTIL_DEPRECATED __declspec(deprecated) +#endif + +#elif defined(_WIN32) && defined(__GNUC__) +/* GCC-compatible on Windows */ + +#ifndef OSVR_UTIL_EXPORT +# ifdef osvrUtil_EXPORTS + /* We are building this library */ +# define OSVR_UTIL_EXPORT __attribute__((dllexport)) +# else + /* We are using this library */ +# define OSVR_UTIL_EXPORT __attribute__((dllimport)) +# endif +#endif + +#ifndef OSVR_UTIL_DEPRECATED +# define OSVR_UTIL_DEPRECATED __attribute__((__deprecated__)) +#endif + +#elif defined(OSVR_UTIL_EXPORT_HEADER_SUPPORTS_ATTRIBUTES) || \ + (defined(__APPLE__) && defined(__MACH__)) +/* GCC4.2+ compatible (assuming something *nix-like) and Mac OS X */ +/* (The first macro is defined at the top of the file, if applicable) */ +/* see https://gcc.gnu.org/wiki/Visibility */ + +#ifndef OSVR_UTIL_EXPORT + /* We are building/using this library */ +# define OSVR_UTIL_EXPORT __attribute__((visibility("default"))) +#endif + +#ifndef OSVR_UTIL_NO_EXPORT +# define OSVR_UTIL_NO_EXPORT __attribute__((visibility("hidden"))) +#endif + +#ifndef OSVR_UTIL_DEPRECATED +# define OSVR_UTIL_DEPRECATED __attribute__((__deprecated__)) +#endif + +#endif +/* End of platform ifdefs */ + +/* fallback def */ +#ifndef OSVR_UTIL_EXPORT +# define OSVR_UTIL_EXPORT +#endif + +/* fallback def */ +#ifndef OSVR_UTIL_NO_EXPORT +# define OSVR_UTIL_NO_EXPORT +#endif + +/* fallback def */ +#ifndef OSVR_UTIL_DEPRECATED_EXPORT +# define OSVR_UTIL_DEPRECATED_EXPORT OSVR_UTIL_EXPORT OSVR_UTIL_DEPRECATED +#endif + +/* fallback def */ +#ifndef OSVR_UTIL_DEPRECATED_NO_EXPORT +# define OSVR_UTIL_DEPRECATED_NO_EXPORT OSVR_UTIL_NO_EXPORT OSVR_UTIL_DEPRECATED +#endif + +/* Clean up after ourselves */ +#undef OSVR_UTIL_EXPORT_HEADER_SUPPORTS_ATTRIBUTES + +#endif diff --git a/gfx/vr/osvr/Util/ImagingReportTypesC.h b/gfx/vr/osvr/Util/ImagingReportTypesC.h new file mode 100644 index 000000000..1ce8b60d6 --- /dev/null +++ b/gfx/vr/osvr/Util/ImagingReportTypesC.h @@ -0,0 +1,91 @@ +/** @file + @brief Header + + Must be c-safe! + + @date 2015 + + @author + Sensics, Inc. + +*/ + +/* +// Copyright 2015 Sensics, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +*/ + +#ifndef INCLUDED_ImagingReportTypesC_h_GUID_746A7BF8_B92D_4585_CA72_DC5391DEDF24 +#define INCLUDED_ImagingReportTypesC_h_GUID_746A7BF8_B92D_4585_CA72_DC5391DEDF24 + +/* Internal Includes */ +#include +#include +#include + +/* Library/third-party includes */ +/* none */ + +/* Standard includes */ +/* none */ + +OSVR_EXTERN_C_BEGIN + +/** @addtogroup ClientKit + @{ +*/ +typedef uint32_t OSVR_ImageDimension; +typedef uint8_t OSVR_ImageChannels; +typedef uint8_t OSVR_ImageDepth; + +/** @brief Type for raw buffer access to image data */ +typedef unsigned char OSVR_ImageBufferElement; + +typedef enum OSVR_ImagingValueType { + OSVR_IVT_UNSIGNED_INT = 0, + OSVR_IVT_SIGNED_INT = 1, + OSVR_IVT_FLOATING_POINT = 2 +} OSVR_ImagingValueType; + +typedef struct OSVR_ImagingMetadata { + /** @brief height in pixels */ + OSVR_ImageDimension height; + /** @brief width in pixels */ + OSVR_ImageDimension width; + /** @brief number of channels of data for each pixel */ + OSVR_ImageChannels channels; + /** @brief the depth (size) in bytes of each channel - valid values are 1, + * 2, 4, and 8 */ + OSVR_ImageDepth depth; + /** @brief Whether values are unsigned ints, signed ints, or floating point + */ + OSVR_ImagingValueType type; + +} OSVR_ImagingMetadata; + +typedef struct OSVR_ImagingState { + OSVR_ImagingMetadata metadata; + OSVR_ImageBufferElement *data; +} OSVR_ImagingState; + +typedef struct OSVR_ImagingReport { + OSVR_ChannelCount sensor; + OSVR_ImagingState state; +} OSVR_ImagingReport; + +/** @} */ + +OSVR_EXTERN_C_END + +#endif diff --git a/gfx/vr/osvr/Util/MatrixConventionsC.h b/gfx/vr/osvr/Util/MatrixConventionsC.h new file mode 100644 index 000000000..b1f2c2797 --- /dev/null +++ b/gfx/vr/osvr/Util/MatrixConventionsC.h @@ -0,0 +1,190 @@ +/** @file + @brief Header + + Must be c-safe! + + @date 2015 + + @author + Sensics, Inc. + +*/ + +/* +// Copyright 2015 Sensics, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +*/ + +#ifndef INCLUDED_MatrixConventionsC_h_GUID_6FC7A4C6_E6C5_4A96_1C28_C3D21B909681 +#define INCLUDED_MatrixConventionsC_h_GUID_6FC7A4C6_E6C5_4A96_1C28_C3D21B909681 + +/* Internal Includes */ +#include +#include +#include +#include +#include + +/* Library/third-party includes */ +/* none */ + +/* Standard includes */ +/* none */ + +OSVR_EXTERN_C_BEGIN + +/** @defgroup MatrixConvention Matrix conventions and bit flags + @ingroup UtilMath +*/ + +/** @brief Type for passing matrix convention flags. + @ingroup MatrixConvention +*/ +typedef uint16_t OSVR_MatrixConventions; + +#ifndef OSVR_DOXYGEN_EXTERNAL +/** @brief Bitmasks for testing matrix conventions. + @ingroup MatrixConvention +*/ +typedef enum OSVR_MatrixMasks { + OSVR_MATRIX_MASK_ROWMAJOR = 0x1, + OSVR_MATRIX_MASK_ROWVECTORS = 0x2, + OSVR_MATRIX_MASK_LHINPUT = 0x4, + OSVR_MATRIX_MASK_UNSIGNEDZ = 0x8 +} OSVR_MatrixMasks; +#endif + +/** @defgroup MatrixFlags Matrix flags + @ingroup MatrixConvention + + Bit flags for specifying matrix options. Only one option may be specified + per enum, with all the specified options combined with bitwise-or `|`. + + Most methods that take matrix flags only obey ::OSVR_MatrixOrderingFlags and + ::OSVR_MatrixVectorFlags - the flags that affect memory order. The remaining + flags are for use with projection matrix generation API methods. + + @{ +*/ +/** @brief Flag bit controlling output memory order */ +typedef enum OSVR_MatrixOrderingFlags { + /** @brief Column-major memory order (default) */ + OSVR_MATRIX_COLMAJOR = 0x0, + /** @brief Row-major memory order */ + OSVR_MATRIX_ROWMAJOR = OSVR_MATRIX_MASK_ROWMAJOR +} OSVR_MatrixOrderingFlags; + +/** @brief Flag bit controlling expected input to matrices. + (Related to ::OSVR_MatrixOrderingFlags - setting one to non-default results + in an output change, but setting both to non-default results in effectively + no change in the output. If this blows your mind, just ignore this aside and + carry on.) +*/ +typedef enum OSVR_MatrixVectorFlags { + /** @brief Matrix transforms column vectors (default) */ + OSVR_MATRIX_COLVECTORS = 0x0, + /** @brief Matrix transforms row vectors */ + OSVR_MATRIX_ROWVECTORS = OSVR_MATRIX_MASK_ROWVECTORS +} OSVR_MatrixVectorFlags; + +/** @brief Flag bit to indicate coordinate system input to projection matrix */ +typedef enum OSVR_ProjectionMatrixInputFlags { + /** @brief Matrix takes vectors from a right-handed coordinate system + (default) */ + OSVR_MATRIX_RHINPUT = 0x0, + /** @brief Matrix takes vectors from a left-handed coordinate system */ + OSVR_MATRIX_LHINPUT = OSVR_MATRIX_MASK_LHINPUT + +} OSVR_ProjectionMatrixInputFlags; + +/** @brief Flag bit to indicate the desired post-projection Z value convention + */ +typedef enum OSVR_ProjectionMatrixZFlags { + /** @brief Matrix maps the near and far planes to signed Z values (in the + range [-1, 1]) (default)*/ + OSVR_MATRIX_SIGNEDZ = 0x0, + /** @brief Matrix maps the near and far planes to unsigned Z values (in the + range [0, 1]) */ + OSVR_MATRIX_UNSIGNEDZ = OSVR_MATRIX_MASK_UNSIGNEDZ +} OSVR_ProjectionMatrixZFlags; +/** @} */ /* end of matrix flags group */ + +enum { + /** @brief Constant for the number of elements in the matrices we use - 4x4. + @ingroup MatrixConvention + */ + OSVR_MATRIX_SIZE = 16 +}; + +/** @addtogroup UtilMath + @{ +*/ +/** @brief Set a matrix of doubles based on a Pose3. + @param pose The Pose3 to convert + @param flags Memory ordering flag - see @ref MatrixFlags + @param[out] mat an array of 16 doubles +*/ +OSVR_UTIL_EXPORT OSVR_ReturnCode osvrPose3ToMatrixd( + OSVR_Pose3 const *pose, OSVR_MatrixConventions flags, double *mat); + +/** @brief Set a matrix of floats based on a Pose3. + @param pose The Pose3 to convert + @param flags Memory ordering flag - see @ref MatrixFlags + @param[out] mat an array of 16 floats +*/ +OSVR_UTIL_EXPORT OSVR_ReturnCode osvrPose3ToMatrixf( + OSVR_Pose3 const *pose, OSVR_MatrixConventions flags, float *mat); +/** @} */ + +OSVR_EXTERN_C_END + +#ifdef __cplusplus +/** @brief Set a matrix based on a Pose3. (C++-only overload - detecting scalar + * type) */ +inline OSVR_ReturnCode osvrPose3ToMatrix(OSVR_Pose3 const *pose, + OSVR_MatrixConventions flags, + double *mat) { + return osvrPose3ToMatrixd(pose, flags, mat); +} + +/** @brief Set a matrix based on a Pose3. (C++-only overload - detecting scalar + * type) */ +inline OSVR_ReturnCode osvrPose3ToMatrix(OSVR_Pose3 const *pose, + OSVR_MatrixConventions flags, + float *mat) { + return osvrPose3ToMatrixf(pose, flags, mat); +} + +/** @brief Set a matrix based on a Pose3. (C++-only overload - detects scalar + * and takes array rather than pointer) */ +template +inline OSVR_ReturnCode osvrPose3ToMatrix(OSVR_Pose3 const *pose, + OSVR_MatrixConventions flags, + Scalar mat[OSVR_MATRIX_SIZE]) { + return osvrPose3ToMatrix(pose, flags, &(mat[0])); +} +/** @brief Set a matrix based on a Pose3. (C++-only overload - detects scalar, + * takes array, takes pose by reference) */ +template +inline OSVR_ReturnCode osvrPose3ToMatrix(OSVR_Pose3 const &pose, + OSVR_MatrixConventions flags, + Scalar mat[OSVR_MATRIX_SIZE]) { + return osvrPose3ToMatrix(&pose, flags, &(mat[0])); +} + +#endif + +/** @} */ + +#endif diff --git a/gfx/vr/osvr/Util/PlatformConfig.h b/gfx/vr/osvr/Util/PlatformConfig.h new file mode 100644 index 000000000..8342e4f8f --- /dev/null +++ b/gfx/vr/osvr/Util/PlatformConfig.h @@ -0,0 +1,88 @@ +/** @file + @brief Auto-configured header + + If this filename ends in `.h`, don't edit it: your edits will + be lost next time this file is regenerated! + + Must be c-safe! + + @date 2014 + + @author + Sensics, Inc. + +*/ + +/* +// Copyright 2014 Sensics, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +*/ + +#ifndef INCLUDED_PlatformConfig_h_GUID_0D10E644_8114_4294_A839_699F39E1F0E0 +#define INCLUDED_PlatformConfig_h_GUID_0D10E644_8114_4294_A839_699F39E1F0E0 + +/** @def OSVR_HAVE_STRUCT_TIMEVAL_IN_WINSOCK2_H + @brief Does the system have struct timeval in ? +*/ +#define OSVR_HAVE_STRUCT_TIMEVAL_IN_WINSOCK2_H + +/** @def OSVR_HAVE_STRUCT_TIMEVAL_IN_SYS_TIME_H + @brief Does the system have struct timeval in ? +*/ + +/* + MinGW and similar environments have both winsock and sys/time.h, so + we hide this define for disambiguation at the top level. +*/ +#ifndef OSVR_HAVE_STRUCT_TIMEVAL_IN_WINSOCK2_H +/* #undef OSVR_HAVE_STRUCT_TIMEVAL_IN_SYS_TIME_H */ +#endif + +#if defined(OSVR_HAVE_STRUCT_TIMEVAL_IN_SYS_TIME_H) || \ + defined(OSVR_HAVE_STRUCT_TIMEVAL_IN_WINSOCK2_H) +#define OSVR_HAVE_STRUCT_TIMEVAL +#endif + +/** + * Platform-specific variables. + * + * Prefer testing for specific compiler or platform features instead of relying + * on these variables. + * + */ +//@{ +/* #undef OSVR_AIX */ +/* #undef OSVR_ANDROID */ +/* #undef OSVR_BSDOS */ +/* #undef OSVR_FREEBSD */ +/* #undef OSVR_HPUX */ +/* #undef OSVR_IRIX */ +/* #undef OSVR_LINUX */ +/* #undef OSVR_KFREEBSD */ +/* #undef OSVR_NETBSD */ +/* #undef OSVR_OPENBSD */ +/* #undef OSVR_OFS1 */ +/* #undef OSVR_SCO_SV */ +/* #undef OSVR_UNIXWARE */ +/* #undef OSVR_XENIX */ +/* #undef OSVR_SUNOS */ +/* #undef OSVR_TRU64 */ +/* #undef OSVR_ULTRIX */ +/* #undef OSVR_CYGWIN */ +/* #undef OSVR_MACOSX */ +#define OSVR_WINDOWS +//@} + +#endif + diff --git a/gfx/vr/osvr/Util/Pose3C.h b/gfx/vr/osvr/Util/Pose3C.h new file mode 100644 index 000000000..173428cfc --- /dev/null +++ b/gfx/vr/osvr/Util/Pose3C.h @@ -0,0 +1,70 @@ +/** @file + @brief Header + + Must be c-safe! + + @date 2014 + + @author + Sensics, Inc. + +*/ + +/* +// Copyright 2014 Sensics, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +*/ + +#ifndef INCLUDED_Pose3C_h_GUID_066CFCE2_229C_4194_5D2B_2602CCD5C439 +#define INCLUDED_Pose3C_h_GUID_066CFCE2_229C_4194_5D2B_2602CCD5C439 + +/* Internal Includes */ + +/* Internal Includes */ +#include +#include +#include + +/* Library/third-party includes */ +/* none */ + +/* Standard includes */ +/* none */ + +OSVR_EXTERN_C_BEGIN + +/** @addtogroup UtilMath + @{ +*/ + +/** @brief A structure defining a 3D (6DOF) rigid body pose: translation and + rotation. +*/ +typedef struct OSVR_Pose3 { + /** @brief Position vector */ + OSVR_Vec3 translation; + /** @brief Orientation as a unit quaternion */ + OSVR_Quaternion rotation; +} OSVR_Pose3; + +/** @brief Set a pose to identity */ +OSVR_INLINE void osvrPose3SetIdentity(OSVR_Pose3 *pose) { + osvrQuatSetIdentity(&(pose->rotation)); + osvrVec3Zero(&(pose->translation)); +} +/** @} */ + +OSVR_EXTERN_C_END + +#endif diff --git a/gfx/vr/osvr/Util/QuaternionC.h b/gfx/vr/osvr/Util/QuaternionC.h new file mode 100644 index 000000000..8056c89a0 --- /dev/null +++ b/gfx/vr/osvr/Util/QuaternionC.h @@ -0,0 +1,92 @@ +/** @file + @brief Header + + Must be c-safe! + + @date 2014 + + @author + Sensics, Inc. + +*/ + +/* +// Copyright 2014 Sensics, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +*/ + +#ifndef INCLUDED_QuaternionC_h_GUID_1470A5FE_8209_41A6_C19E_46077FDF9C66 +#define INCLUDED_QuaternionC_h_GUID_1470A5FE_8209_41A6_C19E_46077FDF9C66 + +/* Internal Includes */ +#include + +/* Library/third-party includes */ +/* none */ + +/* Standard includes */ +/* none */ + +OSVR_EXTERN_C_BEGIN + +/** @addtogroup UtilMath + @{ +*/ +/** @brief A structure defining a quaternion, often a unit quaternion + * representing 3D rotation. +*/ +typedef struct OSVR_Quaternion { + /** @brief Internal data - direct access not recommended */ + double data[4]; +} OSVR_Quaternion; + +#define OSVR_QUAT_MEMBER(COMPONENT, INDEX) \ + /** @brief Accessor for quaternion component COMPONENT */ \ + OSVR_INLINE double osvrQuatGet##COMPONENT(OSVR_Quaternion const *q) { \ + return q->data[INDEX]; \ + } \ + /** @brief Setter for quaternion component COMPONENT */ \ + OSVR_INLINE void osvrQuatSet##COMPONENT(OSVR_Quaternion *q, double val) { \ + q->data[INDEX] = val; \ + } + +OSVR_QUAT_MEMBER(W, 0) +OSVR_QUAT_MEMBER(X, 1) +OSVR_QUAT_MEMBER(Y, 2) +OSVR_QUAT_MEMBER(Z, 3) + +#undef OSVR_QUAT_MEMBER + +/** @brief Set a quaternion to the identity rotation */ +OSVR_INLINE void osvrQuatSetIdentity(OSVR_Quaternion *q) { + osvrQuatSetW(q, 1); + osvrQuatSetX(q, 0); + osvrQuatSetY(q, 0); + osvrQuatSetZ(q, 0); +} + +/** @} */ + +OSVR_EXTERN_C_END + +#ifdef __cplusplus +template +inline StreamType &operator<<(StreamType &os, OSVR_Quaternion const &quat) { + os << "(" << osvrQuatGetW(&quat) << ", (" << osvrQuatGetX(&quat) << ", " + << osvrQuatGetY(&quat) << ", " << osvrQuatGetZ(&quat) << "))"; + return os; +} +#endif + +#endif diff --git a/gfx/vr/osvr/Util/QuatlibInteropC.h b/gfx/vr/osvr/Util/QuatlibInteropC.h new file mode 100644 index 000000000..ef2a7fe12 --- /dev/null +++ b/gfx/vr/osvr/Util/QuatlibInteropC.h @@ -0,0 +1,84 @@ +/** @file + @brief Header + + Must be c-safe! + + @date 2014 + + @author + Sensics, Inc. + +*/ + +/* +// Copyright 2014 Sensics, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +*/ + +#ifndef INCLUDED_QuatlibInteropC_h_GUID_85D92019_F0CC_419C_5F6D_F5A3134AA5D4 +#define INCLUDED_QuatlibInteropC_h_GUID_85D92019_F0CC_419C_5F6D_F5A3134AA5D4 + +/* Internal Includes */ +#include +#include + +/* Library/third-party includes */ +#include + +/* Standard includes */ +#include + +OSVR_EXTERN_C_BEGIN + +/** @addtogroup UtilMath + @{ +*/ +OSVR_INLINE void osvrQuatToQuatlib(q_type dest, OSVR_Quaternion const *src) { + dest[Q_W] = osvrQuatGetW(src); + dest[Q_X] = osvrQuatGetX(src); + dest[Q_Y] = osvrQuatGetY(src); + dest[Q_Z] = osvrQuatGetZ(src); +} + +OSVR_INLINE void osvrQuatFromQuatlib(OSVR_Quaternion *dest, q_type const src) { + osvrQuatSetW(dest, src[Q_W]); + osvrQuatSetX(dest, src[Q_X]); + osvrQuatSetY(dest, src[Q_Y]); + osvrQuatSetZ(dest, src[Q_Z]); +} + +OSVR_INLINE void osvrVec3ToQuatlib(q_vec_type dest, OSVR_Vec3 const *src) { + memcpy((void *)(dest), (void const *)(src->data), sizeof(double) * 3); +} + +OSVR_INLINE void osvrVec3FromQuatlib(OSVR_Vec3 *dest, q_vec_type const src) { + memcpy((void *)(dest->data), (void const *)(src), sizeof(double) * 3); +} + +OSVR_INLINE void osvrPose3ToQuatlib(q_xyz_quat_type *dest, + OSVR_Pose3 const *src) { + osvrVec3ToQuatlib(dest->xyz, &(src->translation)); + osvrQuatToQuatlib(dest->quat, &(src->rotation)); +} + +OSVR_INLINE void osvrPose3FromQuatlib(OSVR_Pose3 *dest, + q_xyz_quat_type const *src) { + osvrVec3FromQuatlib(&(dest->translation), src->xyz); + osvrQuatFromQuatlib(&(dest->rotation), src->quat); +} + +/** @} */ + +OSVR_EXTERN_C_END +#endif diff --git a/gfx/vr/osvr/Util/RadialDistortionParametersC.h b/gfx/vr/osvr/Util/RadialDistortionParametersC.h new file mode 100644 index 000000000..ac85a680e --- /dev/null +++ b/gfx/vr/osvr/Util/RadialDistortionParametersC.h @@ -0,0 +1,62 @@ +/** @file + @brief Header + + Must be c-safe! + + @date 2015 + + @author + Sensics, Inc. + +*/ + +/* +// Copyright 2015 Sensics, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +*/ + +#ifndef INCLUDED_RadialDistortionParametersC_h_GUID_925BCEB1_BACA_4DA7_5133_FFF560C72EBD +#define INCLUDED_RadialDistortionParametersC_h_GUID_925BCEB1_BACA_4DA7_5133_FFF560C72EBD + +/* Internal Includes */ +#include +#include +#include + +/* Library/third-party includes */ +/* none */ + +/* Standard includes */ +/* none */ + +OSVR_EXTERN_C_BEGIN + +/** @addtogroup UtilMath +@{ +*/ + +/** @brief Parameters for a per-color-component radial distortion shader +*/ +typedef struct OSVR_RadialDistortionParameters { + /** @brief Vector of K1 coefficients for the R, G, B channels*/ + OSVR_Vec3 k1; + /** @brief Center of projection for the radial distortion, relative to the + bounds of this surface. + */ + OSVR_Vec2 centerOfProjection; +} OSVR_RadialDistortionParameters; + +OSVR_EXTERN_C_END + +#endif diff --git a/gfx/vr/osvr/Util/RenderingTypesC.h b/gfx/vr/osvr/Util/RenderingTypesC.h new file mode 100644 index 000000000..51ec0cc09 --- /dev/null +++ b/gfx/vr/osvr/Util/RenderingTypesC.h @@ -0,0 +1,134 @@ +/** @file + @brief Header with integer types for Viewer, Eye, and Surface + counts/indices, as well as viewport information. + + Must be c-safe! + + @date 2015 + + @author + Sensics, Inc. + +*/ + +/* +// Copyright 2015 Sensics, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +*/ + +#ifndef INCLUDED_RenderingTypesC_h_GUID_6689A6CA_76AC_48AC_A0D0_2902BC95AC35 +#define INCLUDED_RenderingTypesC_h_GUID_6689A6CA_76AC_48AC_A0D0_2902BC95AC35 + +/* Internal Includes */ +#include +#include + +/* Library/third-party includes */ +/* none */ + +/* Standard includes */ +/* none */ + +OSVR_EXTERN_C_BEGIN + +/** @addtogroup PluginKit +@{ +*/ + +/** @brief A count or index for a display input in a display config. +*/ +typedef uint8_t OSVR_DisplayInputCount; + +/** @brief The integer type used in specification of size or location of a + display input, in pixels. +*/ +typedef int32_t OSVR_DisplayDimension; + +/** @brief The integer type specifying a number of viewers in a system. + + A "head" is a viewer (though not all viewers are necessarily heads). + + The count is output from osvrClientGetNumViewers(). + + When used as an ID/index, it is zero-based, so values range from 0 to (count + - 1) inclusive. + + The most frequent count is 1, though higher values are theoretically + possible. If you do not handle higher values, do still check and alert the + user if their system reports a higher number, as your application may not + behave as the user expects. +*/ +typedef uint32_t OSVR_ViewerCount; + +/** @brief The integer type specifying the number of eyes (viewpoints) of a + viewer. + + The count for a given viewer is output from osvrClientGetNumEyesForViewer(). + + When used as an ID/index, it is zero-based,so values range from 0 to (count + - 1) inclusive, for a given viewer. + + Use as an ID/index is not meaningful except in conjunction with the ID of + the corresponding viewer. (that is, there is no overall "eye 0", but "viewer + 0, eye 0" is meaningful.) + + In practice, the most frequent counts are 1 (e.g. mono) and 2 (e.g. stereo), + and for example the latter results in eyes with ID 0 and 1 for the viewer. + There is no innate or consistent semantics/meaning ("left" or "right") to + indices guaranteed at this time, and applications should not try to infer + any. +*/ +typedef uint8_t OSVR_EyeCount; + +/** @brief The integer type specifying the number of surfaces seen by a viewer's + eye. + + The count for a given viewer and eye is output from + osvrClientGetNumSurfacesForViewerEye(). Note that the count is not + necessarily equal between eyes of a viewer. + + When used as an ID/index, it is zero-based, so values range from 0 to (count + - 1) inclusive, for a given viewer and eye. + + Use as an ID/index is not meaningful except in conjunction with the IDs of + the corresponding viewer and eye. (that is, there is no overall "surface 0", + but "viewer 0, eye 0, surface 0" is meaningful.) +*/ +typedef uint32_t OSVR_SurfaceCount; + +/** @brief The integer type used in specification of size or location of a + viewport. +*/ +typedef int32_t OSVR_ViewportDimension; + +/** @brief The integer type used to indicate relative priorities of a display + distortion strategy. Negative values are defined to mean that strategy is + unavailable. + + @sa OSVR_DISTORTION_PRIORITY_UNAVAILABLE +*/ +typedef int32_t OSVR_DistortionPriority; + +/** @brief The constant to return as an OSVR_DistortionPriority if a given + strategy is not available for a surface. + + @sa OSVR_DistortionPriority +*/ +#define OSVR_DISTORTION_PRIORITY_UNAVAILABLE (-1) + +/** @} */ + +OSVR_EXTERN_C_END + +#endif diff --git a/gfx/vr/osvr/Util/ReturnCodesC.h b/gfx/vr/osvr/Util/ReturnCodesC.h new file mode 100644 index 000000000..971798ea4 --- /dev/null +++ b/gfx/vr/osvr/Util/ReturnCodesC.h @@ -0,0 +1,57 @@ +/** @file + @brief Header declaring a type and values for simple C return codes. + + Must be c-safe! + + @date 2014 + + @author + Sensics, Inc. + +*/ + +/* +// Copyright 2014 Sensics, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +*/ + +#ifndef INCLUDED_ReturnCodesC_h_GUID_C81A2FDE_E5BB_4AAA_70A4_C616DD7C141A +#define INCLUDED_ReturnCodesC_h_GUID_C81A2FDE_E5BB_4AAA_70A4_C616DD7C141A + +/* Internal Includes */ +#include +#include + +OSVR_EXTERN_C_BEGIN + +/** @addtogroup PluginKit + @{ +*/ +/** @name Return Codes + @{ +*/ +/** @brief The "success" value for an OSVR_ReturnCode */ +#define OSVR_RETURN_SUCCESS (0) +/** @brief The "failure" value for an OSVR_ReturnCode */ +#define OSVR_RETURN_FAILURE (1) +/** @brief Return type from C API OSVR functions. */ +typedef OSVR_RETURN_SUCCESS_CONDITION( + return == OSVR_RETURN_SUCCESS) char OSVR_ReturnCode; +/** @} */ + +/** @} */ /* end of group */ + +OSVR_EXTERN_C_END + +#endif diff --git a/gfx/vr/osvr/Util/StdInt.h b/gfx/vr/osvr/Util/StdInt.h new file mode 100644 index 000000000..c9462b62c --- /dev/null +++ b/gfx/vr/osvr/Util/StdInt.h @@ -0,0 +1,42 @@ +/** @file + @brief Header wrapping the C99 standard `stdint` header. + + Must be c-safe! + + @date 2014 + + @author + Sensics, Inc. + +*/ + +/* +// Copyright 2014 Sensics, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +*/ + +#ifndef INCLUDED_StdInt_h_GUID_C1AAF35C_C704_4DB7_14AC_615730C4619B +#define INCLUDED_StdInt_h_GUID_C1AAF35C_C704_4DB7_14AC_615730C4619B + +/* IWYU pragma: begin_exports */ + +#if !defined(_MSC_VER) || (defined(_MSC_VER) && _MSC_VER >= 1600) +#include +#else +#include "MSStdIntC.h" +#endif + +/* IWYU pragma: end_exports */ + +#endif diff --git a/gfx/vr/osvr/Util/TimeValueC.h b/gfx/vr/osvr/Util/TimeValueC.h new file mode 100644 index 000000000..7dcead654 --- /dev/null +++ b/gfx/vr/osvr/Util/TimeValueC.h @@ -0,0 +1,271 @@ +/** @file + @brief Header defining a dependency-free, cross-platform substitute for + struct timeval + + Must be c-safe! + + @date 2014 + + @author + Sensics, Inc. + +*/ + +/* +// Copyright 2014 Sensics, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +*/ + +#ifndef INCLUDED_TimeValueC_h_GUID_A02C6917_124D_4CB3_E63E_07F2DA7144E9 +#define INCLUDED_TimeValueC_h_GUID_A02C6917_124D_4CB3_E63E_07F2DA7144E9 + +/* Internal Includes */ +#include +#include +#include +#include +#include +#include + +/* Library/third-party includes */ +/* none */ + +/* Standard includes */ +/* none */ + +OSVR_EXTERN_C_BEGIN + +/** @defgroup UtilTime Timestamp interaction + @ingroup Util + + This provides a level of interoperability with struct timeval on systems + with that facility. It provides a neutral representation with sufficiently + large types. + + For C++ code, use of std::chrono or boost::chrono instead is recommended. + + Note that these time values may not necessarily correlate between processes + so should not be used to estimate or measure latency, etc. + + @{ +*/ + +/** @brief The signed integer type storing the seconds in a struct + OSVR_TimeValue */ +typedef int64_t OSVR_TimeValue_Seconds; +/** @brief The signed integer type storing the microseconds in a struct + OSVR_TimeValue */ +typedef int32_t OSVR_TimeValue_Microseconds; + +/** @brief Standardized, portable parallel to struct timeval for representing + both absolute times and time intervals. + + Where interpreted as an absolute time, its meaning is to be considered the + same as that of the POSIX struct timeval: + time since 00:00 Coordinated Universal Time (UTC), January 1, 1970. + + For best results, please keep normalized. Output of all functions here + is normalized. + */ +typedef struct OSVR_TimeValue { + /** @brief Seconds portion of the time value. */ + OSVR_TimeValue_Seconds seconds; + /** @brief Microseconds portion of the time value. */ + OSVR_TimeValue_Microseconds microseconds; +} OSVR_TimeValue; + +#ifdef OSVR_HAVE_STRUCT_TIMEVAL +/** @brief Gets the current time in the TimeValue. Parallel to gettimeofday. */ +OSVR_UTIL_EXPORT void osvrTimeValueGetNow(OSVR_OUT OSVR_TimeValue *dest) + OSVR_FUNC_NONNULL((1)); + +struct timeval; /* forward declaration */ + +/** @brief Converts from a TimeValue struct to your system's struct timeval. + + @param dest Pointer to an empty struct timeval for your platform. + @param src A pointer to an OSVR_TimeValue you'd like to convert from. + + If either parameter is NULL, the function will return without doing + anything. +*/ +OSVR_UTIL_EXPORT void +osvrTimeValueToStructTimeval(OSVR_OUT struct timeval *dest, + OSVR_IN_PTR const OSVR_TimeValue *src) + OSVR_FUNC_NONNULL((1, 2)); + +/** @brief Converts from a TimeValue struct to your system's struct timeval. + @param dest An OSVR_TimeValue destination pointer. + @param src Pointer to a struct timeval you'd like to convert from. + + The result is normalized. + + If either parameter is NULL, the function will return without doing + anything. +*/ +OSVR_UTIL_EXPORT void +osvrStructTimevalToTimeValue(OSVR_OUT OSVR_TimeValue *dest, + OSVR_IN_PTR const struct timeval *src) + OSVR_FUNC_NONNULL((1, 2)); +#endif + +/** @brief "Normalizes" a time value so that the absolute number of microseconds + is less than 1,000,000, and that the sign of both components is the same. + + @param tv Address of a struct TimeValue to normalize in place. + + If the given pointer is NULL, this function returns without doing anything. +*/ +OSVR_UTIL_EXPORT void osvrTimeValueNormalize(OSVR_INOUT_PTR OSVR_TimeValue *tv) + OSVR_FUNC_NONNULL((1)); + +/** @brief Sums two time values, replacing the first with the result. + + @param tvA Destination and first source. + @param tvB second source + + If a given pointer is NULL, this function returns without doing anything. + + Both parameters are expected to be in normalized form. +*/ +OSVR_UTIL_EXPORT void osvrTimeValueSum(OSVR_INOUT_PTR OSVR_TimeValue *tvA, + OSVR_IN_PTR const OSVR_TimeValue *tvB) + OSVR_FUNC_NONNULL((1, 2)); + +/** @brief Computes the difference between two time values, replacing the first + with the result. + + Effectively, `*tvA = *tvA - *tvB` + + @param tvA Destination and first source. + @param tvB second source + + If a given pointer is NULL, this function returns without doing anything. + + Both parameters are expected to be in normalized form. +*/ +OSVR_UTIL_EXPORT void +osvrTimeValueDifference(OSVR_INOUT_PTR OSVR_TimeValue *tvA, + OSVR_IN_PTR const OSVR_TimeValue *tvB) + OSVR_FUNC_NONNULL((1, 2)); + +/** @brief Compares two time values (assumed to be normalized), returning + the same values as strcmp + + @return <0 if A is earlier than B, 0 if they are the same, and >0 if A + is later than B. +*/ +OSVR_UTIL_EXPORT int osvrTimeValueCmp(OSVR_IN_PTR const OSVR_TimeValue *tvA, + OSVR_IN_PTR const OSVR_TimeValue *tvB) + OSVR_FUNC_NONNULL((1, 2)); + +OSVR_EXTERN_C_END + +/** @brief Compute the difference between the two time values, returning the + duration as a double-precision floating-point number of seconds. + + Effectively, `ret = *tvA - *tvB` + + @param tvA first source. + @param tvB second source + @return Duration of timespan in seconds (floating-point) +*/ +OSVR_INLINE double +osvrTimeValueDurationSeconds(OSVR_IN_PTR const OSVR_TimeValue *tvA, + OSVR_IN_PTR const OSVR_TimeValue *tvB) { + OSVR_TimeValue A = *tvA; + osvrTimeValueDifference(&A, tvB); + double dt = A.seconds + A.microseconds / 1000000.0; + return dt; +} + +/** @brief True if A is later than B */ +OSVR_INLINE OSVR_CBool +osvrTimeValueGreater(OSVR_IN_PTR const OSVR_TimeValue *tvA, + OSVR_IN_PTR const OSVR_TimeValue *tvB) { + if (!tvA || !tvB) { + return OSVR_FALSE; + } + return ((tvA->seconds > tvB->seconds) || + (tvA->seconds == tvB->seconds && + tvA->microseconds > tvB->microseconds)) + ? OSVR_TRUE + : OSVR_FALSE; +} + +#ifdef __cplusplus + +#include +#include + +/// Returns true if the time value is normalized. Typically used in assertions. +inline bool osvrTimeValueIsNormalized(const OSVR_TimeValue &tv) { +#ifdef __APPLE__ + // apparently standard library used on mac only has floating-point abs? + return std::abs(double(tv.microseconds)) < 1000000 && +#else + return std::abs(tv.microseconds) < 1000000 && +#endif + ((tv.seconds > 0) == (tv.microseconds > 0)); +} + +/// True if A is later than B +inline bool osvrTimeValueGreater(const OSVR_TimeValue &tvA, + const OSVR_TimeValue &tvB) { + assert(osvrTimeValueIsNormalized(tvA) && + "First timevalue argument to comparison was not normalized!"); + assert(osvrTimeValueIsNormalized(tvB) && + "Second timevalue argument to comparison was not normalized!"); + return (tvA.seconds > tvB.seconds) || + (tvA.seconds == tvB.seconds && tvA.microseconds > tvB.microseconds); +} + +/// Operator > overload for time values +inline bool operator>(const OSVR_TimeValue &tvA, const OSVR_TimeValue &tvB) { + return osvrTimeValueGreater(tvA, tvB); +} + +/// Operator < overload for time values +inline bool operator<(const OSVR_TimeValue &tvA, const OSVR_TimeValue &tvB) { + // Change the order of arguments before forwarding. + return osvrTimeValueGreater(tvB, tvA); +} + +/// Operator == overload for time values +inline bool operator==(const OSVR_TimeValue &tvA, const OSVR_TimeValue &tvB) { + assert( + osvrTimeValueIsNormalized(tvA) && + "First timevalue argument to equality comparison was not normalized!"); + assert( + osvrTimeValueIsNormalized(tvB) && + "Second timevalue argument to equality comparison was not normalized!"); + return (tvA.seconds == tvB.seconds) && + (tvA.microseconds == tvB.microseconds); +} +/// Operator == overload for time values +inline bool operator!=(const OSVR_TimeValue &tvA, const OSVR_TimeValue &tvB) { + assert(osvrTimeValueIsNormalized(tvA) && "First timevalue argument to " + "inequality comparison was not " + "normalized!"); + assert(osvrTimeValueIsNormalized(tvB) && "Second timevalue argument to " + "inequality comparison was not " + "normalized!"); + return (tvA.seconds != tvB.seconds) || + (tvA.microseconds != tvB.microseconds); +} +#endif + +/** @} */ + +#endif diff --git a/gfx/vr/osvr/Util/Vec2C.h b/gfx/vr/osvr/Util/Vec2C.h new file mode 100644 index 000000000..0432a32e7 --- /dev/null +++ b/gfx/vr/osvr/Util/Vec2C.h @@ -0,0 +1,86 @@ +/** @file + @brief Header + + Must be c-safe! + + @date 2014 + + @author + Sensics, Inc. + +*/ + +/* +// Copyright 2014 Sensics, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +*/ + +#ifndef INCLUDED_Vec2C_h_GUID_F9715DE4_2649_4182_0F4C_D62121235D5F +#define INCLUDED_Vec2C_h_GUID_F9715DE4_2649_4182_0F4C_D62121235D5F + +/* Internal Includes */ +#include + +/* Library/third-party includes */ +/* none */ + +/* Standard includes */ +/* none */ + +OSVR_EXTERN_C_BEGIN + +/** @addtogroup UtilMath + @{ +*/ +/** @brief A structure defining a 2D vector, which represents position +*/ +typedef struct OSVR_Vec2 { + /** @brief Internal array data. */ + double data[2]; +} OSVR_Vec2; + +#define OSVR_VEC_MEMBER(COMPONENT, INDEX) \ + /** @brief Accessor for Vec2 component COMPONENT */ \ + OSVR_INLINE double osvrVec2Get##COMPONENT(OSVR_Vec2 const *v) { \ + return v->data[INDEX]; \ + } \ + /** @brief Setter for Vec2 component COMPONENT */ \ + OSVR_INLINE void osvrVec2Set##COMPONENT(OSVR_Vec2 *v, double val) { \ + v->data[INDEX] = val; \ + } + +OSVR_VEC_MEMBER(X, 0) +OSVR_VEC_MEMBER(Y, 1) + +#undef OSVR_VEC_MEMBER + +/** @brief Set a Vec2 to the zero vector */ +OSVR_INLINE void osvrVec2Zero(OSVR_Vec2 *v) { + osvrVec2SetX(v, 0); + osvrVec2SetY(v, 0); +} + +/** @} */ + +OSVR_EXTERN_C_END + +#ifdef __cplusplus +template +inline StreamType &operator<<(StreamType &os, OSVR_Vec2 const &vec) { + os << "(" << vec.data[0] << ", " << vec.data[1] << ")"; + return os; +} +#endif + +#endif // INCLUDED_Vec2C_h_GUID_F9715DE4_2649_4182_0F4C_D62121235D5F diff --git a/gfx/vr/osvr/Util/Vec3C.h b/gfx/vr/osvr/Util/Vec3C.h new file mode 100644 index 000000000..666861174 --- /dev/null +++ b/gfx/vr/osvr/Util/Vec3C.h @@ -0,0 +1,89 @@ +/** @file + @brief Header + + Must be c-safe! + + @date 2014 + + @author + Sensics, Inc. + +*/ + +/* +// Copyright 2014 Sensics, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +*/ + +#ifndef INCLUDED_Vec3C_h_GUID_BF4E98ED_74CF_4785_DB61_109A00BA74DE +#define INCLUDED_Vec3C_h_GUID_BF4E98ED_74CF_4785_DB61_109A00BA74DE + +/* Internal Includes */ +#include + +/* Library/third-party includes */ +/* none */ + +/* Standard includes */ +/* none */ + +OSVR_EXTERN_C_BEGIN + +/** @addtogroup UtilMath + @{ +*/ +/** @brief A structure defining a 3D vector, often a position/translation. +*/ +typedef struct OSVR_Vec3 { + /** @brief Internal array data. */ + double data[3]; +} OSVR_Vec3; + +#define OSVR_VEC_MEMBER(COMPONENT, INDEX) \ + /** @brief Accessor for Vec3 component COMPONENT */ \ + OSVR_INLINE double osvrVec3Get##COMPONENT(OSVR_Vec3 const *v) { \ + return v->data[INDEX]; \ + } \ + /** @brief Setter for Vec3 component COMPONENT */ \ + OSVR_INLINE void osvrVec3Set##COMPONENT(OSVR_Vec3 *v, double val) { \ + v->data[INDEX] = val; \ + } + +OSVR_VEC_MEMBER(X, 0) +OSVR_VEC_MEMBER(Y, 1) +OSVR_VEC_MEMBER(Z, 2) + +#undef OSVR_VEC_MEMBER + +/** @brief Set a Vec3 to the zero vector */ +OSVR_INLINE void osvrVec3Zero(OSVR_Vec3 *v) { + osvrVec3SetX(v, 0); + osvrVec3SetY(v, 0); + osvrVec3SetZ(v, 0); +} + +/** @} */ + +OSVR_EXTERN_C_END + +#ifdef __cplusplus +template +inline StreamType &operator<<(StreamType &os, OSVR_Vec3 const &vec) { + os << "(" << vec.data[0] << ", " << vec.data[1] << ", " << vec.data[2] + << ")"; + return os; +} +#endif + +#endif -- cgit v1.2.3