- 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
- 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
older GCCs.
- Fixed: The VC++ project was not set up to redefine RM using del in

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 ();
}
}

View file

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

View file

@ -111,18 +111,41 @@ CUSTOM_CVAR (Float, bgamma, 1.f, CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
static MiniModeInfo WinModes[] =
{
{ 320, 200 },
{ 320, 240 },
{ 400, 300 },
{ 480, 360 },
{ 512, 384 },
{ 320, 240 },
{ 400, 225 }, // 16:9
{ 400, 300 },
{ 480, 270 }, // 16:9
{ 480, 360 },
{ 512, 288 }, // 16:9
{ 512, 384 },
{ 640, 360 }, // 16:9
{ 640, 400 },
{ 640, 480 },
{ 720, 540 },
{ 800, 600 },
{ 960, 720 },
{ 1024, 768 },
{ 1152, 864 },
{ 1280, 960 }
{ 640, 480 },
{ 720, 480 }, // 16:10
{ 720, 540 },
{ 800, 450 }, // 16:9
{ 800, 500 }, // 16:10
{ 800, 600 },
{ 848, 480 }, // 16:9
{ 960, 600 }, // 16:10
{ 960, 720 },
{ 1024, 576 }, // 16:9
{ 1024, 640 }, // 16:10
{ 1024, 768 },
{ 1088, 612 }, // 16:9
{ 1152, 648 }, // 16:9
{ 1152, 720 }, // 16:10
{ 1152, 864 },
{ 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;