ConfigΒΆ

The Config class provides access to Leap Motion system configuration information. More...

Inherits Interface.

Public Types

enum  ValueType
 Enumerates the possible data types for configuration values. More...
 

Public Member Functions

 Config ()
 Constructs a Config object. More...
 
bool getBool (const std::string &key) const
 Gets the boolean representation for the specified key. More...
 
float getFloat (const std::string &key) const
 Gets the floating point representation for the specified key. More...
 
int32_t getInt32 (const std::string &key) const
 Gets the 32-bit integer representation for the specified key. More...
 
std::string getString (const std::string &key) const
 Gets the string representation for the specified key. More...
 
bool save ()
 Saves the current state of the config. More...
 
bool setBool (const std::string &key, bool value)
 Sets the boolean representation for the specified key. More...
 
bool setFloat (const std::string &key, float value)
 Sets the floating point representation for the specified key. More...
 
bool setInt32 (const std::string &key, int32_t value)
 Sets the 32-bit integer representation for the specified key. More...
 
bool setString (const std::string &key, const std::string &value)
 Sets the string representation for the specified key. More...
 
ValueType type (const std::string &key) const
 Reports the natural data type for the value related to the specified key. More...
 

Detailed Description

The Config class provides access to Leap Motion system configuration information.

You can get and set gesture configuration parameters using the Config object obtained from a connected Controller object. The key strings required to identify a configuration parameter include:

embed:rst:leading-asterisk
* ====================================  ========== ============= =======
* Key string                            Value type Default value Units
* ====================================  ========== ============= =======
* Gesture.Circle.MinRadius              float      5.0           mm
* Gesture.Circle.MinArc                 float      1.5 * pi      radians
* Gesture.Swipe.MinLength               float      150           mm
* Gesture.Swipe.MinVelocity             float      1000          mm/s
* Gesture.KeyTap.MinDownVelocity        float      50            mm/s
* Gesture.KeyTap.HistorySeconds         float      0.1           s
* Gesture.KeyTap.MinDistance            float      3.0           mm
* Gesture.ScreenTap.MinForwardVelocity  float      50            mm/s
* Gesture.ScreenTap.HistorySeconds      float      0.1           s
* Gesture.ScreenTap.MinDistance         float      5.0           mm
* ====================================  ========== ============= =======
* 

After setting a configuration value, you must call the Config::save() method to commit the changes. You can save after the Controller has connected to the Leap Motion service/daemon. In other words, after the Controller has dispatched the serviceConnected or connected events or Controller::isConnected is true. The configuration value changes are not persistent; your application needs to set the values every time it runs.

See also
CircleGesture
KeyTapGesture
ScreenTapGesture
SwipeGesture
Since
1.0

Member Enumeration Documentation

enum ValueType

Enumerates the possible data types for configuration values.

The Config::type() function returns an item from the ValueType enumeration.

Since
1.0
Enumerator
TYPE_UNKNOWN 

The data type is unknown.

Since
1.0
TYPE_BOOLEAN 

A boolean value.

Since
1.0
TYPE_INT32 

A 32-bit integer.

Since
1.0
TYPE_FLOAT 

A floating-point number.

Since
1.0
TYPE_STRING 

A string of characters.

Since
1.0

Constructor & Destructor Documentation

Config ( )

Constructs a Config object.

Do not create your own Config objects. Get a Config object using the Controller::config() function.

Leap::Config config = controller.config();
Since
1.0

Member Function Documentation

bool getBool ( const std::string &  key) const
inline

Gets the boolean representation for the specified key.

bool booleanValue = controller.config().getBool("Key.For.Bool.Setting");
Since
1.0
float getFloat ( const std::string &  key) const
inline

Gets the floating point representation for the specified key.

float floatValue = controller.config().getFloat("Gesture.Swipe.MinLength");
Since
1.0
int32_t getInt32 ( const std::string &  key) const
inline

Gets the 32-bit integer representation for the specified key.

int32_t intValue = controller.config().getInt32("Key.For.Integer.Setting");
Since
1.0
std::string getString ( const std::string &  key) const
inline

Gets the string representation for the specified key.

std::string stringValue = controller.config().getString("Key.For.String.Setting");
Since
1.0
bool save ( )

Saves the current state of the config.

Call save() after making a set of configuration changes. The save() function transfers the configuration changes to the Leap Motion service. You can save after the Controller has connected to the Leap Motion service/daemon. In other words, after the Controller has dispatched the serviceConnected or connected events or Controller::isConnected is true. The configuration value changes are not persistent; your application must set the values every time it runs.

controller.config().setFloat("Gesture.Circle.MinRadius", 15);
controller.config().setFloat("Gesture.Circle.MinArc", 1.7);
bool success = controller.config().save();
Returns
true on success, false on failure.
Since
1.0
bool setBool ( const std::string &  key,
bool  value 
)
inline

Sets the boolean representation for the specified key.

controller.config().setBool("tracking_tool_enabled", true);
controller.config().save();
Returns
true on success, false on failure.
Since
1.0
bool setFloat ( const std::string &  key,
float  value 
)
inline

Sets the floating point representation for the specified key.

controller.config().setFloat("Gesture.Circle.MinRadius", 15);
controller.config().save();
Returns
true on success, false on failure.
Since
1.0
bool setInt32 ( const std::string &  key,
int32_t  value 
)
inline

Sets the 32-bit integer representation for the specified key.

controller.config().setInt32("background_app_mode", 2);
controller.config().save();
Returns
true on success, false on failure.
Since
1.0
bool setString ( const std::string &  key,
const std::string &  value 
)
inline

Sets the string representation for the specified key.

controller.config().setString("Key.For.String.Setting", "A String");
controller.config().save();
Returns
true on success, false on failure.
Since
1.0
ValueType type ( const std::string &  key) const
inline

Reports the natural data type for the value related to the specified key.

Leap::Config::ValueType dataType = controller.config().type("Gesture.KeyTap.MinDistance");
Parameters
keyThe key for the looking up the value in the configuration dictionary.
Returns
The native data type of the value, that is, the type that does not require a data conversion.
Since
1.0