forked from simlrh/OSVR-Kinect
-
Notifications
You must be signed in to change notification settings - Fork 0
/
je_nourish_kinect.cpp
59 lines (47 loc) · 1.29 KB
/
je_nourish_kinect.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
// Internal Includes
#include "stdafx.h"
#include "KinectV1Device.h"
#include "KinectV2Device.h"
// Standard includes
#include <iostream>
namespace KinectOsvr {
class HardwareDetectionV1 {
public:
HardwareDetectionV1() : m_found(false) {}
OSVR_ReturnCode operator()(OSVR_PluginRegContext ctx) {
if (!m_found) {
INuiSensor* pNuiSensor;
if (KinectV1Device::Detect(&pNuiSensor)) {
m_found = true;
osvr::pluginkit::registerObjectForDeletion(ctx, new KinectV1Device(ctx, pNuiSensor));
}
}
return OSVR_RETURN_SUCCESS;
}
private:
bool m_found;
};
class HardwareDetectionV2 {
public:
HardwareDetectionV2() : m_found(false) {}
OSVR_ReturnCode operator()(OSVR_PluginRegContext ctx) {
if (!m_found) {
IKinectSensor* pKinectSensor;
if (KinectV2Device::Detect(&pKinectSensor)) {
m_found = true;
osvr::pluginkit::registerObjectForDeletion(
ctx, new KinectV2Device(ctx, pKinectSensor));
}
}
return OSVR_RETURN_SUCCESS;
}
private:
bool m_found;
};
}
OSVR_PLUGIN(je_nourish_kinect) {
osvr::pluginkit::PluginContext context(ctx);
context.registerHardwareDetectCallback(new KinectOsvr::HardwareDetectionV1());
context.registerHardwareDetectCallback(new KinectOsvr::HardwareDetectionV2());
return OSVR_RETURN_SUCCESS;
}