struct ProgramInfo program;
struct NetworkInfo network;
+struct RuntimeInfo runtime;
struct OptionInfo options;
struct VideoSystemInfo video;
struct AudioSystemInfo audio;
int button_status = MB_NOT_PRESSED;
boolean motion_status = FALSE;
int wheel_steps = DEFAULT_WHEEL_STEPS;
-#if defined(TARGET_SDL2)
boolean keyrepeat_status = TRUE;
-#endif
int redraw_mask = REDRAW_NONE;
network.server_port = server_port;
}
+void InitRuntimeInfo()
+{
+ runtime.uses_touch_device = FALSE;
+}
+
void InitScoresInfo(void)
{
char *global_scores_dir = getPath2(getCommonDataDir(), SCORES_DIRECTORY);
OpenLogFiles();
-#if defined(TARGET_SDL2)
- int sdl_init_flags = SDL_INIT_EVENTS | SDL_INIT_NOPARACHUTE;
-#else
- int sdl_init_flags = SDL_INIT_EVENTTHREAD | SDL_INIT_NOPARACHUTE;
-#endif
+ int sdl_init_flags = SDL_INIT_EVENTS | SDL_INIT_NOPARACHUTE;
if (SDL_Init(sdl_init_flags) < 0)
Error(ERR_EXIT, "SDL_Init() failed: %s", SDL_GetError());
{
ReCreateBitmap(&gfx.background_bitmap, win_xsize, win_ysize);
-#if defined(TARGET_SDL2)
ReCreateBitmap(&gfx.final_screen_bitmap, win_xsize, win_ysize);
-#endif
ReCreateBitmap(&gfx.fade_bitmap_backup, win_xsize, win_ysize);
ReCreateBitmap(&gfx.fade_bitmap_source, win_xsize, win_ysize);
void InitGfxOtherSettings(void)
{
gfx.cursor_mode = CURSOR_DEFAULT;
+ gfx.cursor_mode_override = CURSOR_UNDEFINED;
+ gfx.cursor_mode_final = gfx.cursor_mode;
+
+ // prevent initially displaying custom mouse cursor in upper left corner
+ gfx.mouse_x = POS_OFFSCREEN;
+ gfx.mouse_y = POS_OFFSCREEN;
}
void InitTileCursorInfo(void)
SetOverlayEnabled(TRUE);
}
+boolean GetOverlayEnabled(void)
+{
+ return overlay.enabled;
+}
+
boolean GetOverlayActive(void)
{
return overlay.active;
return;
SDLInitVideoDisplay();
-#if defined(TARGET_SDL2)
SDLSetDisplaySize();
-#endif
}
void CloseVideoDisplay(void)
video.window_scaling_available = WINDOW_SCALING_STATUS;
+ video.frame_counter = 0;
video.frame_delay = 0;
video.frame_delay_value = GAME_FRAME_DELAY;
src_x += dst_x - dst_x_unclipped;
src_y += dst_y - dst_y_unclipped;
-#if defined(TARGET_SDL2)
// !!! 2013-12-11: An "old friend" is back. Same bug in SDL2 2.0.1 !!!
// !!! 2009-03-30: Fixed by using self-compiled, patched SDL.dll !!!
/* (This bug still exists in the actual (as of 2009-06-15) version 1.2.13,
if (src_bitmap == dst_bitmap)
{
- /* needed when blitting directly to same bitmap -- should not be needed with
- recent SDL libraries, but apparently does not work in 1.2.11 directly */
+ // needed when blitting directly to same bitmap -- should not be needed with
+ // recent SDL libraries, but apparently does not work in 1.2.11 directly
static Bitmap *tmp_bitmap = NULL;
static int tmp_bitmap_xsize = 0;
return;
}
-#endif
sysCopyArea(src_bitmap, dst_bitmap,
src_x, src_y, width, height, dst_x, dst_y, BLIT_OPAQUE);
void KeyboardAutoRepeatOn(void)
{
-#if defined(TARGET_SDL2)
keyrepeat_status = TRUE;
-#else
- SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY / 2,
- SDL_DEFAULT_REPEAT_INTERVAL / 2);
- SDL_EnableUNICODE(1);
-#endif
}
void KeyboardAutoRepeatOff(void)
{
-#if defined(TARGET_SDL2)
keyrepeat_status = FALSE;
-#else
- SDL_EnableKeyRepeat(0, SDL_DEFAULT_REPEAT_INTERVAL);
- SDL_EnableUNICODE(0);
-#endif
}
boolean SetVideoMode(boolean fullscreen)
if (strEqual(filename, bitmap->source_filename))
{
- /* The old and new image are the same (have the same filename and path).
- This usually means that this image does not exist in this graphic set
- and a fallback to the existing image is done. */
+ // The old and new image are the same (have the same filename and path).
+ // This usually means that this image does not exist in this graphic set
+ // and a fallback to the existing image is done.
return;
}
};
static const char **cursor_image_playfield = cursor_image_dot;
#else
-/* some people complained about a "white dot" on the screen and thought it
- was a graphical error... OK, let's just remove the whole pointer :-) */
+// some people complained about a "white dot" on the screen and thought it
+// was a graphical error... OK, let's just remove the whole pointer :-)
static const char **cursor_image_playfield = cursor_image_none;
#endif
static struct MouseCursorInfo *cursor_none = NULL;
static struct MouseCursorInfo *cursor_playfield = NULL;
struct MouseCursorInfo *cursor_new;
+ int mode_final = mode;
if (cursor_none == NULL)
cursor_none = get_cursor_from_image(cursor_image_none);
if (cursor_playfield == NULL)
cursor_playfield = get_cursor_from_image(cursor_image_playfield);
- cursor_new = (mode == CURSOR_DEFAULT ? NULL :
- mode == CURSOR_NONE ? cursor_none :
- mode == CURSOR_PLAYFIELD ? cursor_playfield : NULL);
+ if (gfx.cursor_mode_override != CURSOR_UNDEFINED)
+ mode_final = gfx.cursor_mode_override;
+
+ cursor_new = (mode_final == CURSOR_DEFAULT ? NULL :
+ mode_final == CURSOR_NONE ? cursor_none :
+ mode_final == CURSOR_PLAYFIELD ? cursor_playfield : NULL);
SDLSetMouseCursor(cursor_new);
gfx.cursor_mode = 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);
}
// event functions
// ============================================================================
+void InitEventFilter(EventFilter filter_function)
+{
+ SDL_SetEventFilter(filter_function, NULL);
+}
+
boolean PendingEvent(void)
{
return (SDL_PollEvent(NULL) ? TRUE : FALSE);
void PeekEvent(Event *event)
{
-#if defined(TARGET_SDL2)
SDL_PeepEvents(event, 1, SDL_PEEKEVENT, SDL_FIRSTEVENT, SDL_LASTEVENT);
-#else
- SDL_PeepEvents(event, 1, SDL_PEEKEVENT, SDL_ALLEVENTS);
-#endif
+}
+
+void PumpEvents(void)
+{
+ SDL_PumpEvents();
}
void CheckQuitEvent(void)
Key GetEventKey(KeyEvent *event, boolean with_modifiers)
{
-#if defined(TARGET_SDL2)
// key up/down events in SDL2 do not return text characters anymore
return event->keysym.sym;
-#else
-
-#if ENABLE_UNUSED_CODE
- printf("unicode == '%d', sym == '%d', mod == '0x%04x'\n",
- (int)event->keysym.unicode,
- (int)event->keysym.sym,
- (int)SDL_GetModState());
-#endif
-
- if (with_modifiers &&
- event->keysym.unicode > 0x0000 &&
- event->keysym.unicode < 0x2000)
- return event->keysym.unicode;
- else
- return event->keysym.sym;
-
-#endif
}
KeyMod HandleKeyModState(Key key, int key_status)
void StartTextInput(int x, int y, int width, int height)
{
-#if defined(TARGET_SDL2)
#if defined(HAS_SCREEN_KEYBOARD)
SDL_StartTextInput();
video.shifted_up = TRUE;
}
#endif
-#endif
}
void StopTextInput(void)
{
-#if defined(TARGET_SDL2)
#if defined(HAS_SCREEN_KEYBOARD)
SDL_StopTextInput();
video.shifted_up = FALSE;
}
#endif
-#endif
}
-boolean CheckCloseWindowEvent(ClientMessageEvent *event)
+void PushUserEvent(int code, int value1, int value2)
{
- if (event->type != EVENT_CLIENTMESSAGE)
- return FALSE;
+ UserEvent event;
+
+ SDL_memset(&event, 0, sizeof(event));
+
+ event.type = EVENT_USER;
+ event.code = code;
+ event.value1 = value1;
+ event.value2 = value2;
- return TRUE; // the only possible message here is SDL_QUIT
+ SDL_PushEvent((SDL_Event *)&event);
}