X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Flibgame%2Fsystem.c;h=9a8d117b85f1f2c7e6f78c3b35d8b582d0e9f311;hb=888ee049;hp=7fcb784d66c9f7608f00dad238a52b76cc0ce464;hpb=8e4eb47925648cd84d134dfe05ca7fb30727dc24;p=rocksndiamonds.git diff --git a/src/libgame/system.c b/src/libgame/system.c index 7fcb784d..9a8d117b 100644 --- a/src/libgame/system.c +++ b/src/libgame/system.c @@ -57,6 +57,7 @@ int button_status = MB_NOT_PRESSED; boolean motion_status = FALSE; int wheel_steps = DEFAULT_WHEEL_STEPS; boolean keyrepeat_status = TRUE; +boolean textinput_status = FALSE; int redraw_mask = REDRAW_NONE; @@ -117,7 +118,11 @@ void InitNetworkInfo(boolean enabled, boolean connected, boolean serveronly, void InitRuntimeInfo() { +#if defined(HAS_TOUCH_DEVICE) + runtime.uses_touch_device = TRUE; +#else runtime.uses_touch_device = FALSE; +#endif } void InitScoresInfo(void) @@ -320,8 +325,9 @@ void InitGfxOtherSettings(void) gfx.cursor_mode_override = CURSOR_UNDEFINED; gfx.cursor_mode_final = gfx.cursor_mode; - gfx.mouse_x = 0; - gfx.mouse_y = 0; + // prevent initially displaying custom mouse cursor in upper left corner + gfx.mouse_x = POS_OFFSCREEN; + gfx.mouse_y = POS_OFFSCREEN; } void InitTileCursorInfo(void) @@ -570,6 +576,7 @@ void InitVideoBuffer(int width, int height, int depth, boolean fullscreen) video.window_scaling_available = WINDOW_SCALING_STATUS; + video.frame_counter = 0; video.frame_delay = 0; video.frame_delay_value = GAME_FRAME_DELAY; @@ -1576,6 +1583,28 @@ void SetMouseCursor(int mode) gfx.cursor_mode_final = mode_final; } +void UpdateRawMousePosition(int mouse_x, int mouse_y) +{ + // mouse events do not contain logical screen size corrections yet + SDLCorrectRawMousePosition(&mouse_x, &mouse_y); + + mouse_x -= video.screen_xoffset; + mouse_y -= video.screen_yoffset; + + gfx.mouse_x = mouse_x; + gfx.mouse_y = mouse_y; +} + +void UpdateMousePosition(void) +{ + int mouse_x, mouse_y; + + SDL_PumpEvents(); + SDL_GetMouseState(&mouse_x, &mouse_y); + + UpdateRawMousePosition(mouse_x, mouse_y); +} + // ============================================================================ // audio functions @@ -1643,6 +1672,11 @@ void PeekEvent(Event *event) SDL_PeepEvents(event, 1, SDL_PEEKEVENT, SDL_FIRSTEVENT, SDL_LASTEVENT); } +void PumpEvents(void) +{ + SDL_PumpEvents(); +} + void CheckQuitEvent(void) { if (SDL_QuitRequested()) @@ -1663,7 +1697,7 @@ KeyMod HandleKeyModState(Key key, int key_status) { KeyMod new_modifier = KMOD_None; - switch(key) + switch (key) { case KSYM_Shift_L: new_modifier = KMOD_Shift_L; @@ -1720,6 +1754,8 @@ KeyMod GetKeyModStateFromEvents(void) void StartTextInput(int x, int y, int width, int height) { + textinput_status = TRUE; + #if defined(HAS_SCREEN_KEYBOARD) SDL_StartTextInput(); @@ -1734,6 +1770,8 @@ void StartTextInput(int x, int y, int width, int height) void StopTextInput(void) { + textinput_status = FALSE; + #if defined(HAS_SCREEN_KEYBOARD) SDL_StopTextInput();