From 06c69d3cc8c536119fe13638ed2dafd20dda16ed Mon Sep 17 00:00:00 2001 From: TheBrokenRail Date: Fri, 3 Nov 2023 17:10:05 -0400 Subject: [PATCH] AppPlatform Fixes --- platforms/android/AppPlatform_android.cpp | 17 ++-- platforms/android/AppPlatform_android.hpp | 6 +- .../project/app/src/main/cpp/CMakeLists.txt | 80 ++++++----------- .../.idea/deploymentTargetDropDown.xml | 17 ++++ .../io/github/reminecraftpe/MainActivity.java | 35 +++++++- .../org/libsdl/app/LimitedSDLActivity.java | 17 ++++ platforms/sdl/base/AppPlatform_sdl_base.cpp | 90 +++++++++++-------- platforms/sdl/base/AppPlatform_sdl_base.hpp | 1 + platforms/sdl/main.cpp | 4 - source/client/app/AppPlatform.cpp | 10 +-- source/client/app/AppPlatform.hpp | 6 +- source/client/gui/Screen.cpp | 10 ++- source/client/gui/components/TextInputBox.cpp | 27 +++--- source/client/gui/components/TextInputBox.hpp | 5 +- source/client/gui/screens/ChatScreen.cpp | 2 +- source/client/options/Options.cpp | 2 +- source/client/player/input/Controller.cpp | 6 +- .../player/input/ControllerTurnInput.cpp | 2 +- 18 files changed, 202 insertions(+), 135 deletions(-) create mode 100644 platforms/sdl/android/.idea/deploymentTargetDropDown.xml create mode 100644 platforms/sdl/android/app/src/main/java/org/libsdl/app/LimitedSDLActivity.java diff --git a/platforms/android/AppPlatform_android.cpp b/platforms/android/AppPlatform_android.cpp index b059ded..afe2dfc 100644 --- a/platforms/android/AppPlatform_android.cpp +++ b/platforms/android/AppPlatform_android.cpp @@ -283,7 +283,17 @@ void AppPlatform_android::setShiftPressed(bool b) m_bShiftPressed = b; } -void AppPlatform_android::showKeyboard(bool bShown) +void AppPlatform_android::showKeyboard(int x, int y, int w, int h) +{ + changeKeyboardVisibility(true); +} + +void AppPlatform_android::hideKeyboard() +{ + changeKeyboardVisibility(false); +} + +void AppPlatform_android::changeKeyboardVisibility(bool bShown) { JavaVM* pVM = m_app->activity->vm; JNIEnv* pEnv = m_app->activity->env; @@ -340,11 +350,6 @@ void AppPlatform_android::showKeyboard(bool bShown) pVM->DetachCurrentThread(); } -void AppPlatform_android::onHideKeyboard() -{ - m_bIsKeyboardShown = false; -} - int AppPlatform_android::getKeyboardUpOffset() { // @TODO diff --git a/platforms/android/AppPlatform_android.hpp b/platforms/android/AppPlatform_android.hpp index 29e32de..ea166be 100644 --- a/platforms/android/AppPlatform_android.hpp +++ b/platforms/android/AppPlatform_android.hpp @@ -46,8 +46,8 @@ public: // Also add these to allow proper text input within the game. bool shiftPressed() override; void setShiftPressed(bool b); - void showKeyboard(bool bShown) override; - void onHideKeyboard() override; // This is an event + void showKeyboard(int x, int y, int w, int h) override; + void hideKeyboard() override; int getKeyboardUpOffset() override; // Also add these to allow saving options. @@ -63,6 +63,8 @@ public: void setExternalStoragePath(const std::string& path); private: + void changeKeyboardVisibility(bool bShown); + int m_ScreenWidth; int m_ScreenHeight; diff --git a/platforms/android/project/app/src/main/cpp/CMakeLists.txt b/platforms/android/project/app/src/main/cpp/CMakeLists.txt index b49bbfe..c395947 100644 --- a/platforms/android/project/app/src/main/cpp/CMakeLists.txt +++ b/platforms/android/project/app/src/main/cpp/CMakeLists.txt @@ -1,59 +1,35 @@ - -# For more information about using CMake with Android Studio, read the -# documentation: https://d.android.com/studio/projects/add-native-code.html - -# Sets the minimum version of CMake required to build the native library. - cmake_minimum_required(VERSION 3.16.0) +project(reminecraftpe-android) -# Declares and names the project. +# Project Root +set(MC_ROOT ../../../../../../..) -project("reminecraftpe") +# Build +add_compile_definitions(USE_NATIVE_ANDROID) +add_library(reminecraftpe SHARED + "${MC_ROOT}/platforms/android/android_native_app_glue.c" + "${MC_ROOT}/platforms/android/AppPlatform_android.cpp" + "${MC_ROOT}/platforms/android/main.cpp" + "${MC_ROOT}/thirdparty/stb_image_impl.c" +) -# The root of the project -SET(MC_ROOT ../../../../../../..) - -# Creates and names a library, sets it as either STATIC -# or SHARED, and provides the relative paths to its source code. -# You can define multiple libraries, and CMake builds them for you. -# Gradle automatically packages shared libraries with your APK. - -add_library( # Sets the name of the library. - reminecraftpe - - # Sets the library as a shared library. - SHARED - - # Provides a relative path to your source file(s). - ${MC_ROOT}/platforms/android/android_native_app_glue.c - ${MC_ROOT}/platforms/android/AppPlatform_android.cpp - ${MC_ROOT}/platforms/android/main.cpp - ${MC_ROOT}/thirdparty/stb_image_impl.c) - -# Check for the presence of some optional asset based features. -if(NOT EXISTS "${MC_ROOT}/game/assets/gui/background/panorama_0.png") - target_compile_definitions(reminecraftpe PUBLIC FEATURE_MENU_BACKGROUND) -endif() - -if(NOT EXISTS "${MC_ROOT}/game/assets/environment/clouds.png") - target_compile_definitions(reminecraftpe PUBLIC FEATURE_CLOUDS) -endif() - -if(NOT EXISTS "${MC_ROOT}/game/assets/misc/grasscolor.png") - target_compile_definitions(reminecraftpe PUBLIC FEATURE_GRASS_COLOR) -endif() - -if(NOT EXISTS "${MC_ROOT}/game/assets/misc/foliagecolor.png") - target_compile_definitions(reminecraftpe PUBLIC FEATURE_FOLIAGE_COLOR) -endif() - -# Add the core as part of the library. -add_subdirectory(${MC_ROOT}/source source) +# Core +add_subdirectory("${MC_ROOT}/source" source) target_link_libraries(reminecraftpe reminecraftpe-core) -# Specifies libraries CMake should link to your target library. You -# can link multiple libraries, such as libraries you define in this -# build script, prebuilt third-party libraries, or system libraries. +# Extra Dependencies +target_link_libraries(reminecraftpe android) -target_link_libraries( # Specifies the target library. - reminecraftpe android ) +# Check for the presence of some optional asset based features. +if(EXISTS "${MC_ROOT}/game/assets/gui/background/panorama_0.png") + target_compile_definitions(reminecraftpe PUBLIC FEATURE_MENU_BACKGROUND) +endif() +if(EXISTS "${MC_ROOT}/game/assets/environment/clouds.png") + target_compile_definitions(reminecraftpe PUBLIC FEATURE_CLOUDS) +endif() +if(EXISTS "${MC_ROOT}/game/assets/misc/grasscolor.png") + target_compile_definitions(reminecraftpe PUBLIC FEATURE_GRASS_COLOR) +endif() +if(EXISTS "${MC_ROOT}/game/assets/misc/foliagecolor.png") + target_compile_definitions(reminecraftpe PUBLIC FEATURE_FOLIAGE_COLOR) +endif() diff --git a/platforms/sdl/android/.idea/deploymentTargetDropDown.xml b/platforms/sdl/android/.idea/deploymentTargetDropDown.xml new file mode 100644 index 0000000..62b2520 --- /dev/null +++ b/platforms/sdl/android/.idea/deploymentTargetDropDown.xml @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/platforms/sdl/android/app/src/main/java/io/github/reminecraftpe/MainActivity.java b/platforms/sdl/android/app/src/main/java/io/github/reminecraftpe/MainActivity.java index 074f0ab..718451c 100644 --- a/platforms/sdl/android/app/src/main/java/io/github/reminecraftpe/MainActivity.java +++ b/platforms/sdl/android/app/src/main/java/io/github/reminecraftpe/MainActivity.java @@ -2,11 +2,14 @@ package io.github.reminecraftpe; import android.os.Build; import android.os.Bundle; +import android.view.View; +import android.view.WindowInsets; +import android.view.WindowInsetsController; import android.view.WindowManager; -import org.libsdl.app.SDLActivity; +import org.libsdl.app.LimitedSDLActivity; -public class MainActivity extends SDLActivity { +public class MainActivity extends LimitedSDLActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -16,4 +19,32 @@ public class MainActivity extends SDLActivity { getWindow().getAttributes().layoutInDisplayCutoutMode = WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES; } } + + @Override + @SuppressWarnings("deprecation") + public void onWindowFocusChanged(boolean hasFocus) { + super.onWindowFocusChanged(hasFocus); + + // Fullscreen + if (hasFocus) { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) { + getWindow().setDecorFitsSystemWindows(false); + WindowInsetsController controller = getWindow().getInsetsController(); + if (controller != null) { + controller.hide(WindowInsets.Type.systemBars()); + controller.setSystemBarsBehavior(WindowInsetsController.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE); + } + } else { + getWindow().getDecorView().setSystemUiVisibility( + View.SYSTEM_UI_FLAG_LAYOUT_STABLE | + View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION | + View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | + View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | + View.SYSTEM_UI_FLAG_FULLSCREEN | + View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY | + View.INVISIBLE + ); + } + } + } } diff --git a/platforms/sdl/android/app/src/main/java/org/libsdl/app/LimitedSDLActivity.java b/platforms/sdl/android/app/src/main/java/org/libsdl/app/LimitedSDLActivity.java new file mode 100644 index 0000000..8f216dd --- /dev/null +++ b/platforms/sdl/android/app/src/main/java/org/libsdl/app/LimitedSDLActivity.java @@ -0,0 +1,17 @@ +package org.libsdl.app; + +// Prevent SDL From Controlling Immersive Mode +public class LimitedSDLActivity extends SDLActivity { + @Override + boolean sendCommand(int command, Object data) { + if (command == COMMAND_CHANGE_WINDOW_STYLE) { + return true; + } else { + return super.sendCommand(command, data); + } + } + + @Override + public void onSystemUiVisibilityChange(int visibility) { + } +} diff --git a/platforms/sdl/base/AppPlatform_sdl_base.cpp b/platforms/sdl/base/AppPlatform_sdl_base.cpp index 29b7f05..cce4c13 100644 --- a/platforms/sdl/base/AppPlatform_sdl_base.cpp +++ b/platforms/sdl/base/AppPlatform_sdl_base.cpp @@ -71,6 +71,24 @@ void AppPlatform_sdl_base::initSoundSystem() } } +std::string AppPlatform_sdl_base::getDateString(int time) +{ + time_t tt = time; + struct tm t; +#ifdef _WIN32 + gmtime_s(&t, &tt); +#else + gmtime_r(&tt, &t); +#endif + + // Format String + char buf[2048]; + strftime(buf, sizeof buf, "%b %d %Y %H:%M:%S", &t); + + // Return + return std::string(buf); +} + void AppPlatform_sdl_base::setIcon(const Texture& icon) { if (!icon.m_pixels) @@ -185,14 +203,14 @@ MouseButtonType AppPlatform_sdl_base::GetMouseButtonType(SDL_Event event) { switch (event.button.button) { - case SDL_BUTTON_LEFT: - return BUTTON_LEFT; - case SDL_BUTTON_RIGHT: - return BUTTON_RIGHT; - case SDL_BUTTON_MIDDLE: - return BUTTON_MIDDLE; - default: - return BUTTON_NONE; + case SDL_BUTTON_LEFT: + return BUTTON_LEFT; + case SDL_BUTTON_RIGHT: + return BUTTON_RIGHT; + case SDL_BUTTON_MIDDLE: + return BUTTON_MIDDLE; + default: + return BUTTON_NONE; } } @@ -202,30 +220,30 @@ bool AppPlatform_sdl_base::GetMouseButtonState(SDL_Event event) switch (event.type) { - case SDL_MOUSEBUTTONDOWN: - result = true; - break; - case SDL_MOUSEBUTTONUP: - result = false; - break; - case SDL_MOUSEWHEEL: - { - short wheelDelta = event.wheel.y; - if (wheelDelta > 0) - { - // "A positive value indicates that the wheel was rotated forward, away from the user." - result = false; - } - else - { - // "A negative value indicates that the wheel was rotated backward, toward the user." + case SDL_MOUSEBUTTONDOWN: result = true; + break; + case SDL_MOUSEBUTTONUP: + result = false; + break; + case SDL_MOUSEWHEEL: + { + short wheelDelta = event.wheel.y; + if (wheelDelta > 0) + { + // "A positive value indicates that the wheel was rotated forward, away from the user." + result = false; + } + else + { + // "A negative value indicates that the wheel was rotated backward, toward the user." + result = true; + } + break; } - break; - } - default: - result = false; - break; + default: + result = false; + break; } return result; @@ -235,11 +253,11 @@ Keyboard::KeyState AppPlatform_sdl_base::GetKeyState(SDL_Event event) { switch (event.key.state) { - case SDL_RELEASED: - return Keyboard::UP; - case SDL_PRESSED: - default: - return Keyboard::DOWN; + case SDL_RELEASED: + return Keyboard::UP; + case SDL_PRESSED: + default: + return Keyboard::DOWN; } } @@ -247,7 +265,7 @@ void AppPlatform_sdl_base::showKeyboard(int x, int y, int w, int h) { if (SDL_IsTextInputActive()) { - SDL_StopTextInput(); + hideKeyboard(); } SDL_Rect rect; rect.x = x; diff --git a/platforms/sdl/base/AppPlatform_sdl_base.hpp b/platforms/sdl/base/AppPlatform_sdl_base.hpp index a3cbb58..4d045dc 100644 --- a/platforms/sdl/base/AppPlatform_sdl_base.hpp +++ b/platforms/sdl/base/AppPlatform_sdl_base.hpp @@ -28,6 +28,7 @@ public: Texture loadTexture(const std::string& path, bool b = false) override = 0; int getUserInputStatus() override; SoundSystem* const getSoundSystem() const override { return m_pSoundSystem; } + std::string getDateString(int time) override; // Also add these to allow proper turning within the game. void setMouseGrabbed(bool b) override; diff --git a/platforms/sdl/main.cpp b/platforms/sdl/main.cpp index cc17094..1a982d4 100644 --- a/platforms/sdl/main.cpp +++ b/platforms/sdl/main.cpp @@ -342,10 +342,6 @@ int main(int argc, char *argv[]) // Create Window int flags = SDL_WINDOW_OPENGL | SDL_WINDOW_SHOWN | SDL_WINDOW_RESIZABLE | SDL_WINDOW_ALLOW_HIGHDPI; -#ifdef ANDROID - // Android Immersive Mode - flags |= SDL_WINDOW_FULLSCREEN; -#endif window = SDL_CreateWindow("ReMinecraftPE", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, Minecraft::width, Minecraft::height, flags); if (!window) { diff --git a/source/client/app/AppPlatform.cpp b/source/client/app/AppPlatform.cpp index 0033a84..f0b5f2a 100644 --- a/source/client/app/AppPlatform.cpp +++ b/source/client/app/AppPlatform.cpp @@ -140,18 +140,12 @@ bool AppPlatform::shiftPressed() return false; } -void AppPlatform::showKeyboard(bool bShown) -{ -} - -void AppPlatform::onHideKeyboard() -{ -} - +#ifdef USE_NATIVE_ANDROID int AppPlatform::getKeyboardUpOffset() { return 0; } +#endif bool AppPlatform::hasFileSystemAccess() { diff --git a/source/client/app/AppPlatform.hpp b/source/client/app/AppPlatform.hpp index f903432..ba29cb0 100644 --- a/source/client/app/AppPlatform.hpp +++ b/source/client/app/AppPlatform.hpp @@ -59,9 +59,6 @@ public: virtual void updateFocused(bool focused); // Also add this to allow proper text input within the game. virtual bool shiftPressed(); - virtual void showKeyboard(bool bShown); - virtual void onHideKeyboard(); // called by the runner, not the game - virtual int getKeyboardUpOffset(); virtual bool hasFileSystemAccess(); // Also add this to allow dynamic patching. @@ -71,6 +68,9 @@ public: // On-screen keyboard virtual void showKeyboard(int x, int y, int w, int h); virtual void hideKeyboard(); +#ifdef USE_NATIVE_ANDROID + virtual int getKeyboardUpOffset(); +#endif #endif public: diff --git a/source/client/gui/Screen.cpp b/source/client/gui/Screen.cpp index 5d32f1f..8b73b44 100644 --- a/source/client/gui/Screen.cpp +++ b/source/client/gui/Screen.cpp @@ -263,11 +263,12 @@ void Screen::mouseClicked(int xPos, int yPos, int d) // d = clicked? TextInputBox* textInput = m_textInputs[i]; if (textInput->m_bFocused == handleFocused) { - textInput->onClick(m_pMinecraft, xPos, yPos); + textInput->onClick(xPos, yPos); } } } +#ifdef USE_NATIVE_ANDROID // if the keyboard is shown: if (m_pMinecraft->platform()->getKeyboardUpOffset()) { @@ -284,9 +285,10 @@ void Screen::mouseClicked(int xPos, int yPos, int d) // d = clicked? } if (!areAnyFocused) - m_pMinecraft->platform()->showKeyboard(false); + m_pMinecraft->platform()->hideKeyboard(); } #endif +#endif } void Screen::mouseReleased(int xPos, int yPos, int d) @@ -361,6 +363,7 @@ void Screen::onRender(int mouseX, int mouseY, float f) int Screen::getYOffset() { +#ifdef USE_NATIVE_ANDROID int keybOffset = m_pMinecraft->platform()->getKeyboardUpOffset(); if (!keybOffset) return 0; @@ -395,6 +398,9 @@ int Screen::getYOffset() } return offset; +#else + return 0; +#endif } void Screen::updateEvents() diff --git a/source/client/gui/components/TextInputBox.cpp b/source/client/gui/components/TextInputBox.cpp index 13832f7..e226fdd 100644 --- a/source/client/gui/components/TextInputBox.cpp +++ b/source/client/gui/components/TextInputBox.cpp @@ -10,7 +10,7 @@ #include "client/app/Minecraft.hpp" #ifndef ORIGINAL_CODE -#if defined(ANDROID) && !defined(USE_SDL) +#ifdef USE_NATIVE_ANDROID #define HANDLE_CHARS_SEPARATELY // faked though, see platforms/android/minecraftcpp/minecraftcpp.NativeActivity/main.cpp #endif @@ -32,6 +32,11 @@ TextInputBox::TextInputBox(Screen* parent, int id, int x, int y, int width, int m_pParent = parent; } +TextInputBox::~TextInputBox() +{ + m_pParent->m_pMinecraft->platform()->hideKeyboard(); +} + void TextInputBox::init(Font* pFont) { m_pFont = pFont; @@ -179,22 +184,22 @@ void TextInputBox::tick() } } -void TextInputBox::setFocused(Minecraft* minecraft, bool b) +void TextInputBox::setFocused(bool b) { if (m_bFocused == b) return; if (b) { - int x = m_xPos / Gui::InvGuiScale; - int y = m_yPos / Gui::InvGuiScale; - int w = m_width / Gui::InvGuiScale; - int h = m_height / Gui::InvGuiScale; - minecraft->platform()->showKeyboard(x, y, w, h); + int x = (int) (((float) m_xPos) / Gui::InvGuiScale); + int y = (int) (((float) m_yPos) / Gui::InvGuiScale); + int w = (int) (((float) m_width) / Gui::InvGuiScale); + int h = (int) (((float) m_height) / Gui::InvGuiScale); + m_pParent->m_pMinecraft->platform()->showKeyboard(x, y, w, h); } else { - minecraft->platform()->hideKeyboard(); + m_pParent->m_pMinecraft->platform()->hideKeyboard(); } m_bFocused = b; @@ -203,17 +208,15 @@ void TextInputBox::setFocused(Minecraft* minecraft, bool b) m_lastFlashed = getTimeMs(); m_bCursorOn = true; m_insertHead = int(m_text.size()); - - m_pParent->m_pMinecraft->platform()->showKeyboard(true); } // don't actually hide the keyboard when unfocusing // - we may be undoing the work of another text box } -void TextInputBox::onClick(Minecraft* minecraft, int x, int y) +void TextInputBox::onClick(int x, int y) { - setFocused(minecraft, clicked(x, y)); + setFocused(clicked(x, y)); } void TextInputBox::charPressed(int k) diff --git a/source/client/gui/components/TextInputBox.hpp b/source/client/gui/components/TextInputBox.hpp index e1cc09d..3ded7c7 100644 --- a/source/client/gui/components/TextInputBox.hpp +++ b/source/client/gui/components/TextInputBox.hpp @@ -23,6 +23,7 @@ class TextInputBox : public GuiComponent { public: TextInputBox(Screen*, int id, int x, int y, int width = 200, int height = 12, const std::string& placeholder = "", const std::string& text = ""); + ~TextInputBox(); void init(Font* pFont); void setEnabled(bool bEnabled); @@ -30,8 +31,8 @@ public: void charPressed(int chr); void render(); void tick(); - void setFocused(Minecraft*, bool b); - void onClick(Minecraft*, int x, int y); + void setFocused(bool b); + void onClick(int x, int y); bool clicked(int x, int y); public: diff --git a/source/client/gui/screens/ChatScreen.cpp b/source/client/gui/screens/ChatScreen.cpp index 14976f3..9363df8 100644 --- a/source/client/gui/screens/ChatScreen.cpp +++ b/source/client/gui/screens/ChatScreen.cpp @@ -35,7 +35,7 @@ void ChatScreen::init() // set focus directly on the chat text box m_textChat.init(m_pFont); - m_textChat.setFocused(m_pMinecraft, true); + m_textChat.setFocused(true); m_buttons.push_back(&m_btnSend); m_textInputs.push_back(&m_textChat); diff --git a/source/client/options/Options.cpp b/source/client/options/Options.cpp index 26db9dd..9e0a66c 100644 --- a/source/client/options/Options.cpp +++ b/source/client/options/Options.cpp @@ -149,7 +149,7 @@ void Options::_initDefaultValues() KM(KM_FLY_DOWN, SDLVK_x); KM(KM_CHAT_CMD, SDLVK_SLASH); #endif -#if defined(ANDROID) && !defined(USE_SDL) +#ifdef USE_NATIVE_ANDROID // -- Original xperia play controls //KM(KM_FORWARD, AKEYCODE_DPAD_UP); //KM(KM_LEFT, AKEYCODE_DPAD_LEFT); diff --git a/source/client/player/input/Controller.cpp b/source/client/player/input/Controller.cpp index 5c7e096..6d695b4 100644 --- a/source/client/player/input/Controller.cpp +++ b/source/client/player/input/Controller.cpp @@ -13,7 +13,7 @@ bool Controller::isTouchedValues[2]; float Controller::stickValuesX[2]; float Controller::stickValuesY[2]; -#if !defined(ANDROID) || defined(USE_SDL) +#ifndef USE_NATIVE_ANDROID const float Controller_unk_1[3] = { 0.0f, 0.64f, -0.64f }; #endif @@ -52,7 +52,7 @@ void Controller::feed(int stickNo, int touched, float x, float y) if (!isValidStick(stickNo)) return; -#if defined(ANDROID) && !defined(USE_SDL) +#ifdef USE_NATIVE_ANDROID int index = stickNo - 1; #else int index = (x >= 0.0f) ? 1 : 0; @@ -61,7 +61,7 @@ void Controller::feed(int stickNo, int touched, float x, float y) // maybe the 2 'touch sticks' are actually internally 1 single surface?? isTouchedValues[index] = touched != 0; -#if defined(ANDROID) && !defined(USE_SDL) +#ifdef USE_NATIVE_ANDROID stickValuesX[index] = x; #else stickValuesX[index] = linearTransform(x + Controller_unk_1[index + 1], 0.0f, 2.78f, true); diff --git a/source/client/player/input/ControllerTurnInput.cpp b/source/client/player/input/ControllerTurnInput.cpp index 7e291e0..8e0ea8b 100644 --- a/source/client/player/input/ControllerTurnInput.cpp +++ b/source/client/player/input/ControllerTurnInput.cpp @@ -22,7 +22,7 @@ ControllerTurnInput::ControllerTurnInput() TurnDelta ControllerTurnInput::getTurnDelta() { -#if defined(ANDROID) && !defined(USE_SDL) +#ifdef USE_NATIVE_ANDROID return TurnDelta(Controller::getX(m_stickNo) * 50.f, Controller::getY(m_stickNo) * 60.f); #endif