Skip to content

Commit

Permalink
Add horizontal mouse wheel support (#544)
Browse files Browse the repository at this point in the history
  • Loading branch information
andrikpowell authored Dec 21, 2024
1 parent 67f3746 commit c7c5cac
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 10 deletions.
23 changes: 13 additions & 10 deletions prboom2/src/SDL/i_video.c
Original file line number Diff line number Diff line change
Expand Up @@ -361,19 +361,22 @@ static void I_GetEvent(void)
case SDL_MOUSEWHEEL:
if (mouse_enabled && window_focused)
{
if (Event->wheel.y > 0)
{
event.data1.i = KEYD_MWHEELUP;

event.type = ev_keydown;
D_PostEvent(&event);
int mouseb;

event.type = ev_keyup;
D_PostEvent(&event);
}
if (Event->wheel.y > 0)
mouseb = KEYD_MWHEELUP;
else if (Event->wheel.y < 0)
mouseb = KEYD_MWHEELDOWN;
else if (Event->wheel.x < 0)
mouseb = KEYD_MWHEELLEFT;
else if (Event->wheel.x > 0)
mouseb = KEYD_MWHEELRIGHT;
else
mouseb = 0;

if(mouseb)
{
event.data1.i = KEYD_MWHEELDOWN;
event.data1.i = mouseb;

event.type = ev_keydown;
D_PostEvent(&event);
Expand Down
2 changes: 2 additions & 0 deletions prboom2/src/doomdef.h
Original file line number Diff line number Diff line change
Expand Up @@ -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:
//
Expand Down
2 changes: 2 additions & 0 deletions prboom2/src/m_menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -4000,6 +4000,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;
Expand Down

0 comments on commit c7c5cac

Please sign in to comment.