fix: changed android defines

This commit is contained in:
2021-11-04 17:42:31 +01:00
parent a3712febca
commit 95e9c270db
9 changed files with 46 additions and 11 deletions

View File

@@ -22,7 +22,7 @@
#include <SDL2/SDL_render.h>
#ifdef ANDROID
#ifdef __ANDROID__
#include <sstream>
#include <android/log.h>
#endif
@@ -49,7 +49,7 @@ void windowResizeEvent(int width, int height) {
bool create() {
window = SDL_CreateWindow(WINDOW_NAME, SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, WINDOW_WIDTH, WINDOW_HEIGHT, SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE);
// Prepare and create context
#ifdef ANDROID
#ifdef __ANDROID__
SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_ES);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 0);
@@ -151,6 +151,19 @@ void pollEvents() {
}
ImGui_ImplSDL2_ProcessEvent(&event);
}
// activating screen keyboard for Android devices
#ifdef __ANDROID__
static bool keyboardShown = false;
if(ImGui::GetIO().WantTextInput != keyboardShown){
if(ImGui::GetIO().WantTextInput){
SDL_StartTextInput();
}else{
SDL_StopTextInput();
}
keyboardShown = ImGui::GetIO().WantTextInput;
}
#endif
}
bool isCloseRequested() {