|
| Listener () |
| Constructs a Listener object. More...
|
|
virtual void | onConnect (const Controller &) |
| Called when the Controller object connects to the Leap Motion software and the Leap Motion hardware device is plugged in, or when this Listener object is added to a Controller that is already connected. More...
|
|
virtual void | onDeviceChange (const Controller &) |
| Called when a Leap Motion controller is plugged in, unplugged, or the device changes state. More...
|
|
virtual void | onDeviceFailure (const Controller &) |
| Called when a Leap Motion controller device is plugged into the client computer, but fails to operate properly. More...
|
|
virtual void | onDisconnect (const Controller &) |
| Called when the Controller object disconnects from the Leap Motion software or the Leap Motion hardware is unplugged. More...
|
|
virtual void | onExit (const Controller &) |
| Called when this Listener object is removed from the Controller or the Controller instance is destroyed. More...
|
|
virtual void | onFocusGained (const Controller &) |
| Called when this application becomes the foreground application. More...
|
|
virtual void | onFocusLost (const Controller &) |
| Called when this application loses the foreground focus. More...
|
|
virtual void | onFrame (const Controller &) |
| Called when a new frame of hand and finger tracking data is available. More...
|
|
virtual void | onImages (const Controller &) |
| Called when new images are available. More...
|
|
virtual void | onInit (const Controller &) |
| Called once, when this Listener object is newly added to a Controller. More...
|
|
virtual void | onLogMessage (const Controller &, MessageSeverity severity, int64_t timestamp, const char *msg) |
| Called when the service emits a log message to report an error, warning, or status change. More...
|
|
virtual void | onServiceChange (const Controller &) |
| Called when the Leap Motion service is paused or resumed or when a controller policy is changed. More...
|
|
virtual void | onServiceConnect (const Controller &) |
| Called when the Leap Motion daemon/service connects to your application Controller. More...
|
|
virtual void | onServiceDisconnect (const Controller &) |
| Called if the Leap Motion daemon/service disconnects from your application Controller. More...
|
|
virtual | ~Listener () |
| Destroys this Listener object. More...
|
|
The Listener class defines a set of callback functions that you can override in a subclass to respond to events dispatched by the Controller object.
To handle Leap Motion events, create an instance of a Listener subclass and assign it to the Controller instance. The Controller calls the relevant Listener callback function when an event occurs, passing in a reference to itself. You do not have to implement callbacks for events you do not want to handle.
The Controller object calls these Listener functions from a thread created by the Leap Motion library, not the thread used to create or set the Listener instance.
- Since
- 1.0
Called when the Controller object disconnects from the Leap Motion software or the Leap Motion hardware is unplugged.
The controller can disconnect when the Leap Motion device is unplugged, the user shuts the Leap Motion software down, or the Leap Motion software encounters an unrecoverable error.
void SampleListener::onDisconnect(const Controller& controller) {
std::cout << "Disconnected" << std::endl;
}
Note: When you launch a Leap-enabled application in a debugger, the Leap Motion library does not disconnect from the application. This is to allow you to step through code without losing the connection because of time outs.
- Parameters
-
controller | The Controller object invoking this callback function. |
- Since
- 1.0
Called when a new frame of hand and finger tracking data is available.
Access the new frame data using the Controller::frame() function.
void SampleListener::onFrame(const Controller& controller) {
std::cout << "New frame available" << std::endl;
}
Note, the Controller skips any pending onFrame events while your onFrame handler executes. If your implementation takes too long to return, one or more frames can be skipped. The Controller still inserts the skipped frames into the frame history. You can access recent frames by setting the history parameter when calling the Controller::frame() function. You can determine if any pending onFrame events were skipped by comparing the ID of the most recent frame with the ID of the last received frame.
- Parameters
-
controller | The Controller object invoking this callback function. |
- Since
- 1.0
virtual void onServiceChange |
( |
const Controller & |
| ) |
|
|
inlinevirtual |
Called when the Leap Motion service is paused or resumed or when a controller policy is changed.
The service can change states because the computer user changes settings in the Leap Motion Control Panel application or because an application connected to the service triggers a change. Any application can pause or unpause the service, but only runtime policy changes you make apply to your own application.
void SampleListener::onServiceChange(const Controller& controller) {
std::cout << "Service state change " << std::endl;
}
You can query the pause state of the controller with Controller::isPaused(). You can check the state of those policies you are interested in with Controller::isPolicySet().
- Parameters
-
controller | The Controller object invoking this callback function. |
- Since
- 3.0