event->x, event->y);
#endif
+#if defined(HAS_SCREEN_KEYBOARD)
+ if (video.shifted_up)
+ event->y += video.shifted_up_pos;
+#endif
+
motion_status = FALSE;
if (event->type == EVENT_BUTTONPRESS)
if (gi->textinput.cursor_position != old_cursor_position)
DrawGadget(gi, DG_PRESSED, gi->direct_draw);
- StartTextInput(gi->x, gi->y);
+ if (press_event)
+ StartTextInput(gi->x, gi->y, gi->width, gi->height);
}
else if (gi->type & GD_TYPE_TEXT_AREA && button != 0 && !motion_status)
{
if (gi->textarea.cursor_position != old_cursor_position)
DrawGadget(gi, DG_PRESSED, gi->direct_draw);
- StartTextInput(gi->x, gi->y);
+ if (press_event)
+ StartTextInput(gi->x, gi->y, gi->width, gi->height);
}
else if (gi->type & GD_TYPE_SELECTBOX && gi->selectbox.open &&
!keep_selectbox_open)
SDL_Rect *src_rect1 = NULL, *dst_rect1 = NULL;
SDL_Rect *src_rect2 = NULL, *dst_rect2 = NULL;
-#if defined(HAS_SCREEN_KEYBOARD)
- SDL_Rect src_rect_up = { 0, video.height / 2, video.width, video.height / 2 };
- SDL_Rect dst_rect_up = { 0, 0, video.width, video.height / 2 };
- if (video.shifted_up)
+#if defined(HAS_SCREEN_KEYBOARD)
+ if (video.shifted_up || video.shifted_up_delay)
{
+ int time_current = SDL_GetTicks();
+ int pos = video.shifted_up_pos;
+ int pos_last = video.shifted_up_pos_last;
+
+ if (!DelayReachedExt(&video.shifted_up_delay, video.shifted_up_delay_value,
+ time_current))
+ {
+ int delay = time_current - video.shifted_up_delay;
+ int delay_value = video.shifted_up_delay_value;
+
+ pos = pos_last + (pos - pos_last) * delay / delay_value;
+ }
+ else
+ {
+ video.shifted_up_pos_last = pos;
+ video.shifted_up_delay = 0;
+ }
+
+ SDL_Rect src_rect_up = { 0, pos, video.width, video.height - pos };
+ SDL_Rect dst_rect_up = { 0, 0, video.width, video.height - pos };
+
if (video.screen_rendering_mode == SPECIAL_RENDERING_TARGET ||
video.screen_rendering_mode == SPECIAL_RENDERING_DOUBLE)
{
video.frame_delay_value = GAME_FRAME_DELAY;
video.shifted_up = FALSE;
+ video.shifted_up_pos = 0;
+ video.shifted_up_pos_last = 0;
+ video.shifted_up_delay = 0;
+ video.shifted_up_delay_value = ONE_SECOND_DELAY / 4;
SDLInitVideoBuffer(fullscreen);
return HandleKeyModState(KSYM_UNDEFINED, 0);
}
-void StartTextInput(int x, int y)
+void StartTextInput(int x, int y, int width, int height)
{
#if defined(TARGET_SDL2)
SDL_StartTextInput();
#if defined(HAS_SCREEN_KEYBOARD)
- if (y > video.height / 2)
+ if (y + height > SCREEN_KEYBOARD_POS(video.height))
+ {
+ video.shifted_up_pos = y + height - SCREEN_KEYBOARD_POS(video.height);
+ video.shifted_up_delay = SDL_GetTicks();
video.shifted_up = TRUE;
+ }
#endif
#endif
}
SDL_StopTextInput();
#if defined(HAS_SCREEN_KEYBOARD)
- video.shifted_up = FALSE;
+ if (video.shifted_up)
+ {
+ video.shifted_up_pos = 0;
+ video.shifted_up_delay = SDL_GetTicks();
+ video.shifted_up = FALSE;
+ }
#endif
#endif
}
/* values for screen keyboard on mobile devices */
#if defined(PLATFORM_ANDROID)
#define HAS_SCREEN_KEYBOARD
+#define SCREEN_KEYBOARD_POS(h) ((h) / 2)
#endif
unsigned int frame_delay_value;
boolean shifted_up;
+ int shifted_up_pos;
+ int shifted_up_pos_last;
+ unsigned int shifted_up_delay;
+ unsigned int shifted_up_delay_value;
boolean initialized;
};
KeyMod HandleKeyModState(Key, int);
KeyMod GetKeyModState();
KeyMod GetKeyModStateFromEvents();
-void StartTextInput(int, int);
+void StartTextInput(int, int, int, int);
void StopTextInput();
boolean CheckCloseWindowEvent(ClientMessageEvent *);
xpos = newxpos;
- StartTextInput(startx, starty);
+ StartTextInput(startx, starty, pos->width, pos->height);
}
else if (is_valid_key_char && xpos < MAX_PLAYER_NAME_LEN)
{