Replaced the mouse button constants ("l", "r", "m", etc.) with button numbers. 1 is the primary button, 2 is the secondary button, 3 is middle-mouse, etc. Resolves issue #1019.

This commit is contained in:
Alex Szpakowski
2015-03-25 00:31:16 -03:00
parent 78dd8bc547
commit 86d41620dd
9 changed files with 43 additions and 123 deletions
+17 -2
View File
@@ -176,12 +176,27 @@ void Mouse::setVisible(bool visible)
SDL_ShowCursor(visible ? SDL_ENABLE : SDL_DISABLE);
}
bool Mouse::isDown(Button *buttonlist) const
bool Mouse::isDown(const std::vector<int> &buttons) const
{
Uint32 buttonstate = SDL_GetMouseState(nullptr, nullptr);
for (Button button = *buttonlist; button != BUTTON_MAX_ENUM; button = *(++buttonlist))
for (int button : buttons)
{
if (button <= 0)
continue;
// We use button index 2 to represent the right mouse button, but SDL
// uses 2 to represent the middle mouse button.
switch (button)
{
case 2:
button = SDL_BUTTON_RIGHT;
break;
case 3:
button = SDL_BUTTON_MIDDLE;
break;
}
if (buttonstate & SDL_BUTTON(button))
return true;
}