Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
c965f26
force refresh rate
ro8inmorgan Oct 4, 2025
0087031
refreshrate based on game
ro8inmorgan Oct 4, 2025
a92f2fc
build release
ro8inmorgan Oct 4, 2025
f2b7d5d
fix
ro8inmorgan Oct 4, 2025
d0a1495
wrong function call fix
ro8inmorgan Oct 4, 2025
0283119
ok compile this one for now
ro8inmorgan Oct 4, 2025
729289f
nog een build
ro8inmorgan Oct 4, 2025
77ec9a4
ff
ro8inmorgan Oct 4, 2025
b0c5e23
huh nog een keer
ro8inmorgan Oct 4, 2025
36d1623
ff
ro8inmorgan Oct 4, 2025
e38bfe3
dd
ro8inmorgan Oct 4, 2025
14ae3b8
added log
ro8inmorgan Oct 4, 2025
d069b6b
forgot include
ro8inmorgan Oct 4, 2025
ca61887
log added 2
ro8inmorgan Oct 4, 2025
5a15871
log adjust
ro8inmorgan Oct 4, 2025
c921840
ff
ro8inmorgan Oct 4, 2025
813bc0d
ffff
ro8inmorgan Oct 4, 2025
f3c43eb
Ok this is my final version for now
ro8inmorgan Oct 4, 2025
3c7ffaa
try to use config refreshrate
ro8inmorgan Oct 5, 2025
ebb7270
idk why this stayed from branch switch
ro8inmorgan Oct 5, 2025
f430378
another build
ro8inmorgan Oct 5, 2025
86a5c0d
trying to fix crash
ro8inmorgan Oct 5, 2025
097e0df
no content fps
ro8inmorgan Oct 5, 2025
66f7c2c
set from config
ro8inmorgan Oct 5, 2025
a15cd81
test
ro8inmorgan Oct 5, 2025
3f3c191
test 2
ro8inmorgan Oct 5, 2025
dca313f
added include
ro8inmorgan Oct 5, 2025
adcb533
test3
ro8inmorgan Oct 5, 2025
6ecedbc
test5
ro8inmorgan Oct 5, 2025
062b55d
don't call ra_notify_refresh_rate() test
ro8inmorgan Oct 5, 2025
93a63f6
different point of setting ra_notify_refresh_rate()
ro8inmorgan Oct 5, 2025
d5a4324
different point of setting ra_notify_refresh_rate()
ro8inmorgan Oct 5, 2025
90df4d7
added a check for ANDROID
ro8inmorgan Oct 5, 2025
a80e8fa
added 90hz option too
ro8inmorgan Oct 5, 2025
74966e8
different spot maybe
ro8inmorgan Oct 5, 2025
46516d3
added ra_notify_refresh_rate() to override load as well
ro8inmorgan Oct 5, 2025
7f1ed1a
added to another override
ro8inmorgan Oct 5, 2025
b51c375
removed unused include
ro8inmorgan Oct 5, 2025
e747bf5
branch cleanup
ro8inmorgan Oct 5, 2025
e5d155f
branch cleanup
ro8inmorgan Oct 5, 2025
a1061cc
branch cleanup
ro8inmorgan Oct 5, 2025
19b6996
branch cleanup
ro8inmorgan Oct 5, 2025
6a9180d
fixed typo
ro8inmorgan Oct 5, 2025
531852d
added match to available display modes
ro8inmorgan Oct 5, 2025
5ddaff4
different approach to last commit
ro8inmorgan Oct 5, 2025
a186867
final branch cleanup
ro8inmorgan Oct 5, 2025
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
28 changes: 27 additions & 1 deletion configuration.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@

#include "list_special.h"

#if defined(ANDROID)
#include "pkg/android/phoenix-common/jni/ra_android_bridge.h"
#endif

