OSVR Framework (Internal Development Docs)  0.6-1962-g59773924
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
LocomotionInterfaceC.cpp
Go to the documentation of this file.
1 
12 // Copyright 2015 Sensics, Inc.
13 //
14 // Licensed under the Apache License, Version 2.0 (the "License");
15 // you may not use this file except in compliance with the License.
16 // You may obtain a copy of the License at
17 //
18 // http://www.apache.org/licenses/LICENSE-2.0
19 //
20 // Unless required by applicable law or agreed to in writing, software
21 // distributed under the License is distributed on an "AS IS" BASIS,
22 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
23 // See the License for the specific language governing permissions and
24 // limitations under the License.
25 
26 // Internal Includes
31 #include "HandleNullContext.h"
34 #include <osvr/Util/Verbosity.h>
36 
37 // Library/third-party includes
38 // - none
39 
40 // Standard includes
41 // - none
42 
46 };
47 
49  OSVR_INOUT_PTR OSVR_DeviceInitOptions opts,
50  OSVR_OUT_PTR OSVR_LocomotionDeviceInterface *iface) {
51 
52  OSVR_PLUGIN_HANDLE_NULL_CONTEXT("osvrDeviceLocomotionConfigure", opts);
53  OSVR_PLUGIN_HANDLE_NULL_CONTEXT("osvrDeviceLocomotionConfigure", iface);
55  opts->makeInterfaceObject<OSVR_LocomotionDeviceInterfaceObject>();
56  *iface = ifaceObj;
58  ifaceObj->locomotion = locomotion.get();
59  opts->addComponent(locomotion);
60  return OSVR_RETURN_SUCCESS;
61 }
62 
64  OSVR_IN_PTR OSVR_LocomotionDeviceInterface iface,
65  OSVR_IN OSVR_NaviVelocityState naviVelocity,
66  OSVR_IN OSVR_ChannelCount sensor,
67  OSVR_IN_PTR OSVR_TimeValue const *timestamp) {
68  auto guard = iface->getSendGuard();
69  if (guard->lock()) {
70  iface->locomotion->sendNaviVelocityData(naviVelocity, sensor,
71  *timestamp);
72  return OSVR_RETURN_SUCCESS;
73  }
74 
75  return OSVR_RETURN_FAILURE;
76 }
77 
79  OSVR_IN_PTR OSVR_LocomotionDeviceInterface iface,
80  OSVR_IN OSVR_NaviPositionState naviPosition,
81  OSVR_IN OSVR_ChannelCount sensor,
82  OSVR_IN_PTR OSVR_TimeValue const *timestamp) {
83  auto guard = iface->getSendGuard();
84  if (guard->lock()) {
85  iface->locomotion->sendNaviPositionData(naviPosition, sensor,
86  *timestamp);
87  return OSVR_RETURN_SUCCESS;
88  }
89 
90  return OSVR_RETURN_FAILURE;
91 }
uint32_t OSVR_ChannelCount
The integer type specifying a number of channels/sensors or a channel/sensor index.
Definition: ChannelCountC.h:51
Structure used internally to construct the desired type of device.
static shared_ptr< LocomotionComponent > create()
Factory method.
OSVR_ReturnCode osvrDeviceLocomotionReportNaviVelocity(OSVR_LocomotionDeviceInterface iface, OSVR_NaviVelocityState naviVelocity, OSVR_ChannelCount sensor, OSVR_TimeValue const *timestamp)
Report velocity data for a specific sensor.
#define OSVR_PLUGIN_HANDLE_NULL_CONTEXT(FUNC, CONTEXT_NAME)
Internal macro for use in C API function implementations to check the validity of a context parameter...
#define OSVR_RETURN_FAILURE
The "failure" value for an OSVR_ReturnCode.
Definition: ReturnCodesC.h:47
A structure defining a 2D vector, which represents position.
Definition: Vec2C.h:48
#define OSVR_RETURN_SUCCESS
The "success" value for an OSVR_ReturnCode.
Definition: ReturnCodesC.h:45
OSVR_ReturnCode osvrDeviceLocomotionConfigure(OSVR_DeviceInitOptions opts, OSVR_LocomotionDeviceInterface *iface)
Specify that your device will implement the Locomotion interface.
OSVR_ReturnCode osvrDeviceLocomotionReportNaviPosition(OSVR_LocomotionDeviceInterface iface, OSVR_NaviPositionState naviPosition, OSVR_ChannelCount sensor, OSVR_TimeValue const *timestamp)
Report position data for a specific sensor.
Internal, configured header file for verbosity macros.
Standardized, portable parallel to struct timeval for representing both absolute times and time inter...
Definition: TimeValueC.h:81
Base class for the DeviceInterfaceObjects retrieved by plugins to let them send data on an interface...