PocketMatrix forums

A read-only archive of the PocketMatrix forums (2001–2014). Posting and accounts are closed.

Issue with SetCursorPos & Fullscreen

InexorableTash · 28 Oct 2002, 00:36 UTC
I'm toying with a first-person shooter type game using GapiDraw. When running on a desktop PC in fullscreen mode I want the mouse behavior to mimic that of Quake (etc) where the mouse controls your view direction.

I should really be using DirectInput in this case, but let's pretend I'm not. To allow unrestricted turning, I use SetCursorPos to re-center the mouse in the window. This is really sleazy, but it works and, interestingly enough, it causes CGapiApplication to flake out on exit.

Here are diffs against the "Minimal" sample but the only necessary part is to add "SetCursorPos(160,100)" to the StylusMove() method. You'll note that the app freezes up when you try and exit.

Any thoughts?

Code:

41a42
> POINT g_mouse;
58,60c59,61
< #ifdef _DEBUG
< config.dwDisplayFlags |= GDOPENDISPLAY_SCALEX2;
< #else
---
> //#ifdef _DEBUG
> // config.dwDisplayFlags |= GDOPENDISPLAY_SCALEX2;
> //#else
62c63
< #endif
---
> //#endif
109a111,116
> static tick = 0;
> TCHAR chBuf[256];
> wsprintf( chBuf, "Tick %d, Mouse: %d x %d", tick++, g_mouse.x, g_mouse.y );
> backbuffer.DrawText(dwXCenter, (dwYCenter+20), chBuf, RGB(255, 255, 255),
> GDDRAWTEXT_CENTER | GDDRAWTEXT_BORDER, 0, NULL);
>
142a150,159
> DWORD dwXCenter = (m_backbuffer.GetWidth()>>1);
> DWORD dwYCenter = (m_backbuffer.GetHeight()>>1);
>
> if( IsFullscreen() )
> {
> ::SetCursorPos( dwXCenter, dwYCenter );
> }
> g_mouse.x = p.x-dwXCenter;
> g_mouse.y = p.y-dwYCenter;
>