void new_selection3() { int selection = (int)SendMessage(combobox_handle, CB_GETCURSEL, 0, 0); if ( selection != CB_ERR ) { // save the adapter to xml file ProxyHelper helper = ProxyHelper(); helper.SaveDisplayAdapter(selection); } }
int WINAPI wWinMain(HINSTANCE instance_handle, HINSTANCE, LPWSTR, INT) { // avoid double driver window HWND window = FindWindow( "perception", "Vireio Perception"); if( window != 0 ) { OutputDebugString("Vireio Perception is already present !"); return 0; } InitConfig(); InitModes(); InstallHook(); frame_window main_window("perception"); main_window.add_item("Disabled\t0"); main_window.add_item("Side by Side\t20"); main_window.add_item("Over Under\t30"); main_window.add_item("Horizontal Interleave\t40"); main_window.add_item("Vertical Interleave\t50"); main_window.add_item("Checkerboard\t60"); main_window.add_item("Anaglyph (Red/Cyan)\t1"); main_window.add_item("Anaglyph (Red/Cyan) B+W\t2"); main_window.add_item("Anaglyph (Yellow/Blue)\t5"); main_window.add_item("Anaglyph (Yellow/Blue) B+W\t6"); main_window.add_item("Anaglyph (Green/Magenta)\t10"); main_window.add_item("Anaglyph (Green/Magenta) B+W\t11"); main_window.add_item("DIY Rift\t100"); main_window.add_item("Oculus Rift: Extended Mode\t110"); main_window.add_item("Oculus Rift: Direct-to-HMD\t111"); main_window.add_item2("No Tracking\t0"); main_window.add_item2("Hillcrest Labs\t10"); main_window.add_item2("FreeTrack\t20"); main_window.add_item2("Shared Memory Tracker\t30"); main_window.add_item2("OculusTrack\t40"); UINT32 num_of_paths = 0; UINT32 num_of_modes = 0; DISPLAYCONFIG_PATH_INFO* displayPaths = NULL; DISPLAYCONFIG_MODE_INFO* displayModes = NULL; GetDisplayConfigBufferSizes(QDC_ALL_PATHS, &num_of_paths, &num_of_modes); // Allocate paths and modes dynamically displayPaths = (DISPLAYCONFIG_PATH_INFO*)calloc((int)num_of_paths, sizeof(DISPLAYCONFIG_PATH_INFO)); displayModes = (DISPLAYCONFIG_MODE_INFO*)calloc((int)num_of_modes, sizeof(DISPLAYCONFIG_MODE_INFO)); // Query for the information QueryDisplayConfig(QDC_ONLY_ACTIVE_PATHS, &num_of_paths, displayPaths, &num_of_modes, displayModes, NULL); UINT32 index = 0; int adapterNum = 0; while (index < num_of_modes) { if (displayModes[index].infoType == DISPLAYCONFIG_MODE_INFO_TYPE_TARGET) { DISPLAYCONFIG_TARGET_DEVICE_NAME deviceName; DISPLAYCONFIG_DEVICE_INFO_HEADER header; header.size = sizeof(DISPLAYCONFIG_TARGET_DEVICE_NAME); header.adapterId = displayModes[index].adapterId; header.id = displayModes[index].id; header.type = DISPLAYCONFIG_DEVICE_INFO_GET_TARGET_NAME; deviceName.header = header; DisplayConfigGetDeviceInfo( (DISPLAYCONFIG_DEVICE_INFO_HEADER*) &deviceName ); char monitorFriendlyDeviceName[256]; ZeroMemory(monitorFriendlyDeviceName, 256); size_t countConverted = 0; wcstombs_s(&countConverted, monitorFriendlyDeviceName, 256, deviceName.monitorFriendlyDeviceName, 256); std::string adapterStr(monitorFriendlyDeviceName); if (adapterNum == 0) adapterStr = "Primary Monitor: " + adapterStr + "\t0"; if (adapterNum == 1) adapterStr = "Secondary Monitor: " + adapterStr + "\t1"; if (adapterNum == 2) adapterStr = "Tertiary Monitor: " + adapterStr + "\t2"; main_window.add_item3(adapterStr.c_str()); adapterNum++; } index++; } ProxyHelper helper = ProxyHelper(); ProxyHelper::UserConfig userConfig; helper.LoadUserConfig(userConfig); SendMessage(main_window.combobox->combobox_handle, CB_SETCURSEL, stereoModes[userConfig.mode], 0); if (main_window.combobox->get_selection() == 111) { ShowWindow(main_window.combobox2->combobox_handle, SW_HIDE); //Select oculus track main_window.combobox2->set_selection(4); } else SendMessage(main_window.combobox2->combobox_handle, CB_SETCURSEL, trackerModes[userConfig.mode2], 0); //If an HMD is unplugged we may not actually be able to select it if (userConfig.adapter >= adapterNum) { userConfig.adapter = 0; helper.SaveDisplayAdapter(0); } SendMessage(main_window.combobox3->combobox_handle, CB_SETCURSEL, userConfig.adapter, 0); main_window.run(); RemoveHook(); return 0; }