mirror of
https://github.com/libretro/RetroArch.git
synced 2025-04-02 10:51:52 -04:00
Add MIDI device menu item dropdowns (#17645)
This commit is contained in:
parent
7cb27c965d
commit
23170b82ec
9 changed files with 136 additions and 8 deletions
|
@ -1043,6 +1043,10 @@ MSG_HASH(
|
|||
MENU_ENUM_LABEL_DEFERRED_DROPDOWN_BOX_LIST_AUDIO_DEVICE,
|
||||
"deferred_dropdown_box_list_audio_device"
|
||||
)
|
||||
MSG_HASH(
|
||||
MENU_ENUM_LABEL_DEFERRED_DROPDOWN_BOX_LIST_MIDI_DEVICE,
|
||||
"deferred_dropdown_box_list_midi_device"
|
||||
)
|
||||
#ifdef HAVE_MICROPHONE
|
||||
MSG_HASH(
|
||||
MENU_ENUM_LABEL_DEFERRED_DROPDOWN_BOX_LIST_MICROPHONE_DEVICE,
|
||||
|
|
|
@ -667,6 +667,7 @@ GENERIC_DEFERRED_PUSH_GENERAL(deferred_push_dropdown_box_list, PUSH_DEFAULT, DIS
|
|||
GENERIC_DEFERRED_PUSH_GENERAL(deferred_push_dropdown_box_list_special, PUSH_DEFAULT, DISPLAYLIST_DROPDOWN_LIST_SPECIAL)
|
||||
GENERIC_DEFERRED_PUSH_GENERAL(deferred_push_dropdown_box_list_resolution, PUSH_DEFAULT, DISPLAYLIST_DROPDOWN_LIST_RESOLUTION)
|
||||
GENERIC_DEFERRED_PUSH_GENERAL(deferred_push_dropdown_box_list_audio_device, PUSH_DEFAULT, DISPLAYLIST_DROPDOWN_LIST_AUDIO_DEVICE)
|
||||
GENERIC_DEFERRED_PUSH_GENERAL(deferred_push_dropdown_box_list_midi_device, PUSH_DEFAULT, DISPLAYLIST_DROPDOWN_LIST_MIDI_DEVICE)
|
||||
#ifdef HAVE_MICROPHONE
|
||||
GENERIC_DEFERRED_PUSH_GENERAL(deferred_push_dropdown_box_list_microphone_device, PUSH_DEFAULT, DISPLAYLIST_DROPDOWN_LIST_MICROPHONE_DEVICE)
|
||||
#endif
|
||||
|
@ -717,6 +718,7 @@ static int menu_cbs_init_bind_deferred_push_compare_label(
|
|||
{MENU_ENUM_LABEL_DEFERRED_DROPDOWN_BOX_LIST_SPECIAL, deferred_push_dropdown_box_list_special},
|
||||
{MENU_ENUM_LABEL_DEFERRED_DROPDOWN_BOX_LIST_RESOLUTION, deferred_push_dropdown_box_list_resolution},
|
||||
{MENU_ENUM_LABEL_DEFERRED_DROPDOWN_BOX_LIST_AUDIO_DEVICE, deferred_push_dropdown_box_list_audio_device},
|
||||
{MENU_ENUM_LABEL_DEFERRED_DROPDOWN_BOX_LIST_MIDI_DEVICE, deferred_push_dropdown_box_list_midi_device},
|
||||
#ifdef HAVE_MICROPHONE
|
||||
{MENU_ENUM_LABEL_DEFERRED_DROPDOWN_BOX_LIST_MICROPHONE_DEVICE, deferred_push_dropdown_box_list_microphone_device},
|
||||
{MENU_ENUM_LABEL_DEFERRED_MICROPHONE_SETTINGS_LIST, deferred_push_microphone_settings_list},
|
||||
|
|
|
@ -267,6 +267,8 @@ static enum msg_hash_enums action_ok_dl_to_enum(unsigned lbl)
|
|||
return MENU_ENUM_LABEL_DEFERRED_DROPDOWN_BOX_LIST_RESOLUTION;
|
||||
case ACTION_OK_DL_DROPDOWN_BOX_LIST_AUDIO_DEVICE:
|
||||
return MENU_ENUM_LABEL_DEFERRED_DROPDOWN_BOX_LIST_AUDIO_DEVICE;
|
||||
case ACTION_OK_DL_DROPDOWN_BOX_LIST_MIDI_DEVICE:
|
||||
return MENU_ENUM_LABEL_DEFERRED_DROPDOWN_BOX_LIST_MIDI_DEVICE;
|
||||
#ifdef HAVE_MICROPHONE
|
||||
case ACTION_OK_DL_DROPDOWN_BOX_LIST_MICROPHONE_DEVICE:
|
||||
return MENU_ENUM_LABEL_DEFERRED_DROPDOWN_BOX_LIST_MICROPHONE_DEVICE;
|
||||
|
@ -961,6 +963,15 @@ int generic_action_ok_displaylist_push(
|
|||
info.enum_idx = MENU_ENUM_LABEL_DEFERRED_DROPDOWN_BOX_LIST_AUDIO_DEVICE;
|
||||
dl_type = DISPLAYLIST_GENERIC;
|
||||
break;
|
||||
case ACTION_OK_DL_DROPDOWN_BOX_LIST_MIDI_DEVICE:
|
||||
info.type = type;
|
||||
info.directory_ptr = idx;
|
||||
info_path = path;
|
||||
info_label = msg_hash_to_str(
|
||||
MENU_ENUM_LABEL_DEFERRED_DROPDOWN_BOX_LIST_MIDI_DEVICE);
|
||||
info.enum_idx = MENU_ENUM_LABEL_DEFERRED_DROPDOWN_BOX_LIST_MIDI_DEVICE;
|
||||
dl_type = DISPLAYLIST_GENERIC;
|
||||
break;
|
||||
#ifdef HAVE_MICROPHONE
|
||||
case ACTION_OK_DL_DROPDOWN_BOX_LIST_MICROPHONE_DEVICE:
|
||||
info.type = type;
|
||||
|
|
|
@ -1818,6 +1818,7 @@ int menu_cbs_init_bind_title(menu_file_list_cbs_t *cbs,
|
|||
{MENU_ENUM_LABEL_DEFERRED_DROPDOWN_BOX_LIST_SPECIAL, action_get_title_dropdown_item},
|
||||
{MENU_ENUM_LABEL_DEFERRED_DROPDOWN_BOX_LIST_RESOLUTION, action_get_title_dropdown_resolution_item},
|
||||
{MENU_ENUM_LABEL_DEFERRED_DROPDOWN_BOX_LIST_AUDIO_DEVICE, action_get_title_dropdown_item},
|
||||
{MENU_ENUM_LABEL_DEFERRED_DROPDOWN_BOX_LIST_MIDI_DEVICE, action_get_title_dropdown_item},
|
||||
#ifdef HAVE_MICROPHONE
|
||||
{MENU_ENUM_LABEL_DEFERRED_DROPDOWN_BOX_LIST_MICROPHONE_DEVICE, action_get_title_dropdown_item},
|
||||
#endif
|
||||
|
|
|
@ -40,6 +40,7 @@ enum
|
|||
ACTION_OK_DL_DROPDOWN_BOX_LIST_SPECIAL,
|
||||
ACTION_OK_DL_DROPDOWN_BOX_LIST_RESOLUTION,
|
||||
ACTION_OK_DL_DROPDOWN_BOX_LIST_AUDIO_DEVICE,
|
||||
ACTION_OK_DL_DROPDOWN_BOX_LIST_MIDI_DEVICE,
|
||||
#ifdef HAVE_MICROPHONE
|
||||
ACTION_OK_DL_DROPDOWN_BOX_LIST_MICROPHONE_DEVICE,
|
||||
#endif
|
||||
|
|
|
@ -80,6 +80,7 @@
|
|||
#endif
|
||||
|
||||
#include "../audio/audio_driver.h"
|
||||
#include "../midi_driver.h"
|
||||
#include "../record/record_driver.h"
|
||||
#include "menu_cbs.h"
|
||||
#include "menu_driver.h"
|
||||
|
@ -5405,6 +5406,65 @@ static int menu_displaylist_parse_audio_device_list(file_list_t *info_list,
|
|||
return count;
|
||||
}
|
||||
|
||||
static int menu_displaylist_parse_midi_device_list(file_list_t *info_list,
|
||||
const char *info_path)
|
||||
{
|
||||
struct menu_state *menu_st = menu_state_get_ptr();
|
||||
enum msg_hash_enums enum_idx = (enum msg_hash_enums)atoi(info_path);
|
||||
rarch_setting_t *setting = menu_setting_find_enum(enum_idx);
|
||||
size_t menu_index = 0;
|
||||
unsigned count = 0;
|
||||
int i = -1;
|
||||
int midi_device_index = -1;
|
||||
struct string_list *ptr = NULL;
|
||||
|
||||
if (!setting)
|
||||
return 0;
|
||||
|
||||
if (enum_idx == MENU_ENUM_LABEL_MIDI_INPUT)
|
||||
ptr = midi_driver_get_avail_inputs();
|
||||
else
|
||||
ptr = midi_driver_get_avail_outputs();
|
||||
|
||||
if (!ptr)
|
||||
return 0;
|
||||
|
||||
/* Get index in the string list */
|
||||
midi_device_index = string_list_find_elem(ptr, setting->value.target.string) - 1;
|
||||
|
||||
for (i = 0; i < (int)ptr->size; i++)
|
||||
{
|
||||
bool add = false;
|
||||
|
||||
/* Add menu entry */
|
||||
if (menu_entries_append(info_list,
|
||||
ptr->elems[i].data,
|
||||
ptr->elems[i].data,
|
||||
MENU_ENUM_LABEL_AUDIO_DEVICE_LIST,
|
||||
MENU_SETTING_DROPDOWN_ITEM_AUDIO_DEVICE, /* Share common audio for reinit */
|
||||
0, i, NULL))
|
||||
add = true;
|
||||
|
||||
if (add)
|
||||
{
|
||||
/* Add checkmark if input is currently
|
||||
* mapped to this entry */
|
||||
if (midi_device_index == i)
|
||||
{
|
||||
menu_file_list_cbs_t *cbs = (menu_file_list_cbs_t*)info_list->list[menu_index].actiondata;
|
||||
if (cbs)
|
||||
cbs->checked = true;
|
||||
menu_st->selection_ptr = menu_index;
|
||||
}
|
||||
|
||||
count++;
|
||||
menu_index++;
|
||||
}
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
#ifdef HAVE_MICROPHONE
|
||||
static int menu_displaylist_parse_microphone_device_list(
|
||||
file_list_t *info_list, const char *info_path)
|
||||
|
@ -14408,6 +14468,20 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type,
|
|||
menu_entries_clear(info->list);
|
||||
count = menu_displaylist_parse_audio_device_list(info->list, info->path);
|
||||
|
||||
if (count == 0)
|
||||
if (menu_entries_append(info->list,
|
||||
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NO_ENTRIES_TO_DISPLAY),
|
||||
msg_hash_to_str(MENU_ENUM_LABEL_NO_ENTRIES_TO_DISPLAY),
|
||||
MENU_ENUM_LABEL_NO_ENTRIES_TO_DISPLAY,
|
||||
FILE_TYPE_NONE, 0, 0, NULL))
|
||||
count++;
|
||||
info->flags |= MD_FLAG_NEED_REFRESH
|
||||
| MD_FLAG_NEED_PUSH;
|
||||
break;
|
||||
case DISPLAYLIST_DROPDOWN_LIST_MIDI_DEVICE:
|
||||
menu_entries_clear(info->list);
|
||||
count = menu_displaylist_parse_midi_device_list(info->list, info->path);
|
||||
|
||||
if (count == 0)
|
||||
if (menu_entries_append(info->list,
|
||||
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NO_ENTRIES_TO_DISPLAY),
|
||||
|
|
|
@ -61,6 +61,7 @@ enum menu_displaylist_ctl_state
|
|||
DISPLAYLIST_DROPDOWN_LIST_SPECIAL,
|
||||
DISPLAYLIST_DROPDOWN_LIST_RESOLUTION,
|
||||
DISPLAYLIST_DROPDOWN_LIST_AUDIO_DEVICE,
|
||||
DISPLAYLIST_DROPDOWN_LIST_MIDI_DEVICE,
|
||||
#ifdef HAVE_MICROPHONE
|
||||
DISPLAYLIST_DROPDOWN_LIST_MICROPHONE_DEVICE,
|
||||
#endif
|
||||
|
|
|
@ -2936,6 +2936,33 @@ static int setting_string_action_start_audio_device(rarch_setting_t *setting)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int setting_string_action_ok_midi_device(
|
||||
rarch_setting_t *setting, size_t idx, bool wraparound)
|
||||
{
|
||||
char enum_idx[16];
|
||||
if (!setting)
|
||||
return -1;
|
||||
|
||||
snprintf(enum_idx, sizeof(enum_idx), "%d", setting->enum_idx);
|
||||
|
||||
generic_action_ok_displaylist_push(
|
||||
enum_idx, /* we will pass the enumeration index of the string as a path */
|
||||
NULL, NULL, 0, idx, 0,
|
||||
ACTION_OK_DL_DROPDOWN_BOX_LIST_MIDI_DEVICE);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int setting_string_action_start_midi_device(rarch_setting_t *setting)
|
||||
{
|
||||
if (!setting)
|
||||
return -1;
|
||||
|
||||
setting_reset_setting(setting);
|
||||
|
||||
command_event(CMD_EVENT_AUDIO_REINIT, NULL);
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef HAVE_MICROPHONE
|
||||
static int setting_string_action_start_microphone_device(rarch_setting_t *setting)
|
||||
{
|
||||
|
@ -6156,7 +6183,7 @@ static int setting_string_action_left_midi_input(
|
|||
{
|
||||
int i = string_list_find_elem(list, setting->value.target.string) - 2;
|
||||
|
||||
if (wraparound && i == -1)
|
||||
if (i == -1)
|
||||
i = (int)list->size - 1;
|
||||
if (i >= 0)
|
||||
{
|
||||
|
@ -6166,6 +6193,7 @@ static int setting_string_action_left_midi_input(
|
|||
}
|
||||
}
|
||||
|
||||
command_event(CMD_EVENT_AUDIO_REINIT, NULL);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -6178,7 +6206,7 @@ static int setting_string_action_right_midi_input(
|
|||
{
|
||||
int i = string_list_find_elem(list, setting->value.target.string);
|
||||
|
||||
if (wraparound && i == (int)list->size)
|
||||
if (i == (int)list->size)
|
||||
i = 0;
|
||||
if (i >= 0 && i < (int)list->size)
|
||||
{
|
||||
|
@ -6188,6 +6216,7 @@ static int setting_string_action_right_midi_input(
|
|||
}
|
||||
}
|
||||
|
||||
command_event(CMD_EVENT_AUDIO_REINIT, NULL);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -6200,7 +6229,7 @@ static int setting_string_action_left_midi_output(
|
|||
{
|
||||
int i = string_list_find_elem(list, setting->value.target.string) - 2;
|
||||
|
||||
if (wraparound && i == -1)
|
||||
if (i == -1)
|
||||
i = (int)list->size - 1;
|
||||
if (i >= 0)
|
||||
{
|
||||
|
@ -6210,6 +6239,7 @@ static int setting_string_action_left_midi_output(
|
|||
}
|
||||
}
|
||||
|
||||
command_event(CMD_EVENT_AUDIO_REINIT, NULL);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -6222,7 +6252,7 @@ static int setting_string_action_right_midi_output(
|
|||
{
|
||||
int i = string_list_find_elem(list, setting->value.target.string);
|
||||
|
||||
if (wraparound && i == (int)list->size)
|
||||
if (i == (int)list->size)
|
||||
i = 0;
|
||||
if (i >= 0 && i < (int)list->size)
|
||||
{
|
||||
|
@ -6232,6 +6262,7 @@ static int setting_string_action_right_midi_output(
|
|||
}
|
||||
}
|
||||
|
||||
command_event(CMD_EVENT_AUDIO_REINIT, NULL);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -24128,6 +24159,7 @@ static bool setting_append_list(
|
|||
START_SUB_GROUP(list, list_info, "State",
|
||||
&group_info, &subgroup_info, parent_group);
|
||||
|
||||
#if !defined(RARCH_CONSOLE)
|
||||
CONFIG_STRING(
|
||||
list, list_info,
|
||||
settings->arrays.midi_input,
|
||||
|
@ -24140,10 +24172,10 @@ static bool setting_append_list(
|
|||
parent_group,
|
||||
general_write_handler,
|
||||
general_read_handler);
|
||||
SETTINGS_DATA_LIST_CURRENT_ADD_FLAGS(list, list_info, SD_FLAG_ALLOW_INPUT);
|
||||
(*list)[list_info->index - 1].action_start = setting_generic_action_start_default;
|
||||
(*list)[list_info->index - 1].action_start = setting_string_action_start_midi_device;
|
||||
(*list)[list_info->index - 1].action_left = setting_string_action_left_midi_input;
|
||||
(*list)[list_info->index - 1].action_right = setting_string_action_right_midi_input;
|
||||
(*list)[list_info->index - 1].action_ok = setting_string_action_ok_midi_device;
|
||||
|
||||
CONFIG_STRING(
|
||||
list, list_info,
|
||||
|
@ -24157,10 +24189,10 @@ static bool setting_append_list(
|
|||
parent_group,
|
||||
general_write_handler,
|
||||
general_read_handler);
|
||||
SETTINGS_DATA_LIST_CURRENT_ADD_FLAGS(list, list_info, SD_FLAG_ALLOW_INPUT);
|
||||
(*list)[list_info->index - 1].action_start = setting_generic_action_start_default;
|
||||
(*list)[list_info->index - 1].action_start = setting_string_action_start_midi_device;
|
||||
(*list)[list_info->index - 1].action_left = setting_string_action_left_midi_output;
|
||||
(*list)[list_info->index - 1].action_right = setting_string_action_right_midi_output;
|
||||
(*list)[list_info->index - 1].action_ok = setting_string_action_ok_midi_device;
|
||||
|
||||
CONFIG_UINT(
|
||||
list, list_info,
|
||||
|
@ -24175,6 +24207,7 @@ static bool setting_append_list(
|
|||
general_read_handler);
|
||||
(*list)[list_info->index - 1].action_ok = &setting_action_ok_uint;
|
||||
menu_settings_list_current_add_range(list, list_info, 0.0f, 100.0f, 1.0f, true, true);
|
||||
#endif
|
||||
|
||||
END_SUB_GROUP(list, list_info, parent_group);
|
||||
END_GROUP(list, list_info, parent_group);
|
||||
|
|
|
@ -2000,6 +2000,7 @@ enum msg_hash_enums
|
|||
MENU_ENUM_LABEL_DEFERRED_DROPDOWN_BOX_LIST_SPECIAL,
|
||||
MENU_ENUM_LABEL_DEFERRED_DROPDOWN_BOX_LIST_RESOLUTION,
|
||||
MENU_ENUM_LABEL_DEFERRED_DROPDOWN_BOX_LIST_AUDIO_DEVICE,
|
||||
MENU_ENUM_LABEL_DEFERRED_DROPDOWN_BOX_LIST_MIDI_DEVICE,
|
||||
#ifdef HAVE_MICROPHONE
|
||||
MENU_ENUM_LABEL_DEFERRED_DROPDOWN_BOX_LIST_MICROPHONE_DEVICE,
|
||||
#endif
|
||||
|
|
Loading…
Add table
Reference in a new issue