DeviceΒΆ

The Device class represents a physically connected device. More...

Inherits Interface.

Public Types

enum  Type
 The available types of Leap Motion controllers. More...
 

Public Member Functions

float baseline () const
 The distance between the center points of the stereo sensors. More...
 
 Device (DeviceImplementation *)
 
 Device ()
 Constructs a Device object. More...
 
float distanceToBoundary (const Vector &position) const
 The distance to the nearest edge of the Leap Motion controller's view volume. More...
 
float horizontalViewAngle () const
 The angle of view along the x axis of this device. More...
 
bool isEmbedded () const
 
bool isLightingBad () const
 The software has detected excessive IR illumination, which may interfere with tracking. More...
 
bool isSmudged () const
 The software has detected a possible smudge on the translucent cover over the Leap Motion cameras. More...
 
bool isStreaming () const
 Reports whether this device is streaming data to your application. More...
 
bool isValid () const
 Reports whether this is a valid Device object. More...
 
bool operator!= (const Device &) const
 Compare Device object inequality. More...
 
bool operator== (const Device &) const
 Compare Device object equality. More...
 
Matrix orientation () const
 
Vector position () const
 
float range () const
 The maximum reliable tracking range from the center of this device. More...
 
std::string serialNumber () const
 An alphanumeric serial number unique to each device. More...
 
std::string toString () const
 A string containing a brief, human readable description of the Device object. More...
 
Type type () const
 The device type. More...
 
float verticalViewAngle () const
 The angle of view along the z axis of this device. More...
 

Static Public Member Functions

static const Deviceinvalid ()
 Returns an invalid Device object. More...
 

Friends

std::ostream & operator<< (std::ostream &, const Device &)
 Writes a brief, human readable description of the Device object. More...
 

Detailed Description

The Device class represents a physically connected device.

The Device class contains information related to a particular connected device such as device id, field of view relative to the device, and the position and orientation of the device in relative coordinates.

The position and orientation describe the alignment of the device relative to the user. The alignment relative to the user is only descriptive. Aligning devices to users provides consistency in the parameters that describe user interactions.

Note that Device objects can be invalid, which means that they do not contain valid device information and do not correspond to a physical device. Test for validity with the Device::isValid() function.

Since
1.0

Member Enumeration Documentation

enum Type

The available types of Leap Motion controllers.

Since
1.2
Enumerator
TYPE_PERIPHERAL 

A standalone USB peripheral.

The original Leap Motion controller device.

Since
1.2
TYPE_HP_LEGACY 
Deprecated:
3.0
TYPE_KEYBOARD 
Deprecated:
3.0
TYPE_LAPTOP 
Deprecated:
3.0

Constructor & Destructor Documentation

Device ( DeviceImplementation *  )
Device ( )

Constructs a Device object.

An uninitialized device is considered invalid. Get valid Device objects from a DeviceList object obtained using the Controller::devices() method.

Leap::Device device = controller.devices()[0];
Since
1.0

Member Function Documentation

float baseline ( ) const

The distance between the center points of the stereo sensors.

The baseline value, together with the maximum resolution, influence the maximum range.

Returns
The separation distance between the center of each sensor, in mm.
Since
2.2.5
float distanceToBoundary ( const Vector position) const

The distance to the nearest edge of the Leap Motion controller's view volume.

The view volume is an axis-aligned, inverted pyramid centered on the device origin and extending upward to the range limit. The walls of the pyramid are described by the horizontalViewAngle and verticalViewAngle and the roof by the range. This function estimates the distance between the specified input position and the nearest wall or roof of the view volume.

Leap::Pointable frontFinger = controller.frame().fingers().frontmost();
float distanceToBoxWall = device.distanceToBoundary(frontFinger.tipPosition());
Parameters
positionThe point to use for the distance calculation.
Returns
The distance in millimeters from the input position to the nearest boundary.
Since
1.0
float horizontalViewAngle ( ) const

The angle of view along the x axis of this device.

Leap_horizontalViewAngle.png

The Leap Motion controller scans a region in the shape of an inverted pyramid centered at the device's center and extending upwards. The horizontalViewAngle reports the view angle along the long dimension of the device.

float angleOnLongDimension = device.horizontalViewAngle();
Returns
The horizontal angle of view in radians.
Since
1.0
static const Device& invalid ( )
static

Returns an invalid Device object.

You can use the instance returned by this function in comparisons testing whether a given Device instance is valid or invalid. (You can also use the Device::isValid() function.)

if (device != Leap::Device::invalid()) {
float trackingRange = device.range();
}
Returns
The invalid Device instance.
Since
1.0
bool isEmbedded ( ) const
Returns
False.
Deprecated:
3.0
bool isLightingBad ( ) const

The software has detected excessive IR illumination, which may interfere with tracking.

If robust mode is enabled, the system will enter robust mode when isLightingBad() is true.

bool tooBright = device.isLightingBad();
Since
3.0
bool isSmudged ( ) const

The software has detected a possible smudge on the translucent cover over the Leap Motion cameras.

bool dirty = device.isSmudged();
Since
3.0
bool isStreaming ( ) const

Reports whether this device is streaming data to your application.

Currently only one controller can provide data at a time.

Since
1.2
bool isValid ( ) const

Reports whether this is a valid Device object.

if (device.isValid()) {
float maxRange = device.range();
}
Returns
True, if this Device object contains valid data.
Since
1.0
bool operator!= ( const Device ) const

Compare Device object inequality.

thisDevice != thatDevice;

Two Device objects are equal if and only if both Device objects represent the exact same Device and both Devices are valid.

Since
1.0
bool operator== ( const Device ) const

Compare Device object equality.

thisDevice == thatDevice;

Two Device objects are equal if and only if both Device objects represent the exact same Device and both Devices are valid.

Since
1.0
Matrix orientation ( ) const
Vector position ( ) const
float range ( ) const

The maximum reliable tracking range from the center of this device.

The range reports the maximum recommended distance from the device center for which tracking is expected to be reliable. This distance is not a hard limit. Tracking may be still be functional above this distance or begin to degrade slightly before this distance depending on calibration and extreme environmental conditions.

float range = device.range();
Returns
The recommended maximum range of the device in mm.
Since
1.0
std::string serialNumber ( ) const
inline

An alphanumeric serial number unique to each device.

Consumer device serial numbers consist of 2 letters followed by 11 digits.

When using multiple devices, the serial number provides an unambiguous identifier for each device.

Since
2.2.2
std::string toString ( ) const
inline

A string containing a brief, human readable description of the Device object.

Returns
A description of the Device as a string.
Since
1.0
Type type ( ) const

The device type.

Use the device type value in the (rare) circumstances that you have an application feature which relies on a particular type of device. Current types of device include the original Leap Motion peripheral, keyboard-embedded controllers, and laptop-embedded controllers.

Returns
The physical device type as a member of the DeviceType enumeration.
Since
1.2
float verticalViewAngle ( ) const

The angle of view along the z axis of this device.

Leap_verticalViewAngle.png

The Leap Motion controller scans a region in the shape of an inverted pyramid centered at the device's center and extending upwards. The verticalViewAngle reports the view angle along the short dimension of the device.

float angleOnShortDimension = device.verticalViewAngle();
Returns
The vertical angle of view in radians.
Since
1.0

Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  ,
const Device  
)
friend

Writes a brief, human readable description of the Device object.

std::cout << device << std::endl;
Since
1.0