X-Git-Url: https://de.git.xonotic.org/?p=xonotic%2Fdarkplaces.git;a=blobdiff_plain;f=vid_wgl.c;h=298d5668169fb37a10b827e65b9b908445ededd6;hp=df392e98d6b9781964e2636787799ade33931de9;hb=c4e92b9982882076e7b35e55fb43bd1a0dbd340d;hpb=395dcde3e90091081963e81a6468c95b9b06c05d diff --git a/vid_wgl.c b/vid_wgl.c index df392e98..298d5668 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; @@ -121,8 +122,6 @@ static qboolean vid_isfullscreen; static int window_x, window_y; -static void IN_Activate (qboolean grab); - static qboolean mouseinitialized; #ifdef SUPPORTDIRECTX @@ -243,10 +242,8 @@ static void IN_StartupMouse (void); //==================================== -void VID_Finish (qboolean allowmousegrab) +void VID_Finish (void) { - qboolean vid_usemouse; - vid_usevsync = vid_vsync.integer && !cls.timedemo && gl_videosyncavailable; if (vid_usingvsync != vid_usevsync && gl_videosyncavailable) { @@ -254,16 +251,6 @@ void VID_Finish (qboolean allowmousegrab) qwglSwapIntervalEXT (vid_usevsync); } -// handle the mouse state when windowed if that's changed - vid_usemouse = false; - if (allowmousegrab && vid_mouse.integer && !key_consoleactive && (key_dest != key_game || !cls.demoplayback)) - vid_usemouse = true; - if (vid_isfullscreen) - vid_usemouse = true; - if (!vid_activewindow) - vid_usemouse = false; - IN_Activate(vid_usemouse); - if (r_render.integer && !vid_hidden) { CHECKGLERROR @@ -441,7 +428,7 @@ void AppActivate(BOOL fActive, BOOL minimize) if (!fActive) { - IN_Activate (false); + VID_SetMouse(false, false, false); if (vid_isfullscreen) { ChangeDisplaySettings (NULL, 0); @@ -493,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; @@ -515,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); - IN_Activate(false); + VID_SetMouse(false, false, false); break; case WM_KEYDOWN: @@ -592,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 @@ -796,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; @@ -825,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; @@ -937,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) { @@ -971,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"); @@ -1029,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; } @@ -1068,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) @@ -1234,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; @@ -1257,6 +1243,7 @@ void VID_Shutdown (void) if(vid_initialized == false) return; + VID_SetMouse(false, false, false); VID_RestoreSystemGamma(); vid_initialized = false; @@ -1278,7 +1265,7 @@ void VID_Shutdown (void) vid_isfullscreen = false; } -static void IN_Activate (qboolean grab) +void VID_SetMouse(qboolean fullscreengrab, qboolean relative, qboolean hidecursor) { static qboolean restore_spi; static int originalmouseparms[3]; @@ -1286,7 +1273,7 @@ static void IN_Activate (qboolean grab) if (!mouseinitialized) return; - if (grab) + if (relative) { if (!vid_usingmouse) { @@ -1324,7 +1311,6 @@ static void IN_Activate (qboolean grab) SetCapture (mainwindow); ClipCursor (&window_rect); } - ShowCursor (false); } } else @@ -1349,9 +1335,14 @@ static void IN_Activate (qboolean grab) ClipCursor (NULL); ReleaseCapture (); } - ShowCursor (true); } } + + if (vid_usinghidecursor != hidecursor) + { + vid_usinghidecursor = hidecursor; + ShowCursor (!hidecursor); + } } @@ -1482,15 +1473,14 @@ IN_MouseMove */ static void IN_MouseMove (void) { - int mx, my; POINT current_pos; + GetCursorPos (¤t_pos); + in_windowmouse_x = current_pos.x - window_x; + in_windowmouse_y = current_pos.y - window_y; + if (!vid_usingmouse) - { - //GetCursorPos (¤t_pos); - //ui_mouseupdate(current_pos.x - window_x, current_pos.y - window_y); return; - } #ifdef SUPPORTDIRECTX if (dinput_acquired) @@ -1499,8 +1489,6 @@ static void IN_MouseMove (void) DIDEVICEOBJECTDATA od; DWORD dwElements; HRESULT hr; - mx = 0; - my = 0; for (;;) { @@ -1524,11 +1512,11 @@ static void IN_MouseMove (void) switch (od.dwOfs) { case DIMOFS_X: - mx += (LONG) od.dwData; + in_mouse_x += (LONG) od.dwData; break; case DIMOFS_Y: - my += (LONG) od.dwData; + in_mouse_y += (LONG) od.dwData; break; case DIMOFS_Z: @@ -1579,23 +1567,15 @@ static void IN_MouseMove (void) if ((mstate_di ^ mouse_oldbuttonstate) & (1<