From cb8c6f4a025732e1b9823c8110ce4e48d2ad7bc8 Mon Sep 17 00:00:00 2001 From: Ose Pedro Date: Thu, 5 Jul 2012 15:58:29 +0100 Subject: [PATCH] Added FreenectDevice::setRangeMode(). Modified Freenect's constructor so that the user can set the device flags themselves (for the benefit of Kinect for Windows users, whose devices apparently don't support the motor subdevice). Removed the unnecessary explicit template parameters of std::make_pair(), which cause compilation errors when code that's compiled with -std=c++0x includes libfreenect.hpp. --- wrappers/cpp/libfreenect.hpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/wrappers/cpp/libfreenect.hpp b/wrappers/cpp/libfreenect.hpp index 0a5f637e..8264bc51 100644 --- a/wrappers/cpp/libfreenect.hpp +++ b/wrappers/cpp/libfreenect.hpp @@ -95,6 +95,9 @@ namespace Freenect { void updateState() { if (freenect_update_tilt_state(m_dev) < 0) throw std::runtime_error("Cannot update device state"); } + void setRangeMode(freenect_range_mode range) { + freenect_set_range_mode(m_dev, range); + } FreenectTiltState getState() const { return FreenectTiltState(freenect_get_tilt_state(m_dev)); } @@ -174,11 +177,11 @@ namespace Freenect { private: typedef std::map DeviceMap; public: - Freenect() : m_stop(false) { + Freenect(const int device_flags=FREENECT_DEVICE_MOTOR | FREENECT_DEVICE_CAMERA) : m_stop(false) { if(freenect_init(&m_ctx, NULL) < 0) throw std::runtime_error("Cannot initialize freenect library"); // We claim both the motor and camera devices, since this class exposes both. // It does not support audio, so we do not claim it. - freenect_select_subdevices(m_ctx, static_cast(FREENECT_DEVICE_MOTOR | FREENECT_DEVICE_CAMERA)); + freenect_select_subdevices(m_ctx, static_cast(device_flags)); if(pthread_create(&m_thread, NULL, pthread_callback, (void*)this) != 0) throw std::runtime_error("Cannot initialize freenect thread"); } ~Freenect() { @@ -194,7 +197,7 @@ namespace Freenect { DeviceMap::iterator it = m_devices.find(_index); if (it != m_devices.end()) delete it->second; ConcreteDevice * device = new ConcreteDevice(m_ctx, _index); - m_devices.insert(std::make_pair(_index, device)); + m_devices.insert(std::make_pair(_index, device)); return *device; } void deleteDevice(int _index) {