summaryrefslogtreecommitdiffstats
path: root/src/frontend/mame/ui/inputmap.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/frontend/mame/ui/inputmap.cpp')
-rw-r--r--src/frontend/mame/ui/inputmap.cpp213
1 files changed, 107 insertions, 106 deletions
diff --git a/src/frontend/mame/ui/inputmap.cpp b/src/frontend/mame/ui/inputmap.cpp
index d333f2bd35d..224b37c7944 100644
--- a/src/frontend/mame/ui/inputmap.cpp
+++ b/src/frontend/mame/ui/inputmap.cpp
@@ -25,12 +25,12 @@ namespace ui {
#define MAX_INPUT_PORTS 32
#define MAX_BITS_PER_PORT 32
-// DIP switch rendering parameters
+/* DIP switch rendering parameters */
#define DIP_SWITCH_HEIGHT 0.05f
#define DIP_SWITCH_SPACING 0.01f
#define SINGLE_TOGGLE_SWITCH_FIELD_WIDTH 0.025f
#define SINGLE_TOGGLE_SWITCH_WIDTH 0.020f
-// make the switch 80% of the width space and 1/2 of the switch height
+/* make the switch 80% of the width space and 1/2 of the switch height */
#define PERCENTAGE_OF_HALF_FIELD_USED 0.80f
#define SINGLE_TOGGLE_SWITCH_HEIGHT ((DIP_SWITCH_HEIGHT / 2) * PERCENTAGE_OF_HALF_FIELD_USED)
@@ -49,7 +49,7 @@ void menu_input_groups::populate()
{
int player;
- // build up the menu
+ /* build up the menu */
item_append(_("User Interface"), "", 0, (void *)(IPG_UI + 1));
for (player = 0; player < MAX_PLAYERS; player++)
{
@@ -70,7 +70,7 @@ menu_input_groups::~menu_input_groups()
void menu_input_groups::handle()
{
- // process the menu
+ /* process the menu */
const event *menu_event = process(0);
if (menu_event != nullptr && menu_event->iptkey == IPT_UI_SELECT)
menu::stack_push<menu_input_general>(ui(), container, int((long long)(menu_event->itemref)-1));
@@ -94,24 +94,24 @@ void menu_input_general::populate()
int suborder[SEQ_TYPE_TOTAL];
int sortorder = 1;
- // create a mini lookup table for sort order based on sequence type
+ /* create a mini lookup table for sort order based on sequence type */
suborder[SEQ_TYPE_STANDARD] = 0;
suborder[SEQ_TYPE_DECREMENT] = 1;
suborder[SEQ_TYPE_INCREMENT] = 2;
- // iterate over the input ports and add menu items
+ /* iterate over the input ports and add menu items */
for (input_type_entry &entry : machine().ioport().types())
- // add if we match the group and we have a valid name
+ /* add if we match the group and we have a valid name */
if (entry.group() == group && entry.name() != nullptr && entry.name()[0] != 0)
{
input_seq_type seqtype;
- // loop over all sequence types
+ /* loop over all sequence types */
sortorder++;
for (seqtype = SEQ_TYPE_STANDARD; seqtype < SEQ_TYPE_TOTAL; ++seqtype)
{
- // build an entry for the standard sequence
+ /* build an entry for the standard sequence */
input_item_data *item = (input_item_data *)m_pool_alloc(sizeof(*item));
memset(item, 0, sizeof(*item));
item->ref = &entry;
@@ -127,13 +127,13 @@ void menu_input_general::populate()
item->next = itemlist;
itemlist = item;
- // stop after one, unless we're analog
+ /* stop after one, unless we're analog */
if (item->type == INPUT_TYPE_DIGITAL)
break;
}
}
- // sort and populate the menu in a standard fashion
+ /* sort and populate the menu in a standard fashion */
populate_and_sort(itemlist);
}
@@ -156,12 +156,12 @@ void menu_input_specific::populate()
int suborder[SEQ_TYPE_TOTAL];
int port_count = 0;
- // create a mini lookup table for sort order based on sequence type
+ /* create a mini lookup table for sort order based on sequence type */
suborder[SEQ_TYPE_STANDARD] = 0;
suborder[SEQ_TYPE_DECREMENT] = 1;
suborder[SEQ_TYPE_INCREMENT] = 2;
- // iterate over the input ports and add menu items
+ /* iterate over the input ports and add menu items */
for (auto &port : machine().ioport().ports())
{
port_count++;
@@ -169,13 +169,13 @@ void menu_input_specific::populate()
{
ioport_type_class type_class = field.type_class();
- // add if we match the group and we have a valid name
+ /* add if we match the group and we have a valid name */
if (field.enabled() && (type_class == INPUT_CLASS_CONTROLLER || type_class == INPUT_CLASS_MISC || type_class == INPUT_CLASS_KEYBOARD))
{
input_seq_type seqtype;
UINT32 sortorder;
- // determine the sorting order
+ /* determine the sorting order */
if (type_class == INPUT_CLASS_CONTROLLER)
{
sortorder = (field.type() << 2) | (field.player() << 12);
@@ -185,10 +185,10 @@ void menu_input_specific::populate()
else
sortorder = field.type() | 0xf000;
- // loop over all sequence types
+ /* loop over all sequence types */
for (seqtype = SEQ_TYPE_STANDARD; seqtype < SEQ_TYPE_TOTAL; ++seqtype)
{
- // build an entry for the standard sequence
+ /* build an entry for the standard sequence */
input_item_data *item = (input_item_data *)m_pool_alloc(sizeof(*item));
memset(item, 0, sizeof(*item));
item->ref = &field;
@@ -204,7 +204,7 @@ void menu_input_specific::populate()
item->next = itemlist;
itemlist = item;
- // stop after one, unless we're analog
+ /* stop after one, unless we're analog */
if (item->type == INPUT_TYPE_DIGITAL)
break;
}
@@ -212,7 +212,7 @@ void menu_input_specific::populate()
}
}
- // sort and populate the menu in a standard fashion
+ /* sort and populate the menu in a standard fashion */
populate_and_sort(itemlist);
}
@@ -241,11 +241,11 @@ menu_input::~menu_input()
void menu_input::toggle_none_default(input_seq &selected_seq, input_seq &original_seq, const input_seq &selected_defseq)
{
- // if we used to be "none", toggle to the default value
+ /* if we used to be "none", toggle to the default value */
if (original_seq.length() == 0)
selected_seq = selected_defseq;
- // otherwise, toggle to "none"
+ /* otherwise, toggle to "none" */
else
selected_seq.reset();
}
@@ -253,74 +253,75 @@ void menu_input::toggle_none_default(input_seq &selected_seq, input_seq &origina
void menu_input::handle()
{
input_item_data *seqchangeditem = nullptr;
- auto invalidate = false;
+ const event *menu_event;
+ int invalidate = false;
- // process the menu
- auto menu_event = process((pollingitem != nullptr) ? PROCESS_NOKEYS : 0);
+ /* process the menu */
+ menu_event = process((pollingitem != nullptr) ? PROCESS_NOKEYS : 0);
- // if we are polling, handle as a special case
+ /* if we are polling, handle as a special case */
if (pollingitem != nullptr)
{
- auto pitem = pollingitem;
+ input_item_data *item = pollingitem;
- // if UI_CANCEL is pressed, abort
+ /* if UI_CANCEL is pressed, abort */
if (machine().ui_input().pressed(IPT_UI_CANCEL))
{
pollingitem = nullptr;
record_next = false;
- toggle_none_default(pitem->seq, starting_seq, *pitem->defseq);
- seqchangeditem = pitem;
+ toggle_none_default(item->seq, starting_seq, *item->defseq);
+ seqchangeditem = item;
}
- // poll again; if finished, update the sequence
+ /* poll again; if finished, update the sequence */
if (machine().input().seq_poll())
{
pollingitem = nullptr;
record_next = true;
- pitem->seq = machine().input().seq_poll_final();
- seqchangeditem = pitem;
+ item->seq = machine().input().seq_poll_final();
+ seqchangeditem = item;
}
}
- // otherwise, handle the events
+ /* otherwise, handle the events */
else if (menu_event != nullptr && menu_event->itemref != nullptr)
{
- auto pitem = (input_item_data *)menu_event->itemref;
+ input_item_data *item = (input_item_data *)menu_event->itemref;
switch (menu_event->iptkey)
{
- // an item was selected: begin polling
+ /* an item was selected: begin polling */
case IPT_UI_SELECT:
- pollingitem = pitem;
- last_sortorder = pitem->sortorder;
- starting_seq = pitem->seq;
- machine().input().seq_poll_start((pitem->type == INPUT_TYPE_ANALOG) ? ITEM_CLASS_ABSOLUTE : ITEM_CLASS_SWITCH, record_next ? &pitem->seq : nullptr);
+ pollingitem = item;
+ last_sortorder = item->sortorder;
+ starting_seq = item->seq;
+ machine().input().seq_poll_start((item->type == INPUT_TYPE_ANALOG) ? ITEM_CLASS_ABSOLUTE : ITEM_CLASS_SWITCH, record_next ? &item->seq : nullptr);
invalidate = true;
break;
- // if the clear key was pressed, reset the selected item
+ /* if the clear key was pressed, reset the selected item */
case IPT_UI_CLEAR:
- toggle_none_default(pitem->seq, pitem->seq, *pitem->defseq);
+ toggle_none_default(item->seq, item->seq, *item->defseq);
record_next = false;
- seqchangeditem = pitem;
+ seqchangeditem = item;
break;
}
- // if the selection changed, reset the "record next" flag
- if (pitem->sortorder != last_sortorder)
+ /* if the selection changed, reset the "record next" flag */
+ if (item->sortorder != last_sortorder)
record_next = false;
- last_sortorder = pitem->sortorder;
+ last_sortorder = item->sortorder;
}
- // if the sequence changed, update it
+ /* if the sequence changed, update it */
if (seqchangeditem != nullptr)
{
update_input(seqchangeditem);
- // invalidate the menu to force an update
+ /* invalidate the menu to force an update */
invalidate = true;
}
- // if the menu is invalidated, clear it now
+ /* if the menu is invalidated, clear it now */
if (invalidate)
{
pollingref = nullptr;
@@ -335,7 +336,7 @@ void menu_input::handle()
void menu_input_general::update_input(struct input_item_data *seqchangeditem)
{
- auto entry = (const input_type_entry *)seqchangeditem->ref;
+ const input_type_entry *entry = (const input_type_entry *)seqchangeditem->ref;
machine().ioport().set_type_seq(entry->type(), entry->player(), seqchangeditem->seqtype, seqchangeditem->seq);
}
@@ -356,8 +357,8 @@ void menu_input_specific::update_input(struct input_item_data *seqchangeditem)
int menu_input::compare_items(const void *i1, const void *i2)
{
- auto data1 = (const input_item_data * const *)i1;
- auto data2 = (const input_item_data * const *)i2;
+ const input_item_data * const *data1 = (const input_item_data * const *)i1;
+ const input_item_data * const *data2 = (const input_item_data * const *)i2;
if ((*data1)->sortorder < (*data2)->sortorder)
return -1;
if ((*data1)->sortorder > (*data2)->sortorder)
@@ -381,30 +382,30 @@ void menu_input::populate_and_sort(input_item_data *itemlist)
std::string prev_owner;
bool first_entry = true;
- // create a mini lookup table for name format based on type
+ /* create a mini lookup table for name format based on type */
nameformat[INPUT_TYPE_DIGITAL] = "%s";
nameformat[INPUT_TYPE_ANALOG] = "%s Analog";
nameformat[INPUT_TYPE_ANALOG_INC] = "%s Analog Inc";
nameformat[INPUT_TYPE_ANALOG_DEC] = "%s Analog Dec";
- // first count the number of items
+ /* first count the number of items */
for (item = itemlist; item != nullptr; item = item->next)
numitems++;
- // now allocate an array of items and fill it up
+ /* now allocate an array of items and fill it up */
itemarray = (input_item_data **)m_pool_alloc(sizeof(*itemarray) * numitems);
for (item = itemlist, curitem = 0; item != nullptr; item = item->next)
itemarray[curitem++] = item;
- // sort it
+ /* sort it */
qsort(itemarray, numitems, sizeof(*itemarray), compare_items);
- // build the menu
+ /* build the menu */
for (curitem = 0; curitem < numitems; curitem++)
{
UINT32 flags = 0;
- // generate the name of the item itself, based off the base name and the type
+ /* generate the name of the item itself, based off the base name and the type */
item = itemarray[curitem];
assert(nameformat[item->type] != nullptr);
@@ -420,21 +421,21 @@ void menu_input::populate_and_sort(input_item_data *itemlist)
std::string text = string_format(nameformat[item->type], item->name);
- // if we're polling this item, use some spaces with left/right arrows
+ /* if we're polling this item, use some spaces with left/right arrows */
if (pollingref == item->ref)
{
subtext.assign(" ");
flags |= FLAG_LEFT_ARROW | FLAG_RIGHT_ARROW;
}
- // otherwise, generate the sequence name and invert it if different from the default
+ /* otherwise, generate the sequence name and invert it if different from the default */
else
{
subtext = machine().input().seq_name(item->seq);
flags |= (item->seq != *item->defseq) ? FLAG_INVERT : 0;
}
- // add the item
+ /* add the item */
item_append(text, subtext, flags, item);
}
}
@@ -494,7 +495,7 @@ void menu_settings::handle()
switch (menu_event->iptkey)
{
- // if selected, reset to default value
+ /* if selected, reset to default value */
case IPT_UI_SELECT:
field->get_user_settings(settings);
settings.value = field->defvalue();
@@ -502,20 +503,20 @@ void menu_settings::handle()
changed = true;
break;
- // left goes to previous setting
+ /* left goes to previous setting */
case IPT_UI_LEFT:
field->select_previous_setting();
changed = true;
break;
- // right goes to next setting
+ /* right goes to next setting */
case IPT_UI_RIGHT:
field->select_next_setting();
changed = true;
break;
}
- // if anything changed, rebuild the menu, trying to stay on the same field
+ /* if anything changed, rebuild the menu, trying to stay on the same field */
if (changed)
reset(reset_options::REMEMBER_REF);
}
@@ -539,25 +540,25 @@ void menu_settings::populate()
std::string prev_owner;
bool first_entry = true;
- // reset the dip switch tracking
+ /* reset the dip switch tracking */
dipcount = 0;
diplist = nullptr;
diplist_tailptr = &diplist;
- // loop over input ports and set up the current values
+ /* loop over input ports and set up the current values */
for (auto &port : machine().ioport().ports())
for (ioport_field &field : port.second->fields())
if (field.type() == type && field.enabled())
{
UINT32 flags = 0;
- // set the left/right flags appropriately
+ /* set the left/right flags appropriately */
if (field.has_previous_setting())
flags |= FLAG_LEFT_ARROW;
if (field.has_next_setting())
flags |= FLAG_RIGHT_ARROW;
- // add the menu item
+ /* add the menu item */
if (strcmp(field.device().tag(), prev_owner.c_str()) != 0)
{
if (first_entry)
@@ -571,27 +572,27 @@ void menu_settings::populate()
item_append(field.name(), field.setting_name(), flags, (void *)&field);
- // for DIP switches, build up the model
+ /* for DIP switches, build up the model */
if (type == IPT_DIPSWITCH && !field.diplocations().empty())
{
ioport_field::user_settings settings;
- auto accummask = field.mask();
+ UINT32 accummask = field.mask();
- // get current settings
+ /* get current settings */
field.get_user_settings(settings);
- // iterate over each bit in the field
+ /* iterate over each bit in the field */
for (const ioport_diplocation &diploc : field.diplocations())
{
UINT32 mask = accummask & ~(accummask - 1);
dip_descriptor *dip;
- // find the matching switch name
+ /* find the matching switch name */
for (dip = diplist; dip != nullptr; dip = dip->next)
if (strcmp(dip->name, diploc.name()) == 0)
break;
- // allocate new if none
+ /* allocate new if none */
if (dip == nullptr)
{
dip = (dip_descriptor *)m_pool_alloc(sizeof(*dip));
@@ -603,12 +604,12 @@ void menu_settings::populate()
dipcount++;
}
- // apply the bits
+ /* apply the bits */
dip->mask |= 1 << (diploc.number() - 1);
if (((settings.value & mask) != 0 && !diploc.inverted()) || ((settings.value & mask) == 0 && diploc.inverted()))
dip->state |= 1 << (diploc.number() - 1);
- // clear the relevant bit in the accumulated mask
+ /* clear the relevant bit in the accumulated mask */
accummask &= ~mask;
}
}
@@ -651,7 +652,7 @@ void menu_settings_dip_switches::custom_render(void *selectedref, float top, flo
// determine the mask of selected bits
if ((FPTR)selectedref != 1)
{
- auto field = (ioport_field *)selectedref;
+ ioport_field *field = (ioport_field *)selectedref;
if (field != nullptr && !field->diplocations().empty())
for (const ioport_diplocation &diploc : field->diplocations())
@@ -679,13 +680,13 @@ void menu_settings_dip_switches::custom_render_one(float x1, float y1, float x2,
float switch_toggle_gap;
float y1_off, y1_on;
- // determine the number of toggles in the DIP
+ /* determine the number of toggles in the DIP */
numtoggles = 32 - count_leading_zeros(dip->mask);
- // center based on the number of switches
+ /* center based on the number of switches */
x1 += (x2 - x1 - numtoggles * switch_field_width) / 2;
- // draw the dip switch name
+ /* draw the dip switch name */
ui().draw_text_full( container,
dip->name,
0,
@@ -699,23 +700,23 @@ void menu_settings_dip_switches::custom_render_one(float x1, float y1, float x2,
nullptr ,
nullptr);
- // compute top and bottom for on and off positions
+ /* compute top and bottom for on and off positions */
switch_toggle_gap = ((DIP_SWITCH_HEIGHT/2) - SINGLE_TOGGLE_SWITCH_HEIGHT)/2;
y1_off = y1 + UI_LINE_WIDTH + switch_toggle_gap;
y1_on = y1 + DIP_SWITCH_HEIGHT/2 + switch_toggle_gap;
- // iterate over toggles
+ /* iterate over toggles */
for (toggle = 0; toggle < numtoggles; toggle++)
{
float innerx1;
- // first outline the switch
+ /* first outline the switch */
ui().draw_outlined_box(container, x1, y1, x1 + switch_field_width, y2, UI_BACKGROUND_COLOR);
- // compute x1/x2 for the inner filled in switch
+ /* compute x1/x2 for the inner filled in switch */
innerx1 = x1 + (switch_field_width - switch_width) / 2;
- // see if the switch is actually used
+ /* see if the switch is actually used */
if (dip->mask & (1 << toggle))
{
float innery1 = (dip->state & (1 << toggle)) ? y1_on : y1_off;
@@ -730,7 +731,7 @@ void menu_settings_dip_switches::custom_render_one(float x1, float y1, float x2,
PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA));
}
- // advance to the next switch
+ /* advance to the next switch */
x1 += switch_field_width;
}
}
@@ -742,45 +743,45 @@ void menu_settings_dip_switches::custom_render_one(float x1, float y1, float x2,
void menu_analog::handle()
{
- // process the menu
- auto menu_event = process(PROCESS_LR_REPEAT);
+ /* process the menu */
+ const event *menu_event = process(PROCESS_LR_REPEAT);
- // handle events
+ /* handle events */
if (menu_event != nullptr && menu_event->itemref != nullptr)
{
- auto data = (analog_item_data *)menu_event->itemref;
- auto newval = data->cur;
+ analog_item_data *data = (analog_item_data *)menu_event->itemref;
+ int newval = data->cur;
switch (menu_event->iptkey)
{
- // if selected, reset to default value
+ /* if selected, reset to default value */
case IPT_UI_SELECT:
newval = data->defvalue;
break;
- // left decrements
+ /* left decrements */
case IPT_UI_LEFT:
newval -= machine().input().code_pressed(KEYCODE_LSHIFT) ? 10 : 1;
break;
- // right increments
+ /* right increments */
case IPT_UI_RIGHT:
newval += machine().input().code_pressed(KEYCODE_LSHIFT) ? 10 : 1;
break;
}
- // clamp to range
+ /* clamp to range */
if (newval < data->min)
newval = data->min;
if (newval > data->max)
newval = data->max;
- // if things changed, update
+ /* if things changed, update */
if (newval != data->cur)
{
ioport_field::user_settings settings;
- // get the settings and set the new value
+ /* get the settings and set the new value */
data->field->get_user_settings(settings);
switch (data->type)
{
@@ -791,7 +792,7 @@ void menu_analog::handle()
}
data->field->set_user_settings(settings);
- // rebuild the menu
+ /* rebuild the menu */
reset(reset_options::REMEMBER_POSITION);
}
}
@@ -812,7 +813,7 @@ void menu_analog::populate()
std::string prev_owner;
bool first_entry = true;
- // loop over input ports and add the items
+ /* loop over input ports and add the items */
for (auto &port : machine().ioport().ports())
for (ioport_field &field : port.second->fields())
if (field.is_analog() && field.enabled())
@@ -821,7 +822,7 @@ void menu_analog::populate()
int use_autocenter = false;
int type;
- // based on the type, determine if we enable autocenter
+ /* based on the type, determine if we enable autocenter */
switch (field.type())
{
case IPT_POSITIONAL:
@@ -844,10 +845,10 @@ void menu_analog::populate()
break;
}
- // get the user settings
+ /* get the user settings */
field.get_user_settings(settings);
- // iterate over types
+ /* iterate over types */
for (type = 0; type < ANALOG_ITEM_COUNT; type++)
if (type != ANALOG_ITEM_CENTERSPEED || use_autocenter)
{
@@ -865,12 +866,12 @@ void menu_analog::populate()
prev_owner.assign(field.device().tag());
}
- // allocate a data item for tracking what this menu item refers to
+ /* allocate a data item for tracking what this menu item refers to */
data = (analog_item_data *)m_pool_alloc(sizeof(*data));
data->field = &field;
data->type = type;
- // determine the properties of this item
+ /* determine the properties of this item */
switch (type)
{
default:
@@ -911,13 +912,13 @@ void menu_analog::populate()
break;
}
- // put on arrows
+ /* put on arrows */
if (data->cur > data->min)
flags |= FLAG_LEFT_ARROW;
if (data->cur < data->max)
flags |= FLAG_RIGHT_ARROW;
- // append a menu item
+ /* append a menu item */
item_append(std::move(text), std::move(subtext), flags, data);
}
}