34 #include "com_osvr_example_Configured_json.h"
37 #include <json/value.h>
38 #include <json/reader.h>
48 class ConfiguredDevice {
51 : m_myVal(myVal), m_sleepTime(sleepTime) {
59 m_dev.initAsync(ctx,
"MyConfiguredDevice", opts);
62 m_dev.sendJsonDescriptor(com_osvr_example_Configured_json);
65 m_dev.registerUpdateCallback(
this);
68 OSVR_ReturnCode update() {
71 std::this_thread::sleep_for(std::chrono::seconds(m_sleepTime));
85 class ConfiguredDeviceConstructor {
94 if (!r.parse(params, root)) {
95 std::cerr <<
"Could not parse parameters!" << std::endl;
99 if (!root.isMember(
"value")) {
103 std::cerr <<
"Warning: got configuration, but nothing specified "
104 "for \"value\" - will use default!"
109 double val = root.get(
"value", 5.0).asDouble();
113 int sleepTime = root.get(
"sleepTime", 1).asInt();
117 ctx,
new ConfiguredDevice(ctx, val, sleepTime));
128 ctx,
"ConfiguredDevice",
new ConfiguredDeviceConstructor);
Wrapper class for OSVR_DeviceToken.
OSVR_ReturnCode osvrDeviceAnalogSetValue(OSVR_DeviceToken dev, OSVR_AnalogDeviceInterface iface, OSVR_AnalogState val, OSVR_ChannelCount chan)
Report the value of a single channel.
T * registerObjectForDeletion(OSVR_PluginRegContext ctx, T *obj)
Registers an object to be destroyed with delete when the plugin is unloaded.
void registerDriverInstantiationCallback(OSVR_PluginRegContext ctx, const char driverName[], T functor)
Registers a function object to be called when the server is told to instantiate a driver by name with...
struct OSVR_DeviceInitObject * OSVR_DeviceInitOptions
Opaque type of a device initialization object.
#define OSVR_RETURN_SUCCESS
The "success" value for an OSVR_ReturnCode.
OSVR_DeviceInitOptions osvrDeviceCreateInitOptions(OSVR_PluginRegContext ctx)
Create a OSVR_DeviceInitOptions object.
Header including the full PluginKit C++ interface.
struct OSVR_AnalogDeviceInterfaceObject * OSVR_AnalogDeviceInterface
Opaque type used in conjunction with a device token to send data on an analog interface.
OSVR_EXTERN_C_BEGIN typedef void * OSVR_PluginRegContext
A context pointer passed in to your plugin's entry point and other locations of control flow transfer...
OSVR_ReturnCode osvrDeviceAnalogConfigure(OSVR_DeviceInitOptions opts, OSVR_AnalogDeviceInterface *iface, OSVR_ChannelCount numChan)
Specify that your device will implement the Analog interface.