- Added button mappings for 8 mouse buttons on SDL. It works with my system,

but Linux being Linux, there are no guarantees that it's appropriate for
  other systems.
- Fixed: SDL input code did not generate GUI events for the mousewheel, so it
  could not be used to scroll the console buffer.



SVN r1381 (trunk)
This commit is contained in:
Randy Heit 2009-01-31 02:26:24 +00:00
parent 40d740506d
commit a7ffb9db6a
2 changed files with 54 additions and 4 deletions

View file

@ -1,3 +1,10 @@
January 30, 2009
- Added button mappings for 8 mouse buttons on SDL. It works with my system,
but Linux being Linux, there are no guarantees that it's appropriate for
other systems.
- Fixed: SDL input code did not generate GUI events for the mousewheel, so it
could not be used to scroll the console buffer.
January 30, 2009 (Changes by Graf Zahl)
- Added Blzut3's statusbar maintenance patch.

View file

@ -281,6 +281,25 @@ static void MouseRead ()
}
}
static void WheelMoved(event_t *event)
{
if (GUICapture)
{
SDLMod mod = SDL_GetModState();
event->type = EV_GUI_Event;
event->subtype = event->data1 == KEY_MWHEELUP ? EV_GUI_WheelUp : EV_GUI_WheelDown;
event->data1 = 0;
event->data3 = ((mod & KMOD_SHIFT) ? GKM_SHIFT : 0) |
((mod & KMOD_CTRL) ? GKM_CTRL : 0) |
((mod & KMOD_ALT) ? GKM_ALT : 0);
D_PostEvent(event);
}
else
{
D_PostEvent(event);
}
}
CUSTOM_CVAR(Int, mouse_capturemode, 1, CVAR_GLOBALCONFIG|CVAR_ARCHIVE)
{
if (self < 0) self = 0;
@ -316,7 +335,7 @@ static void I_CheckNativeMouse ()
{
SDL_ShowCursor (1);
SDL_WM_GrabInput (SDL_GRAB_OFF);
FlushDIKState (KEY_MOUSE1, KEY_MOUSE4);
FlushDIKState (KEY_MOUSE1, KEY_MOUSE8);
}
else
{
@ -358,6 +377,12 @@ void MessagePump (const SDL_Event &sev)
case SDL_MOUSEBUTTONDOWN:
case SDL_MOUSEBUTTONUP:
event.type = sev.type == SDL_MOUSEBUTTONDOWN ? EV_KeyDown : EV_KeyUp;
/* These button mappings work with my Gentoo system using the
* evdev driver and a Logitech MX510 mouse. Whether or not they
* carry over to other Linux systems, I have no idea, but I sure
* hope so. (Though buttons 11 and 12 are kind of useless, since
* they also trigger buttons 4 and 5.)
*/
switch (sev.button.button)
{
case 1: event.data1 = KEY_MOUSE1; break;
@ -365,10 +390,28 @@ void MessagePump (const SDL_Event &sev)
case 3: event.data1 = KEY_MOUSE2; break;
case 4: event.data1 = KEY_MWHEELUP; break;
case 5: event.data1 = KEY_MWHEELDOWN; break;
case 6: event.data1 = KEY_MOUSE4; break; /* dunno */
case 6: event.data1 = KEY_MOUSE4; break; /* dunno; not generated by my mouse */
case 7: event.data1 = KEY_MOUSE5; break; /* ditto */
case 8: event.data1 = KEY_MOUSE4; break;
case 9: event.data1 = KEY_MOUSE5; break;
case 10: event.data1 = KEY_MOUSE6; break;
case 11: event.data1 = KEY_MOUSE7; break;
case 12: event.data1 = KEY_MOUSE8; break;
default: printf("SDL mouse button %s %d\n",
sev.type == SDL_MOUSEBUTTONDOWN ? "down" : "up", sev.button.button); break;
}
if (event.data1 != 0)
{
//DIKState[ActiveDIKState][event.data1] = (event.type == EV_KeyDown);
if (event.data1 == KEY_MWHEELUP || event.data1 == KEY_MWHEELDOWN)
{
WheelMoved(&event);
}
else
{
D_PostEvent(&event);
}
}
//DIKState[ActiveDIKState][event.data1] = (event.type == EV_KeyDown);
D_PostEvent (&event);
break;
case SDL_KEYDOWN: