let any number of mouse buttons work

This commit is contained in:
Dana Jansens 2003-02-19 01:07:29 +00:00
parent d647de97be
commit d2a1ecb1b5

View file

@ -16,24 +16,30 @@ extern "C" {
#define _(str) gettext(str) #define _(str) gettext(str)
} }
#include <cstdlib>
#include <algorithm> #include <algorithm>
namespace ob { namespace ob {
static bool buttonvalue(const std::string &button, unsigned int *val) static bool buttonvalue(const std::string &button, unsigned int *val)
{ {
if (button == "Left" || button == "1" || button == "Button1") { if (button == "Left")
*val |= Button1; *val = 1;
} else if (button == "Middle" || button == "2" || button == "Button2") { else if (button == "Middle")
*val |= Button2; *val = 2;
} else if (button == "Right" || button == "3" || button == "Button3") { else if (button == "Right")
*val |= Button3; *val = 3;
} else if (button == "Up" || button == "4" || button == "Button4") { else if (button == "Up")
*val |= Button4; *val = 4;
} else if (button == "Down" || button == "5" || button == "Button5") { else if (button == "Down")
*val |= Button5; *val = 5;
} else else {
return false; // try convert to number
int i = atoi(button.c_str());
if (i <= 0)
return false;
*val = i;
}
return true; return true;
} }