Skip to content

Serious bug in mouse button detection #52

Description

@LeeTeng2001

Hello, first of all I really thank you for writing this book. When I was doing the camera part I noticed the weird behaviour of mouse detection in the InputSystem, turns out it's wrong to test equality for mouse button because valid result should be non-negative but doesn't guarantee 1.

bool MouseState::GetButtonValue(int button) const
{
	return (SDL_BUTTON(button) & mCurrButtons) == 1;  // Will not work!!!
}

The correct code should be

bool MouseState::GetButtonValue(int button) const
{
	return (SDL_BUTTON(button) & mCurrButtons);
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions