Skip to content

Commit c327745

Browse files
authored
Merge branch 'libretro:master' into master
2 parents 9bd3d1b + 68c5d3c commit c327745

38 files changed

+2438
-371
lines changed

Makefile.common

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,10 @@ OBJ += \
302302
$(LIBRETRO_COMM_DIR)/streams/network_stream.o \
303303
$(LIBRETRO_COMM_DIR)/vfs/vfs_implementation.o
304304

305+
ifeq ($(ANDROID), 1)
306+
OBJ += $(LIBRETRO_COMM_DIR)/vfs/vfs_implementation_saf.o
307+
endif
308+
305309
OBJ += \
306310
$(LIBRETRO_COMM_DIR)/lists/string_list.o \
307311
$(LIBRETRO_COMM_DIR)/string/stdstring.o \

cores/libretro-net-retropad/net_retropad_core.c

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@
6161
#define NETRETROPAD_SCREEN_KEYBOARD 1
6262
#define NETRETROPAD_SCREEN_SENSORS 2
6363
#define EVENT_RATE 60
64+
#define POINTER_IDLE_MAX EVENT_RATE*2
6465
#define NETRETROPAD_MOUSE 3
6566
#define NETRETROPAD_POINTER 4
6667
#define NETRETROPAD_LIGHTGUN 5
@@ -101,6 +102,7 @@ static int pointer_y = 0;
101102
static unsigned pointer_prev_x = 0;
102103
static unsigned pointer_prev_y = 0;
103104
static unsigned pointer_prev_color = 0;
105+
static unsigned pointer_idle = 0;
104106

105107
static int s;
106108
static int port;
@@ -536,7 +538,6 @@ void NETRETROPAD_CORE_PREFIX(retro_init)(void)
536538

537539
NETRETROPAD_CORE_PREFIX(log_cb)(RETRO_LOG_INFO, "Initialising sockets...\n");
538540
network_init();
539-
540541
}
541542

542543
void NETRETROPAD_CORE_PREFIX(retro_deinit)(void)
@@ -833,6 +834,7 @@ static void netretropad_check_variables(void)
833834
|| (current_screen == NETRETROPAD_SCREEN_KEYBOARD && strstr(screen_var.value,"Keyboard"))
834835
|| (current_screen == NETRETROPAD_SCREEN_SENSORS && strstr(screen_var.value,"Sensor"))))
835836
flip_screen();
837+
836838
if (hide_a_var.value && strstr(hide_a_var.value,"True"))
837839
hide_analog_mismatch = true;
838840
else
@@ -1350,8 +1352,6 @@ void NETRETROPAD_CORE_PREFIX(retro_run)(void)
13501352
}
13511353
else if (current_screen == NETRETROPAD_SCREEN_SENSORS)
13521354
{
1353-
unsigned pointer_x_coord = get_pixel_coordinate(pointer_x, 320);
1354-
unsigned pointer_y_coord = get_pixel_coordinate(pointer_y, 240);
13551355

13561356
for (rle = 0; rle < ARRAY_SIZE(sensor_buttons); )
13571357
{
@@ -1381,18 +1381,30 @@ void NETRETROPAD_CORE_PREFIX(retro_run)(void)
13811381

13821382
pixel += 65;
13831383
}
1384+
}
1385+
1386+
if (mouse_type)
1387+
{
1388+
unsigned pointer_x_coord = get_pixel_coordinate(pointer_x, 320);
1389+
unsigned pointer_y_coord = get_pixel_coordinate(pointer_y, 240);
13841390

1385-
if(pointer_x_coord != pointer_prev_x || pointer_y_coord != pointer_prev_y)
1391+
set_pixel(pointer_prev_x, pointer_prev_y, pointer_prev_color);
1392+
1393+
if (pointer_x_coord != pointer_prev_x || pointer_y_coord != pointer_prev_y)
13861394
{
1387-
set_pixel(pointer_prev_x, pointer_prev_y, pointer_prev_color);
1388-
pointer_prev_color = set_pixel(pointer_x_coord, pointer_y_coord, 0xffff);
1395+
pointer_prev_color = set_pixel(pointer_x_coord, pointer_y_coord, 0xbff7);
13891396
pointer_prev_x = pointer_x_coord;
13901397
pointer_prev_y = pointer_y_coord;
1398+
pointer_idle = 0;
1399+
}
1400+
else if (pointer_idle <= POINTER_IDLE_MAX)
1401+
{
1402+
pointer_prev_color = set_pixel(pointer_x_coord, pointer_y_coord, (pointer_idle > POINTER_IDLE_MAX / 2) ? 0xA000 : 0xbff7);
1403+
pointer_idle++;
13911404
}
13921405
}
13931406

