OSVR Framework (Internal Development Docs)  0.6-1962-g59773924
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
DirectionInterfaceC.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
33 #include "HandleNullContext.h"
34 #include <osvr/Util/Verbosity.h>
35 
36 // Library/third-party includes
37 // - none
38 
39 // Standard includes
40 // - none
41 
45 };
46 
47 OSVR_ReturnCode
49  OSVR_OUT_PTR OSVR_DirectionDeviceInterface *iface,
50  OSVR_IN OSVR_ChannelCount numSensors) {
51 
52  OSVR_PLUGIN_HANDLE_NULL_CONTEXT("osvrDeviceDirectionConfigure", opts);
53  OSVR_PLUGIN_HANDLE_NULL_CONTEXT("osvrDeviceDirectionConfigure", iface);
55  opts->makeInterfaceObject<OSVR_DirectionDeviceInterfaceObject>();
56  *iface = ifaceObj;
57 
58  auto direction = osvr::common::DirectionComponent::create(numSensors);
59  ifaceObj->direction = direction.get();
60  opts->addComponent(direction);
61  return OSVR_RETURN_SUCCESS;
62 }
63 
64 OSVR_ReturnCode
66  OSVR_IN_PTR OSVR_DirectionState directionData,
67  OSVR_IN OSVR_ChannelCount sensor,
68  OSVR_IN_PTR OSVR_TimeValue const *timestamp) {
69  auto guard = iface->getSendGuard();
70  if (guard->lock()) {
71  iface->direction->sendDirectionData(directionData, sensor, *timestamp);
72  return OSVR_RETURN_SUCCESS;
73  }
74 
75  return OSVR_RETURN_FAILURE;
76 }
uint32_t OSVR_ChannelCount
The integer type specifying a number of channels/sensors or a channel/sensor index.
Definition: ChannelCountC.h:51
A structure defining a 3D vector, often a position/translation.
Definition: Vec3C.h:48
static shared_ptr< DirectionComponent > create(OSVR_ChannelCount numSensor=1)
Factory method.
Structure used internally to construct the desired type of device.
#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
#define OSVR_RETURN_SUCCESS
The "success" value for an OSVR_ReturnCode.
Definition: ReturnCodesC.h:45
Internal, configured header file for verbosity macros.
OSVR_ReturnCode osvrDeviceDirectionReportData(OSVR_DirectionDeviceInterface iface, OSVR_DirectionState directionData, OSVR_ChannelCount sensor, OSVR_TimeValue const *timestamp)
Report data for a specific sensor.
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...
OSVR_ReturnCode osvrDeviceDirectionConfigure(OSVR_DeviceInitOptions opts, OSVR_DirectionDeviceInterface *iface, OSVR_ChannelCount numSensors)
Specify that your device will implement the Direction interface.