#if defined(__WINRT__) || defined(WINAPI_FAMILY) && WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP
#include "uwp/uwp_func.h"
#endif
Expand Down Expand Up @@ -2383,7 +2387,11 @@ static struct config_float_setting *populate_settings_float(
#endif

*size = count;

#if defined(__ANDROID__) || defined(ANDROID)
if (settings && settings->floats.video_refresh_rate > 0.0f) {
ra_notify_refresh_rate(settings->floats.video_refresh_rate);
}
#endif
return tmp;
}

Expand Down Expand Up @@ -2995,6 +3003,7 @@ void config_set_defaults(void *data)
g_defaults.settings_video_refresh_rate != DEFAULT_REFRESH_RATE)
settings->floats.video_refresh_rate = g_defaults.settings_video_refresh_rate;


if (DEFAULT_AUDIO_DEVICE)
configuration_set_string(settings,
settings->arrays.audio_device,
Expand Down Expand Up @@ -4543,6 +4552,12 @@ static bool config_load_file(global_t *global,
if (size_settings)
free(size_settings);
first_load = false;

#if defined(__ANDROID__) || defined(ANDROID)
if (settings && settings->floats.video_refresh_rate > 0.0f) {
ra_notify_refresh_rate(settings->floats.video_refresh_rate);
}
#endif
return true;
}

Expand Down Expand Up @@ -4746,6 +4761,12 @@ bool config_load_override(void *data)
else
runloop_state_get_ptr()->flags &= ~RUNLOOP_FLAG_OVERRIDES_ACTIVE;


#if defined(__ANDROID__) || defined(ANDROID)
if (settings && settings->floats.video_refresh_rate > 0.0f) {
ra_notify_refresh_rate(settings->floats.video_refresh_rate);
}
#endif
return true;
}

Expand Down Expand Up @@ -4788,6 +4809,11 @@ bool config_load_override_file(const char *config_path)
else
runloop_state_get_ptr()->flags &= ~RUNLOOP_FLAG_OVERRIDES_ACTIVE;

#if defined(__ANDROID__) || defined(ANDROID)
if (settings && settings->floats.video_refresh_rate > 0.0f) {
ra_notify_refresh_rate(settings->floats.video_refresh_rate);
}
#endif
return true;
}

Expand Down
22 changes: 16 additions & 6 deletions pkg/android/phoenix-common/jni/Android.mk
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)

RARCH_DIR := ../../../..
RA_ROOT := $(LOCAL_PATH)/$(RARCH_DIR)

HAVE_NEON := 1
HAVE_LOGGER := 0
Expand Down Expand Up @@ -57,6 +58,14 @@ LOCAL_MODULE := retroarch-activity
LOCAL_SRC_FILES += $(RARCH_DIR)/griffin/griffin.c \
$(RARCH_DIR)/griffin/griffin_cpp.cpp

LOCAL_SRC_FILES += \
ra_android_bridge.c

LOCAL_C_INCLUDES += \
$(RA_ROOT) \
$(RA_ROOT)/libretro-common/include \
$(RA_ROOT)/gfx/include

ifeq ($(HAVE_LOGGER), 1)
DEFINES += -DHAVE_LOGGER
endif
Expand Down Expand Up @@ -173,13 +182,14 @@ LOCAL_CPPFLAGS := -fexceptions -fpermissive -std=gnu++11 -fno-rtti -Wno-reorder
LOCAL_CFLAGS := $(subst -O3,-O2,$(LOCAL_CFLAGS))

LOCAL_LDLIBS := -landroid -lEGL $(GLES_LIB) $(LOGGER_LDLIBS) -ldl
LOCAL_C_INCLUDES := \
$(LOCAL_PATH)/$(RARCH_DIR)/libretro-common/include \
$(LOCAL_PATH)/$(RARCH_DIR)/deps \
$(LOCAL_PATH)/$(RARCH_DIR)/deps/stb \
$(LOCAL_PATH)/$(RARCH_DIR)/deps/7zip
LOCAL_C_INCLUDES += \
$(RA_ROOT)/libretro-common/include \
$(RA_ROOT)/deps \
$(RA_ROOT)/deps/stb \
$(RA_ROOT)/deps/7zip


