Sfoglia il codice sorgente

Add love.keyboard.isScreenKeyboardVisible.

Sasha Szpakowski 4 mesi fa
parent
commit
5067179715

+ 2 - 0
src/modules/keyboard/Keyboard.h

@@ -587,6 +587,8 @@ public:
 	 **/
 	 **/
 	virtual bool hasScreenKeyboard() const = 0;
 	virtual bool hasScreenKeyboard() const = 0;
 
 
+	virtual bool isScreenKeyboardVisible() const = 0;
+
 	static bool getConstant(const char *in, Key &out);
 	static bool getConstant(const char *in, Key &out);
 	static bool getConstant(Key in, const char *&out);
 	static bool getConstant(Key in, const char *&out);
 
 

+ 8 - 0
src/modules/keyboard/sdl/Keyboard.cpp

@@ -177,6 +177,14 @@ bool Keyboard::hasScreenKeyboard() const
 	return SDL_HasScreenKeyboardSupport();
 	return SDL_HasScreenKeyboardSupport();
 }
 }
 
 
+bool Keyboard::isScreenKeyboardVisible() const
+{
+	SDL_Window *window = getSDLWindow();
+	if (window == nullptr)
+		return false;
+	return SDL_ScreenKeyboardShown(window);
+}
+
 bool Keyboard::getConstant(Key in, SDL_Keycode &out)
 bool Keyboard::getConstant(Key in, SDL_Keycode &out)
 {
 {
 	if (in & KEY_SCANCODE_MASK)
 	if (in & KEY_SCANCODE_MASK)

+ 1 - 0
src/modules/keyboard/sdl/Keyboard.h

@@ -56,6 +56,7 @@ public:
 	void setTextInput(bool enable, double x, double y, double w, double h);
 	void setTextInput(bool enable, double x, double y, double w, double h);
 	bool hasTextInput() const;
 	bool hasTextInput() const;
 	bool hasScreenKeyboard() const;
 	bool hasScreenKeyboard() const;
+	bool isScreenKeyboardVisible() const;
 
 
 	static bool getConstant(Key in, SDL_Keycode &out);
 	static bool getConstant(Key in, SDL_Keycode &out);
 	static bool getConstant(SDL_Keycode in, Key &out);
 	static bool getConstant(SDL_Keycode in, Key &out);

+ 7 - 0
src/modules/keyboard/wrap_Keyboard.cpp

@@ -187,6 +187,12 @@ int w_hasScreenKeyboard(lua_State *L)
 	return 1;
 	return 1;
 }
 }
 
 
+int w_isScreenKeyboardVisible(lua_State *L)
+{
+	luax_pushboolean(L, instance()->isScreenKeyboardVisible());
+	return 1;
+}
+
 int w_isModifierActive(lua_State* L)
 int w_isModifierActive(lua_State* L)
 {
 {
 	const char *keystr = luaL_checkstring(L, 1);
 	const char *keystr = luaL_checkstring(L, 1);
@@ -206,6 +212,7 @@ static const luaL_Reg functions[] =
 	{ "setTextInput", w_setTextInput },
 	{ "setTextInput", w_setTextInput },
 	{ "hasTextInput", w_hasTextInput },
 	{ "hasTextInput", w_hasTextInput },
 	{ "hasScreenKeyboard", w_hasScreenKeyboard },
 	{ "hasScreenKeyboard", w_hasScreenKeyboard },
+	{ "isScreenKeyboardVisible", w_isScreenKeyboardVisible },
 	{ "isDown", w_isDown },
 	{ "isDown", w_isDown },
 	{ "isScancodeDown", w_isScancodeDown },
 	{ "isScancodeDown", w_isScancodeDown },
 	{ "getScancodeFromKey", w_getScancodeFromKey },
 	{ "getScancodeFromKey", w_getScancodeFromKey },