Update SDL2 with screen keyboard height functions for iOS

This commit is contained in:
Benau 2020-06-16 12:07:13 +08:00
parent 945565790c
commit 2171bd7bf3
4 changed files with 29 additions and 7 deletions

View File

@ -1108,12 +1108,12 @@ bool CIrrDeviceSDL::hasOnScreenKeyboard() const
}
bool CIrrDeviceSDL::hasHardwareKeyboard() const
u32 CIrrDeviceSDL::getOnScreenKeyboardHeight() const
{
#ifdef MOBILE_STK
return SDL_HasHardwareKeyboardConnected() == SDL_TRUE;
return SDL_GetScreenKeyboardHeight() * NativeScale;
#else
return true;
return 0;
#endif
}

View File

@ -137,8 +137,7 @@ namespace irr
virtual bool hasOnScreenKeyboard() const;
virtual bool hasHardwareKeyboard() const;
virtual u32 getOnScreenKeyboardHeight() const;
virtual bool activateAccelerometer(float updateInterval);
virtual bool deactivateAccelerometer();

View File

@ -780,6 +780,7 @@ void IrrDriver::initDevice()
m_device->registerGetMovedHeightFunction([]
(const IrrlichtDevice* device)->int
{
#ifdef ANDROID
int screen_keyboard_height =
device->getOnScreenKeyboardHeight();
int screen_height = device->getScreenHeight();
@ -803,6 +804,9 @@ void IrrDriver::initDevice()
return screen_keyboard_height;
}
return screen_keyboard_height - element_height;
#else
return 0;
#endif
});
} // initDevice

View File

@ -27,6 +27,11 @@
#include <atomic>
#include <memory>
// Can be removed later when android STK uses SDL2
#ifdef IOS_STK
#include "SDL_keyboard.h"
#endif
using namespace GUIEngine;
namespace MessageQueue
@ -212,9 +217,16 @@ public:
int pos_transform = 0;
if (m_container == g_container.get())
pos_transform = s_msg_raise;
int moved_height = 0;
#ifdef ANDROID
moved_height = irr_driver->getDevice()->getMovedHeight();
#elif defined(IOS_STK)
moved_height = SDL_GetMovedHeightByScreenKeyboard() *
irr_driver->getDevice()->getNativeScale();
#endif
core::position2di raise = core::position2di(0,
irr_driver->getDevice()->getOnScreenKeyboardHeight() -
irr_driver->getDevice()->getMovedHeight() + pos_transform);
moved_height + pos_transform);
GUIEngine::getSkin()->drawMessage(m_container, m_area - raise,
m_render_type);
GUIEngine::getFont()->draw(m_gls, m_text_rect - raise,
@ -317,9 +329,16 @@ public:
{
Message::draw(dt);
m_display_timer = 9999999.9f;
int moved_height = 0;
#ifdef ANDROID
moved_height = irr_driver->getDevice()->getMovedHeight();
#elif defined(IOS_STK)
moved_height = SDL_GetMovedHeightByScreenKeyboard() *
irr_driver->getDevice()->getNativeScale();
#endif
core::position2di raise = core::position2di(0,
irr_driver->getDevice()->getOnScreenKeyboardHeight() -
irr_driver->getDevice()->getMovedHeight());
moved_height);
GUIEngine::getSkin()->drawProgressBarInScreen(&m_swc, m_area - raise,
(float)g_progress.load() / 100.0f);
video::SColor color(255, 0, 0, 0);