ConfigΒΆ

Methods:

class Leap::Config

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

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(int connectionKey)

Creates a new Config object for setting runtime configuration settings.

Note that the Controller.Config provides a properly initialized Config object already.

Since
3.0
Parameters
  • connectionKey -

    The id of the connnection. This id must match the key used to create the Controller.

bool Get< T >(string key, Action< T > onResult)

Requests a configuration value.

Since
3.0
Parameters
  • key -

    The string identifier for the setting.

  • onResult -

    The action to take when the Leap service returns the config value. The Action delegate must take a parameter matching the config value type. The current value of the setting is passed to this delegate.

bool GetBool(string key)

Gets the boolean representation for the specified key.

@ deprecated use Get<bool>(key, delegate)

Since
1.0

bool GetFloat(string key)

Gets the floating point representation for the specified key.

@ deprecated use Get<float>(key, delegate)

Since
1.0

bool GetInt32(string key)

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

@ deprecated use Get<Int32>(key, delegate)

Since
1.0

bool GetString(string key)

Gets the string representation for the specified key.

@ deprecated use Get<string>(key, delegate)

Since
1.0

bool Save()

Saves the current state of the config.

bool Set< T >(string key, T value, Action< bool > onResult)

Sets a configuration value.

Since
3.0
Parameters
  • key -

    The string identifier for the setting.

  • onResult -

    The action to take when the Leap service sets the config value. The Action delegate must take a boolean parameter. The service calls this delegate with the value true if the setting was changed successfully and false, otherwise.

bool SetBool(string key, bool value)

Sets the boolean representation for the specified key.

controller.Config.Set<bool> ("websockets_enabled", true, delegate( bool success){
    if(!success)
        Console.WriteLine("Warning: Could not enable WebSockets");
});

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.Set<float> ("Key.For.Float.Setting", 15, delegate(bool success){
    if(!success)
        Console.WriteLine("Warning: Could not set configuration.");
});

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.Set<Int32> ("Key.For.Integer.Setting", 12, delegate(bool success){
    if(!success)
        Console.WriteLine("Warning: Could not set configuration.");
});

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.Set<string> ("Key.For.String.Setting", "A String", delegate(bool success){
    if(!success)
        Console.WriteLine("Warning: Could not set configuration.");
});

Return
true on success, false on failure.
Since
1.0

Config.ValueType Type(string key)

The data type for a configuration parameter.

@ deprecated Always returns Config.ValueType.TYPE_UNKNOWN