Add more support about keyboard.

Now class Window has default constructor.
This commit is contained in:
Kirigaya Kazuto 2017-05-22 18:47:28 +08:00
parent 08a858acf0
commit 14c31689be
2 changed files with 39 additions and 10 deletions

View File

@ -1243,6 +1243,11 @@ namespace MiniEngine
return SDL_ShowSimpleMessageBox(flags,Title.c_str(),Message.c_str(),_get());
}
bool Window::isScreenKeyboardShown()
{
return SDL_IsScreenKeyboardShown(_get())==SDL_TRUE;
}
void Font::_set(TTF_Font* p)
{
_font.reset(p,TTF_CloseFont);
@ -1728,11 +1733,22 @@ namespace MiniEngine
SDL_StartTextInput();
}
bool SDLSystem::IsTextInputActive()
{
return SDL_IsTextInputActive()==SDL_TRUE;
}
void SDLSystem::StopTextInput()
{
SDL_StopTextInput();
}
//static
bool SDLSystem::HasScreenKeyboardSupport()
{
return SDL_HasScreenKeyboardSupport()==SDL_TRUE;
}
/// Global Executor For class Timer
Uint32 _global_timer_executor(Uint32 interval,void* param)
{
@ -2099,6 +2115,11 @@ namespace MiniEngine
return SDL_HasClipboardText()==SDL_TRUE;
}
bool GetScanKeyState(SDL_Scancode code)
{
return SDL_GetKeyboardState(NULL)[code];
}
}/// End of namespace MiniEngine
/// The Following Functions are not avaliable in Visual Studio

View File

@ -273,6 +273,7 @@ namespace MiniEngine
class Window
{
public:
Window()=default;
Window(std::string Title, int Width, int Height,
std::initializer_list<RendererType> RendererFlags = { RendererType::Accelerated,RendererType::TargetTexture },
std::initializer_list<WindowType> WindowFlags = {WindowType::Shown} ,
@ -281,15 +282,15 @@ namespace MiniEngine
void setRenderer(RendererType Type)
{
_internal_rndflagcalc=0;
_setRenderer(Type);
int flagcalc=0;
_setRenderer(flagcalc,Type);
}
template<typename... Args>
void setRenderer(RendererType Type,Args&&... args)
{
_internal_rndflagcalc=0;
_setRenderer(Type,std::forward<RendererType>(args...));
int flagcalc=0;
_setRenderer(flagcalc,Type,std::forward<RendererType>(args...));
}
void setRenderer(std::initializer_list<RendererType>);
@ -324,23 +325,24 @@ namespace MiniEngine
_DECL_DEPRECATED Surface getSurface();
bool isScreenKeyboardShown();
void release();
protected:
template<typename... Args>
void _setRenderer(RendererType Type,Args&&... args)
void _setRenderer(int& refcalc,RendererType Type,Args&&... args)
{
_internal_rndflagcalc|=_render_caster(Type);
refcalc|=_render_caster(Type);
_setRenderer(args...);
}
void _setRenderer(RendererType Type)
void _setRenderer(int& refcalc,RendererType Type)
{
_internal_rndflagcalc|=_render_caster(Type);
_setRenderer_Real(_internal_rndflagcalc);
refcalc|=_render_caster(Type);
_setRenderer_Real(refcalc);
}
private:
void _setRenderer_Real(Uint32 flags);
Uint32 _internal_rndflagcalc;
Uint32 _render_caster(RendererType);
std::shared_ptr<SDL_Window> _wnd;
@ -489,8 +491,11 @@ namespace MiniEngine
static Platform GetPlatform();
static void StartTextInput();
static bool IsTextInputActive();
static void StopTextInput();
bool HasScreenKeyboardSupport();
class Android
{
public:
@ -654,6 +659,9 @@ namespace MiniEngine
std::string GetClipboardText();
bool HasClipboardText();
/// Experimental - For Experts: Use SDL ScanCode
bool GetScanKeyState(SDL_Scancode);
}/// End of namespace MiniEngine
std::string UTF8ToGBK(std::string UTF8String);