OSVR-Core
Typedefs | Functions
DeviceInterfaceC.h File Reference

Header. More...

#include <osvr/PluginKit/Export.h>
#include <osvr/PluginKit/CommonC.h>
#include <osvr/Util/DeviceCallbackTypesC.h>
#include <osvr/Util/AnnotationMacrosC.h>
#include <osvr/Util/TimeValueC.h>
#include <stddef.h>

Go to the source code of this file.

Typedefs

typedef struct OSVR_DeviceTokenObjectOSVR_DeviceToken
 Opaque type of a registered device token within the core library. More...
 
typedef struct OSVR_MessageTypeObjectOSVR_MessageType
 Opaque type of a registered message type within the core library. More...
 
typedef struct OSVR_DeviceInitObjectOSVR_DeviceInitOptions
 Opaque type of a device initialization object. More...
 

Functions

OSVR_PLUGINKIT_EXPORT OSVR_DeviceInitOptions osvrDeviceCreateInitOptions (OSVR_IN_PTR OSVR_PluginRegContext ctx) OSVR_FUNC_NONNULL((1))
 Create a OSVR_DeviceInitOptions object. More...
 
OSVR_PLUGINKIT_EXPORT OSVR_ReturnCode osvrDeviceRegisterMessageType (OSVR_IN_PTR OSVR_PluginRegContext ctx, OSVR_IN_STRZ const char *name, OSVR_OUT_PTR OSVR_MessageType *msgtype) OSVR_FUNC_NONNULL((1
 Register (or recall) a message type by name. More...
 
OSVR_PLUGINKIT_EXPORT OSVR_ReturnCode OSVR_PLUGINKIT_EXPORT OSVR_ReturnCode osvrDeviceSendData (OSVR_IN_PTR OSVR_DeviceToken dev, OSVR_IN_PTR OSVR_MessageType msg, OSVR_IN_READS(len) const char *bytestream, OSVR_IN size_t len) OSVR_FUNC_NONNULL((1
 Send a raw bytestream from your device. More...
 
OSVR_PLUGINKIT_EXPORT OSVR_ReturnCode OSVR_PLUGINKIT_EXPORT OSVR_ReturnCode OSVR_PLUGINKIT_EXPORT OSVR_ReturnCode osvrDeviceSendTimestampedData (OSVR_IN_PTR OSVR_DeviceToken dev, OSVR_IN_PTR const OSVR_TimeValue *timestamp, OSVR_IN_PTR OSVR_MessageType msg, OSVR_IN_READS(len) const char *bytestream, OSVR_IN size_t len) OSVR_FUNC_NONNULL((1
 Send a raw bytestream from your device, with a known timestamp. More...
 
OSVR_PLUGINKIT_EXPORT OSVR_ReturnCode OSVR_PLUGINKIT_EXPORT OSVR_ReturnCode OSVR_PLUGINKIT_EXPORT OSVR_ReturnCode OSVR_PLUGINKIT_EXPORT OSVR_ReturnCode osvrDeviceSendJsonDescriptor (OSVR_IN_PTR OSVR_DeviceToken dev, OSVR_IN_READS(len) const char *json, OSVR_IN size_t len) OSVR_FUNC_NONNULL((1
 Submit a JSON self-descriptor string for the device. More...
 
OSVR_PLUGINKIT_EXPORT OSVR_ReturnCode OSVR_PLUGINKIT_EXPORT OSVR_ReturnCode OSVR_PLUGINKIT_EXPORT OSVR_ReturnCode OSVR_PLUGINKIT_EXPORT OSVR_ReturnCode OSVR_PLUGINKIT_EXPORT OSVR_ReturnCode osvrDeviceRegisterUpdateCallback (OSVR_IN_PTR OSVR_DeviceToken dev, OSVR_IN OSVR_DeviceUpdateCallback updateCallback, OSVR_IN_OPT void *userData OSVR_CPP_ONLY(=NULL)) OSVR_FUNC_NONNULL((1))
 Register the update callback of a device. More...
 
OSVR_PLUGINKIT_EXPORT OSVR_ReturnCode OSVR_PLUGINKIT_EXPORT OSVR_ReturnCode OSVR_PLUGINKIT_EXPORT OSVR_ReturnCode osvrDeviceMicrosleep (OSVR_IN uint64_t microseconds)
 Request a thread sleep for at least the given number of microseconds. More...
 
Synchronous Devices

Devices declaring themselves to be synchronous must abide by strict rules.

Their update method is run regularly in the main thread of the device system, without the overhead of locking. In exchange, however, the following restrictions apply:

  • The update method must complete as quickly as reasonably possible, since it adds to overall latency.
  • No data may be sent through the library outside of the update method, and the update method should only be called by the core library (not by the plugin)
OSVR_PLUGINKIT_EXPORT OSVR_ReturnCode osvrDeviceSyncInit (OSVR_IN_PTR OSVR_PluginRegContext ctx, OSVR_IN_STRZ const char *name, OSVR_OUT_PTR OSVR_DeviceToken *device) OSVR_FUNC_NONNULL((1
 Initialize a synchronous device token. More...
 
OSVR_PLUGINKIT_EXPORT OSVR_ReturnCode OSVR_PLUGINKIT_EXPORT OSVR_ReturnCode osvrDeviceSyncInitWithOptions (OSVR_IN_PTR OSVR_PluginRegContext ctx, OSVR_IN_STRZ const char *name, OSVR_IN_PTR OSVR_DeviceInitOptions options, OSVR_OUT_PTR OSVR_DeviceToken *device) OSVR_FUNC_NONNULL((1
 Initialize a synchronous device token. More...
 
Asynchronous Devices

These devices are more event-based: either it's convenient for your driver to block until full data arrives, or you can't be sure your driver can get in and out of an update function very rapidly.

As a result, devices registered as async have their update method run in a thread of its own, repeatedly as long as the device exists. Calls sending data from an async device are automatically made thread-safe.

OSVR_PLUGINKIT_EXPORT OSVR_ReturnCode osvrDeviceAsyncInit (OSVR_IN_PTR OSVR_PluginRegContext ctx, OSVR_IN_STRZ const char *name, OSVR_OUT_PTR OSVR_DeviceToken *device) OSVR_FUNC_NONNULL((1
 Initialize an asynchronous device token. More...
 
OSVR_PLUGINKIT_EXPORT OSVR_ReturnCode OSVR_PLUGINKIT_EXPORT OSVR_ReturnCode osvrDeviceAsyncInitWithOptions (OSVR_IN_PTR OSVR_PluginRegContext ctx, OSVR_IN_STRZ const char *name, OSVR_IN_PTR OSVR_DeviceInitOptions options, OSVR_OUT_PTR OSVR_DeviceToken *device) OSVR_FUNC_NONNULL((1
 Initialize an asynchronous device token. More...
 

Detailed Description

Header.

Must be c-safe!

Date
2014
Author
Sensics, Inc. http://sensics.com/osvr