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

View File

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