Public Types | Public Member Functions | Public Attributes | Static Public Attributes | Static Private Attributes
Leap::Controller Class Reference

#include <Leap.h>

Inheritance diagram for Leap::Controller:
Inheritance graph
[legend]

List of all members.

Public Types

enum  PolicyFlag { POLICY_DEFAULT = 0, POLICY_BACKGROUND_FRAMES = (1 << 0), POLICY_IMAGES = (1 << 1), POLICY_OPTIMIZE_HMD = (1 << 2) }

Public Member Functions

def __init__
def add_listener
LEAP_EXPORT bool addListener (Listener &listener)
LEAP_EXPORT BugReport bugReport () const
def clear_policy
LEAP_EXPORT void clearPolicy (PolicyFlag policy) const
LEAP_EXPORT Config config () const
 Controller (ControllerImplementation *)
LEAP_EXPORT Controller ()
LEAP_EXPORT Controller (Listener &listener)
LEAP_EXPORT DeviceList devices () const
def enable_gesture
LEAP_EXPORT void enableGesture (Gesture::Type type, bool enable=true) const
def frame
LEAP_EXPORT Frame frame (int history=0) const
LEAP_EXPORT bool hasFocus () const
LEAP_EXPORT ImageList images () const
def is_gesture_enabled
def is_policy_set
def is_service_connected
LEAP_EXPORT bool isConnected () const
LEAP_EXPORT bool isGestureEnabled (Gesture::Type type) const
LEAP_EXPORT bool isPolicySet (PolicyFlag policy) const
LEAP_EXPORT bool isServiceConnected () const
LEAP_EXPORT ScreenList locatedScreens () const
def now
LEAP_EXPORT int64_t now () const
LEAP_EXPORT PolicyFlag policyFlags () const
def remove_listener
LEAP_EXPORT bool removeListener (Listener &listener)
def set_policy
def set_policy_flags
LEAP_EXPORT void setPolicy (PolicyFlag policy) const
LEAP_EXPORT void setPolicyFlags (PolicyFlag flags) const
LEAP_EXPORT TrackedQuad trackedQuad () const
virtual LEAP_EXPORT ~Controller ()

Public Attributes

 this

Static Public Attributes

tuple config = _swig_property(LeapPython.Controller_config_get)
tuple devices = _swig_property(LeapPython.Controller_devices_get)
tuple has_focus = _swig_property(LeapPython.Controller_has_focus_get)
tuple images = _swig_property(LeapPython.Controller_images_get)
tuple is_connected = _swig_property(LeapPython.Controller_is_connected_get)
tuple located_screens = _swig_property(LeapPython.Controller_located_screens_get)
 POLICY_BACKGROUND_FRAMES = LeapPython.Controller_POLICY_BACKGROUND_FRAMES
 POLICY_DEFAULT = LeapPython.Controller_POLICY_DEFAULT
tuple policy_flags = _swig_property(LeapPython.Controller_policy_flags_get)
 POLICY_IMAGES = LeapPython.Controller_POLICY_IMAGES
 POLICY_OPTIMIZE_HMD = LeapPython.Controller_POLICY_OPTIMIZE_HMD
tuple tracked_quad = _swig_property(LeapPython.Controller_tracked_quad_get)

Static Private Attributes

 __del__ = lambdaself:None
tuple __getattr__ = lambdaself,name:_swig_getattr(self, Controller, name)
 __repr__ = _swig_repr
tuple __setattr__ = lambdaself,name,value:_swig_setattr(self, Controller, name, value)
 __swig_destroy__ = LeapPython.delete_Controller
dictionary __swig_getmethods__ = {}
dictionary __swig_setmethods__ = {}

Detailed Description

The Controller class is your main interface to the Leap Motion Controller.

Create an instance of this Controller class to access frames of tracking data and configuration information. Frame data can be polled at any time using the Controller::frame() function. Call frame() or frame(0) to get the most recent frame. Set the history parameter to a positive integer to access previous frames. A controller stores up to 60 frames in its frame history.

Polling is an appropriate strategy for applications which already have an intrinsic update loop, such as a game. You can also add an instance of a subclass of Leap::Listener to the controller to handle events as they occur. The Controller dispatches events to the listener upon initialization and exiting, on connection changes, when the application gains and loses the OS input focus, and when a new frame of tracking data is available. When these events occur, the controller object invokes the appropriate callback function defined in your subclass of Listener.

To access frames of tracking data as they become available:

