OSVR Framework (Internal Development Docs)  0.6-1962-g59773924
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
Location2DInterfaceC.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
32 #include "HandleNullContext.h"
33 #include <osvr/Util/Verbosity.h>
35 
36 // Library/third-party includes
37 // - none
38 
39 // Standard includes
40 // - none
41 
45 };
46 
48  OSVR_INOUT_PTR OSVR_DeviceInitOptions opts,
49  OSVR_OUT_PTR OSVR_Location2D_DeviceInterface *iface,
50  OSVR_IN OSVR_ChannelCount numSensors) {
51 
52  OSVR_PLUGIN_HANDLE_NULL_CONTEXT("osvrDeviceLocation2DConfigure", opts);
53  OSVR_PLUGIN_HANDLE_NULL_CONTEXT("osvrDeviceLocation2DConfigure", iface);
55  opts->makeInterfaceObject<OSVR_Location2D_DeviceInterfaceObject>();
56  *iface = ifaceObj;
57  auto location = osvr::common::Location2DComponent::create(numSensors);
58  ifaceObj->location = location.get();
59  opts->addComponent(location);
60  return OSVR_RETURN_SUCCESS;
61 }
62 
64  OSVR_IN_PTR OSVR_Location2D_DeviceInterface iface,
65  OSVR_IN_PTR OSVR_Location2DState locationData,
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->location->sendLocationData(locationData, sensor, *timestamp);
71  return OSVR_RETURN_SUCCESS;
72  }
73 
74  return OSVR_RETURN_FAILURE;
75 }
uint32_t OSVR_ChannelCount
The integer type specifying a number of channels/sensors or a channel/sensor index.
Definition: ChannelCountC.h:51
OSVR_ReturnCode osvrDeviceLocation2DReportData(OSVR_Location2D_DeviceInterface iface, OSVR_Location2DState locationData, OSVR_ChannelCount sensor, OSVR_TimeValue const *timestamp)
Report data for a specific sensor.
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
A structure defining a 2D vector, which represents position.
Definition: Vec2C.h:48
OSVR_ReturnCode osvrDeviceLocation2DConfigure(OSVR_DeviceInitOptions opts, OSVR_Location2D_DeviceInterface *iface, OSVR_ChannelCount numSensors)
Specify that your device will implement the Location2D interface.
#define OSVR_RETURN_SUCCESS
The "success" value for an OSVR_ReturnCode.
Definition: ReturnCodesC.h:45
static shared_ptr< Location2DComponent > create(OSVR_ChannelCount numSensor=1)
Factory method.
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...