diff --git a/src/main.cpp b/src/main.cpp index d33e5b5..cc0fd29 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -10,6 +10,10 @@ #include #include +#ifdef GEODE_IS_ANDROID +#include +#endif + #include #include "../include/Keybinds.hpp" @@ -240,8 +244,17 @@ class ControllerChecker : public CCObject { public: void checkController(float) { - //TODO: remove the android thingy once/if zmx figures out how to get the controller state through the launcher - bool controllerConnected = GEODE_ANDROID(true || ) PlatformToolbox::isControllerConnected(); +#ifdef GEODE_IS_ANDROID + bool controllerConnected = true; + JniMethodInfo info; + if (cocos2d::JniHelper::getStaticMethodInfo(info, "com/geode/launcher/utils/GeodeUtils", "getControllerCount", "()I")) { + int controllerCount = info.env->CallStaticIntMethod(info.classID, info.methodID); + controllerConnected = controllerCount > 0; + info.env->DeleteLocalRef(info.classID); + } +#else + bool controllerConnected = PlatformToolbox::isControllerConnected(); +#endif if (m_cached != controllerConnected) { m_cached = controllerConnected; if (m_cached) { @@ -262,10 +275,6 @@ class ControllerChecker : public CCObject { } } } - - ControllerChecker() { - this->retain(); - } }; $execute {