1. Implement a subclass of the Listener class and override the Listener::onFrame() function. 2. In your Listener::onFrame() function, call the Controller::frame() function to access the newest frame of tracking data. 3. To start receiving frames, create a Controller object and add an instance of the Listener subclass to the Controller::addListener() function.

When an instance of a Listener subclass is added to a Controller object, it calls the Listener::onInit() function when the listener is ready for use. When a connection is established between the controller and the Leap Motion software, the controller calls the Listener::onConnect() function. At this point, your application will start receiving frames of data. The controller calls the Listener::onFrame() function each time a new frame is available. If the controller loses its connection with the Leap Motion software or device for any reason, it calls the Listener::onDisconnect() function. If the listener is removed from the controller or the controller is destroyed, it calls the Listener::onExit() function. At that point, unless the listener is added to another controller again, it will no longer receive frames of tracking data.

The Controller object is multithreaded and calls the Listener functions on its own thread, not on an application thread.

Since:
1.0

Definition at line 5558 of file Leap.h.


Member Enumeration Documentation

The supported controller policies.

The supported policy flags are:

**POLICY_BACKGROUND_FRAMES** -- requests that your application receives frames when it is not the foreground application for user input.

The background frames policy determines whether an application receives frames of tracking data while in the background. By default, the Leap Motion software only sends tracking data to the foreground application. Only applications that need this ability should request the background frames policy. The "Allow Background Apps" checkbox must be enabled in the Leap Motion Control Panel or this policy will be denied.

**POLICY_IMAGES** -- request that your application receives images from the device cameras. The "Allow Images" checkbox must be enabled in the Leap Motion Control Panel or this policy will be denied.

The images policy determines whether an application receives image data from the Leap Motion sensors which each frame of data. By default, this data is not sent. Only applications that use the image data should request this policy.

**POLICY_OPTIMIZE_HMD** -- request that the tracking be optimized for head-mounted tracking.

The optimize HMD policy improves tracking in situations where the Leap Motion hardware is attached to a head-mounted display. This policy is not granted for devices that cannot be mounted to an HMD, such as Leap Motion controllers embedded in a laptop or keyboard.

Some policies can be denied if the user has disabled the feature on their Leap Motion control panel.

Since:
1.0
Enumerator:
POLICY_DEFAULT 

The default policy.

Since:
1.0
POLICY_BACKGROUND_FRAMES 

Receive background frames.

Since:
1.0
POLICY_IMAGES 

Receive raw images from sensor cameras.

Since:
2.1.0
POLICY_OPTIMIZE_HMD 

Optimize the tracking for head-mounted device.

Since:
2.1.2

Definition at line 5669 of file Leap.h.


Constructor & Destructor Documentation

Leap::Controller::Controller ( ControllerImplementation *  )

Constructs a Controller object.

When creating a Controller object, you may optionally pass in a reference to an instance of a subclass of Leap::Listener. Alternatively, you may add a listener using the Controller::addListener() function.

Since:
1.0

Constructs a Controller object.

When creating a Controller object, you may optionally pass in a reference to an instance of a subclass of Leap::Listener. Alternatively, you may add a listener using the Controller::addListener() function.

Parameters:
listenerAn instance of Leap::Listener implementing the callback functions for the Leap Motion events you want to handle in your application.
Since:
1.0
def Leap::Controller::__init__ (   self,
  args 
)

Definition at line 2158 of file Leap.py.


Member Function Documentation

def Leap::Controller::add_listener (   self,
  listener 
)

Definition at line 2184 of file Leap.py.

Adds a listener to this Controller.

The Controller dispatches Leap Motion events to each associated listener. The order in which listener callback functions are invoked is arbitrary. If you pass a listener to the Controller's constructor function, it is automatically added to the list and can be removed with the Controller::removeListener() function.

The Controller does not keep a strong reference to the Listener instance. Ensure that you maintain a reference until the listener is removed from the controller.

Parameters:
listenerA subclass of Leap::Listener implementing the callback functions for the Leap Motion events you want to handle in your application.
Returns:
Whether or not the listener was successfully added to the list of listeners.
Since:
1.0
def Leap::Controller::clear_policy (   self,
  policy 
)

Definition at line 2178 of file Leap.py.

Requests clearing a policy.

Policy changes are completed asynchronously and, because they are subject to user approval or system compatibility checks, may not complete successfully. Call Controller::isPolicySet() after a suitable interval to test whether the change was accepted.

Parameters:
flagsA PolicyFlag value indicating the policy to request.
Since:
2.1.6

Returns a Config object, which you can use to query the Leap Motion system for configuration information.

