- 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
parent cbac8db8a5
commit b2b28fa2f5
4 changed files with 107 additions and 40 deletions

View file

@ -1,4 +1,13 @@
December 28, 2006 December 28, 2006
- 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.
- Fixed all the warnings from GCC 4.2, including a handful that were present in - Fixed all the warnings from GCC 4.2, including a handful that were present in
older GCCs. older GCCs.
- Fixed: The VC++ project was not set up to redefine RM using del in - Fixed: The VC++ project was not set up to redefine RM using del in

View file

@ -225,13 +225,66 @@ 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 () static void I_CheckNativeMouse ()
{ {
bool focus = (SDL_GetAppState() & (SDL_APPINPUTFOCUS|SDL_APPACTIVE)) bool focus = (SDL_GetAppState() & (SDL_APPINPUTFOCUS|SDL_APPACTIVE))
== (SDL_APPINPUTFOCUS|SDL_APPACTIVE); == (SDL_APPINPUTFOCUS|SDL_APPACTIVE);
bool fs = (SDL_GetVideoSurface ()->flags & SDL_FULLSCREEN) != 0; 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) if (wantNative != NativeMouse)
{ {
@ -246,6 +299,7 @@ static void I_CheckNativeMouse ()
{ {
SDL_ShowCursor (0); SDL_ShowCursor (0);
SDL_WM_GrabInput (SDL_GRAB_ON); SDL_WM_GrabInput (SDL_GRAB_ON);
CenterMouse ();
} }
} }
} }
@ -278,30 +332,6 @@ void MessagePump (const SDL_Event &sev)
} }
break; 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_MOUSEBUTTONDOWN:
case SDL_MOUSEBUTTONUP: case SDL_MOUSEBUTTONUP:
event.type = sev.type == SDL_MOUSEBUTTONDOWN ? EV_KeyDown : EV_KeyUp; event.type = sev.type == SDL_MOUSEBUTTONDOWN ? EV_KeyDown : EV_KeyUp;
@ -395,6 +425,7 @@ void MessagePump (const SDL_Event &sev)
event.data2 = sev.key.keysym.unicode & 0xff; event.data2 = sev.key.keysym.unicode & 0xff;
if (event.data1 < 128) if (event.data1 < 128)
{ {
event.data1 = toupper(event.data1);
D_PostEvent (&event); D_PostEvent (&event);
} }
if (!iscntrl(event.data2) && event.subtype != EV_GUI_KeyUp) if (!iscntrl(event.data2) && event.subtype != EV_GUI_KeyUp)
@ -417,6 +448,10 @@ void I_GetEvent ()
{ {
MessagePump (sev); MessagePump (sev);
} }
if (use_mouse)
{
MouseRead ();
}
} }
void I_StartTic () void I_StartTic ()

View file

@ -416,7 +416,7 @@ int I_FindNext (void *handle, findstate_t *fileinfo)
int I_FindClose (void *handle) int I_FindClose (void *handle)
{ {
findstate_t *state = (findstate_t *)handle; findstate_t *state = (findstate_t *)handle;
if (state->count > 0) if (handle != (void*)-1 && state->count > 0)
{ {
state->count = 0; state->count = 0;
free (state->namelist); free (state->namelist);

View file

@ -112,17 +112,40 @@ static MiniModeInfo WinModes[] =
{ {
{ 320, 200 }, { 320, 200 },
{ 320, 240 }, { 320, 240 },
{ 400, 225 }, // 16:9
{ 400, 300 }, { 400, 300 },
{ 480, 270 }, // 16:9
{ 480, 360 }, { 480, 360 },
{ 512, 288 }, // 16:9
{ 512, 384 }, { 512, 384 },
{ 640, 360 }, // 16:9
{ 640, 400 }, { 640, 400 },
{ 640, 480 }, { 640, 480 },
{ 720, 480 }, // 16:10
{ 720, 540 }, { 720, 540 },
{ 800, 450 }, // 16:9
{ 800, 500 }, // 16:10
{ 800, 600 }, { 800, 600 },
{ 848, 480 }, // 16:9
{ 960, 600 }, // 16:10
{ 960, 720 }, { 960, 720 },
{ 1024, 576 }, // 16:9
{ 1024, 640 }, // 16:10
{ 1024, 768 }, { 1024, 768 },
{ 1088, 612 }, // 16:9
{ 1152, 648 }, // 16:9
{ 1152, 720 }, // 16:10
{ 1152, 864 }, { 1152, 864 },
{ 1280, 960 } { 1280, 720 }, // 16:9
{ 1280, 800 }, // 16:10
{ 1280, 960 },
{ 1360, 768 }, // 16:9
{ 1400, 787 }, // 16:9
{ 1400, 875 }, // 16:10
{ 1400, 1050 },
{ 1600, 900 }, // 16:9
{ 1600, 1000 }, // 16:10
{ 1600, 1200 },
}; };
static cycle_t BlitCycles; static cycle_t BlitCycles;