1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
|
Subject: Change weapons with the mouse wheel.
Author: Fabian Greffrath <fabian+debian@greffrath.com>
--- a/id_in.cpp
+++ b/id_in.cpp
@@ -237,6 +237,8 @@ boolean IN_JoyPresent()
return Joystick != NULL;
}
+boolean mw_dn = false, mw_up = false;
+
static void processEvent(SDL_Event *event)
{
switch (event->type)
@@ -328,6 +330,15 @@ static void processEvent(SDL_Event *even
break;
}
+ case SDL_MOUSEBUTTONDOWN:
+ {
+ if (event->button.button == SDL_BUTTON_WHEELDOWN)
+ mw_dn = true;
+ else if(event->button.button == SDL_BUTTON_WHEELUP)
+ mw_up = true;
+ break;
+ }
+
case SDL_ACTIVEEVENT:
{
if(fullscreen && (event->active.state & SDL_APPACTIVE) != 0)
--- a/wl_play.cpp
+++ b/wl_play.cpp
@@ -273,6 +273,7 @@ void PollKeyboardButtons (void)
void PollMouseButtons (void)
{
int buttons = IN_MouseButtons ();
+ extern boolean mw_dn, mw_up;
if (buttons & 1)
buttonstate[buttonmouse[0]] = true;
@@ -280,6 +281,12 @@ void PollMouseButtons (void)
buttonstate[buttonmouse[1]] = true;
if (buttons & 4)
buttonstate[buttonmouse[2]] = true;
+
+ if (mw_dn)
+ buttonstate[bt_prevweapon] = true;
+ if (mw_up)
+ buttonstate[bt_nextweapon] = true;
+ mw_dn = mw_up = false;
}
|