Tracker Event API

Detailed Description

These functions add and remove event handlers for a specific tracker target and type of event.

List of Functions

ZSError  zsAddTrackerEventHandler (ZSHandle targetHandle, ZSTrackerEventType trackerEventType, ZSTrackerEventHandler trackerEventHandler, const void* userData)
ZSError  zsRemoveTrackerEventHandler (ZSHandle targetHandle, ZSTrackerEventType trackerEventType, ZSTrackerEventHandler trackerEventHandler)

List of Data Structures

struct   ZSTrackerEventData
  The tracker event data type. More...

List of Typedefs

typedef void(*  ZSTrackerEventHandler )(ZSHandle targetHandle, const ZSTrackerEventData *eventData, const void *userData)

List of Enumerations

enum   ZSTrackerEventType {
  ZS_TRACKER_EVENT_MOVE = 0x0101,
  ZS_TRACKER_EVENT_BUTTON_PRESS = 0x0201,
  ZS_TRACKER_EVENT_BUTTON_RELEASE = 0x0202,
  ZS_TRACKER_EVENT_TAP_PRESS = 0x0301,
  ZS_TRACKER_EVENT_TAP_RELEASE = 0x0302,
  ZS_TRACKER_EVENT_TAP_HOLD = 0x0303,
  ZS_TRACKER_EVENT_TAP_SINGLE = 0x0304,
  ZS_TRACKER_EVENT_TAP_DOUBLE = 0x0305,
  ZS_TRACKER_EVENT_ALL = 0xFFFF
}

Function Descriptions

ZSError zsAddTrackerEventHandler ( ZSHandle  targetHandle,
ZSTrackerEventType  trackerEventType,
ZSTrackerEventHandler  trackerEventHandler,
const void*   userData 
)

Adds an event handler for the specified tracker target and event type. Event handlers are invoked asynchronously on a background thread managed by the zSpace SDK. Refer to ZSTrackerEventType for the available types of tracker events.

Parameters:
[in] targetHandle A handle to the tracker target.
[in] trackerEventType The event type with which the handler is being registered.
[in] trackerEventHandler The user defined event handler that adheres to the ZSTrackerEventHandler signature.
[in] userData A reference to custom user data that will be passed along to the event handler.
Example:
  // Custom button press handler 
  void handleButtonPress(ZSHandle targetHandle, 
                         const ZSTrackerEventData* eventData, 
                         const void* userData)
 {
   if (eventData->type == ZS_TRACKER_EVENT_BUTTON_PRESS)
   {
     printf("Button %d: Pressed (%f, %f, %f)\n", 
             eventData->buttonId, 
             eventData->poseMatrix.m03, 
             eventData->poseMatrix.m13, 
             eventData->poseMatrix.m23);
   }
 }
 
 int main()
 {
   // zSpace initialization code goes here. 
   ZSContext context = ...;

   // Get the stylus target
   ZSHandle stylusHandle = NULL;
   zsFindTargetByType(context, ZS_TARGET_TYPE_PRIMARY, 0, &stylusHandle);

   // Register button event handler. 
   zsAddTrackerEventHandler(stylusHandle, 
                            ZS_TRACKER_EVENT_BUTTON_PRESS, 
                            &handleButtonPress, 
                            0);

   // zSpace shutdown code goes here. 
   return 0;
 }
ZSError zsRemoveTrackerEventHandler ( ZSHandle  targetHandle,
ZSTrackerEventType  trackerEventType,
ZSTrackerEventHandler  trackerEventHandler 
)

Removes a tracker event handler. Both the event handler and event type must match for the handler to be deregistered.

Parameters:
[in] targetHandle A handle to the tracker target.
[in] trackerEventType The event type with which the handler is being deregistered.
[in] trackerEventHandler The handler to be removed.

Typedef Descriptions

typedef void(* ZSTrackerEventHandler)(ZSHandle targetHandle, const ZSTrackerEventData *eventData, const void *userData)

Handler for tracker events.

Parameters:
[in] targetHandle The handle to the tracker target that the event was generated for.
[in] eventData A pointer to the event data.
[in] userData A pointer to the user defined data that was passed in to the zsAddTrackerEventHandler() function.

Enumeration Descriptions

Defines event types that you can use with a tracker event handler.

Enumerator:
ZS_TRACKER_EVENT_MOVE 
ZS_TRACKER_EVENT_BUTTON_PRESS 
ZS_TRACKER_EVENT_BUTTON_RELEASE 
ZS_TRACKER_EVENT_TAP_PRESS 
ZS_TRACKER_EVENT_TAP_RELEASE 
ZS_TRACKER_EVENT_TAP_HOLD 
ZS_TRACKER_EVENT_TAP_SINGLE 
ZS_TRACKER_EVENT_TAP_DOUBLE 
ZS_TRACKER_EVENT_ALL