Update code for android tv

This commit is contained in:
Benau 2020-07-14 15:22:25 +08:00
parent ffbf5149cd
commit 33fb8d3f5b
3 changed files with 19 additions and 3 deletions

View File

@ -20,7 +20,7 @@
#include "input/gamepad_config.hpp" #include "input/gamepad_config.hpp"
#ifdef ANDROID #ifdef ANDROID
#include "graphics/irr_driver.hpp" #include <SDL_system.h>
#endif #endif
#include "io/xml_node.hpp" #include "io/xml_node.hpp"
#include "utils/log.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 // For android tv we default to dpad if it has direction pad, because it
// cannot rebind control using touchscreen, and dpad direction seems more // cannot rebind control using touchscreen, and dpad direction seems more
// reliable // reliable
if (!irr_driver->getDevice()->supportsTouchDevice() && has_direction) if (SDL_IsAndroidTV() && has_direction)
use_axes_direction = false; use_axes_direction = false;
#endif #endif
if (use_axes_direction) if (use_axes_direction)

View File

@ -160,6 +160,11 @@
# include <signal.h> # include <signal.h>
# include <unistd.h> # include <unistd.h>
#endif #endif
#ifdef ANDROID
#include <SDL_system.h>
#endif
#include <stdexcept> #include <stdexcept>
#include <cstdio> #include <cstdio>
#include <string> #include <string>
@ -2175,7 +2180,13 @@ int main(int argc, char *argv[])
#ifdef MOBILE_STK #ifdef MOBILE_STK
if (UserConfigParams::m_multitouch_controls == MULTITOUCH_CONTROLS_UNDEFINED) 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( InitAndroidDialog* init_android = new InitAndroidDialog(
0.6f, 0.6f); 0.6f, 0.6f);

View File

@ -69,7 +69,12 @@ void override_default_params_for_mobile()
#ifdef ANDROID #ifdef ANDROID
// For usage in StringUtils::getUserAgentString // For usage in StringUtils::getUserAgentString
if (SDL_IsAndroidTV()) 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)"; g_android_main_user_agent = " (AndroidTV)";
}
else if (SDL_IsChromebook()) else if (SDL_IsChromebook())
g_android_main_user_agent = " (Linux)"; g_android_main_user_agent = " (Linux)";
else else