Config

Methods:

class Leap::Config

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:

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
CircleGesture
See
KeyTapGesture
See
ScreenTapGesture
See
SwipeGesture
Since
1.0

Public Type

ValueType enum

Enumerates the possible data types for configuration values.

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

Since
1.0

Values:

  • TYPE_UNKNOWN = = 0 -

    The data type is unknown.

    Since

    1.0

  • TYPE_BOOLEAN = = 1 -

    A boolean value.

    Since

    1.0

  • TYPE_INT32 = = 2 -

    A 32-bit integer.

    Since

    1.0

  • TYPE_FLOAT = = 6 -

    A floating-point number.

    Since

    1.0

  • TYPE_STRING = = 8 -

    A string of characters.

    Since

    1.0

Public Functions

Config()

Constructs a Config object.

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

Config config = controller.Config;

Since
1.0

bool GetBool(string key)

Gets the boolean representation for the specified key.

Boolean booleanValue = controller.Config.GetBool ("Bool.Key");

Since
1.0

float GetFloat(string key)

Gets the floating point representation for the specified key.

float floatValue = controller.Config.GetFloat ("Gesture.Swipe.MinLength");

Since
1.0

int GetInt32(string key)

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

int intValue = controller.Config.GetInt32 ("Key.For.Integer.Setting");

Since
1.0

string GetString(string key)

Gets the string representation for the specified key.

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.7f);
Boolean success = controller.Config.Save ();

Return
true on success, false on failure.
Since
1.0

bool SetBool(string key, bool value)

Sets the boolean representation for the specified key.

controller.Config.SetBool ("tracking_tool_enabled", true);
controller.Config.Save ();

Return
true on success, false on failure.
Since
1.0

bool SetFloat(string key, float value)

Sets the floating point representation for the specified key.

controller.Config.SetFloat ("Gesture.Circle.MinRadius", 15);
controller.Config.Save ();

Return
true on success, false on failure.
Since
1.0

bool SetInt32(string key, int value)

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

controller.Config.SetInt32 ("Key.For.Integer.Setting", 12);
controller.Config.Save ();

Return
true on success, false on failure.
Since
1.0

bool SetString(string key, string value)

Sets the string representation for the specified key.

controller.Config.SetString ("Key.For.String.Setting", "A String");
controller.Config.Save ();

Return
true on success, false on failure.
Since
1.0

Config.ValueType Type(string key)

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

Config.ValueType dataType = controller.Config.Type ("Gesture.KeyTap.MinDistance");

Return
The native data type of the value, that is, the type that does not require a data conversion.
Since
1.0
Parameters
  • key -

    The key for the looking up the value in the configuration dictionary.

Value Type

ValueType enum

Enumerates the possible data types for configuration values.

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

Since
1.0

Values:

  • TYPE_UNKNOWN = = 0 -

    The data type is unknown.

    Since

    1.0

  • TYPE_BOOLEAN = = 1 -

    A boolean value.

    Since

    1.0

  • TYPE_INT32 = = 2 -

    A 32-bit integer.

    Since

    1.0

  • TYPE_FLOAT = = 6 -

    A floating-point number.

    Since

    1.0

  • TYPE_STRING = = 8 -

    A string of characters.

    Since

    1.0