diff --git a/prboom2/src/SDL/i_video.c b/prboom2/src/SDL/i_video.c index ac8fae201..18c897fe4 100644 --- a/prboom2/src/SDL/i_video.c +++ b/prboom2/src/SDL/i_video.c @@ -292,6 +292,8 @@ int I_SDLtoDoomMouseState(Uint32 buttonstate) ; } +static event_t delay_event; + static void I_GetEvent(void) { event_t event; @@ -299,6 +301,8 @@ static void I_GetEvent(void) SDL_Event SDLEvent; SDL_Event *Event = &SDLEvent; + I_DelayEvent(); + while (SDL_PollEvent(Event)) { switch (Event->type) { @@ -361,26 +365,33 @@ static void I_GetEvent(void) case SDL_MOUSEWHEEL: if (mouse_enabled && window_focused) { + int button = -1; + if (Event->wheel.y > 0) { - event.data1.i = KEYD_MWHEELUP; - - event.type = ev_keydown; - D_PostEvent(&event); - - event.type = ev_keyup; - D_PostEvent(&event); + button = KEYD_MWHEELUP; } else if (Event->wheel.y < 0) { - event.data1.i = KEYD_MWHEELDOWN; + button = KEYD_MWHEELDOWN; + } + else if (Event->wheel.x < 0) + { + button = KEYD_MWHEELLEFT; + } + else if (Event->wheel.x > 0) + { + button = KEYD_MWHEELRIGHT; + } - event.type = ev_keydown; - D_PostEvent(&event); + // post a button down event + event.data1.i = button; + event.type = ev_mouseb_down; + D_PostEvent(&event); - event.type = ev_keyup; - D_PostEvent(&event); - } + // hold button for one tic, required for checks in G_BuildTiccmd + delay_event.data1.i = button; + delay_event.type = ev_mouseb_up; } break; @@ -422,6 +433,16 @@ static void I_GetEvent(void) } } +// Pulled from Woof +void I_DelayEvent(void) +{ + if (delay_event.data1.i) + { + D_PostEvent(&delay_event); + delay_event.data1.i = 0; + } +} + // // I_StartTic // diff --git a/prboom2/src/am_map.c b/prboom2/src/am_map.c index bb3615290..f91f9c5c9 100644 --- a/prboom2/src/am_map.c +++ b/prboom2/src/am_map.c @@ -1073,7 +1073,7 @@ dboolean AM_Responder } else if ( dsda_InputActivated(dsda_input_map_zoomout) || - (map_wheel_zoom && ev->type == ev_keydown && ev->data1.i == KEYD_MWHEELDOWN) + (map_wheel_zoom && ev->type == ev_mouseb_down && ev->data1.i == KEYD_MWHEELDOWN) ) { mtof_zoommul = M_ZOOMOUT; @@ -1085,7 +1085,7 @@ dboolean AM_Responder } else if ( dsda_InputActivated(dsda_input_map_zoomin) || - (map_wheel_zoom && ev->type == ev_keydown && ev->data1.i == KEYD_MWHEELUP) + (map_wheel_zoom && ev->type == ev_mouseb_down && ev->data1.i == KEYD_MWHEELUP) ) { mtof_zoommul = M_ZOOMIN; @@ -1164,7 +1164,7 @@ dboolean AM_Responder dsda_InputDeactivated(dsda_input_map_zoomout) || dsda_InputDeactivated(dsda_input_map_zoomin) || ( - map_wheel_zoom && ev->type == ev_keyup && + map_wheel_zoom && ev->type == ev_mouseb_up && (ev->data1.i == KEYD_MWHEELDOWN || ev->data1.i == KEYD_MWHEELUP) ) ) diff --git a/prboom2/src/d_event.h b/prboom2/src/d_event.h index 8faaee3c2..6ee5bc1c0 100644 --- a/prboom2/src/d_event.h +++ b/prboom2/src/d_event.h @@ -48,6 +48,8 @@ typedef enum { ev_keydown, ev_keyup, + ev_mouseb_down, + ev_mouseb_up, ev_mouse, ev_mousemotion, ev_joystick, diff --git a/prboom2/src/d_main.c b/prboom2/src/d_main.c index d85474c40..41ff1b570 100644 --- a/prboom2/src/d_main.c +++ b/prboom2/src/d_main.c @@ -209,7 +209,7 @@ void D_PostEvent(event_t *ev) // use key is used for seeing the current frame if ( !dsda_InputActivated(dsda_input_use) && !dsda_InputActivated(dsda_input_demo_skip) && - (ev->type == ev_keydown || ev->type == ev_keyup) // is this condition important? + (ev->type == ev_keydown || ev->type == ev_keyup || ev->type == ev_mouseb_down || ev->type == ev_mouseb_up) // is this condition important? ) { return; diff --git a/prboom2/src/doomdef.h b/prboom2/src/doomdef.h index 1b71a57e2..c5b43c9b2 100644 --- a/prboom2/src/doomdef.h +++ b/prboom2/src/doomdef.h @@ -396,6 +396,8 @@ typedef enum { #define KEYD_MOUSE3 (0x80 + 0x62) #define KEYD_MWHEELUP (0x80 + 0x6b) #define KEYD_MWHEELDOWN (0x80 + 0x6c) +#define KEYD_MWHEELLEFT (0X80 + 0X6d) +#define KEYD_MWHEELRIGHT (0X80 + 0X6e) // phares 3/20/98: // diff --git a/prboom2/src/dsda/input.c b/prboom2/src/dsda/input.c index 7455292d9..63a81939c 100644 --- a/prboom2/src/dsda/input.c +++ b/prboom2/src/dsda/input.c @@ -90,6 +90,12 @@ void dsda_InputTrackEvent(event_t* ev) { case ev_keyup: dsda_InputTrackKeyUp(ev); break; + case ev_mouseb_down: + dsda_InputTrackKeyDown(ev); + break; + case ev_mouseb_up: + dsda_InputTrackKeyUp(ev); + break; case ev_mouse: dsda_InputTrackButtons(mousebuttons, MAX_MOUSE_BUTTONS, ev); break; @@ -142,6 +148,12 @@ void dsda_InputTrackGameEvent(event_t* ev) { case ev_keyup: dsda_InputTrackGameKeyUp(ev); break; + case ev_mouseb_down: + dsda_InputTrackGameKeyDown(ev); + break; + case ev_mouseb_up: + dsda_InputTrackGameKeyUp(ev); + break; case ev_mouse: dsda_InputTrackGameButtons(mousebuttons, MAX_MOUSE_BUTTONS, ev); break; diff --git a/prboom2/src/f_finale.c b/prboom2/src/f_finale.c index 651e84868..631c12743 100644 --- a/prboom2/src/f_finale.c +++ b/prboom2/src/f_finale.c @@ -617,7 +617,7 @@ void F_CastTicker (void) dboolean F_CastResponder (event_t* ev) { - if (ev->type != ev_keydown) + if (ev->type != ev_keydown && ev->type != ev_mouseb_down) return false; if (castdeath) diff --git a/prboom2/src/g_game.c b/prboom2/src/g_game.c index d21f6ff4a..1323ebe2b 100644 --- a/prboom2/src/g_game.c +++ b/prboom2/src/g_game.c @@ -1380,6 +1380,12 @@ dboolean G_Responder (event_t* ev) case ev_keydown: return true; // eat key down events + case ev_mouseb_up: + return true; + + case ev_mouseb_down: + return true; + case ev_mousemotion: { double value; diff --git a/prboom2/src/heretic/f_finale.c b/prboom2/src/heretic/f_finale.c index dabba154f..d3a3e10aa 100644 --- a/prboom2/src/heretic/f_finale.c +++ b/prboom2/src/heretic/f_finale.c @@ -90,7 +90,7 @@ dboolean F_BlockingInput(void) dboolean Heretic_F_Responder(event_t * event) { - if (event->type != ev_keydown) + if (event->type != ev_keydown && event->type != ev_mouseb_down) { return false; } diff --git a/prboom2/src/i_video.h b/prboom2/src/i_video.h index 2cacf3d34..8fb900137 100644 --- a/prboom2/src/i_video.h +++ b/prboom2/src/i_video.h @@ -65,6 +65,7 @@ void I_SetPalette(int pal); /* CPhipps - pass down palette number */ void I_QueueFrameCapture(void); void I_QueueScreenshot(void); void I_HandleCapture(void); +void I_DelayEvent(void); void I_FinishUpdate (void); diff --git a/prboom2/src/m_menu.c b/prboom2/src/m_menu.c index f62e9a6ec..3805a9600 100644 --- a/prboom2/src/m_menu.c +++ b/prboom2/src/m_menu.c @@ -3993,6 +3993,8 @@ int M_GetKeyString(int c,int offset) case KEYD_PAUSE: s = "PAUS"; break; case KEYD_MWHEELDOWN: s = "MWDN"; break; case KEYD_MWHEELUP: s = "MWUP"; break; + case KEYD_MWHEELLEFT: s = "MWLT"; break; + case KEYD_MWHEELRIGHT: s = "MWRT"; break; case KEYD_PRINTSC: s = "PRSC"; break; case 0: s = "NONE"; break; default: s = "JUNK"; break; @@ -5622,14 +5624,14 @@ int M_EventToCharacter(event_t* ev) } } } - else if (ev->type == ev_keydown) + else if (ev->type == ev_keydown || ev->type == ev_mouseb_down) { if (ev->data1.i == KEYD_RSHIFT) // phares 4/11/98 shiftdown = true; return ev->data1.i; } - else if (ev->type == ev_keyup) + else if (ev->type == ev_keyup || ev->type == ev_mouseb_up) { if (ev->data1.i == KEYD_RSHIFT) // phares 4/11/98 shiftdown = false;