void HMDDeviceFactory::EnumerateDevices(EnumerateVisitor& visitor) { SSSA_LOG_FUNCALL(1); // LDC - Use zero data for now. HMDDeviceCreateDesc hmdCreateDesc(this, String("Android Device"), 0); hmdCreateDesc.SetScreenParameters(0, 0, 0, 0, 0.0f, 0.0f); // Notify caller about detected device. This will call EnumerateAddDevice // if the this is the first time device was detected. visitor.Visit(hmdCreateDesc); }
void HMDDeviceFactory::EnumerateDevices(EnumerateVisitor& visitor) { // For now we'll assume the Rift DK1 is attached in extended monitor mode. Ultimately we need to // use XFree86 to enumerate X11 screens in case the Rift is attached as a separate screen. We also // need to be able to read the EDID manufacturer product code to be able to differentiate between // Rift models. bool foundHMD = false; Display* display = XOpenDisplay(NULL); if (display && XineramaIsActive(display)) { int numberOfScreens; XineramaScreenInfo* screens = XineramaQueryScreens(display, &numberOfScreens); for (int i = 0; i < numberOfScreens; i++) { XineramaScreenInfo screenInfo = screens[i]; if (screenInfo.width == 1280 && screenInfo.height == 800) { String deviceName = "OVR0001"; HMDDeviceCreateDesc hmdCreateDesc(this, deviceName, i); hmdCreateDesc.SetScreenParameters(screenInfo.x_org, screenInfo.y_org, 1280, 800, 0.14976f, 0.0936f); OVR_DEBUG_LOG_TEXT(("DeviceManager - HMD Found %s - %d\n", deviceName.ToCStr(), i)); // Notify caller about detected device. This will call EnumerateAddDevice // if the this is the first time device was detected. visitor.Visit(hmdCreateDesc); foundHMD = true; break; } } XFree(screens); } // Real HMD device is not found; however, we still may have a 'fake' HMD // device created via SensorDeviceImpl::EnumerateHMDFromSensorDisplayInfo. // Need to find it and set 'Enumerated' to true to avoid Removal notification. if (!foundHMD) { Ptr<DeviceCreateDesc> hmdDevDesc = getManager()->FindDevice("", Device_HMD); if (hmdDevDesc) hmdDevDesc->Enumerated = true; } }
void HMDDeviceFactory::EnumerateDevices(EnumerateVisitor& visitor) { MonitorSet monitors; monitors.MonitorCount = 0; // Get all the monitor handles EnumDisplayMonitors(NULL, NULL, MonitorEnumProc, (LPARAM)&monitors); bool foundHMD = false; // DeviceManager* manager = getManager(); DISPLAY_DEVICE dd, ddm; UINT i, j; for (i = 0; (ZeroMemory(&dd, sizeof(dd)), dd.cb = sizeof(dd), EnumDisplayDevices(0, i, &dd, 0)) != 0; i++) { /* wchar_t buff[500], flagsBuff[200]; swprintf_s(buff, 500, L"\nDEV: \"%s\" \"%s\" 0x%08x=%s\n \"%s\" \"%s\"\n", dd.DeviceName, dd.DeviceString, dd.StateFlags, FormatDisplayStateFlags(flagsBuff, 200, dd.StateFlags), dd.DeviceID, dd.DeviceKey); ::OutputDebugString(buff); */ for (j = 0; (ZeroMemory(&ddm, sizeof(ddm)), ddm.cb = sizeof(ddm), EnumDisplayDevices(dd.DeviceName, j, &ddm, 0)) != 0; j++) { /* wchar_t mbuff[500]; swprintf_s(mbuff, 500, L"MON: \"%s\" \"%s\" 0x%08x=%s\n \"%s\" \"%s\"\n", ddm.DeviceName, ddm.DeviceString, ddm.StateFlags, FormatDisplayStateFlags(flagsBuff, 200, ddm.StateFlags), ddm.DeviceID, ddm.DeviceKey); ::OutputDebugString(mbuff); */ // Our monitor hardware has string "RTD2205" in it // Nate's device "CVT0003" if (wcsstr(ddm.DeviceID, L"RTD2205") || wcsstr(ddm.DeviceID, L"CVT0003") || wcsstr(ddm.DeviceID, L"MST0030") || wcsstr(ddm.DeviceID, L"OVR00") ) // Part of Oculus EDID. { String deviceId(ddm.DeviceID); String displayDeviceName(ddm.DeviceName); // The default monitor coordinates int mx = 0; int my = 0; int mwidth = 1280; int mheight = 800; // Find the matching MONITORINFOEX for this device so we can get the // screen coordinates MONITORINFOEX info; for (int m=0; m < monitors.MonitorCount; m++) { info.cbSize = sizeof(MONITORINFOEX); GetMonitorInfo(monitors.Monitors[m], &info); if (_tcsstr(ddm.DeviceName, info.szDevice) == ddm.DeviceName) { // If the device name starts with the monitor name // then we found the matching DISPLAY_DEVICE and MONITORINFO // so we can gather the monitor coordinates mx = info.rcMonitor.left; my = info.rcMonitor.top; //mwidth = info.rcMonitor.right - info.rcMonitor.left; //mheight = info.rcMonitor.bottom - info.rcMonitor.top; break; } } HMDDeviceCreateDesc hmdCreateDesc(this, deviceId, displayDeviceName); if (wcsstr(ddm.DeviceID, L"OVR0002")) { hmdCreateDesc.SetScreenParameters(mx, my, 1920, 1080, 0.12096f, 0.06804f); } else { if (hmdCreateDesc.Is7Inch()) { // Physical dimension of SLA screen. hmdCreateDesc.SetScreenParameters(mx, my, mwidth, mheight, 0.14976f, 0.0936f); } else { hmdCreateDesc.SetScreenParameters(mx, my, mwidth, mheight, 0.12096f, 0.0756f); } } OVR_DEBUG_LOG_TEXT(("DeviceManager - HMD Found %s - %s\n", deviceId.ToCStr(), displayDeviceName.ToCStr())); // Notify caller about detected device. This will call EnumerateAddDevice // if the this is the first time device was detected. visitor.Visit(hmdCreateDesc); foundHMD = true; break; } } } // Real HMD device is not found; however, we still may have a 'fake' HMD // device created via SensorDeviceImpl::EnumerateHMDFromSensorDisplayInfo. // Need to find it and set 'Enumerated' to true to avoid Removal notification. if (!foundHMD) { Ptr<DeviceCreateDesc> hmdDevDesc = getManager()->FindDevice("", Device_HMD); if (hmdDevDesc) hmdDevDesc->Enumerated = true; } }
void MySensorDeviceFactory::EnumerateDevices(EnumerateVisitor& visitor) { SSSA_LOG_FUNCALL(1); MySensorDeviceDesc desc(this,Device_Sensor); visitor.Visit(desc); }