Skip to content

Commit

Permalink
Reset the MOUSE_WHEEL in LocalEvent::GetClean() and LocalEvent::Handl…
Browse files Browse the repository at this point in the history
…eEvents(), add a few comments regarding event modes (ihhub#6100)
  • Loading branch information
oleg-derevenetz authored Nov 6, 2022
1 parent 6bc4e02 commit dbd59ac
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
9 changes: 6 additions & 3 deletions src/engine/localevent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1090,12 +1090,15 @@ void LocalEvent::PauseCycling()
LocalEvent & LocalEvent::GetClean()
{
LocalEvent & le = Get();

le.ResetModes( KEY_PRESSED );
le.ResetModes( MOUSE_MOTION );
le.ResetModes( MOUSE_PRESSED );
le.ResetModes( MOUSE_RELEASED );
le.ResetModes( MOUSE_CLICKED );
le.ResetModes( MOUSE_WHEEL );
le.ResetModes( KEY_HOLD );

return le;
}

Expand All @@ -1119,12 +1122,12 @@ bool LocalEvent::HandleEvents( bool delay, bool allowExit )

SDL_Event event;

// We shouldn't reset the MOUSE_PRESSED and KEY_HOLD here because these are "lasting" states
ResetModes( KEY_PRESSED );
ResetModes( MOUSE_MOTION );
ResetModes( MOUSE_RELEASED );
ResetModes( MOUSE_CLICKED );
ResetModes( KEY_PRESSED );

mouse_wm = fheroes2::Point();
ResetModes( MOUSE_WHEEL );

while ( SDL_PollEvent( &event ) ) {
switch ( event.type ) {
Expand Down
8 changes: 4 additions & 4 deletions src/engine/localevent.h
Original file line number Diff line number Diff line change
Expand Up @@ -324,13 +324,13 @@ class LocalEvent

enum flag_t
{
KEY_PRESSED = 0x0001,
MOUSE_MOTION = 0x0002,
KEY_PRESSED = 0x0001, // key on the keyboard has been pressed
MOUSE_MOTION = 0x0002, // mouse cursor has been moved
MOUSE_PRESSED = 0x0004, // mouse button is currently pressed
MOUSE_RELEASED = 0x0008, // mouse button has just been released
MOUSE_CLICKED = 0x0010, // mouse button has been clicked
MOUSE_WHEEL = 0x0020,
KEY_HOLD = 0x0040
MOUSE_WHEEL = 0x0020, // mouse wheel has been rotated
KEY_HOLD = 0x0040 // key on the keyboard is currently being held down
};

void SetModes( flag_t f )
Expand Down

0 comments on commit dbd59ac

Please sign in to comment.