-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathControllerDevice.cpp
75 lines (61 loc) · 3.18 KB
/
ControllerDevice.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
66
67
68
69
70
71
72
73
74
75
#include "ControllerDevice.h"
#include "com_osvr_LeapMotion_json.h"
#include "LeapC.h"
using namespace LeapOsvr;
using namespace osvr::pluginkit;
////////////////////////////////////////////////////////////////////////////////////////////////////////
/*----------------------------------------------------------------------------------------------------*/
ControllerDevice::ControllerDevice(OSVR_PluginRegContext pContext, LEAP_CONNECTION connection, LeapConfig config) :
mConnection(connection), mLeapData(NULL), mAnalog(NULL),
/*mImaging(NULL), */mTracker(NULL), /*mGestures(NULL),*/ mConfigure(NULL), mConfigOptions(config) {
//mController.setPolicy(Controller::POLICY_BACKGROUND_FRAMES);
//mController.setPolicy(Controller::POLICY_IMAGES);
//mController.setPolicy(Controller::POLICY_OPTIMIZE_HMD);
OSVR_DeviceInitOptions options = osvrDeviceCreateInitOptions(pContext);
mLeapData = new LeapData(mConnection);
mAnalog = new Analog(mDeviceToken, options, *mLeapData);
//mImaging = new Imaging(mDeviceToken, options, *mLeapData);
mTracker = new Tracker(mDeviceToken, options, *mLeapData);
//mGestures = new Gestures(mDeviceToken, options, *mLeapData);
mConfigure = new Configure(mDeviceToken, options, *mLeapData);
mConfigure->setPolicy(eLeapPolicyFlag_BackgroundFrames, true);
mConfigure->setPolicy(eLeapPolicyFlag_OptimizeHMD, mConfigOptions.hmdMode);
//mConfigure->setBool(ConfigureKey::Policy_Images, true);
//mConfigure->setBool(ConfigureKey::Policy_OptimizeHmd, false); // @todo: make this a configurable setting
//mConfigure->setBool(ConfigureKey::Gesture_Swipe, true);
//mConfigure->setBool(ConfigureKey::Gesture_Circle, true);
//mConfigure->setBool(ConfigureKey::Gesture_KeyTap, true);
//mConfigure->setBool(ConfigureKey::Gesture_ScreenTap, true);
// just let the user set these in their control panel?
//mConfigure->setBoolDirect("image_processing_auto_flip", false);
//mConfigure->setBoolDirect("robust_mode_enabled", false);
//mConfigure->setBoolDirect("head_mounted_display_mode", false);
//mConfigure->setBoolDirect("avoid_poor_performance", false);
//mConfigure->setIntDirect("low_resource_mode_enabled", 0);
mConfigure->setBoolDirect("tracking_hand_enabled", true);
mConfigure->setBoolDirect("tracking_tool_enabled", true);
mConfigure->setIntDirect("images_mode", 2);
mConfigure->setIntDirect("klaatu_barada_nikto", 1);
mDeviceToken.initAsync(pContext, "Controller", options);
mDeviceToken.sendJsonDescriptor(com_osvr_LeapMotion_json);
mDeviceToken.registerUpdateCallback(this);
}
/*----------------------------------------------------------------------------------------------------*/
ControllerDevice::~ControllerDevice() {
delete mLeapData;
delete mAnalog;
//delete mImaging;
delete mTracker;
//delete mGestures;
delete mConfigure;
}
/*----------------------------------------------------------------------------------------------------*/
OSVR_ReturnCode ControllerDevice::update() {
if (mLeapData->update()) {
mAnalog->update();
//mImaging->update();
mTracker->update();
//mGestures->update();
}
return OSVR_RETURN_SUCCESS;
}