X-Git-Url: http://git.xonotic.org/?a=blobdiff_plain;f=vid_wgl.c;h=e6cb700219633a247e62e65b732b9ffb64dcef09;hb=144f44c523edfab569e960288dd6d84ad7f4d5f4;hp=0c55110216efe94480c7e30982e55de0cd7590d7;hpb=facaed0509e7b7c30d6ec3f9d3438ee21f77c6e8;p=xonotic%2Fdarkplaces.git diff --git a/vid_wgl.c b/vid_wgl.c index 0c551102..e6cb7002 100644 --- a/vid_wgl.c +++ b/vid_wgl.c @@ -95,6 +95,7 @@ static DEVMODE gdevmode, initialdevmode; static qboolean vid_initialized = false; static qboolean vid_wassuspended = false; static qboolean vid_usingmouse = false; +static qboolean vid_usinghidecursor = false; static qboolean vid_usingvsync = false; static qboolean vid_usevsync = false; static HICON hIcon; @@ -243,8 +244,6 @@ static void IN_StartupMouse (void); void VID_Finish (void) { - qboolean vid_usemouse; - vid_usevsync = vid_vsync.integer && !cls.timedemo && gl_videosyncavailable; if (vid_usingvsync != vid_usevsync && gl_videosyncavailable) { @@ -255,7 +254,7 @@ void VID_Finish (void) if (r_render.integer && !vid_hidden) { CHECKGLERROR - if (r_speeds.integer || gl_finish.integer) + if (r_speeds.integer == 2 || gl_finish.integer) { qglFinish();CHECKGLERROR } @@ -429,7 +428,7 @@ void AppActivate(BOOL fActive, BOOL minimize) if (!fActive) { - VID_GrabMouse(false); + VID_SetMouse(false, false, false); if (vid_isfullscreen) { ChangeDisplaySettings (NULL, 0); @@ -481,8 +480,8 @@ LONG WINAPI MainWndProc (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { LONG lRet = 1; int fActive, fMinimized, temp; - char state[256]; - char asciichar[4]; + unsigned char state[256]; + unsigned char asciichar[4]; int vkey; int charlength; qboolean down = false; @@ -503,7 +502,7 @@ LONG WINAPI MainWndProc (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) case WM_MOVE: window_x = (int) LOWORD(lParam); window_y = (int) HIWORD(lParam); - VID_GrabMouse(false); + VID_SetMouse(false, false, false); break; case WM_KEYDOWN: @@ -580,9 +579,7 @@ LONG WINAPI MainWndProc (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) temp |= 512; #ifdef SUPPORTDIRECTX - if (vid_usingmouse && !dinput_acquired) -#else - if (vid_usingmouse) + if (!dinput_acquired) #endif { // perform button actions @@ -784,7 +781,7 @@ void VID_Init(void) IN_Init(); } -int VID_InitMode (int fullscreen, int width, int height, int bpp, int refreshrate, int stereobuffer, int samples) +int VID_InitMode (int fullscreen, int *width, int *height, int bpp, int refreshrate, int stereobuffer, int samples) { int i; HDC hdc; @@ -813,7 +810,7 @@ int VID_InitMode (int fullscreen, int width, int height, int bpp, int refreshrat }; int windowpass; int pixelformat, newpixelformat; - int numpixelformats; + UINT numpixelformats; DWORD WindowStyle, ExWindowStyle; int CenterX, CenterY; const char *gldrivername; @@ -925,8 +922,8 @@ int VID_InitMode (int fullscreen, int width, int height, int bpp, int refreshrat foundmode = true; gdevmode.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT; gdevmode.dmBitsPerPel = bpp; - gdevmode.dmPelsWidth = width; - gdevmode.dmPelsHeight = height; + gdevmode.dmPelsWidth = *width; + gdevmode.dmPelsHeight = *height; gdevmode.dmSize = sizeof (gdevmode); if(refreshrate) { @@ -959,13 +956,13 @@ int VID_InitMode (int fullscreen, int width, int height, int bpp, int refreshrat Con_Printf("wrong bpp\n"); continue; } - if(thismode.dmPelsWidth != (DWORD)width) + if(thismode.dmPelsWidth != (DWORD)*width) { if(developer.integer >= 100) Con_Printf("wrong width\n"); continue; } - if(thismode.dmPelsHeight != (DWORD)height) + if(thismode.dmPelsHeight != (DWORD)*height) { if(developer.integer >= 100) Con_Printf("wrong height\n"); @@ -1017,13 +1014,13 @@ int VID_InitMode (int fullscreen, int width, int height, int bpp, int refreshrat if (!foundmode) { VID_Shutdown(); - Con_Printf("Unable to find the requested mode %dx%dx%dbpp\n", width, height, bpp); + Con_Printf("Unable to find the requested mode %dx%dx%dbpp\n", *width, *height, bpp); return false; } else if(ChangeDisplaySettings (&gdevmode, CDS_FULLSCREEN) != DISP_CHANGE_SUCCESSFUL) { VID_Shutdown(); - Con_Printf("Unable to change to requested mode %dx%dx%dbpp\n", width, height, bpp); + Con_Printf("Unable to change to requested mode %dx%dx%dbpp\n", *width, *height, bpp); return false; } @@ -1056,8 +1053,8 @@ int VID_InitMode (int fullscreen, int width, int height, int bpp, int refreshrat rect.top = 0; rect.left = 0; - rect.right = width; - rect.bottom = height; + rect.right = *width; + rect.bottom = *height; AdjustWindowRectEx(&rect, WindowStyle, false, 0); if (fullscreen) @@ -1222,6 +1219,7 @@ int VID_InitMode (int fullscreen, int width, int height, int bpp, int refreshrat //vid_menudrawfn = VID_MenuDraw; //vid_menukeyfn = VID_MenuKey; vid_usingmouse = false; + vid_usinghidecursor = false; vid_usingvsync = false; vid_hidden = false; vid_initialized = true; @@ -1245,7 +1243,7 @@ void VID_Shutdown (void) if(vid_initialized == false) return; - VID_GrabMouse(false); + VID_SetMouse(false, false, false); VID_RestoreSystemGamma(); vid_initialized = false; @@ -1267,7 +1265,7 @@ void VID_Shutdown (void) vid_isfullscreen = false; } -void VID_GrabMouse(qboolean grab) +void VID_SetMouse(qboolean fullscreengrab, qboolean relative, qboolean hidecursor) { static qboolean restore_spi; static int originalmouseparms[3]; @@ -1275,7 +1273,7 @@ void VID_GrabMouse(qboolean grab) if (!mouseinitialized) return; - if (grab) + if (relative) { if (!vid_usingmouse) { @@ -1313,7 +1311,6 @@ void VID_GrabMouse(qboolean grab) SetCapture (mainwindow); ClipCursor (&window_rect); } - ShowCursor (false); } } else @@ -1338,9 +1335,14 @@ void VID_GrabMouse(qboolean grab) ClipCursor (NULL); ReleaseCapture (); } - ShowCursor (true); } } + + if (vid_usinghidecursor != hidecursor) + { + vid_usinghidecursor = hidecursor; + ShowCursor (!hidecursor); + } } @@ -2066,3 +2068,31 @@ static void IN_Shutdown(void) g_pdi = NULL; #endif } + +size_t VID_ListModes(vid_mode_t *modes, size_t maxcount) +{ + int i, k; + DEVMODE thismode; + + thismode.dmSize = sizeof(thismode); + thismode.dmDriverExtra = 0; + k = 0; + for(i = 0; EnumDisplaySettings(NULL, i, &thismode); ++i) + { + if(~thismode.dmFields & (DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT | DM_DISPLAYFREQUENCY)) + { + Con_DPrintf("enumerating modes yielded a bogus item... please debug this\n"); + continue; + } + if(k >= maxcount) + break; + modes[k].width = thismode.dmPelsWidth; + modes[k].height = thismode.dmPelsHeight; + modes[k].bpp = thismode.dmBitsPerPixel; + modes[k].refreshrate = thismode.dmDisplayFrequency; + modes[k].pixelheight_num = 1; + modes[k].pixelheight_denom = 1; // Win32 apparently does not provide this (FIXME) + ++k; + } + return k; +}