From 33fb8d3f5b116c7af3fa867668ea5b4f406a8999 Mon Sep 17 00:00:00 2001 From: Benau Date: Tue, 14 Jul 2020 15:22:25 +0800 Subject: [PATCH] Update code for android tv --- src/input/gamepad_config.cpp | 4 ++-- src/main.cpp | 13 ++++++++++++- src/main_android.cpp | 5 +++++ 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/src/input/gamepad_config.cpp b/src/input/gamepad_config.cpp index 0ca4c5a63..0452ed189 100644 --- a/src/input/gamepad_config.cpp +++ b/src/input/gamepad_config.cpp @@ -20,7 +20,7 @@ #include "input/gamepad_config.hpp" #ifdef ANDROID -#include "graphics/irr_driver.hpp" +#include #endif #include "io/xml_node.hpp" #include "utils/log.hpp" @@ -490,7 +490,7 @@ void GamepadConfig::initSDLMapping() // For android tv we default to dpad if it has direction pad, because it // cannot rebind control using touchscreen, and dpad direction seems more // reliable - if (!irr_driver->getDevice()->supportsTouchDevice() && has_direction) + if (SDL_IsAndroidTV() && has_direction) use_axes_direction = false; #endif if (use_axes_direction) diff --git a/src/main.cpp b/src/main.cpp index 27d72759a..c941db368 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -160,6 +160,11 @@ # include # include #endif + +#ifdef ANDROID +#include +#endif + #include #include #include @@ -2175,7 +2180,13 @@ int main(int argc, char *argv[]) #ifdef MOBILE_STK if (UserConfigParams::m_multitouch_controls == MULTITOUCH_CONTROLS_UNDEFINED) { - if (irr_driver->getDevice()->supportsTouchDevice()) + bool android_tv = false; +#ifdef ANDROID + // For some android tv sdl returns a touch screen device even it + // doesn't have + android_tv = SDL_IsAndroidTV(); +#endif + if (!android_tv && irr_driver->getDevice()->supportsTouchDevice()) { InitAndroidDialog* init_android = new InitAndroidDialog( 0.6f, 0.6f); diff --git a/src/main_android.cpp b/src/main_android.cpp index 06cfabd13..bea875f66 100644 --- a/src/main_android.cpp +++ b/src/main_android.cpp @@ -69,7 +69,12 @@ void override_default_params_for_mobile() #ifdef ANDROID // For usage in StringUtils::getUserAgentString if (SDL_IsAndroidTV()) + { + // For some android tv sdl returns a touch screen device even it doesn't + // have + UserConfigParams::m_multitouch_draw_gui = false; g_android_main_user_agent = " (AndroidTV)"; + } else if (SDL_IsChromebook()) g_android_main_user_agent = " (Linux)"; else