frame_window(LPCSTR window_class_identity) : window_class_name(window_class_identity) { int screen_width = GetSystemMetrics(SM_CXFULLSCREEN); int screen_height = GetSystemMetrics(SM_CYFULLSCREEN); instance_handle = GetModuleHandle(NULL); WNDCLASS window_class = { CS_OWNDC, main_window_proc, 0, 0, instance_handle, NULL, NULL, NULL, NULL, window_class_name }; window_class.hIcon = LoadIcon(instance_handle, MAKEINTRESOURCE(IDI_ICON_BIG)); RegisterClass(&window_class); window_handle = CreateWindowEx(WS_EX_WINDOWEDGE | WS_EX_CLIENTEDGE | WS_EX_TOPMOST, window_class_name, "Vireio Perception", WS_OVERLAPPEDWINDOW & ~(WS_THICKFRAME | WS_MAXIMIZEBOX), //WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN | WS_CLIPSIBLINGS, (screen_width-585)/2, (screen_height-240)/2, 585, 270, NULL, NULL, instance_handle, NULL); SetWindowLongPtr(window_handle, GWL_USERDATA, (LONG)this); GetClientRect(window_handle, &client_rectangle); int width = client_rectangle.right - client_rectangle.left; int height = client_rectangle.bottom - client_rectangle.top; text = new static_control(instance_handle, window_handle); combobox = new combobox_control(instance_handle, window_handle, text, 20, 81, 1001); combobox2 = new combobox_control(instance_handle, window_handle, text, 20, 115, 1002); combobox3 = new combobox_control(instance_handle, window_handle, text, 20, 149, 1003); ProxyHelper helper = ProxyHelper(); std::string viewPath = helper.GetPath("img\\logo.bmp"); logo_bitmap = (HBITMAP)LoadImage(NULL,viewPath.c_str(),IMAGE_BITMAP,0,0,LR_LOADFROMFILE); OutputDebugString("Load the bitmap\n"); ProxyConfig cfg; helper.LoadUserConfig(cfg, oculusProfile); SetCursor(LoadCursor(NULL, IDC_ARROW)); ShowWindow(window_handle, SW_SHOW); UpdateWindow(window_handle); //Refresh on timer for FPS readings SetTimer(window_handle, 1, 500, NULL); }
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; }