Skip to content

Commit

Permalink
Merge branch 'libretro:master' into avoidMultipleDetectFromSingle12wa…
Browse files Browse the repository at this point in the history
…yRotate
  • Loading branch information
zorro2055 authored Mar 28, 2024
2 parents 8d25800 + ed33eb7 commit b71c652
Show file tree
Hide file tree
Showing 13 changed files with 430 additions and 8 deletions.
4 changes: 3 additions & 1 deletion command.h
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,9 @@ enum event_command
CMD_EVENT_MICROPHONE_REINIT,
#endif
/* Deprecated */
CMD_EVENT_SEND_DEBUG_INFO
CMD_EVENT_SEND_DEBUG_INFO,
/* Add a playlist entry to another playlist. */
CMD_EVENT_ADD_TO_PLAYLIST
};

enum cmd_source_t
Expand Down
11 changes: 8 additions & 3 deletions input/drivers_joypad/mfi_joypad.m
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@
#ifndef MAX_MFI_CONTROLLERS
#define MAX_MFI_CONTROLLERS 4
#endif
#ifndef MAX_MFI_AXES
#define MAX_MFI_AXES 6
#endif

#if TARGET_OS_IOS
#include "../../configuration.h"
Expand All @@ -48,7 +51,7 @@

/* TODO/FIXME - static globals */
static uint32_t mfi_buttons[MAX_USERS];
static int16_t mfi_axes[MAX_USERS][4];
static int16_t mfi_axes[MAX_USERS][MAX_MFI_AXES];
static uint32_t mfi_controllers[MAX_MFI_CONTROLLERS];
static MFIRumbleController *mfi_rumblers[MAX_MFI_CONTROLLERS];
static NSMutableArray *mfiControllers;
Expand Down Expand Up @@ -143,6 +146,8 @@ static void apple_gamecontroller_joypad_poll_internal(GCController *controller,
mfi_axes[slot][1] = gp.leftThumbstick.yAxis.value * 32767.0f;
mfi_axes[slot][2] = gp.rightThumbstick.xAxis.value * 32767.0f;
mfi_axes[slot][3] = gp.rightThumbstick.yAxis.value * 32767.0f;
mfi_axes[slot][4] = gp.leftTrigger.value * 32767.0f;
mfi_axes[slot][5] = gp.rightTrigger.value * 32767.0f;

}
else if (controller.microGamepad)
Expand Down Expand Up @@ -633,14 +638,14 @@ static void apple_gamecontroller_joypad_get_buttons(unsigned port,
static int16_t apple_gamecontroller_joypad_axis(
unsigned port, uint32_t joyaxis)
{
if (AXIS_NEG_GET(joyaxis) < 4)
if (AXIS_NEG_GET(joyaxis) < MAX_MFI_AXES)
{
int16_t axis = AXIS_NEG_GET(joyaxis);
int16_t val = mfi_axes[port][axis];
if (val < 0)
return val;
}
else if (AXIS_POS_GET(joyaxis) < 4)
else if (AXIS_POS_GET(joyaxis) < MAX_MFI_AXES)
{
int16_t axis = AXIS_POS_GET(joyaxis);
int16_t val = mfi_axes[port][axis];
Expand Down
6 changes: 3 additions & 3 deletions input/input_autodetect_builtin.c
Original file line number Diff line number Diff line change
Expand Up @@ -716,8 +716,6 @@ DECL_BTN(l, 10) \
DECL_BTN(r, 11) \
DECL_BTN(start, 3) \
DECL_BTN(select, 2) \
DECL_BTN(l2, 12) \
DECL_BTN(r2, 13) \
DECL_BTN(l3, 14) \
DECL_BTN(r3, 15) \
DECL_AXIS(l_x_plus, +0) \
Expand All @@ -727,7 +725,9 @@ DECL_AXIS(l_y_minus, +1) \
DECL_AXIS(r_x_plus, +2) \
DECL_AXIS(r_x_minus, -2) \
DECL_AXIS(r_y_plus, -3) \
DECL_AXIS(r_y_minus, +3)
DECL_AXIS(r_y_minus, +3) \
DECL_AXIS(l2, +4) \
DECL_AXIS(r2, +5)

const char* const input_builtin_autoconfs[] =
{
Expand Down
22 changes: 22 additions & 0 deletions intl/msg_hash_lbl.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,28 @@ MSG_HASH(
"switch_cpu_profile"
)
#endif

MSG_HASH(
MENU_ENUM_LABEL_ADD_TO_PLAYLIST,
"playlist_add"
)
MSG_HASH(
MENU_ENUM_LABEL_DEFERRED_ADD_TO_PLAYLIST_LIST,
"deferred_add_to_playlist_list"
)
MSG_HASH(
MENU_ENUM_LABEL_ADD_ENTRY_TO_PLAYLIST,
"add_entry_to_playlist"
)
MSG_HASH(
MSG_ADDED_TO_PLAYLIST,
"Added to playlist"
)
MSG_HASH(
MSG_ADD_TO_PLAYLIST_FAILED,
"Failed to add to playlist: playlist full"
)

MSG_HASH(
MENU_ENUM_LABEL_ACCOUNTS_CHEEVOS_USERNAME,
"accounts_cheevos_username"
Expand Down
18 changes: 18 additions & 0 deletions intl/msg_hash_us.h
Original file line number Diff line number Diff line change
Expand Up @@ -6658,6 +6658,24 @@ MSG_HASH(
MENU_ENUM_SUBLABEL_QUICK_MENU_SHOW_ADD_TO_FAVORITES,
"Show the 'Add to Favorites' option."
)

MSG_HASH(
MENU_ENUM_LABEL_VALUE_ADD_TO_PLAYLIST,
"Add to Playlist"
)
MSG_HASH(
MENU_ENUM_SUBLABEL_ADD_TO_PLAYLIST,
"Add the content to a playlist."
)
MSG_HASH(
MENU_ENUM_LABEL_VALUE_CREATE_NEW_PLAYLIST,
"Create New Playlist"
)
MSG_HASH(
MENU_ENUM_SUBLABEL_CREATE_NEW_PLAYLIST,
"Create a new playlist and add the current entry to it."
)

MSG_HASH(
MENU_ENUM_LABEL_VALUE_QUICK_MENU_SHOW_SET_CORE_ASSOCIATION,
"Show 'Set Core Association'"
Expand Down
5 changes: 5 additions & 0 deletions menu/cbs/menu_cbs_deferred_push.c
Original file line number Diff line number Diff line change
Expand Up @@ -672,6 +672,7 @@ GENERIC_DEFERRED_PUSH_GENERAL(deferred_push_dropdown_box_list_input_select_physi
#ifdef HAVE_NETWORKING
GENERIC_DEFERRED_PUSH_GENERAL(deferred_push_dropdown_box_list_netplay_mitm_server, PUSH_DEFAULT, DISPLAYLIST_DROPDOWN_LIST_NETPLAY_MITM_SERVER)
#endif
GENERIC_DEFERRED_PUSH(deferred_push_add_to_playlist_list, DISPLAYLIST_ADD_TO_PLAYLIST_LIST)

static int menu_cbs_init_bind_deferred_push_compare_label(
menu_file_list_cbs_t *cbs,
Expand Down Expand Up @@ -933,6 +934,7 @@ static int menu_cbs_init_bind_deferred_push_compare_label(
#ifdef HAVE_NETWORKING
{MENU_ENUM_LABEL_DEFERRED_LAKKA_LIST, deferred_push_lakka_list},
#endif
{MENU_ENUM_LABEL_DEFERRED_ADD_TO_PLAYLIST_LIST, deferred_push_add_to_playlist_list},
};

if (!string_is_equal(label, "null"))
Expand Down Expand Up @@ -1394,6 +1396,9 @@ static int menu_cbs_init_bind_deferred_push_compare_label(
case MENU_ENUM_LABEL_SIDELOAD_CORE_LIST:
BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_file_browser_select_sideload_core);
break;
case MENU_ENUM_LABEL_DEFERRED_ADD_TO_PLAYLIST_LIST:
BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_add_to_playlist_list);
break;
default:
return -1;
}
Expand Down
3 changes: 3 additions & 0 deletions menu/cbs/menu_cbs_label.c
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,9 @@ int menu_cbs_init_bind_label(menu_file_list_cbs_t *cbs,
case MENU_ENUM_LABEL_PLAYLIST_MANAGER_SETTINGS:
BIND_ACTION_LABEL(cbs, action_bind_label_playlist_collection_entry);
break;
case MENU_ENUM_LABEL_CONTENT_SETTINGS:
BIND_ACTION_LABEL(cbs, action_bind_label_playlist_collection_entry);
break;
case MENU_ENUM_LABEL_CHEAT_BROWSE_MEMORY:
#ifdef HAVE_CHEATS
BIND_ACTION_LABEL(cbs, action_bind_label_cheat_browse_address);
Expand Down
182 changes: 182 additions & 0 deletions menu/cbs/menu_cbs_ok.c
Original file line number Diff line number Diff line change
Expand Up @@ -543,6 +543,8 @@ static enum msg_hash_enums action_ok_dl_to_enum(unsigned lbl)
return MENU_ENUM_LABEL_DEFERRED_CORE_OPTION_OVERRIDE_LIST;
case ACTION_OK_DL_REMAP_FILE_MANAGER_LIST:
return MENU_ENUM_LABEL_DEFERRED_REMAP_FILE_MANAGER_LIST;
case ACTION_OK_DL_ADD_TO_PLAYLIST:
return MENU_ENUM_LABEL_DEFERRED_ADD_TO_PLAYLIST_LIST;
default:
break;
}
Expand Down Expand Up @@ -1779,6 +1781,7 @@ int generic_action_ok_displaylist_push(
#endif
case ACTION_OK_DL_CORE_OPTION_OVERRIDE_LIST:
case ACTION_OK_DL_REMAP_FILE_MANAGER_LIST:
case ACTION_OK_DL_ADD_TO_PLAYLIST:
ACTION_OK_DL_LBL(action_ok_dl_to_enum(action_type), DISPLAYLIST_GENERIC);
break;
case ACTION_OK_DL_CDROM_INFO_DETAIL_LIST:
Expand Down Expand Up @@ -5769,6 +5772,181 @@ static int action_ok_add_to_favorites(const char *path,
return ret;
}

static int action_ok_add_entry_to_playlist(const char *path,
const char *label, unsigned type, size_t idx, size_t entry_idx)
{
playlist_t *playlist_curr = playlist_get_cached();
const struct playlist_entry *entry = NULL;
menu_handle_t *menu = menu_state_get_ptr()->driver_data;
int ret = 0;

if (!playlist_curr)
return 0;
if (!menu)
return -1;
if(!label)
return 0;

/*
*
* path = menu entry select. use this to identify the menu item to add the content to
* entry->path = The file path of the currently selected content
* [INFO] [playlist] = Add to Favorites
* [INFO] [content_path] = C:\roms\Arcade - Mame 2003 Plus\aburner2.zip
*/
/* Read current playlist parameters */
playlist_get_index(playlist_curr, menu->rpl_entry_selection_ptr, &entry);

/* Error checking
* > If content path is empty, cannot do anything... */
if (!string_is_empty(entry->path))
{
union string_list_elem_attr attr;
char core_display_name[PATH_MAX_LENGTH];
char core_path[PATH_MAX_LENGTH];
char core_name[PATH_MAX_LENGTH];
struct string_list
*str_list = NULL;

core_display_name[0] = '\0';
core_path[0] = '\0';
core_name[0] = '\0';

/* Create string list container for playlist parameters */
attr.i = 0;
if (!(str_list = string_list_new()))
return 0;

/* Copy playlist parameters into string list
* [0]: content_path
* [1]: content_label
* [2]: core_path
* [3]: core_name
* [4]: crc32
* [5]: db_name
* [6]: playlist*/

/* > content_path */
string_list_append(str_list, entry->path, attr);

/* > content_label */
if (!string_is_empty(entry->label))
string_list_append(str_list, entry->label, attr);
else
{
/* Label is empty - use file name instead */
char fallback_content_label[PATH_MAX_LENGTH];
fallback_content_label[0] = '\0';
fill_pathname(fallback_content_label,
path_basename(entry->path), "",
sizeof(fallback_content_label));
string_list_append(str_list, fallback_content_label, attr);
}

/* Replace "DETECT" with default_core_path + name if available */
if ( !string_is_empty(entry->core_path)
&& !string_is_empty(entry->core_name))
{
if ( string_is_equal(entry->core_path, FILE_PATH_DETECT)
&& string_is_equal(entry->core_name, FILE_PATH_DETECT))
{
const char *default_core_path = playlist_get_default_core_path(playlist_curr);
const char *default_core_name = playlist_get_default_core_name(playlist_curr);

if ( !string_is_empty(default_core_path)
&& !string_is_empty(default_core_name))
{
strlcpy(core_path, default_core_path, sizeof(core_path));
strlcpy(core_name, default_core_name, sizeof(core_name));
}
}
else
{
strlcpy(core_path, entry->core_path, sizeof(core_path));
strlcpy(core_name, entry->core_name, sizeof(core_name));
}
}

/* > core_path + core_name */
if ( !string_is_empty(core_path)
&& !string_is_empty(core_name))
{
core_info_t *core_info = NULL;

/* >> core_path */
string_list_append(str_list, core_path, attr);

/* >> core_name
* (always use display name, if available) */
if (core_info_find(core_path, &core_info))
if (!string_is_empty(core_info->display_name))
strlcpy(core_display_name, core_info->display_name, sizeof(core_display_name));

if (!string_is_empty(core_display_name))
string_list_append(str_list, core_display_name, attr);
else
string_list_append(str_list, core_name, attr);
}
else
{
string_list_append(str_list, FILE_PATH_DETECT, attr);
string_list_append(str_list, FILE_PATH_DETECT, attr);
}

/* crc32 */
string_list_append(str_list, !string_is_empty(entry->crc32) ? entry->crc32 : "", attr);

/* db_name */
string_list_append(str_list, !string_is_empty(entry->db_name) ? entry->db_name : "", attr);

/* db_name */
string_list_append(str_list, label, attr);


/* Trigger 'ADD_TO_FAVORITES' event */
if (!command_event(CMD_EVENT_ADD_TO_PLAYLIST, (void*)str_list))
ret = -1;

/* Clean up */
string_list_free(str_list);
str_list = NULL;
}

return ret;
}

static void action_input_add_entry_to_new_playlist(void *userdata, const char *line)
{
settings_t *settings = config_get_ptr();
size_t path_length = 0;
char path[PATH_MAX_LENGTH];

menu_input_dialog_end();

if(!line)
return;

/* Create path for new file */
path_length = fill_pathname_join_special(path, settings->paths.directory_playlist, line, sizeof(path));
strlcat(path, ".lpl", sizeof(path) - path_length);

action_ok_add_entry_to_playlist(NULL, path, 0, 0, 0);
}

static int action_ok_add_entry_to_new_playlist(const char *path,
const char *label, unsigned type, size_t idx, size_t entry_idx)
{
menu_input_ctx_line_t line;
line.label = msg_hash_to_str(MENU_ENUM_LABEL_VALUE_CREATE_NEW_PLAYLIST);
line.label_setting = NULL;
line.type = 0;
line.idx = 0;
line.cb = action_input_add_entry_to_new_playlist;
menu_input_dialog_start(&line);

return 0;
}

/* This function is called when selecting 'add to favorites'
* while viewing a playlist entry */
static int action_ok_add_to_favorites_playlist(const char *path,
Expand Down Expand Up @@ -6194,6 +6372,7 @@ STATIC_DEFAULT_ACTION_OK_FUNC(action_ok_push_core_option_override_list, ACTION_O
STATIC_DEFAULT_ACTION_OK_FUNC(action_ok_push_remap_file_manager_list, ACTION_OK_DL_REMAP_FILE_MANAGER_LIST)
STATIC_DEFAULT_ACTION_OK_FUNC(action_ok_push_savestate_list, ACTION_OK_DL_SAVESTATE_LIST)
STATIC_DEFAULT_ACTION_OK_FUNC(action_ok_push_core_options_list, ACTION_OK_DL_CORE_OPTIONS_LIST)
STATIC_DEFAULT_ACTION_OK_FUNC(action_ok_push_add_to_playlist_list, ACTION_OK_DL_ADD_TO_PLAYLIST)
DEFAULT_ACTION_OK_FUNC(action_ok_push_playlist_manager_settings, ACTION_OK_DL_PLAYLIST_MANAGER_SETTINGS)
#ifdef HAVE_CHEEVOS
DEFAULT_ACTION_OK_FUNC(action_ok_push_achievements_hardcore_pause_list, ACTION_OK_DL_ACHIEVEMENTS_HARDCORE_PAUSE_LIST)
Expand Down Expand Up @@ -8536,9 +8715,12 @@ static int menu_cbs_init_bind_ok_compare_label(menu_file_list_cbs_t *cbs,
{MENU_ENUM_LABEL_HALT_REPLAY, action_ok_halt_replay},
{MENU_ENUM_LABEL_RESUME_CONTENT, action_ok_resume_content},
{MENU_ENUM_LABEL_ADD_TO_FAVORITES_PLAYLIST, action_ok_add_to_favorites_playlist},
{MENU_ENUM_LABEL_ADD_ENTRY_TO_PLAYLIST, action_ok_add_entry_to_playlist},
{MENU_ENUM_LABEL_CREATE_NEW_PLAYLIST, action_ok_add_entry_to_new_playlist},
{MENU_ENUM_LABEL_SET_CORE_ASSOCIATION, action_ok_set_core_association},
{MENU_ENUM_LABEL_RESET_CORE_ASSOCIATION, action_ok_reset_core_association},
{MENU_ENUM_LABEL_ADD_TO_FAVORITES, action_ok_add_to_favorites},
{MENU_ENUM_LABEL_ADD_TO_PLAYLIST, action_ok_push_add_to_playlist_list},
{MENU_ENUM_LABEL_RESTART_CONTENT, action_ok_restart_content},
{MENU_ENUM_LABEL_TAKE_SCREENSHOT, action_ok_screenshot},
{MENU_ENUM_LABEL_RENAME_ENTRY, action_ok_rename_entry},
Expand Down
3 changes: 2 additions & 1 deletion menu/menu_cbs.h
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,8 @@ enum
ACTION_OK_DL_SAVESTATE_LIST,
ACTION_OK_DL_CORE_OPTION_OVERRIDE_LIST,
ACTION_OK_DL_CORE_OPTIONS_LIST,
ACTION_OK_DL_REMAP_FILE_MANAGER_LIST
ACTION_OK_DL_REMAP_FILE_MANAGER_LIST,
ACTION_OK_DL_ADD_TO_PLAYLIST
};

/* Function callbacks */
Expand Down
Loading

0 comments on commit b71c652

Please sign in to comment.