As suggested in the previous two sections, you can get more than the stylus's current pose. You can track stylus movement and stylus button state. Refer to Handling Events for an example of tracking stylus movement.
To determine whether a button is pressed, you can use the Target Button API. The following partial code example shows polling for the stylus button state. For brevity, error handling is not shown. For a more complete example, refer to the Stylus Button Polled sample application in the Samples\Device subdirectory.
// zSpaceContext set during initialization. // ZSContext zSpaceContext = ...; // Get the stylus target. ZSHandle stylusHandle = NULL; zsFindTargetByType(zSpaceContext, ZS_TARGET_TYPE_PRIMARY, 0, &stylusHandle); // Get the number of buttons. ZSInt32 numButtons = 0; zsGetNumTargetButtons(stylusHandle, &numButtons); // For every stylus button: for (ZSInt32 buttonId = 0; buttonId < numButtons; ++buttonId) { // Get the state of the specified stylus button. ZSBool isButtonPressed = false; zsIsTargetButtonPressed(stylusHandle, buttonId, &isButtonPressed); // Report the current state of the specified stylus button. if (isButtonPressed) printf("Button Id %d: Pressed\n", buttonId); else printf("Button Id %d: Not Pressed\n", buttonId); }
You can also check whether the stylus is vibrating or the LED light is on with the following functions: