Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 15 additions & 6 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
#include <Geode/cocos/robtop/keyboard_dispatcher/CCKeyboardDelegate.h>
#include <Geode/cocos/robtop/keyboard_dispatcher/CCKeyboardDispatcher.h>

#ifdef GEODE_IS_ANDROID
#include <Geode/cocos/platform/android/jni/JniHelper.h>
#endif

#include <unordered_set>

#include "../include/Keybinds.hpp"
Expand Down Expand Up @@ -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;
Copy link

Copilot AI Jun 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After calling CallStaticIntMethod, consider releasing the JNI local reference (e.g., info.classID) if needed to avoid potential local reference leaks.

Copilot uses AI. Check for mistakes.

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) {
Expand All @@ -262,10 +275,6 @@ class ControllerChecker : public CCObject {
}
}
}

ControllerChecker() {
this->retain();
}
};

$execute {
Expand Down