mirror of
https://github.com/holub/mame
synced 2025-05-17 19:24:59 +03:00
01825: Toggling Tab menu works as F2 key in games with their service
mode DIPs on the top of the menu Fixed behavior of toggle switches so that they don't lose their value when the UI is up. They also can now be used for multibit DIP switch settings in which case they toggle through all the options. New functions input_field_select_next_setting() and input_field_select_previous_setting() which can be used to iterate properly through DIP switches. Fixed the behavior for cases where conditional ports are in play (you could get stuck). Changed uimenu.c to call these instead of implementing its own. Changed uimenu.c so that hitting ENTER on a DIP switch resets it to its default value. This is analagous to how the OSD sliders behave.
This commit is contained in:
parent
4e1afc32f5
commit
a643604cbd
@ -208,7 +208,6 @@ struct _input_field_state
|
||||
input_port_value value; /* current value of this port */
|
||||
UINT8 impulse; /* counter for impulse controls */
|
||||
UINT8 last; /* were we pressed last time? */
|
||||
UINT8 toggle; /* current toggle state */
|
||||
UINT8 joydir; /* digital joystick direction index */
|
||||
};
|
||||
|
||||
@ -838,6 +837,86 @@ void input_field_set_user_settings(const input_field_config *field, const input_
|
||||
}
|
||||
|
||||
|
||||
/*-------------------------------------------------
|
||||
input_field_select_previous_setting - select
|
||||
the previous item for a DIP switch or
|
||||
configuration field
|
||||
-------------------------------------------------*/
|
||||
|
||||
void input_field_select_previous_setting(const input_field_config *field)
|
||||
{
|
||||
const input_setting_config *setting, *prevsetting;
|
||||
int found_match = FALSE;
|
||||
|
||||
/* only makes sense if we have settings */
|
||||
assert(field->settings != NULL);
|
||||
|
||||
/* scan the list of settings looking for a match on the current value */
|
||||
prevsetting = NULL;
|
||||
for (setting = field->settinglist; setting != NULL; setting = setting->next)
|
||||
if (input_condition_true(field->port->machine, &setting->condition))
|
||||
{
|
||||
if (setting->value == field->state->value)
|
||||
{
|
||||
found_match = TRUE;
|
||||
if (prevsetting != NULL)
|
||||
break;
|
||||
}
|
||||
prevsetting = setting;
|
||||
}
|
||||
|
||||
/* if we didn't find a matching value, select the first */
|
||||
if (!found_match)
|
||||
{
|
||||
for (prevsetting = field->settinglist; prevsetting != NULL; prevsetting = prevsetting->next)
|
||||
if (input_condition_true(field->port->machine, &prevsetting->condition))
|
||||
break;
|
||||
}
|
||||
|
||||
/* update the value to the previous one */
|
||||
if (prevsetting != NULL)
|
||||
field->state->value = prevsetting->value;
|
||||
}
|
||||
|
||||
|
||||
/*-------------------------------------------------
|
||||
input_field_select_next_setting - select the
|
||||
next item for a DIP switch or
|
||||
configuration field
|
||||
-------------------------------------------------*/
|
||||
|
||||
void input_field_select_next_setting(const input_field_config *field)
|
||||
{
|
||||
const input_setting_config *setting, *nextsetting;
|
||||
|
||||
/* only makes sense if we have settings */
|
||||
assert(field->settings != NULL);
|
||||
|
||||
/* scan the list of settings looking for a match on the current value */
|
||||
nextsetting = NULL;
|
||||
for (setting = field->settinglist; setting != NULL; setting = setting->next)
|
||||
if (input_condition_true(field->port->machine, &setting->condition))
|
||||
if (setting->value == field->state->value)
|
||||
break;
|
||||
|
||||
/* if we found one, scan forward for the next valid one */
|
||||
if (setting != NULL)
|
||||
for (nextsetting = setting->next; nextsetting != NULL; nextsetting = nextsetting->next)
|
||||
if (input_condition_true(field->port->machine, &nextsetting->condition))
|
||||
break;
|
||||
|
||||
/* if we hit the end, search from the beginning */
|
||||
if (nextsetting == NULL)
|
||||
for (nextsetting = field->settinglist; nextsetting != NULL; nextsetting = nextsetting->next)
|
||||
if (input_condition_true(field->port->machine, &nextsetting->condition))
|
||||
break;
|
||||
|
||||
/* update the value to the previous one */
|
||||
if (nextsetting != NULL)
|
||||
field->state->value = nextsetting->value;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/***************************************************************************
|
||||
ACCESSORS FOR INPUT TYPES
|
||||
@ -1075,7 +1154,6 @@ input_port_value input_port_read_direct(const input_port_config *port)
|
||||
result = (result & ~custom->field->mask) | ((newbits << custom->shift) & custom->field->mask);
|
||||
}
|
||||
|
||||
|
||||
/* update VBLANK bits */
|
||||
if (port->state->vblank != 0)
|
||||
{
|
||||
@ -2153,9 +2231,14 @@ static int frame_get_digital_field_state(const input_field_config *field)
|
||||
if (field->impulse != 0 && field->state->impulse == 0)
|
||||
field->state->impulse = field->impulse;
|
||||
|
||||
/* toggle controls: flip the toggle state */
|
||||
/* toggle controls: flip the toggle state or advance to the next setting */
|
||||
if (field->flags & FIELD_FLAG_TOGGLE)
|
||||
field->state->toggle = !field->state->toggle;
|
||||
{
|
||||
if (field->settinglist == NULL)
|
||||
field->state->value ^= field->mask;
|
||||
else
|
||||
input_field_select_next_setting(field);
|
||||
}
|
||||
}
|
||||
|
||||
/* update the current state with the impulse state */
|
||||
@ -2170,9 +2253,10 @@ static int frame_get_digital_field_state(const input_field_config *field)
|
||||
curstate = FALSE;
|
||||
}
|
||||
|
||||
/* update the current state with the toggle state */
|
||||
/* for toggle switches, the current value is folded into the port's default value */
|
||||
/* so we always return FALSE here */
|
||||
if (field->flags & FIELD_FLAG_TOGGLE)
|
||||
curstate = field->state->toggle;
|
||||
curstate = FALSE;
|
||||
|
||||
/* additional logic to restrict digital joysticks */
|
||||
if (curstate && field->state->joystick != NULL && field->way != 16)
|
||||
|
@ -988,6 +988,11 @@ void input_field_get_user_settings(const input_field_config *field, input_field_
|
||||
/* modify the current settings for the given input field */
|
||||
void input_field_set_user_settings(const input_field_config *field, const input_field_user_settings *settings);
|
||||
|
||||
/* select the previous item for a DIP switch or configuration field */
|
||||
void input_field_select_previous_setting(const input_field_config *field);
|
||||
|
||||
/* select the next item for a DIP switch or configuration field */
|
||||
void input_field_select_next_setting(const input_field_config *field);
|
||||
|
||||
|
||||
/* ----- user interface sequence reading ----- */
|
||||
|
@ -186,8 +186,6 @@ static int input_menu_get_game_items(running_machine *machine, input_item_data *
|
||||
static void input_menu_toggle_none_default(input_seq *selected_seq, input_seq *original_seq, const input_seq *selected_defseq);
|
||||
static int input_menu_compare_items(const void *i1, const void *i2);
|
||||
static void switches_menu_add_item(ui_menu_item *item, const input_field_config *field);
|
||||
static void switches_menu_select_previous(const input_field_config *field);
|
||||
static void switches_menu_select_next(const input_field_config *field);
|
||||
static void analog_menu_add_item(ui_menu_item *item, const input_field_config *field, const char *append_string, int which_item);
|
||||
|
||||
/* DIP switch helpers */
|
||||
@ -1090,15 +1088,24 @@ static UINT32 menu_switches(running_machine *machine, UINT32 state)
|
||||
/* handle left/right arrows */
|
||||
if (input_ui_pressed(machine, IPT_UI_LEFT) && (item_list[selected].flags & MENU_FLAG_LEFT_ARROW))
|
||||
{
|
||||
switches_menu_select_previous(selected_field);
|
||||
input_field_select_previous_setting(selected_field);
|
||||
changed = TRUE;
|
||||
}
|
||||
if (input_ui_pressed(machine, IPT_UI_RIGHT) && (item_list[selected].flags & MENU_FLAG_RIGHT_ARROW))
|
||||
{
|
||||
switches_menu_select_next(selected_field);
|
||||
input_field_select_next_setting(selected_field);
|
||||
changed = TRUE;
|
||||
}
|
||||
|
||||
/* select resets to the default value */
|
||||
if (input_ui_pressed(machine, IPT_UI_SELECT))
|
||||
{
|
||||
input_field_user_settings settings;
|
||||
input_field_get_user_settings(selected_field, &settings);
|
||||
settings.value = selected_field->defvalue;
|
||||
input_field_set_user_settings(selected_field, &settings);
|
||||
}
|
||||
|
||||
/* update the selection to match the existing entry in case things got shuffled */
|
||||
/* due to conditional DIPs changing things */
|
||||
if (changed)
|
||||
@ -2088,87 +2095,6 @@ static void switches_menu_add_item(ui_menu_item *item, const input_field_config
|
||||
}
|
||||
|
||||
|
||||
/*-------------------------------------------------
|
||||
switches_menu_select_previous - select the
|
||||
previous item in the switches list
|
||||
-------------------------------------------------*/
|
||||
|
||||
static void switches_menu_select_previous(const input_field_config *field)
|
||||
{
|
||||
const input_setting_config *setting, *prevsetting;
|
||||
input_field_user_settings settings;
|
||||
int found_match = FALSE;
|
||||
|
||||
/* get the current configured settings */
|
||||
input_field_get_user_settings(field, &settings);
|
||||
|
||||
/* scan the list of settings looking for a match on the current value */
|
||||
prevsetting = NULL;
|
||||
for (setting = field->settinglist; setting != NULL; setting = setting->next)
|
||||
{
|
||||
if (setting->value == settings.value)
|
||||
{
|
||||
found_match = TRUE;
|
||||
if (prevsetting != NULL)
|
||||
break;
|
||||
}
|
||||
if (input_condition_true(field->port->machine, &setting->condition))
|
||||
prevsetting = setting;
|
||||
}
|
||||
|
||||
/* if we didn't find a matching value, select the first */
|
||||
if (!found_match)
|
||||
{
|
||||
for (prevsetting = field->settinglist; prevsetting != NULL; prevsetting = prevsetting->next)
|
||||
if (input_condition_true(field->port->machine, &prevsetting->condition))
|
||||
break;
|
||||
}
|
||||
|
||||
/* update the value to the previous one */
|
||||
if (prevsetting != NULL)
|
||||
settings.value = prevsetting->value;
|
||||
input_field_set_user_settings(field, &settings);
|
||||
}
|
||||
|
||||
|
||||
/*-------------------------------------------------
|
||||
switches_menu_select_next - select the
|
||||
next item in the switches list
|
||||
-------------------------------------------------*/
|
||||
|
||||
static void switches_menu_select_next(const input_field_config *field)
|
||||
{
|
||||
const input_setting_config *setting, *nextsetting;
|
||||
input_field_user_settings settings;
|
||||
|
||||
/* get the current configured settings */
|
||||
input_field_get_user_settings(field, &settings);
|
||||
|
||||
/* scan the list of settings looking for a match on the current value */
|
||||
nextsetting = NULL;
|
||||
for (setting = field->settinglist; setting != NULL; setting = setting->next)
|
||||
if (setting->value == settings.value)
|
||||
break;
|
||||
|
||||
/* if we found one, scan forward for the next valid one */
|
||||
if (setting != NULL)
|
||||
for (nextsetting = setting->next; nextsetting != NULL; nextsetting = nextsetting->next)
|
||||
if (input_condition_true(field->port->machine, &nextsetting->condition))
|
||||
break;
|
||||
|
||||
/* if we hit the end, search from the beginning */
|
||||
if (nextsetting == NULL)
|
||||
for (nextsetting = field->settinglist; nextsetting != NULL; nextsetting = nextsetting->next)
|
||||
if (input_condition_true(field->port->machine, &nextsetting->condition))
|
||||
break;
|
||||
|
||||
/* update the value to the previous one */
|
||||
if (nextsetting != NULL)
|
||||
settings.value = nextsetting->value;
|
||||
input_field_set_user_settings(field, &settings);
|
||||
}
|
||||
|
||||
|
||||
/*-------------------------------------------------
|
||||
analog_menu_add_item - add an item to the
|
||||
analog controls menu
|
||||
|
Loading…
Reference in New Issue
Block a user