struct ProgramInfo program;
struct NetworkInfo network;
+struct RuntimeInfo runtime;
struct OptionInfo options;
struct VideoSystemInfo video;
struct AudioSystemInfo audio;
boolean motion_status = FALSE;
int wheel_steps = DEFAULT_WHEEL_STEPS;
boolean keyrepeat_status = TRUE;
+boolean textinput_status = FALSE;
int redraw_mask = REDRAW_NONE;
network.server_port = server_port;
}
+void InitRuntimeInfo()
+{
+#if defined(HAS_TOUCH_DEVICE)
+ runtime.uses_touch_device = TRUE;
+#else
+ runtime.uses_touch_device = FALSE;
+#endif
+}
+
void InitScoresInfo(void)
{
char *global_scores_dir = getPath2(getCommonDataDir(), SCORES_DIRECTORY);
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;
video.window_scaling_available = WINDOW_SCALING_STATUS;
+ video.frame_counter = 0;
video.frame_delay = 0;
video.frame_delay_value = GAME_FRAME_DELAY;
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);
SDL_PeepEvents(event, 1, SDL_PEEKEVENT, SDL_FIRSTEVENT, SDL_LASTEVENT);
}
+void PumpEvents(void)
+{
+ SDL_PumpEvents();
+}
+
void CheckQuitEvent(void)
{
if (SDL_QuitRequested())
{
KeyMod new_modifier = KMOD_None;
- switch(key)
+ switch (key)
{
case KSYM_Shift_L:
new_modifier = KMOD_Shift_L;
void StartTextInput(int x, int y, int width, int height)
{
+ textinput_status = TRUE;
+
#if defined(HAS_SCREEN_KEYBOARD)
SDL_StartTextInput();
void StopTextInput(void)
{
+ textinput_status = FALSE;
+
#if defined(HAS_SCREEN_KEYBOARD)
SDL_StopTextInput();
#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);
}