7 #include "imstkVRPNDeviceManager.h" 9 #include "vrpn_Analog.h" 10 #include "vrpn_Button.h" 11 #include "vrpn_Tracker.h" 13 #include "imstkDeviceClient.h" 14 #include "imstkLogger.h" 15 #include "imstkVRPNDeviceClient.h" 23 m_deviceConnections(new vrpn_MainloopContainer())
25 setSleepDelay(1000 / 60);
29 VRPNDeviceManager::addDeviceClient(std::shared_ptr<VRPNDeviceClient> client)
31 std::string name = client->getDeviceName();
32 void* handle = client.get();
34 std::string address = name +
"@" + m_machine;
35 const char* _address = address.c_str();
37 int type = client->getType();
39 if ( (type & VRPNAnalog) != 0)
41 LOG(INFO) <<
"Adding Analog Device: " << name;
42 vrpn_Analog_Remote* vrpnAnalog =
new vrpn_Analog_Remote(_address);
43 m_deviceConnections->add(vrpnAnalog);
45 m_deviceMap[VRPNAnalog].push_back(client);
47 if ( (type & VRPNTracker) != 0)
49 LOG(INFO) <<
"Adding Tracker Device: " << name;
50 vrpn_Tracker_Remote* vrpnTracker =
new vrpn_Tracker_Remote(_address);
51 m_deviceConnections->add(vrpnTracker);
54 m_deviceMap[VRPNTracker].push_back(client);
56 if ( (type & VRPNButton) != 0)
58 LOG(INFO) <<
"Adding Button Device: " << name;
59 vrpn_Button_Remote* vrpnButton =
new vrpn_Button_Remote(_address);
60 m_deviceConnections->add(vrpnButton);
62 m_deviceMap[VRPNButton].push_back(client);
66 std::shared_ptr<imstk::DeviceClient>
69 auto client = std::make_shared<VRPNDeviceClient>(deviceName, deviceType, m_machine);
70 addDeviceClient(client);
74 std::shared_ptr<imstk::DeviceClient>
89 m_deviceConnections->mainloop();
95 m_deviceConnections->clear();
static void VRPN_CALLBACK trackerPositionChangeHandler(void *userData, const _vrpn_TRACKERCB t)
VRPN call back for position and orientation data.
static void VRPN_CALLBACK trackerVelocityChangeHandler(void *userData, const _vrpn_TRACKERVELCB v)
VRPN call back for velocity data.
void updateModule() override
Run the server module.
std::shared_ptr< DeviceClient > makeDeviceClient(const std::string &deviceName, VRPNDeviceType deviceType)
Creates a client from the given parameters.
static void VRPN_CALLBACK buttonChangeHandler(void *userData, const _vrpn_BUTTONCB b)
VRPN call back for button changed (pressed or released)
VRPNDeviceManager(const std::string &machine="localhost", int port=vrpn_DEFAULT_LISTEN_PORT_NO)
Constructor.
static void VRPN_CALLBACK analogChangeHandler(void *userData, const _vrpn_ANALOGCB a)
VRPN call back analog data.
void uninitModule() override
Clean the server module.
bool initModule() override
Initialize the server module.