GetKeyModState());
#endif
-#if defined(PLATFORM_ANDROID)
- if (game_status == GAME_MODE_PSEUDO_TYPENAME)
- {
- HandleTypeName(0, key);
-
+#if !defined(HAS_SCREEN_KEYBOARD)
+ // non-mobile devices: only handle key input with modifier keys pressed here
+ // (every other key input is handled directly as physical key input event)
+ if (!checkTextInputKeyModState())
return;
- }
#endif
- // only handle key input with text modifier keys pressed
- if (checkTextInputKeyModState())
- {
- HandleKey(key, KEY_PRESSED);
- HandleKey(key, KEY_RELEASED);
- }
+ // process text input as "classic" (with uppercase etc.) key input event
+ HandleKey(key, KEY_PRESSED);
+ HandleKey(key, KEY_RELEASED);
}
void HandlePauseResumeEvent(PauseResumeEvent *event)
if (gadget_pressed_inside_select_line)
new_gi = NULL;
+
+ StopTextInput();
}
gadget_pressed =
if (gi->textinput.cursor_position != old_cursor_position)
DrawGadget(gi, DG_PRESSED, gi->direct_draw);
+
+ StartTextInput(gi->x, gi->y);
}
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);
}
else if (gi->type & GD_TYPE_SELECTBOX && gi->selectbox.open &&
!keep_selectbox_open)
gi->type & GD_TYPE_SELECTBOX))
return FALSE;
- if (key == KSYM_Return) /* valid for both text input and selectbox */
+ if (key == KSYM_Escape)
+ {
+ StopTextInput();
+ }
+ else if (key == KSYM_Return) /* valid for both text input and selectbox */
{
boolean gadget_changed = ((gi->event_mask & GD_EVENT_TEXT_RETURN) != 0);
strcpy(gi->textinput.last_value, gi->textinput.value);
else
gadget_changed = FALSE;
+
+ StopTextInput();
}
else if (gi->type & GD_TYPE_SELECTBOX)
{
SDL_UpdateTexture(sdl_texture, NULL, screen->pixels, screen->pitch);
}
+ 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 (video.screen_rendering_mode == SPECIAL_RENDERING_TARGET ||
+ video.screen_rendering_mode == SPECIAL_RENDERING_DOUBLE)
+ {
+ src_rect2 = &src_rect_up;
+ dst_rect2 = &dst_rect_up;
+ }
+ else
+ {
+ src_rect1 = &src_rect_up;
+ dst_rect1 = &dst_rect_up;
+ }
+ }
+#endif
+
// clear render target buffer
SDL_RenderClear(sdl_renderer);
// copy backbuffer texture to render target buffer
if (video.screen_rendering_mode != SPECIAL_RENDERING_TARGET)
- SDL_RenderCopy(sdl_renderer, sdl_texture_stream, NULL, NULL);
+ SDL_RenderCopy(sdl_renderer, sdl_texture_stream, src_rect1, dst_rect1);
if (video.screen_rendering_mode != SPECIAL_RENDERING_BITMAP)
FinalizeScreen(DRAW_TO_SCREEN);
video.screen_rendering_mode == SPECIAL_RENDERING_DOUBLE)
{
SDL_SetRenderTarget(sdl_renderer, NULL);
- SDL_RenderCopy(sdl_renderer, sdl_texture_target, NULL, NULL);
+ SDL_RenderCopy(sdl_renderer, sdl_texture_target, src_rect2, dst_rect2);
}
#endif
video.frame_delay = 0;
video.frame_delay_value = GAME_FRAME_DELAY;
+ video.shifted_up = FALSE;
+
SDLInitVideoBuffer(fullscreen);
video.initialized = TRUE;
return HandleKeyModState(KSYM_UNDEFINED, 0);
}
+void StartTextInput(int x, int y)
+{
+#if defined(TARGET_SDL2)
+ SDL_StartTextInput();
+
+#if defined(HAS_SCREEN_KEYBOARD)
+ if (y > video.height / 2)
+ video.shifted_up = TRUE;
+#endif
+#endif
+}
+
+void StopTextInput()
+{
+#if defined(TARGET_SDL2)
+ SDL_StopTextInput();
+
+#if defined(HAS_SCREEN_KEYBOARD)
+ video.shifted_up = FALSE;
+#endif
+#endif
+}
+
boolean CheckCloseWindowEvent(ClientMessageEvent *event)
{
if (event->type != EVENT_CLIENTMESSAGE)
#define TOUCH_DROP_DISTANCE_DEFAULT 5
+/* values for screen keyboard on mobile devices */
+#if defined(PLATFORM_ANDROID)
+#define HAS_SCREEN_KEYBOARD
+#endif
+
+
/* default input keys */
#define DEFAULT_KEY_LEFT KSYM_Left
#define DEFAULT_KEY_RIGHT KSYM_Right
unsigned int frame_delay;
unsigned int frame_delay_value;
+ boolean shifted_up;
+
boolean initialized;
};
KeyMod HandleKeyModState(Key, int);
KeyMod GetKeyModState();
KeyMod GetKeyModStateFromEvents();
+void StartTextInput(int, int);
+void StopTextInput();
boolean CheckCloseWindowEvent(ClientMessageEvent *);
void InitJoysticks();
xpos = newxpos;
-#if defined(TARGET_SDL2)
- SDL_StartTextInput();
-#endif
+ StartTextInput(startx, starty);
}
else if (is_valid_key_char && xpos < MAX_PLAYER_NAME_LEN)
{
DrawText(startx, starty, setup.player_name, font_nr);
-#if defined(TARGET_SDL2)
- SDL_StopTextInput();
-#endif
+ StopTextInput();
}
}