Returns:
The Controller's Config object.
Since:
1.0

The list of currently attached and recognized Leap Motion controller devices.

The Device objects in the list describe information such as the range and tracking volume.

Currently, the Leap Motion Controller only allows a single active device at a time, however there may be multiple devices physically attached and listed here. Any active device(s) are guaranteed to be listed first, however order is not determined beyond that.

Returns:
The list of Leap Motion controllers.
Since:
1.0
def Leap::Controller::enable_gesture (   self,
  type,
  enable = True 
)

Definition at line 2193 of file Leap.py.

LEAP_EXPORT void Leap::Controller::enableGesture ( Gesture::Type  type,
bool  enable = true 
) const

Enables or disables reporting of a specified gesture type.

By default, all gesture types are disabled. When disabled, gestures of the disabled type are never reported and will not appear in the frame gesture list.

As a performance optimization, only enable recognition for the types of movements that you use in your application.

Parameters:
typeThe type of gesture to enable or disable. Must be a member of the Gesture::Type enumeration.
enableTrue, to enable the specified gesture type; False, to disable.
See also:
Controller::isGestureEnabled()
Since:
1.0
def Leap::Controller::frame (   self,
  history = 0 
)

Definition at line 2190 of file Leap.py.

LEAP_EXPORT Frame Leap::Controller::frame ( int  history = 0) const

Returns a frame of tracking data from the Leap Motion software. Use the optional history parameter to specify which frame to retrieve. Call frame() or frame(0) to access the most recent frame; call frame(1) to access the previous frame, and so on. If you use a history value greater than the number of stored frames, then the controller returns an invalid frame.

You can call this function in your Listener implementation to get frames at the Leap Motion frame rate:

Parameters:
historyThe age of the frame to return, counting backwards from the most recent frame (0) into the past and up to the maximum age (59).
Returns:
The specified frame; or, if no history parameter is specified, the newest frame. If a frame is not available at the specified history position, an invalid Frame is returned.
Since:
1.0

Reports whether this application is the focused, foreground application.

By default, your application only receives tracking information from the Leap Motion controller when it has the operating system input focus. To receive tracking data when your application is in the background, the background frames policy flag must be set.

Returns:
True, if application has focus; false otherwise.
See also:
Controller::setPolicyFlags()
Since:
1.0

The most recent set of images from the Leap Motion cameras.

Depending on timing and the current processing frame rate, the images obtained with this function can be newer than images obtained from the current frame of tracking data.

Returns:
An ImageList object containing the most recent camera images.
Since:
2.2.1
def Leap::Controller::is_gesture_enabled (   self,
  type 
)

Definition at line 2196 of file Leap.py.

def Leap::Controller::is_policy_set (   self,
  policy 
)

Definition at line 2181 of file Leap.py.

Definition at line 2165 of file Leap.py.

Reports whether this Controller is connected to the Leap Motion service and the Leap Motion hardware is plugged in.

When you first create a Controller object, isConnected() returns false. After the controller finishes initializing and connects to the Leap Motion software and if the Leap Motion hardware is plugged in, isConnected() returns true.

You can either handle the onConnect event using a Listener instance or poll the isConnected() function if you need to wait for your application to be connected to the Leap Motion software before performing some other operation.

Returns:
True, if connected; false otherwise.
Since:
1.0

Reports whether the specified gesture type is enabled.

Parameters:
typeThe type of gesture to check; a member of the Gesture::Type enumeration.
Returns:
True, if the specified type is enabled; false, otherwise.
See also:
Controller::enableGesture()
Since:
1.0

Gets the active setting for a specific policy.

Keep in mind that setting a policy flag is asynchronous, so changes are not effective immediately after calling setPolicyFlag(). In addition, a policy request can be declined by the user. You should always set the policy flags required by your application at startup and check that the policy change request was successful after an appropriate interval.

If the controller object is not connected to the Leap Motion software, then the default state for the selected policy is returned.

Parameters:
flagsA PolicyFlag value indicating the policy to query.
Returns:
A boolean indicating whether the specified policy has been set.
Since:
2.1.6

Reports whether your application has a connection to the Leap Motion daemon/service. Can be true even if the Leap Motion hardware is not available.

Since:
1.2
def Leap::Controller::now (   self)

Definition at line 2199 of file Leap.py.

Returns a timestamp value as close as possible to the current time. Values are in microseconds, as with all the other timestamp values.

Since:
2.2.7

This function has been deprecated. Use isPolicySet() instead.

Deprecated:
2.1.6
def Leap::Controller::remove_listener (   self,
  listener 
)

