26 #include "com_osvr_example_Locomotion_json.h"
40 class LocomotionDevice {
49 m_dev.initAsync(ctx,
"Locomotion", opts);
52 m_dev.sendJsonDescriptor(com_osvr_example_Locomotion_json);
55 m_dev.registerUpdateCallback(
this);
58 std::srand(std::time(0));
61 OSVR_ReturnCode update() {
63 std::this_thread::sleep_for(std::chrono::milliseconds(
69 int randVel = rand() % (int)(11);
75 velo.
data[0] = randVel * std::abs(std::sin(randVel));
76 velo.
data[1] = randVel * randVel * std::abs(std::sin(randVel));
77 posn.
data[0] = std::abs(std::sin(randPos));
78 posn.
data[1] = std::abs(std::cos(randPos));
92 class HardwareDetection {
94 HardwareDetection() : m_found(false) {}
101 std::cout <<
"PLUGIN: Got a hardware detection request" << std::endl;
106 std::cout <<
"PLUGIN: We have detected Locomotion device! "
110 new LocomotionDevice(ctx));
125 context.registerHardwareDetectCallback(
new HardwareDetection());
Wrapper class for OSVR_DeviceToken.
void osvrTimeValueGetNow(OSVR_TimeValue *dest)
Gets the current time in the TimeValue. Parallel to gettimeofday.
C++ wrapper class for the opaque plugin context.
struct OSVR_LocomotionDeviceInterfaceObject * OSVR_LocomotionDeviceInterface
Opaque type used in conjunction with a device token to send data on Locomotion Interface.
OSVR_ReturnCode osvrDeviceLocomotionReportNaviVelocity(OSVR_LocomotionDeviceInterface iface, OSVR_NaviVelocityState naviVelocity, OSVR_ChannelCount sensor, OSVR_TimeValue const *timestamp)
Report velocity data for a specific sensor.
A structure defining a 2D vector, which represents position.
T * registerObjectForDeletion(OSVR_PluginRegContext ctx, T *obj)
Registers an object to be destroyed with delete when the plugin is unloaded.
double data[2]
Internal array data.
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.
OSVR_ReturnCode osvrDeviceLocomotionConfigure(OSVR_DeviceInitOptions opts, OSVR_LocomotionDeviceInterface *iface)
Specify that your device will implement the Locomotion interface.
#define OSVR_PLUGIN(PLUGIN_NAME)
This macro begins the entry point function of your plugin.
OSVR_ReturnCode osvrDeviceLocomotionReportNaviPosition(OSVR_LocomotionDeviceInterface iface, OSVR_NaviPositionState naviPosition, OSVR_ChannelCount sensor, OSVR_TimeValue const *timestamp)
Report position data for a specific sensor.
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...
Standardized, portable parallel to struct timeval for representing both absolute times and time inter...