您的位置:首页 > 其它

Config类(Leap::Config)

2015-09-13 16:52 435 查看
Config类(Leap::Config)

Config类提供了Leap Motion系统配置信息的访问。用由Controller对象得到的Config对象可以得到和设置手势配置参数。确定一个配置参数所需要的关键字符串包括:



当设置了配置的值,必须调用Config::save()函数来提交修改。在Controller和服务连接之后你可以保存。换句话说,在Controller分派之后,serviceConnected或者连接的事件或者Controller::isConnected是true。配置的值的改变并不保持,你的应用程序需要在每次运行时都要设置这些值。

enum ValueType: 表示配置值可能的数据类型。

TYPE_UNKNOWN = 0表示数据类型是未知的;

TYPE_BOOLEAN = 1表示布尔值;

TYPE_INT32 =2表示32位整型;

TYPE_FLOAT =6表示浮点数;

TYPE_STRING =8表示一串字符。

ValueType type(const std::string& key): 报告与指定的key相关的值的数据类型。返回的是这个值原始的数据类型,也就是说这个类型不要求数据的转换。

用法:Leap::Config::ValueType dataType = controller.config().type(“Gesture.KeyTap.Min

Distance”);

bool getBool(const std::string& key): 得到指定的key的布尔表示。

用法:bool booleanValue = controller.config().getBool(“Key.For.Bool.Setting”);

bool setBool(const std::string& key): 设置指定的key的布尔表示。

用法:controller.config().setBool(“Key.For.Bool.Setting”,true);

int32_t getInt32(const std::string& key): 得到指定的key的32位整型表示。

用法:int32_t intValue = controller.config().getInt32(“Key.For.Integer.Setting”);

bool setInt32(const std::string& key): 设置指定的key的32位整型表示。

用法:controller.config().setInt32(“Key.For. Integer.Setting”,12);

float getFloat(const std::string& key): 得到指定的key的浮点数表示。

用法:float floatValue = controller.config().getFloat(“Gesture.Swipe.MinLength”);

bool setFloat(const std::string& key): 设置指定的key的浮点数表示。

用法:controller.config().setFloat(“Gesture.Circle.MinRadius”,15);

std::string getString(const std::string& key): 得到指定的key的字符串表示。

用法:std::string stringValue = controller.config().getString(“Key.For.String.Setting”);

bool setString(const std::string& key): 设置指定的key的字符串表示。

用法:controller.config().setString(“Key.For.String.Setting”,”A String”);

Config(): 构造一个Config对象。不要创建你自己的Config对象,用Controller::Config()函数来得到一个Config对象。

用法:Leap::Config config=controller. Config();

bool save(): 保存当前配置状态。在改变了一系列配置之后调用该函数。该函数把配置改变传递给Leap Motion服务。

用法:controller.config().setFloat(“Gesture.Circle.MinRadius”, 15);

controller.config().setFloat(“Gesture.Circle.MinArc”, 1.7);

bool success = controller.config().save();

译自:https://developer.leapmotion.com/documentation/cpp/api/Leap.Config.html
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  leap motion