Forum Discussion
2EyeGuy
12 years agoAdventurer
EnumDisplaySettings not working.
EnumDisplaySettingsA works fine when I pass nullptr, but when I pass hmdDesc.DisplayDeviceName it returns no results. Does anyone know why?
Using nullptr isn't an option, because my laptop screen can't do 1280x800, so the mode I need the other display to use won't be in the list.
Using nullptr isn't an option, because my laptop screen can't do 1280x800, so the mode I need the other display to use won't be in the list.
const char *g_hmd_device_name = nullptr;
g_hmd_device_name = hmdDesc.DisplayDeviceName;
wxArrayString GetListOfResolutions()
{
wxArrayString retlist;
retlist.Add("Auto");
#ifdef _WIN32
DWORD iModeNum = 0;
DEVMODEA dmi;
ZeroMemory(&dmi, sizeof(dmi));
dmi.dmSize = sizeof(dmi);
std::vector<std::string> resos;
while (EnumDisplaySettingsA(g_hmd_device_name, iModeNum++, &dmi) != 0)
{
char res[100];
sprintf(res, "%dx%d", dmi.dmPelsWidth, dmi.dmPelsHeight);
std::string strRes(res);
// Only add unique resolutions
if (std::find(resos.begin(), resos.end(), strRes) == resos.end())
{
resos.push_back(strRes);
retlist.Add(StrToWxStr(res));
}
ZeroMemory(&dmi, sizeof(dmi));
}
3 Replies
- PathogenDavidHonored GuestCan you print out hmdDesc.DisplayDeviceName and check what it was? It looks like Oculus might be putting the wrong value in there, but I don't have a DK1 to test the behavior to be sure.
If you get something like \\.\DISPLAY2 then you should be fine, but if you get something like \\.\DISPLAY2\Monitor0 then you can't use it directly with EnumDisplaySettings because it expects the former.
I made a small playground for testing EnumDisplayDevices and EnumDisplaySettings (Available here) As you can see on this output, you won't get any display modes out of EnumDisplaySettings if you use a \\.\DISPLAY#\Monitor# device string.
In LibOVR 0.3.2, in OVR_Win32_HMDDevice.cpp on line 285, you can see that the device name that is used is the one from the second call to EnumDisplayDevices, which is the one that gives you the monitor device string, not the display one.
---
EDIT: Also, not immediately on topic: But you need to set dmidmSize again after you call ZeroMemory on dmi. Either that or just skip the ZeroMemory, you don't really need it. Also, you need to set dmi.dmDriverExtra as per the documentation. - 2EyeGuyAdventurerThanks. That fixed it.
Wow, the Rift supports a lot of resolutions, all the way up to 1920x1200.const char *g_hmd_device_name = nullptr;
#ifdef _WIN32
static char hmd_device_name[MAX_PATH] = "";
#endif#ifdef _WIN32
g_hmd_device_name = hmdDesc.DisplayDeviceName;
const char *p;
if (g_hmd_device_name && (p = strstr(g_hmd_device_name, "\\Monitor")))
{
size_t n = p - g_hmd_device_name;
if (n >= MAX_PATH)
n = MAX_PATH - 1;
g_hmd_device_name = strncpy(hmd_device_name, g_hmd_device_name, n);
hmd_device_name[n] = '\0';
}
#endifwxArrayString GetListOfResolutions()
{
wxArrayString retlist;
retlist.Add("Auto");
#ifdef _WIN32
DWORD iModeNum = 0;
DEVMODEA dmi;
ZeroMemory(&dmi, sizeof(dmi));
dmi.dmSize = sizeof(dmi);
std::vector<std::string> resos;
#if 0
// Add the HMD's required resolution, even if it isn't listed or supported.
{
char res[100];
sprintf(res, "%dx%d", g_hmd_window_width, g_hmd_window_height);
std::string strRes(res);
if (std::find(resos.begin(), resos.end(), strRes) == resos.end())
{
resos.push_back(strRes);
retlist.Add(StrToWxStr(res));
}
}
#endif
while (EnumDisplaySettingsA(g_hmd_device_name, iModeNum++, &dmi) != 0)
{
char res[100];
sprintf(res, "%dx%d", dmi.dmPelsWidth, dmi.dmPelsHeight);
std::string strRes(res);
// Only add unique resolutions
if (std::find(resos.begin(), resos.end(), strRes) == resos.end())
{
resos.push_back(strRes);
retlist.Add(StrToWxStr(res));
}
} - PathogenDavidHonored GuestGlad that fixed it! Hopefully someone from Oculus drops by and can make an internal report that either the behavior needs to be changed or the documentation needs to be corrected.
Quick Links
- Horizon Developer Support
- Quest User Forums
- Troubleshooting Forum for problems with a game or app
- Quest Support for problems with your device
Other Meta Support
Related Content
- 6 years ago
- 2 years ago
- 2 years ago
- 3 years ago