Source

love / src / modules / joystick / sdl / wrap_Joystick.cpp

Diff from to

File src/modules/joystick/sdl/wrap_Joystick.cpp

 
 	int w_getName(lua_State * L)
 	{
-		int index = luaL_checkint(L, 1);
+		int index = luaL_checkint(L, 1)-1;
 		lua_pushstring(L, instance->getName(index));
 		return 1;
 	}
 
 	int w_open(lua_State * L)
 	{
-		int index = luaL_checkint(L, 1);
+		int index = luaL_checkint(L, 1)-1;
 		luax_pushboolean(L, instance->open(index));
 		return 1;
 	}
 
 	int w_isOpen(lua_State * L)
 	{
-		int index = luaL_checkint(L, 1);
+		int index = luaL_checkint(L, 1)-1;
 		luax_pushboolean(L, instance->isOpen(index));
 		return 1;
 	}
 
 	int w_getNumAxes(lua_State * L)
 	{
-		int index = luaL_checkint(L, 1);
+		int index = luaL_checkint(L, 1)-1;
 		lua_pushinteger(L, instance->getNumAxes(index));
 		return 1;
 	}
 
 	int w_getNumBalls(lua_State * L)
 	{
-		int index = luaL_checkint(L, 1);
+		int index = luaL_checkint(L, 1)-1;
 		lua_pushinteger(L, instance->getNumBalls(index));
 		return 1;
 	}
 
 	int w_getNumButtons(lua_State * L)
 	{
-		int index = luaL_checkint(L, 1);
+		int index = luaL_checkint(L, 1)-1;
 		lua_pushinteger(L, instance->getNumButtons(index));
 		return 1;
 	}
 
 	int w_getNumHats(lua_State * L)
 	{
-		int index = luaL_checkint(L, 1);
+		int index = luaL_checkint(L, 1)-1;
 		lua_pushinteger(L, instance->getNumHats(index));
 		return 1;
 	}
 
 	int w_getAxis(lua_State * L)
 	{
-		int index = luaL_checkint(L, 1);
-		int axis = luaL_checkint(L, 2);
+		int index = luaL_checkint(L, 1)-1;
+		int axis = luaL_checkint(L, 2)-1;
 		lua_pushnumber(L, instance->getAxis(index, axis));
 		return 1;
 	}
 
 	int w_isDown(lua_State * L)
 	{
-		int index = luaL_checkint(L, 1);
+		int index = luaL_checkint(L, 1)-1;
 		unsigned int num = lua_gettop(L);
 		int * buttonlist = new int[num];
 		unsigned int counter = 0;
 		
 		for (unsigned int i = 1; i < num; i++)
 		{
-			buttonlist[counter++] = (int) luaL_checknumber(L, i+1);
+			buttonlist[counter++] = (int) luaL_checknumber(L, i+1)-1;
 		}
 		buttonlist[counter] = -1;
 		
 
 	int w_getHat(lua_State * L)
 	{
-		int index = luaL_checkint(L, 1);
-		int hat = luaL_checkint(L, 2);
+		int index = luaL_checkint(L, 1)-1;
+		int hat = luaL_checkint(L, 2)-1;
 
 		Joystick::Hat h = instance->getHat(index, hat);
 
 
 	int w_close(lua_State * L)
 	{
-		int index = luaL_checkint(L, 1);
+		int index = luaL_checkint(L, 1)-1;
 		instance->close(index);
 		return 0;
 	}