- Fixed: The SDL input code must convert the event.data1 to uppercase.

- Added more resolution options when playing windowed under SDL.
- Changed SDL mouse handling to be basically identical to the (non-DirectInput)
  Win32 code. The mouse is polled periodically and constantly warped to the
  center of the window. Despite what the SDL docs specify, SDL_WM_GrabInput()
  is apparently no longer a reliable means of obtaining continuous relative
  mouse motion events.
- Fixed: The non-Windows implementation of I_FindClose() did not check for -1
  handles.



SVN r432 (trunk)
This commit is contained in:
Randy Heit 2006-12-29 05:14:19 +00:00
commit b2b28fa2f5
4 changed files with 107 additions and 40 deletions

View file

@ -224,6 +224,59 @@ static void I_CheckGUICapture ()
}
}
}
static void CenterMouse ()
{
SDL_WarpMouse (screen->GetWidth()/2, screen->GetHeight()/2);
SDL_PumpEvents ();
SDL_GetRelativeMouseState (NULL, NULL);
}
static void PostMouseMove (int x, int y)
{
static int lastx = 0, lasty = 0;
event_t ev = { 0 };
if (m_filter)
{
ev.x = (x + lastx) / 2;
ev.y = (y + lasty) / 2;
}
else
{
ev.x = x;
ev.y = y;
}
lastx = x;
lasty = y;
if (ev.x | ev.y)
{
ev.type = EV_Mouse;
D_PostEvent (&ev);
}
}
static void MouseRead ()
{
int x, y;
if (NativeMouse)
{
return;
}
SDL_GetRelativeMouseState (&x, &y);
if (!m_noprescale)
{
x *= 3;
y *= 2;
}
if (x | y)
{
CenterMouse ();
PostMouseMove (x, -y);
}
}
static void I_CheckNativeMouse ()
{
@ -231,7 +284,7 @@ static void I_CheckNativeMouse ()
== (SDL_APPINPUTFOCUS|SDL_APPACTIVE);
bool fs = (SDL_GetVideoSurface ()->flags & SDL_FULLSCREEN) != 0;
bool wantNative = !focus || (!fs && (GUICapture || paused));
bool wantNative = !focus || !use_mouse || (!fs && (GUICapture || paused));
if (wantNative != NativeMouse)
{
@ -240,12 +293,13 @@ static void I_CheckNativeMouse ()
{
SDL_ShowCursor (1);
SDL_WM_GrabInput (SDL_GRAB_OFF);
FlushDIKState (KEY_MOUSE1, KEY_MOUSE4);
FlushDIKState (KEY_MOUSE1, KEY_MOUSE4);
}
else
{
SDL_ShowCursor (0);
SDL_WM_GrabInput (SDL_GRAB_ON);
CenterMouse ();
}
}
}
@ -278,30 +332,6 @@ void MessagePump (const SDL_Event &sev)
}
break;
case SDL_MOUSEMOTION:
x = sev.motion.xrel;
y = -sev.motion.yrel;
if (!m_noprescale)
{
x *= 3;
y *= 2;
}
if (m_filter)
{
event.x = (x + lastx) / 2;
event.y = (y + lasty) / 2;
}
else
{
event.x = x;
event.y = y;
}
lastx = x;
lasty = y;
event.type = EV_Mouse;
D_PostEvent (&event);
break;
case SDL_MOUSEBUTTONDOWN:
case SDL_MOUSEBUTTONUP:
event.type = sev.type == SDL_MOUSEBUTTONDOWN ? EV_KeyDown : EV_KeyUp;
@ -394,9 +424,10 @@ void MessagePump (const SDL_Event &sev)
}
event.data2 = sev.key.keysym.unicode & 0xff;
if (event.data1 < 128)
{
{
event.data1 = toupper(event.data1);
D_PostEvent (&event);
}
}
if (!iscntrl(event.data2) && event.subtype != EV_GUI_KeyUp)
{
event.subtype = EV_GUI_Char;
@ -416,6 +447,10 @@ void I_GetEvent ()
while (SDL_PollEvent (&sev))
{
MessagePump (sev);
}
if (use_mouse)
{
MouseRead ();
}
}