13941407
NETRETROPAD_CORE_PREFIX(video_cb)(frame_buf, 320, 240, 640);
1395-
retro_sleep(4);
13961408
}
13971409

13981410
bool NETRETROPAD_CORE_PREFIX(retro_load_game)(const struct retro_game_info *info)

frontend/drivers/platform_unix.c

Lines changed: 200 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,10 @@
5757

5858
#ifdef ANDROID
5959
#include <sys/system_properties.h>
60+
#ifdef HAVE_SAF
61+
#include <vfs/vfs_implementation_saf.h>
62+
#include "../../menu/menu_cbs.h"
63+
#endif
6064
#endif
6165

6266
#if defined(DINGUX)
@@ -608,6 +612,64 @@ static void frontend_android_shutdown(bool unused)
608612
exit(0);
609613
}
610614

615+
#ifdef HAVE_SAF
616+
void android_show_saf_tree_picker(void)
617+
{
618+
JNIEnv *env;
619+
620+
if (!g_android || !g_android->have_saf)
621+
return;
622+
623+
env = jni_thread_getenv();
624+
if (!env)
625+
return;
626+
627+
CALL_VOID_METHOD(env, g_android->activity->clazz, g_android->requestOpenDocumentTree);
628+
}
629+
#endif
630+
631+
/*
632+
* Class: com_retroarch_browser_retroactivity_RetroActivityCommon
633+
* Method: safTreeAdded
634+
* Signature: (Ljava/lang/String;)V
635+
*/
636+
JNIEXPORT void JNICALL Java_com_retroarch_browser_retroactivity_RetroActivityCommon_safTreeAdded
637+
(JNIEnv *env, jobject this_obj, jstring tree_obj)
638+
{
639+
#ifdef HAVE_SAF
640+
const char *tree;
641+
char *serialized_path;
642+
643+
tree = (*env)->GetStringUTFChars(env, tree_obj, NULL);
644+
if ((*env)->ExceptionOccurred(env))
645+
{
646+
(*env)->ExceptionDescribe(env);
647+
(*env)->ExceptionClear(env);
648+
return;
649+
}
650+
651+
if ((serialized_path = retro_vfs_path_join_saf(tree, "")) != NULL)
652+
{
653+
generic_action_ok_displaylist_push(
654+
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_FILE_BROWSER_OPEN_PICKER),
655+
serialized_path,
656+
msg_hash_to_str(MENU_ENUM_LABEL_FAVORITES),
657+
MENU_SETTING_ACTION,
658+
0,
659+
0,
660+
ACTION_OK_DL_CONTENT_LIST);
661+
free(serialized_path);
662+
}
663+
664+
(*env)->ReleaseStringUTFChars(env, tree_obj, tree);
665+
if ((*env)->ExceptionOccurred(env))
666+
{
667+
(*env)->ExceptionDescribe(env);
668+
(*env)->ExceptionClear(env);
669+
}
670+
#endif
671+
}
672+
611673
#elif !defined(DINGUX)
612674
static bool make_proc_acpi_key_val(char **_ptr, char **_key, char **_val)
613675
{
@@ -1973,6 +2035,11 @@ static void android_app_destroy(struct android_app *android_app)
19732035
CALL_VOID_METHOD(env, android_app->activity->clazz,
19742036
android_app->onRetroArchExit);
19752037

2038+
#ifdef HAVE_SAF
2039+
if (android_app->have_saf)
2040+
retro_vfs_deinit_saf();
2041+
#endif
2042+
19762043
if (android_app->inputQueue)
19772044
AInputQueue_detachLooper(android_app->inputQueue);
19782045

@@ -2135,6 +2202,18 @@ static void frontend_unix_init(void *data)
21352202
GET_METHOD_ID(env, android_app->accessibilitySpeak, class,
21362203
"accessibilitySpeak", "(Ljava/lang/String;)V");
21372204

2205+
CALL_BOOLEAN_METHOD(env, android_app->is_play_store_build, android_app->activity->clazz, android_app->isPlayStoreBuild)
2206+
2207+
#ifdef HAVE_SAF
2208+
GET_METHOD_ID(env, android_app->requestOpenDocumentTree, class,
2209+
"requestOpenDocumentTree", "()V");
2210+
2211+
GET_METHOD_ID(env, android_app->getPersistedSafTrees, class,
2212+
"getPersistedSafTrees", "()[Ljava/lang/String;");
2213+
2214+
android_app->have_saf = retro_vfs_init_saf(jni_thread_getenv, android_app->activity->clazz);
2215+
#endif
2216+
21382217
GET_OBJECT_CLASS(env, class, obj);
21392218
GET_METHOD_ID(env, android_app->getStringExtra, class,
21402219
"getStringExtra", "(Ljava/lang/String;)Ljava/lang/String;");
@@ -2184,53 +2263,73 @@ static int frontend_unix_parse_drive_list(void *data, bool load_content)
21842263
CALL_OBJ_METHOD(env, obj, g_android->activity->clazz,
21852264
g_android->getIntent);
21862265

2187-
if (g_android->getVolumeCount)
2266+
if (!g_android->is_play_store_build && g_android->getVolumeCount)
21882267
{
21892268
CALL_INT_METHOD(env, output,
21902269
g_android->activity->clazz, g_android->getVolumeCount);
21912270
volume_count = output;
21922271
}
21932272

2194-
if (!string_is_empty(internal_storage_path))
2273+
if (!g_android->is_play_store_build)
21952274
{
2196-
if (storage_permissions == INTERNAL_STORAGE_WRITABLE)
2275+
if (!string_is_empty(internal_storage_path))
21972276
{
2198-
char user_data_path[PATH_MAX_LENGTH];
2199-
fill_pathname_join_special(user_data_path,
2200-
internal_storage_path, "RetroArch",
2201-
sizeof(user_data_path));
2277+
if (storage_permissions == INTERNAL_STORAGE_WRITABLE)
2278+
{
2279+
char user_data_path[PATH_MAX_LENGTH];
2280+
fill_pathname_join_special(user_data_path,
2281+
internal_storage_path, "RetroArch",
2282+
sizeof(user_data_path));
2283+
2284+
menu_entries_append(list,
2285+
user_data_path,
2286+
msg_hash_to_str(MSG_INTERNAL_STORAGE),
2287+
enum_idx,
2288+
FILE_TYPE_DIRECTORY, 0, 0, NULL);
2289+
}
22022290

22032291
menu_entries_append(list,
2204-
user_data_path,
2292+
internal_storage_path,
22052293
msg_hash_to_str(MSG_INTERNAL_STORAGE),
22062294
enum_idx,
22072295
FILE_TYPE_DIRECTORY, 0, 0, NULL);
22082296
}
2209-
2210-
menu_entries_append(list,
2211-
internal_storage_path,
2212-
msg_hash_to_str(MSG_INTERNAL_STORAGE),
2213-
enum_idx,
2214-
FILE_TYPE_DIRECTORY, 0, 0, NULL);
2297+
else
2298+
menu_entries_append(list,
2299+
"/storage/emulated/0",
2300+
msg_hash_to_str(MSG_REMOVABLE_STORAGE),
2301+
enum_idx,
2302+
FILE_TYPE_DIRECTORY, 0, 0, NULL);
22152303
}
2216-
else
2304+
2305+
if (!g_android->is_play_store_build)
22172306
menu_entries_append(list,
2218-
"/storage/emulated/0",
2307+
"/storage",
22192308
msg_hash_to_str(MSG_REMOVABLE_STORAGE),
22202309
enum_idx,
22212310
FILE_TYPE_DIRECTORY, 0, 0, NULL);
2222-
2223-
menu_entries_append(list,
2224-
"/storage",
2225-
msg_hash_to_str(MSG_REMOVABLE_STORAGE),
2226-
enum_idx,
2227-
FILE_TYPE_DIRECTORY, 0, 0, NULL);
22282311
if (!string_is_empty(internal_storage_app_path))
2312+
{
2313+
if (g_android->is_play_store_build)
2314+
{
2315+
char user_data_app_path[PATH_MAX_LENGTH];
2316+
fill_pathname_join_special(user_data_app_path,
2317+
internal_storage_app_path, "RetroArch",
2318+
sizeof(user_data_app_path));
2319+
2320+
menu_entries_append(list,
2321+
user_data_app_path,
2322+
msg_hash_to_str(MSG_EXTERNAL_APPLICATION_DIR),
2323+
enum_idx,
2324+
FILE_TYPE_DIRECTORY, 0, 0, NULL);
2325+
}
2326+
22292327
menu_entries_append(list,
22302328
internal_storage_app_path,
22312329
msg_hash_to_str(MSG_EXTERNAL_APPLICATION_DIR),
22322330
enum_idx,
22332331
FILE_TYPE_DIRECTORY, 0, 0, NULL);
2332+
}
22342333
if (!string_is_empty(app_dir))
22352334
menu_entries_append(list,
22362335
app_dir,
@@ -2266,8 +2365,8 @@ static int frontend_unix_parse_drive_list(void *data, bool load_content)
22662365
enum_idx,
22672366
FILE_TYPE_DIRECTORY, 0, 0, NULL);
22682367
}
2269-
22702368
}
2369+
22712370
#elif defined(WEBOS)
22722371
if (path_is_directory("/media/internal"))
22732372
menu_entries_append(list, "/media/internal",
@@ -2349,10 +2448,84 @@ static int frontend_unix_parse_drive_list(void *data, bool load_content)
23492448
}
23502449
#endif
23512450

