OSVR_ReturnCode operator()(OSVR_PluginRegContext ctx) { bool gotDevice; #ifdef OSVR_MULTISERVER_VERBOSE bool first = true; #endif do { gotDevice = false; struct hid_device_info *enumData = hid_enumerate(0, 0); for (struct hid_device_info *dev = enumData; dev != nullptr; dev = dev->next) { if (m_isPathHandled(dev->path)) { continue; } #ifdef OSVR_MULTISERVER_VERBOSE if (first) { std::cout << "[OSVR Multiserver] HID Enumeration: " << boost::format("0x%04x") % dev->vendor_id << ":" << boost::format("0x%04x") % dev->product_id << std::endl; } #endif if (gotDevice) { continue; } // Razer Hydra if (dev->vendor_id == 0x1532 && dev->product_id == 0x0300) { // OK, found one half of device, let's find the other half. auto dataDev = dev; auto ctrlDev = dev->next; while (ctrlDev != nullptr && !(ctrlDev->vendor_id == 0x1532 && ctrlDev->product_id == 0x0300)) { ctrlDev = ctrlDev->next; } if (!ctrlDev) { std::cout << "com_osvr_Multiserver warning: could only find " "one of two interfaces for the Razer Hydra!" << std::endl; continue; } if (dataDev->interface_number == 1 && ctrlDev->interface_number == 0) { // If we found these reversed, swap them: the data // device should be interface 0, control is interface 1 // (if the interface numbers are valid at all) std::swap(dataDev, ctrlDev); } gotDevice = true; m_handlePath(dataDev->path); m_handlePath(ctrlDev->path); auto hydraJsonString = osvr::util::makeString( com_osvr_Multiserver_RazerHydra_json); Json::Value hydraJson; Json::Reader reader; if (!reader.parse(hydraJsonString, hydraJson)) { throw std::logic_error("Faulty JSON file for Hydra - " "should not be possible!"); } /// Decorated name for Hydra std::string name; { // Razer Hydra osvr::vrpnserver::VRPNDeviceRegistration reg(ctx); name = reg.useDecoratedName(m_data.getName("RazerHydra")); reg.registerDevice(new vrpn_Tracker_RazerHydra( name.c_str(), ctrlDev->path, dataDev->path, reg.getVRPNConnection())); reg.setDeviceDescriptor(hydraJsonString); } std::string localName = "*" + name; { // Copy semantic paths for corresponding filter: just // want left/$target and right/$target Json::Value filterJson; if (!reader.parse( osvr::util::makeString( com_osvr_Multiserver_OneEuroFilter_json), filterJson)) { throw std::logic_error("Faulty JSON file for One " "Euro Filter - should not " "be possible!"); } auto &filterSem = (filterJson["semantic"] = Json::objectValue); auto &hydraSem = hydraJson["semantic"]; for (auto const &element : {"left", "right"}) { filterSem[element] = Json::objectValue; filterSem[element]["$target"] = hydraSem[element]["$target"]; } auto &filterAuto = (filterJson["automaticAliases"] = Json::objectValue); filterAuto["$priority"] = 130; // enough to override a normal automatic route. auto &hydraAuto = hydraJson["automaticAliases"]; for (auto const &element : {"/me/hands/left", "/me/hands/right"}) { filterAuto[element] = hydraAuto[element]; } // Corresponding filter osvr::vrpnserver::VRPNDeviceRegistration reg(ctx); reg.registerDevice(new vrpn_Tracker_FilterOneEuro( reg.useDecoratedName( m_data.getName("OneEuroFilter")).c_str(), reg.getVRPNConnection(), localName.c_str(), 2, 1.15, 1.0, 1.2, 1.5, 5.0, 1.2)); reg.setDeviceDescriptor(filterJson.toStyledString()); } continue; } // OSVR Hacker Dev Kit if ((dev->vendor_id == 0x1532 && dev->product_id == 0x0b00) || (dev->vendor_id == 0x03EB && dev->product_id == 0x2421)) { gotDevice = true; m_handlePath(dev->path); osvr::vrpnserver::VRPNDeviceRegistration reg(ctx); auto name = m_data.getName("OSVRHackerDevKit"); auto decName = reg.useDecoratedName(name); reg.constructAndRegisterDevice< vrpn_Tracker_OSVRHackerDevKit>(name); reg.setDeviceDescriptor(osvr::util::makeString( com_osvr_Multiserver_OSVRHackerDevKit_json)); { osvr::vrpnserver::VRPNDeviceRegistration reg2(ctx); reg2.registerDevice( new vrpn_Tracker_DeadReckoning_Rotation( reg2.useDecoratedName(m_data.getName( "OSVRHackerDevKitPrediction")), reg2.getVRPNConnection(), "*" + decName, 1, 32.0e-3, false)); reg2.setDeviceDescriptor(osvr::util::makeString( com_osvr_Multiserver_OSVRHackerDevKit_json)); } continue; } //Sensics zSight (This block adds detection of Sensics zSight 1280 dual input device by osvr server) //you can add other zSight devices by adding vendor id and product id in if block. #if defined(_WIN32) && defined(VRPN_USE_DIRECTINPUT) && defined(VRPN_HAVE_ATLBASE) if ((dev->vendor_id == 0x16d0 && dev->product_id == 0x0515)) { gotDevice = true; m_handlePath(dev->path); osvr::vrpnserver::VRPNDeviceRegistration reg(ctx); auto name = m_data.getName("Sensics_zSight"); auto decName = reg.useDecoratedName(name); reg.constructAndRegisterDevice< vrpn_Tracker_zSight>(name); reg.setDeviceDescriptor(osvr::util::makeString( com_osvr_Multiserver_Sensics_zSight_json)); continue; } #endif } hid_free_enumeration(enumData); #ifdef OSVR_MULTISERVER_VERBOSE first = false; #endif } while (gotDevice); return OSVR_RETURN_SUCCESS; }
OSVR_ReturnCode operator()(OSVR_PluginRegContext ctx) { bool gotDevice; #ifdef OSVR_MULTISERVER_VERBOSE bool first = true; #endif do { gotDevice = false; struct hid_device_info *enumData = hid_enumerate(0, 0); for (struct hid_device_info *dev = enumData; dev != nullptr; dev = dev->next) { if (m_isPathHandled(dev->path)) { continue; } #ifdef OSVR_MULTISERVER_VERBOSE if (first) { std::cout << "[OSVR Multiserver] HID Enumeration: " << boost::format("0x%04x") % dev->vendor_id << ":" << boost::format("0x%04x") % dev->product_id << std::endl; } #endif if (gotDevice) { continue; } // Razer Hydra if (dev->vendor_id == 0x1532 && dev->product_id == 0x0300) { gotDevice = true; m_handlePath(dev->path); auto hydraJsonString = osvr::util::makeString( com_osvr_Multiserver_RazerHydra_json); Json::Value hydraJson; Json::Reader reader; if (!reader.parse(hydraJsonString, hydraJson)) { throw std::logic_error("Faulty JSON file for Hydra - " "should not be possible!"); } /// Decorated name for Hydra std::string name; { // Razer Hydra osvr::vrpnserver::VRPNDeviceRegistration reg(ctx); name = reg.useDecoratedName(m_data.getName("RazerHydra")); reg.registerDevice(new vrpn_Tracker_RazerHydra( name.c_str(), reg.getVRPNConnection())); reg.setDeviceDescriptor(hydraJsonString); } std::string localName = "*" + name; { // Copy semantic paths for corresponding filter: just // want left/$target and right/$target Json::Value filterJson; if (!reader.parse( osvr::util::makeString( com_osvr_Multiserver_OneEuroFilter_json), filterJson)) { throw std::logic_error("Faulty JSON file for One " "Euro Filter - should not " "be possible!"); } auto &filterSem = (filterJson["semantic"] = Json::objectValue); auto &hydraSem = hydraJson["semantic"]; for (auto const &element : {"left", "right"}) { filterSem[element] = Json::objectValue; filterSem[element]["$target"] = hydraSem[element]["$target"]; } auto &filterAuto = (filterJson["automaticAliases"] = Json::objectValue); filterAuto["$priority"] = 130; // enough to override a normal automatic route. auto &hydraAuto = hydraJson["automaticAliases"]; for (auto const &element : {"/me/hands/left", "/me/hands/right"}) { filterAuto[element] = hydraAuto[element]; } // Corresponding filter osvr::vrpnserver::VRPNDeviceRegistration reg(ctx); reg.registerDevice(new vrpn_Tracker_FilterOneEuro( reg.useDecoratedName( m_data.getName("OneEuroFilter")).c_str(), reg.getVRPNConnection(), localName.c_str(), 2, 1.15, 1.0, 1.2, 1.5, 5.0, 1.2)); reg.setDeviceDescriptor(filterJson.toStyledString()); } continue; } // OSVR Hacker Dev Kit if ((dev->vendor_id == 0x1532 && dev->product_id == 0x0300) || (dev->vendor_id == 0x03EB && dev->product_id == 0x2421)) { gotDevice = true; m_handlePath(dev->path); osvr::vrpnserver::VRPNDeviceRegistration reg(ctx); reg.constructAndRegisterDevice< vrpn_Tracker_OSVRHackerDevKit>( m_data.getName("OSVRHackerDevKit")); reg.setDeviceDescriptor(osvr::util::makeString( com_osvr_Multiserver_OSVRHackerDevKit_json)); continue; } } hid_free_enumeration(enumData); #ifdef OSVR_MULTISERVER_VERBOSE first = false; #endif } while (gotDevice); return OSVR_RETURN_SUCCESS; }