27 #include "com_osvr_example_EyeTracker_json.h"
44 class EyeTrackerDevice {
53 m_dev.initAsync(ctx,
"EyeTracker", opts);
56 m_dev.sendJsonDescriptor(com_osvr_example_EyeTracker_json);
59 m_dev.registerUpdateCallback(
this);
62 std::srand(std::time(0));
65 OSVR_ReturnCode update() {
67 std::this_thread::sleep_for(std::chrono::milliseconds(
73 int randVal = std::rand();
77 gaze2D.
data[0] = std::abs(std::sin(randVal));
78 gaze2D.
data[1] = std::abs(std::cos(randVal));
81 gaze3D.
data[0] = std::abs(std::sin(randVal) / (std::cos(randVal)));
82 gaze3D.
data[1] = std::abs(std::cos(randVal) / (std::sin(randVal)));
83 gaze3D.
data[2] = std::abs(std::sin(randVal) * std::sin(randVal));
89 dir.direction = gaze3D;
90 dir.basePoint = gaze3D;
93 dir.basePoint, 0, ×);
106 class HardwareDetection {
108 HardwareDetection() : m_found(false) {}
115 std::cout <<
"PLUGIN: Got a hardware detection request" << std::endl;
120 std::cout <<
"PLUGIN: We have detected Eye Tracker device! "
124 new EyeTrackerDevice(ctx));
139 context.registerHardwareDetectCallback(
new HardwareDetection());
Wrapper class for OSVR_DeviceToken.
A structure defining a 3D vector, often a position/translation.
void osvrTimeValueGetNow(OSVR_TimeValue *dest)
Gets the current time in the TimeValue. Parallel to gettimeofday.
C++ wrapper class for the opaque plugin context.
OSVR_ReturnCode osvrDeviceEyeTrackerReportBlink(OSVR_EyeTrackerDeviceInterface iface, OSVR_EyeTrackerBlinkState blink, OSVR_ChannelCount sensor, OSVR_TimeValue const *timestamp)
Report the blink state.
double data[3]
Internal array data.
struct OSVR_EyeTrackerDeviceInterfaceObject * OSVR_EyeTrackerDeviceInterface
Opaque type used to send data on eye tracker interface (which internally is carried over several inte...
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.
OSVR_ReturnCode osvrDeviceEyeTrackerConfigure(OSVR_DeviceInitOptions opts, OSVR_EyeTrackerDeviceInterface *iface, OSVR_ChannelCount numSensors)
Specify that your device will implement the Eye Tracker interface.
double data[2]
Internal array data.
struct OSVR_MessageTypeObject * OSVR_MessageType
Opaque type of a registered message type within the core library.
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.
OSVR_ReturnCode osvrDeviceEyeTrackerReportGaze(OSVR_EyeTrackerDeviceInterface iface, OSVR_EyeGazePosition2DState gazePosition, OSVR_EyeGazeDirectionState gazeDirection, OSVR_EyeGazeBasePoint3DState gazeBasePoint, OSVR_ChannelCount sensor, OSVR_TimeValue const *timestamp)
Report both 2D and 3D gaze for an eye.
State for 3D gaze report.
Header including the full PluginKit C++ interface.
#define OSVR_PLUGIN(PLUGIN_NAME)
This macro begins the entry point function of your plugin.
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...