2352-
menu_entries_append(list, "/",
2353-
msg_hash_to_str(MENU_ENUM_LABEL_FILE_DETECT_CORE_LIST_PUSH_DIR),
2354-
enum_idx,
2355-
FILE_TYPE_DIRECTORY, 0, 0, NULL);
2451+
#ifdef ANDROID
2452+
if (!g_android->is_play_store_build)
2453+
#else
2454+
if (1)
2455+
#endif
2456+
{
2457+
menu_entries_append(list, "/",
2458+
msg_hash_to_str(MENU_ENUM_LABEL_FILE_DETECT_CORE_LIST_PUSH_DIR),
2459+
enum_idx,
2460+
FILE_TYPE_DIRECTORY, 0, 0, NULL);
2461+
}
2462+
2463+
#if defined(ANDROID) && defined(HAVE_SAF)
2464+
if (g_android->have_saf)
2465+
{
2466+
JNIEnv *env = jni_thread_getenv();
2467+
2468+
if (env != NULL)
2469+
{
2470+
jarray trees = (*env)->CallObjectMethod(env, g_android->activity->clazz, g_android->getPersistedSafTrees);
2471+
if ((*env)->ExceptionOccurred(env))
2472+
{
2473+
(*env)->ExceptionDescribe(env);
2474+
(*env)->ExceptionClear(env);
2475+
}
2476+
else
2477+
{
2478+
jsize trees_length = (*env)->GetArrayLength(env, trees);
2479+
if ((*env)->ExceptionOccurred(env))
2480+
{
2481+
(*env)->ExceptionDescribe(env);
2482+
(*env)->ExceptionClear(env);
2483+
}
2484+
else
2485+
for (jsize i = 0; i < trees_length; ++i)
2486+
{
2487+
const char *tree_chars;
2488+
char *serialized_path;
2489+
jstring tree = (*env)->GetObjectArrayElement(env, trees, i);
2490+
if ((*env)->ExceptionOccurred(env))
2491+
{
2492+
(*env)->ExceptionDescribe(env);
2493+
(*env)->ExceptionClear(env);
2494+
continue;
2495+
}
2496+
tree_chars = (*env)->GetStringUTFChars(env, tree, NULL);
2497+
if ((*env)->ExceptionOccurred(env))
2498+
{
2499+
(*env)->ExceptionDescribe(env);
2500+
(*env)->ExceptionClear(env);
2501+
continue;
2502+
}
2503+
if ((serialized_path = retro_vfs_path_join_saf(tree_chars, "")) != NULL)
2504+
{
2505+
menu_entries_append(list,
2506+
serialized_path,
2507+
msg_hash_to_str(MSG_REMOVABLE_STORAGE),
2508+
enum_idx,
2509+
FILE_TYPE_DIRECTORY, 0, 0, NULL);
2510+
free(serialized_path);
2511+
}
2512+
(*env)->ReleaseStringUTFChars(env, tree, tree_chars);
2513+
if ((*env)->ExceptionOccurred(env))
2514+
{
2515+
(*env)->ExceptionDescribe(env);
2516+
(*env)->ExceptionClear(env);
2517+
}
2518+
}
2519+
}
2520+
}
2521+
2522+
menu_entries_append(list,
2523+
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_FILE_BROWSER_OPEN_PICKER),
2524+
msg_hash_to_str(MENU_ENUM_LABEL_FILE_BROWSER_OPEN_PICKER),
2525+
MENU_ENUM_LABEL_FILE_BROWSER_OPEN_PICKER,
2526+
MENU_SETTING_ACTION, 0, 0, NULL);
2527+
}
2528+
#endif
23562529
#endif
23572530

23582531
return 0;

0 commit comments

Comments
 (0)