work around yet another bug in fuckdows

This commit is contained in:
Ben Russell (300178622) 2015-11-02 14:16:56 +13:00
parent f8eb5c070b
commit cae9db1fa9
3 changed files with 51 additions and 37 deletions

View File

@ -14,7 +14,7 @@
CFLAGS = -O2 -fno-strict-aliasing -g -Wall -Wextra \ CFLAGS = -O2 -fno-strict-aliasing -g -Wall -Wextra \
-Wno-unused-variable -Wno-unused-parameter \ -Wno-unused-variable -Wno-unused-parameter \
-Wno-unused-but-set-variable \ -Wno-unused-but-set-variable \
-Iwinlibs -Iwinlibs/SDL \ -Iwinlibs -Iwinlibs/SDL2 \
-DGL_BGRA=0x80E1 \ -DGL_BGRA=0x80E1 \
$(CFLAGS_EXTRA) \ $(CFLAGS_EXTRA) \
-I $(INCDIR) -I $(INCDIR)

View File

@ -1,87 +1,88 @@
/* /*
This file is part of Iceball. This file is part of Iceball.
Iceball is free software: you can redistribute it and/or modify Iceball is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or the Free Software Foundation, either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
Iceball is distributed in the hope that it will be useful, Iceball is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with Iceball. If not, see <http://www.gnu.org/licenses/>. along with Iceball. If not, see <http://www.gnu.org/licenses/>.
*/ */
// client functions // client functions
int icelua_fn_client_text_input_start(lua_State *L) int icelua_fn_client_text_input_start(lua_State *L)
{ {
#ifdef DEDI #ifdef DEDI
return luaL_error(L, "EDOOFUS: why the hell is this being called in the dedi version?"); return luaL_error(L, "EDOOFUS: why the hell is this being called in the dedi version?");
#else #else
SDL_StartTextInput(); SDL_StartTextInput();
#endif #endif
return 0; return 0;
} }
int icelua_fn_client_text_input_stop(lua_State *L) int icelua_fn_client_text_input_stop(lua_State *L)
{ {
#ifdef DEDI #ifdef DEDI
return luaL_error(L, "EDOOFUS: why the hell is this being called in the dedi version?"); return luaL_error(L, "EDOOFUS: why the hell is this being called in the dedi version?");
#else #else
SDL_StopTextInput(); SDL_StopTextInput();
#endif #endif
return 0; return 0;
} }
int icelua_fn_client_mouse_lock_set(lua_State *L) int icelua_fn_client_mouse_lock_set(lua_State *L)
{ {
int top = icelua_assert_stack(L, 1, 1); int top = icelua_assert_stack(L, 1, 1);
#ifdef DEDI #ifdef DEDI
return luaL_error(L, "EDOOFUS: why the hell is this being called in the dedi version?"); return luaL_error(L, "EDOOFUS: why the hell is this being called in the dedi version?");
#else #else
// workaround for SDL2 not properly resetting state when // workaround for SDL2 not properly resetting state when
// alt-tabbing // alt-tabbing
SDL_SetWindowGrab(window, SDL_FALSE); SDL_SetWindowGrab(window, SDL_FALSE);
SDL_SetRelativeMouseMode(SDL_FALSE); SDL_SetRelativeMouseMode(SDL_FALSE);
int lock = lua_toboolean(L, 1); int lock = lua_toboolean(L, 1);
if (lock) { if (lock) {
SDL_SetWindowGrab(window, SDL_TRUE); SDL_SetWindowGrab(window, SDL_TRUE);
SDL_SetRelativeMouseMode(SDL_TRUE); SDL_SetRelativeMouseMode(SDL_TRUE);
} }
#endif #endif
return 0; return 0;
} }
int icelua_fn_client_mouse_visible_set(lua_State *L) int icelua_fn_client_mouse_visible_set(lua_State *L)
{ {
int top = icelua_assert_stack(L, 1, 1); int top = icelua_assert_stack(L, 1, 1);
#ifdef DEDI #ifdef DEDI
return luaL_error(L, "EDOOFUS: why the hell is this being called in the dedi version?"); return luaL_error(L, "EDOOFUS: why the hell is this being called in the dedi version?");
#else #else
SDL_ShowCursor(lua_toboolean(L, 1)); SDL_ShowCursor(lua_toboolean(L, 1));
#endif #endif
return 0; return 0;
} }
int icelua_fn_client_mouse_warp(lua_State *L) int icelua_fn_client_mouse_warp(lua_State *L)
{ {
int top = icelua_assert_stack(L, 2, 2); int top = icelua_assert_stack(L, 2, 2);
#ifdef DEDI #ifdef DEDI
return luaL_error(L, "EDOOFUS: why the hell is this being called in the dedi version?"); return luaL_error(L, "EDOOFUS: why the hell is this being called in the dedi version?");
#else #else
SDL_WarpMouseInWindow(window, lua_tonumber(L, 1), lua_tonumber(L, 2)); SDL_WarpMouseInWindow(window, lua_tonumber(L, 1), lua_tonumber(L, 2));
#endif #endif
return 0; return 0;
} }

View File

@ -120,8 +120,6 @@ int video_init(void)
SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24); SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24);
SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, 8); SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, 8);
if(!gl_vsync)
SDL_GL_SetSwapInterval(1);
if (screen_antialiasing_level > 0) if (screen_antialiasing_level > 0)
{ {
@ -146,6 +144,11 @@ int video_init(void)
SDL_GL_MakeCurrent(window, gl_context); SDL_GL_MakeCurrent(window, gl_context);
if(gl_vsync)
SDL_GL_SetSwapInterval(1);
else
SDL_GL_SetSwapInterval(0);
//screen = SDL_GetWindowSurface(window); //screen = SDL_GetWindowSurface(window);
//if(screen == NULL) //if(screen == NULL)
@ -453,7 +456,17 @@ static int ib_client_mouse_press_hook(SDL_Event ev) {
return 0; return 0;
} }
static int ib_client_mouse_motion_hook(SDL_Event ev) { static int ib_client_mouse_motion_hook(SDL_Event ev)
{
#ifdef WIN32
// THANKS FUCKDOWS
// TODO: make fuckdows behave
//printf("%i %i %i %i\n", ev.motion.xrel, ev.motion.yrel, ev.motion.x, ev.motion.y);
if(ev.motion.xrel < -screen_width/4) return 0;
if(ev.motion.xrel > screen_width/4) return 0;
if(ev.motion.yrel < -screen_height/4) return 0;
if(ev.motion.yrel > screen_height/4) return 0;
#endif
lua_getglobal(lstate_client, "client"); lua_getglobal(lstate_client, "client");
lua_getfield(lstate_client, -1, "hook_mouse_motion"); lua_getfield(lstate_client, -1, "hook_mouse_motion");
lua_remove(lstate_client, -2); lua_remove(lstate_client, -2);