| 71 | public: |
| 72 | VRPNHardwareDetect(VRPNMultiserverData &data) : m_data(data) {} |
| 73 | OSVR_ReturnCode operator()(OSVR_PluginRegContext ctx) { |
| 74 | bool gotDevice; |
| 75 | #ifdef OSVR_MULTISERVER_VERBOSE |
| 76 | bool first = true; |
| 77 | #endif |
| 78 | do { |
| 79 | gotDevice = false; |
| 80 | struct hid_device_info *enumData = hid_enumerate(0, 0); |
| 81 | for (struct hid_device_info *dev = enumData; dev != nullptr; |
| 82 | dev = dev->next) { |
| 83 | |
| 84 | if (m_isPathHandled(dev->path)) { |
| 85 | continue; |
| 86 | } |
| 87 | |
| 88 | #ifdef OSVR_MULTISERVER_VERBOSE |
| 89 | if (first) { |
| 90 | std::cout << "[OSVR Multiserver] HID Enumeration: " |
| 91 | << boost::format("0x%04x") % dev->vendor_id << ":" |
| 92 | << boost::format("0x%04x") % dev->product_id |
| 93 | << std::endl; |
| 94 | } |
| 95 | #endif |
| 96 | |
| 97 | if (gotDevice) { |
| 98 | continue; |
| 99 | } |
| 100 | // Razer Hydra |
| 101 | if (dev->vendor_id == 0x1532 && dev->product_id == 0x0300) { |
| 102 | gotDevice = true; |
| 103 | m_handlePath(dev->path); |
| 104 | auto hydraJsonString = osvr::util::makeString( |
| 105 | com_osvr_Multiserver_RazerHydra_json); |
| 106 | Json::Value hydraJson; |
| 107 | Json::Reader reader; |
| 108 | if (!reader.parse(hydraJsonString, hydraJson)) { |
| 109 | throw std::logic_error("Faulty JSON file for Hydra - " |
| 110 | "should not be possible!"); |
| 111 | } |
| 112 | /// Decorated name for Hydra |
| 113 | std::string name; |
| 114 | { |
| 115 | // Razer Hydra |
| 116 | osvr::vrpnserver::VRPNDeviceRegistration reg(ctx); |
| 117 | name = |
| 118 | reg.useDecoratedName(m_data.getName("RazerHydra")); |
| 119 | reg.registerDevice(new vrpn_Tracker_RazerHydra( |
| 120 | name.c_str(), reg.getVRPNConnection())); |
| 121 | reg.setDeviceDescriptor(hydraJsonString); |
| 122 | } |
| 123 | std::string localName = "*" + name; |
| 124 | |
| 125 | { |
| 126 | // Copy semantic paths for corresponding filter: just |
| 127 | // want left/$target and right/$target |
| 128 | Json::Value filterJson; |
| 129 | if (!reader.parse( |
| 130 | osvr::util::makeString( |
nothing calls this directly
no test coverage detected