Make mouse.c max_button match event.c max_button, ~reduce~ mask-to-table logic

Signed-off-by: Uli Schlachter <psychon@znc.in>
This commit is contained in:
Majic 2011-11-16 19:03:06 -08:00 committed by Uli Schlachter
parent c3174f4581
commit dea949a1c8
1 changed files with 4 additions and 7 deletions

11
mouse.c
View File

@ -157,14 +157,11 @@ luaA_mouse_pushstatus(lua_State *L, int x, int y)
lua_createtable(L, 5, 0); lua_createtable(L, 5, 0);
const int max_button = sizeof(globalconf.buttons_pressed) * 8; const unsigned int max_button = sizeof(globalconf.buttons_pressed) * 8;
int mask = 1; unsigned int mask = 1;
for (int i = 1; i <= max_button; i++, mask <<= 1) for (unsigned int i = 1; i <= max_button; i++, mask <<= 1)
{ {
if(globalconf.buttons_pressed & mask) lua_pushboolean(L, globalconf.buttons_pressed & mask);
lua_pushboolean(L, true);
else
lua_pushboolean(L, false);
lua_rawseti(L, -2, i); lua_rawseti(L, -2, i);
} }
lua_setfield(L, -2, "buttons"); lua_setfield(L, -2, "buttons");