-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathConfigure.cpp
65 lines (55 loc) · 2.93 KB
/
Configure.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#include <iostream>
#include "Configure.h"
using namespace LeapOsvr;
////////////////////////////////////////////////////////////////////////////////////////////////////////
/*----------------------------------------------------------------------------------------------------*/
Configure::Configure(const osvr::pluginkit::DeviceToken& pDeviceToken,
OSVR_DeviceInitOptions pOptions, const LeapData& pLeapData) :
mDeviceToken(pDeviceToken), mLeapData(pLeapData)/*,mConfigInterface(NULL)*/ {
//osvrDeviceConfigConfig(pOptions, &mConfigInterface);
}
////////////////////////////////////////////////////////////////////////////////////////////////////////
/*----------------------------------------------------------------------------------------------------*/
inline bool isMatch(const std::string& pKeyA, const std::string& pKeyB) {
return (pKeyA.compare(pKeyB) == 0);
}
void Configure::setPolicy(eLeapPolicyFlag flag, bool pValue) {
eLeapRS result;
LEAP_CONNECTION connection = mLeapData.getConnection();
if (pValue) {
result = LeapSetPolicyFlags(connection, flag, 0);
if (LEAP_FAILED(result)) {
std::cerr << "com_osvr_LeapMotion - Configure::setPolicy(" << flag << ", " << pValue << "): LeapSetPolicyFlags call failed." << std::endl;
}
}
else {
result = LeapSetPolicyFlags(connection, 0, flag);
if (LEAP_FAILED(result)) {
std::cerr << "com_osvr_LeapMotion - Configure::setPolicy(" << flag << ", " << pValue << "): LeapSetPolicyFlags call failed." << std::endl;
}
}
}
////////////////////////////////////////////////////////////////////////////////////////////////////////
/*----------------------------------------------------------------------------------------------------*/
void Configure::setBoolDirect(const std::string& pKey, bool pValue) {
LEAP_CONNECTION connection = mLeapData.getConnection();
LEAP_VARIANT value;
value.type = eLeapValueType_Boolean;
value.boolValue = pValue;
eLeapRS result = LeapSaveConfigValue(connection, pKey.c_str(), &value, nullptr);
if (LEAP_FAILED(result)) {
std::cerr << "com_osvr_LeapMotion - Configure::setBoolDirect(" << pKey << ", " << pValue << "): LeapSaveConfigValue call failed." << std::endl;
}
}
////////////////////////////////////////////////////////////////////////////////////////////////////////
/*----------------------------------------------------------------------------------------------------*/
void Configure::setIntDirect(const std::string& pKey, int pValue) {
LEAP_CONNECTION connection = mLeapData.getConnection();
LEAP_VARIANT value;
value.type = eLeapValueType_Int32;
value.iValue = pValue;
eLeapRS result = LeapSaveConfigValue(connection, pKey.c_str(), &value, nullptr);
if (LEAP_FAILED(result)) {
std::cerr << "com_osvr_LeapMotion - Configure::setIntDirect(" << pKey << ", " << pValue << "): LeapSaveConfigValue call failed." << std::endl;
}
}