INCLUDE_DIRS := \
INCLUDE_DIRS := \
-I$(LOCAL_PATH)/$(DEPS_DIR)/stb/ \
-I$(LOCAL_PATH)/$(DEPS_DIR)/7zip/ \
-I$(LOCAL_PATH)/$(DEPS_DIR)/libFLAC/include
Expand Down
79 changes: 79 additions & 0 deletions pkg/android/phoenix-common/jni/ra_android_bridge.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
#include <jni.h>
#include <libretro.h>
#include "runloop.h"
#include "verbosity.h"
#include "configuration.h"

// ---------- Cached JNI handles ----------
static JavaVM *g_vm = NULL;
static jclass g_cls_RetroActivityFuture = NULL; // GlobalRef
static jmethodID g_mid_nativePushContentFps = NULL; // (F)V

// Small helper: get/attach JNIEnv for the current thread
static JNIEnv* ra_get_env(bool *out_attached)
{
if (out_attached) *out_attached = false;
if (!g_vm) return NULL;

JNIEnv *env = NULL;
jint r = (*g_vm)->GetEnv(g_vm, (void**)&env, JNI_VERSION_1_6);
if (r == JNI_OK && env) return env;

// Not attached -> attach
if ((*g_vm)->AttachCurrentThread(g_vm, &env, NULL) != 0)
return NULL;
if (out_attached) *out_attached = true;
return env;
}

// ---------- JNI load/unload ----------
JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *reserved)
{
g_vm = vm;
JNIEnv *env = NULL;
if ((*vm)->GetEnv(vm, (void**)&env, JNI_VERSION_1_6) != JNI_OK || !env)
return JNI_ERR;

jclass local = (*env)->FindClass(env, "com/retroarch/browser/retroactivity/RetroActivityFuture");
if (!local) return JNI_ERR;

g_cls_RetroActivityFuture = (jclass)(*env)->NewGlobalRef(env, local);
(*env)->DeleteLocalRef(env, local);
if (!g_cls_RetroActivityFuture) return JNI_ERR;

// Cache static push method: public static void nativePushContentFps(float)
g_mid_nativePushContentFps = (*env)->GetStaticMethodID(env, g_cls_RetroActivityFuture,
"nativePushContentFps", "(F)V");
// It's fine if Java side doesn't have it yet; we just won't call it
return JNI_VERSION_1_6;
}

JNIEXPORT void JNICALL JNI_OnUnload(JavaVM *vm, void *reserved)
{
JNIEnv *env = NULL;
if ((*vm)->GetEnv(vm, (void**)&env, JNI_VERSION_1_6) == JNI_OK && env) {
if (g_cls_RetroActivityFuture) {
(*env)->DeleteGlobalRef(env, g_cls_RetroActivityFuture);
g_cls_RetroActivityFuture = NULL;
}
}
g_vm = NULL;
g_mid_nativePushContentFps = NULL;
}

// ---------- Public C API: push fresh FPS to Java (optional) ----------
void ra_notify_refresh_rate(float fps)
{
if (fps <= 0.f) return;
if (!g_vm || !g_cls_RetroActivityFuture || !g_mid_nativePushContentFps) return;

bool attached = false;
JNIEnv *env = ra_get_env(&attached);
if (!env) return;

(*env)->CallStaticVoidMethod(env, g_cls_RetroActivityFuture,
g_mid_nativePushContentFps, (jfloat)fps);

if (attached)
(*g_vm)->DetachCurrentThread(g_vm);
}
13 changes: 13 additions & 0 deletions pkg/android/phoenix-common/jni/ra_android_bridge.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#ifndef RA_ANDROID_BRIDGE_H
#define RA_ANDROID_BRIDGE_H

#ifdef __cplusplus
extern "C" {
#endif

void ra_notify_refresh_rate(float fps);

#ifdef __cplusplus
}
#endif
#endif
Loading
Loading