Definition at line 2187 of file Leap.py.

Remove a listener from the list of listeners that will receive Leap Motion events. A listener must be removed if its lifetime is shorter than the controller to which it is listening.

Parameters:
listenerThe listener to remove.
Returns:
Whether or not the listener was successfully removed from the list of listeners.
Since:
1.0
def Leap::Controller::set_policy (   self,
  policy 
)

Definition at line 2175 of file Leap.py.

def Leap::Controller::set_policy_flags (   self,
  flags 
)

Definition at line 2172 of file Leap.py.

Requests setting a policy.

A request to change a policy is subject to user approval and a policy can be changed by the user at any time (using the Leap Motion settings dialog). The desired policy flags must be set every time an application runs.

Policy changes are completed asynchronously and, because they are subject to user approval or system compatibility checks, may not complete successfully. Call Controller::isPolicySet() after a suitable interval to test whether the change was accepted.

Parameters:
policyA PolicyFlag value indicating the policy to request.
Since:
2.1.6

This function has been deprecated. Use setPolicy() and clearPolicy() instead.

Deprecated:
2.1.6

Note: This class is an experimental API for internal use only. It may be removed without warning.

Returns information about the currently detected quad in the scene.

If no quad is being tracked, then an invalid TrackedQuad is returned.

Since:
2.2.6

Member Data Documentation

Leap::Controller::__del__ = lambdaself:None [static, private]

Definition at line 2156 of file Leap.py.

tuple Leap::Controller::__getattr__ = lambdaself,name:_swig_getattr(self, Controller, name) [static, private]

Reimplemented from Leap::Interface.

Definition at line 2153 of file Leap.py.

Definition at line 2154 of file Leap.py.

tuple Leap::Controller::__setattr__ = lambdaself,name,value:_swig_setattr(self, Controller, name, value) [static, private]

Reimplemented from Leap::Interface.

Definition at line 2149 of file Leap.py.

Leap::Controller::__swig_destroy__ = LeapPython.delete_Controller [static, private]

Definition at line 2155 of file Leap.py.

dictionary Leap::Controller::__swig_getmethods__ = {} [static, private]

Reimplemented from Leap::Interface.

Definition at line 2150 of file Leap.py.

dictionary Leap::Controller::__swig_setmethods__ = {} [static, private]

Reimplemented from Leap::Interface.

Definition at line 2146 of file Leap.py.

tuple Leap::Controller::config = _swig_property(LeapPython.Controller_config_get) [static]

Definition at line 2212 of file Leap.py.

tuple Leap::Controller::devices = _swig_property(LeapPython.Controller_devices_get) [static]

Definition at line 2221 of file Leap.py.

tuple Leap::Controller::has_focus = _swig_property(LeapPython.Controller_has_focus_get) [static]

Definition at line 2206 of file Leap.py.

tuple Leap::Controller::images = _swig_property(LeapPython.Controller_images_get) [static]

Definition at line 2215 of file Leap.py.

tuple Leap::Controller::is_connected = _swig_property(LeapPython.Controller_is_connected_get) [static]

Definition at line 2203 of file Leap.py.

tuple Leap::Controller::located_screens = _swig_property(LeapPython.Controller_located_screens_get) [static]

Definition at line 2218 of file Leap.py.

Leap::Controller::POLICY_BACKGROUND_FRAMES = LeapPython.Controller_POLICY_BACKGROUND_FRAMES [static]

Definition at line 2168 of file Leap.py.

Leap::Controller::POLICY_DEFAULT = LeapPython.Controller_POLICY_DEFAULT [static]

Definition at line 2167 of file Leap.py.

tuple Leap::Controller::policy_flags = _swig_property(LeapPython.Controller_policy_flags_get) [static]

Definition at line 2209 of file Leap.py.

Leap::Controller::POLICY_IMAGES = LeapPython.Controller_POLICY_IMAGES [static]

Definition at line 2169 of file Leap.py.

Leap::Controller::POLICY_OPTIMIZE_HMD = LeapPython.Controller_POLICY_OPTIMIZE_HMD [static]

Definition at line 2170 of file Leap.py.

Definition at line 2158 of file Leap.py.

tuple Leap::Controller::tracked_quad = _swig_property(LeapPython.Controller_tracked_quad_get) [static]

Definition at line 2224 of file Leap.py.


The documentation for this class was generated from the following files:


leap_motion
Author(s): Florian Lier , Mirza Shah , Isaac IY Saito
autogenerated on Sat Jun 8 2019 18:47:25