summaryrefslogtreecommitdiffstatshomepage
path: root/src/emu/uimain.c
diff options
context:
space:
mode:
author Aaron Giles <aaron@aarongiles.com>2012-05-03 09:00:08 +0000
committer Aaron Giles <aaron@aarongiles.com>2012-05-03 09:00:08 +0000
commit2a88e54278acc526c11dba7961204f234f1f6e05 (patch)
tree1d78e932e47bb535e7e56ddac05232cdf551c3a1 /src/emu/uimain.c
parent605a48921b48e0127ff0330f1e895dcf16d084fb (diff)
ioport.c C++ conversion. Mostly internal changes, with no
intended differences from previous behavior. For drivers, the main change is that input_port_read() no longer exists. Instead, the port must be fetched from the appropriate device, and then read() is called. For member functions, this is actually simpler/cleaner: value = ioport("tag")->read() For legacy functions which have a driver_data state, it goes: value = state->ioport("tag")->read() For other legacy functions, they need to fetch the root device: value = machine.root_device().ioport("tag")->read() The other big change for drivers is that IPT_VBLANK is gone. Instead, it has been replaced by a device line callback on the screen device. There's a new macro PORT_VBLANK("tag") which automatically points things to the right spot. Here's a set of imperfect search & replace strings to convert the input_port_read calls and fix up IPT_VBLANK: input_port_read( *\( *)(machine\(\)) *, *([^)]+ *\)) ioport\1\3->read\(\) input_port_read( *\( *)(.*machine[()]*) *, *([^)]+ *\)) \2\.root_device\(\)\.ioport\1\3->read\(\) (state = .*driver_data[^}]+)space->machine\(\)\.root_device\(\)\. \1state-> (state = .*driver_data[^}]+)device->machine\(\)\.root_device\(\)\. \1state-> input_port_read_safe( *\( *)(machine\(\)) *, *([^,]+), *([^)]+\)) ioport\1\3->read_safe\(\4\) IPT_VBLANK( *\)) IPT_CUSTOM\1 PORT_VBLANK("screen")
Diffstat (limited to 'src/emu/uimain.c')
-rw-r--r--src/emu/uimain.c165
1 files changed, 84 insertions, 81 deletions
diff --git a/src/emu/uimain.c b/src/emu/uimain.c
index 85af3575eeb..48538e7a573 100644
--- a/src/emu/uimain.c
+++ b/src/emu/uimain.c
@@ -109,8 +109,8 @@ ui_menu_main::ui_menu_main(running_machine &machine, render_container *container
void ui_menu_main::populate()
{
- input_field_config *field;
- input_port_config *port;
+ ioport_field *field;
+ ioport_port *port;
int has_configs = false;
int has_analog = false;
int has_dips = false;
@@ -118,13 +118,13 @@ void ui_menu_main::populate()
astring menu_text;
/* scan the input port array to see what options we need to enable */
for (port = machine().ioport().first_port(); port != NULL; port = port->next())
- for (field = port->fieldlist().first(); field != NULL; field = field->next())
+ for (field = port->first_field(); field != NULL; field = field->next())
{
- if (field->type == IPT_DIPSWITCH)
+ if (field->type() == IPT_DIPSWITCH)
has_dips = true;
- if (field->type == IPT_CONFIG)
+ if (field->type() == IPT_CONFIG)
has_configs = true;
- if (input_type_is_analog(field->type))
+ if (field->is_analog())
has_analog = true;
}
device_iterator deviter(machine().root_device());
@@ -192,7 +192,7 @@ void ui_menu_main::populate()
}
/* add keyboard mode menu */
- if (input_machine_has_keyboard(machine()) && inputx_can_post(machine()))
+ if (machine().ioport().has_keyboard() && machine().ioport().natkeyboard().can_post())
item_append("Keyboard Mode", NULL, 0, (void *)KEYBOARD_MODE);
/* add sliders menu */
@@ -671,10 +671,10 @@ void ui_menu_input_general::populate()
suborder[SEQ_TYPE_INCREMENT] = 2;
/* iterate over the input ports and add menu items */
- for (input_type_entry *entry = input_type_list(machine()).first(); entry != NULL; entry = entry->next())
+ for (input_type_entry *entry = machine().ioport().first_type(); entry != NULL; entry = entry->next())
/* add if we match the group and we have a valid name */
- if (entry->group == group && entry->name != NULL && entry->name[0] != 0)
+ if (entry->group() == group && entry->name() != NULL && entry->name()[0] != 0)
{
input_seq_type seqtype;
@@ -689,11 +689,11 @@ void ui_menu_input_general::populate()
if(pollingitem && pollingref == entry && pollingseq == seqtype)
pollingitem = item;
item->seqtype = seqtype;
- item->seq = input_type_seq(machine(), entry->type, entry->player, seqtype);
- item->defseq = &entry->defseq[seqtype];
+ item->seq = machine().ioport().type_seq(entry->type(), entry->player(), seqtype);
+ item->defseq = &entry->defseq(seqtype);
item->sortorder = sortorder * 4 + suborder[seqtype];
- item->type = input_type_is_analog(entry->type) ? (INPUT_TYPE_ANALOG + seqtype) : INPUT_TYPE_DIGITAL;
- item->name = entry->name;
+ item->type = ioport_manager::type_is_analog(entry->type()) ? (INPUT_TYPE_ANALOG + seqtype) : INPUT_TYPE_DIGITAL;
+ item->name = entry->name();
item->next = itemlist;
itemlist = item;
@@ -723,8 +723,8 @@ ui_menu_input_specific::ui_menu_input_specific(running_machine &machine, render_
void ui_menu_input_specific::populate()
{
input_item_data *itemlist = NULL;
- input_field_config *field;
- input_port_config *port;
+ ioport_field *field;
+ ioport_port *port;
int suborder[SEQ_TYPE_TOTAL];
astring tempstring;
@@ -735,22 +735,22 @@ void ui_menu_input_specific::populate()
/* iterate over the input ports and add menu items */
for (port = machine().ioport().first_port(); port != NULL; port = port->next())
- for (field = port->fieldlist().first(); field != NULL; field = field->next())
+ for (field = port->first_field(); field != NULL; field = field->next())
{
- const char *name = input_field_name(field);
+ const char *name = field->name();
/* add if we match the group and we have a valid name */
- if (name != NULL && input_condition_true(machine(), &field->condition, port->owner()) &&
- ((field->type == IPT_OTHER && field->name != NULL) || input_type_group(machine(), field->type, field->player) != IPG_INVALID))
+ if (name != NULL && field->enabled() &&
+ ((field->type() == IPT_OTHER && field->name() != NULL) || machine().ioport().type_group(field->type(), field->player()) != IPG_INVALID))
{
input_seq_type seqtype;
UINT16 sortorder;
/* determine the sorting order */
- if (field->type >= IPT_START1 && field->type <= __ipt_analog_end)
- sortorder = (field->type << 2) | (field->player << 12);
+ if (field->type() >= IPT_START1 && field->type() < IPT_ANALOG_LAST)
+ sortorder = (field->type() << 2) | (field->player() << 12);
else
- sortorder = field->type | 0xf000;
+ sortorder = field->type() | 0xf000;
/* loop over all sequence types */
for (seqtype = SEQ_TYPE_STANDARD; seqtype < SEQ_TYPE_TOTAL; seqtype++)
@@ -762,10 +762,10 @@ void ui_menu_input_specific::populate()
item->seqtype = seqtype;
if(pollingitem && pollingref == field && pollingseq == seqtype)
pollingitem = item;
- item->seq = input_field_seq(field, seqtype);
+ item->seq = field->seq(seqtype);
item->defseq = &get_field_default_seq(field, seqtype);
item->sortorder = sortorder + suborder[seqtype];
- item->type = input_type_is_analog(field->type) ? (INPUT_TYPE_ANALOG + seqtype) : INPUT_TYPE_DIGITAL;
+ item->type = field->is_analog() ? (INPUT_TYPE_ANALOG + seqtype) : INPUT_TYPE_DIGITAL;
item->name = name;
item->next = itemlist;
itemlist = item;
@@ -820,12 +820,12 @@ void ui_menu_input::toggle_none_default(input_seq &selected_seq, input_seq &orig
to the default sequence for the given field
-------------------------------------------------*/
-const input_seq &ui_menu_input::get_field_default_seq(input_field_config *field, input_seq_type seqtype)
+const input_seq &ui_menu_input::get_field_default_seq(ioport_field *field, input_seq_type seqtype)
{
- if (field->seq[seqtype].is_default())
- return input_type_seq(field->machine(), field->type, field->player, seqtype);
+ if (field->seq(seqtype).is_default())
+ return field->machine().ioport().type_seq(field->type(), field->player(), seqtype);
else
- return field->seq[seqtype];
+ return field->seq(seqtype);
}
void ui_menu_input::handle()
@@ -916,16 +916,16 @@ void ui_menu_input::handle()
void ui_menu_input_general::update_input(struct input_item_data *seqchangeditem)
{
const input_type_entry *entry = (const input_type_entry *)seqchangeditem->ref;
- input_type_set_seq(machine(), entry->type, entry->player, seqchangeditem->seqtype, &seqchangeditem->seq);
+ machine().ioport().set_type_seq(entry->type(), entry->player(), seqchangeditem->seqtype, seqchangeditem->seq);
}
void ui_menu_input_specific::update_input(struct input_item_data *seqchangeditem)
{
- input_field_user_settings settings;
+ ioport_field::user_settings settings;
- input_field_get_user_settings((input_field_config *)seqchangeditem->ref, &settings);
+ ((ioport_field *)seqchangeditem->ref)->get_user_settings(settings);
settings.seq[seqchangeditem->seqtype] = seqchangeditem->seq;
- input_field_set_user_settings((input_field_config *)seqchangeditem->ref, &settings);
+ ((ioport_field *)seqchangeditem->ref)->set_user_settings(settings);
}
@@ -1047,29 +1047,29 @@ void ui_menu_settings::handle()
/* handle events */
if (menu_event != NULL && menu_event->itemref != NULL)
{
- input_field_config *field = (input_field_config *)menu_event->itemref;
- input_field_user_settings settings;
+ ioport_field *field = (ioport_field *)menu_event->itemref;
+ ioport_field::user_settings settings;
int changed = false;
switch (menu_event->iptkey)
{
/* if selected, reset to default value */
case IPT_UI_SELECT:
- input_field_get_user_settings(field, &settings);
- settings.value = field->defvalue;
- input_field_set_user_settings(field, &settings);
+ field->get_user_settings(settings);
+ settings.value = field->defvalue();
+ field->set_user_settings(settings);
changed = true;
break;
/* left goes to previous setting */
case IPT_UI_LEFT:
- input_field_select_previous_setting(field);
+ field->select_previous_setting();
changed = true;
break;
/* right goes to next setting */
case IPT_UI_RIGHT:
- input_field_select_next_setting(field);
+ field->select_next_setting();
changed = true;
break;
}
@@ -1093,8 +1093,8 @@ ui_menu_settings::ui_menu_settings(running_machine &machine, render_container *c
void ui_menu_settings::populate()
{
- input_field_config *field;
- input_port_config *port;
+ ioport_field *field;
+ ioport_port *port;
dip_descriptor **diplist_tailptr;
/* reset the dip switch tracking */
@@ -1104,39 +1104,39 @@ void ui_menu_settings::populate()
/* loop over input ports and set up the current values */
for (port = machine().ioport().first_port(); port != NULL; port = port->next())
- for (field = port->fieldlist().first(); field != NULL; field = field->next())
- if (field->type == type && input_condition_true(machine(), &field->condition, port->owner()))
+ for (field = port->first_field(); field != NULL; field = field->next())
+ if (field->type() == type && field->enabled())
{
UINT32 flags = 0;
/* set the left/right flags appropriately */
- if (input_field_has_previous_setting(field))
+ if (field->has_previous_setting())
flags |= MENU_FLAG_LEFT_ARROW;
- if (input_field_has_next_setting(field))
+ if (field->has_next_setting())
flags |= MENU_FLAG_RIGHT_ARROW;
/* add the menu item */
- item_append(input_field_name(field), input_field_setting_name(field), flags, (void *)field);
+ item_append(field->name(), field->setting_name(), flags, (void *)field);
/* for DIP switches, build up the model */
- if (type == IPT_DIPSWITCH && field->diploclist().count() != 0)
+ if (type == IPT_DIPSWITCH && field->first_diplocation() != NULL)
{
- const input_field_diplocation *diploc;
- input_field_user_settings settings;
- UINT32 accummask = field->mask;
+ const ioport_diplocation *diploc;
+ ioport_field::user_settings settings;
+ UINT32 accummask = field->mask();
/* get current settings */
- input_field_get_user_settings(field, &settings);
+ field->get_user_settings(settings);
/* iterate over each bit in the field */
- for (diploc = field->diploclist().first(); diploc != NULL; diploc = diploc->next())
+ for (diploc = field->first_diplocation(); diploc != NULL; diploc = diploc->next())
{
UINT32 mask = accummask & ~(accummask - 1);
dip_descriptor *dip;
/* find the matching switch name */
for (dip = diplist; dip != NULL; dip = dip->next)
- if (strcmp(dip->name, diploc->swname) == 0)
+ if (strcmp(dip->name, diploc->name()) == 0)
break;
/* allocate new if none */
@@ -1144,7 +1144,7 @@ void ui_menu_settings::populate()
{
dip = (dip_descriptor *)m_pool_alloc(sizeof(*dip));
dip->next = NULL;
- dip->name = diploc->swname;
+ dip->name = diploc->name();
dip->mask = dip->state = 0;
*diplist_tailptr = dip;
diplist_tailptr = &dip->next;
@@ -1153,9 +1153,9 @@ void ui_menu_settings::populate()
}
/* apply the bits */
- dip->mask |= 1 << (diploc->swnum - 1);
- if (((settings.value & mask) != 0 && !diploc->invert) || ((settings.value & mask) == 0 && diploc->invert))
- dip->state |= 1 << (diploc->swnum - 1);
+ 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 */
accummask &= ~mask;
@@ -1177,7 +1177,7 @@ ui_menu_settings::~ui_menu_settings()
void ui_menu_settings_dip_switches::custom_render(void *selectedref, float top, float bottom, float x1, float y1, float x2, float y2)
{
- input_field_config *field = (input_field_config *)selectedref;
+ ioport_field *field = (ioport_field *)selectedref;
dip_descriptor *dip;
/* add borders */
@@ -1193,14 +1193,14 @@ void ui_menu_settings_dip_switches::custom_render(void *selectedref, float top,
{
if (mame_stricmp(dip->name, "FAKE") != 0)
{
- const input_field_diplocation *diploc;
+ const ioport_diplocation *diploc;
UINT32 selectedmask = 0;
/* determine the mask of selected bits */
if (field != NULL)
- for (diploc = field->diploclist().first(); diploc != NULL; diploc = diploc->next())
- if (strcmp(dip->name, diploc->swname) == 0)
- selectedmask |= 1 << (diploc->swnum - 1);
+ for (diploc = field->first_diplocation(); diploc != NULL; diploc = diploc->next())
+ if (strcmp(dip->name, diploc->name()) == 0)
+ selectedmask |= 1 << (diploc->number() - 1);
/* draw one switch */
custom_render_one(x1, y1, x2, y1 + DIP_SWITCH_HEIGHT, dip, selectedmask);
@@ -1322,10 +1322,10 @@ void ui_menu_analog::handle()
/* if things changed, update */
if (newval != data->cur)
{
- input_field_user_settings settings;
+ ioport_field::user_settings settings;
/* get the settings and set the new value */
- input_field_get_user_settings(data->field, &settings);
+ data->field->get_user_settings(settings);
switch (data->type)
{
case ANALOG_ITEM_KEYSPEED: settings.delta = newval; break;
@@ -1333,7 +1333,7 @@ void ui_menu_analog::handle()
case ANALOG_ITEM_REVERSE: settings.reverse = newval; break;
case ANALOG_ITEM_SENSITIVITY: settings.sensitivity = newval; break;
}
- input_field_set_user_settings(data->field, &settings);
+ data->field->set_user_settings(settings);
/* rebuild the menu */
reset(UI_MENU_RESET_REMEMBER_POSITION);
@@ -1353,26 +1353,26 @@ ui_menu_analog::ui_menu_analog(running_machine &machine, render_container *conta
void ui_menu_analog::populate()
{
- input_field_config *field;
- input_port_config *port;
+ ioport_field *field;
+ ioport_port *port;
astring subtext;
astring text;
/* loop over input ports and add the items */
for (port = machine().ioport().first_port(); port != NULL; port = port->next())
- for (field = port->fieldlist().first(); field != NULL; field = field->next())
- if (input_type_is_analog(field->type) && input_condition_true(machine(), &field->condition, port->owner()))
+ for (field = port->first_field(); field != NULL; field = field->next())
+ if (field->is_analog() && field->enabled())
{
- input_field_user_settings settings;
+ ioport_field::user_settings settings;
int use_autocenter = false;
int type;
/* based on the type, determine if we enable autocenter */
- switch (field->type)
+ switch (field->type())
{
case IPT_POSITIONAL:
case IPT_POSITIONAL_V:
- if (field->flags & ANALOG_FLAG_WRAPS)
+ if (field->analog_wraps())
break;
case IPT_AD_STICK_X:
@@ -1385,10 +1385,13 @@ void ui_menu_analog::populate()
case IPT_PEDAL3:
use_autocenter = true;
break;
+
+ default:
+ break;
}
/* get the user settings */
- input_field_get_user_settings(field, &settings);
+ field->get_user_settings(settings);
/* iterate over types */
for (type = 0; type < ANALOG_ITEM_COUNT; type++)
@@ -1407,39 +1410,39 @@ void ui_menu_analog::populate()
{
default:
case ANALOG_ITEM_KEYSPEED:
- text.printf("%s Digital Speed", input_field_name(field));
+ text.printf("%s Digital Speed", field->name());
subtext.printf("%d", settings.delta);
data->min = 0;
data->max = 255;
data->cur = settings.delta;
- data->defvalue = field->delta;
+ data->defvalue = field->delta();
break;
case ANALOG_ITEM_CENTERSPEED:
- text.printf("%s Autocenter Speed", input_field_name(field));
+ text.printf("%s Autocenter Speed", field->name());
subtext.printf("%d", settings.centerdelta);
data->min = 0;
data->max = 255;
data->cur = settings.centerdelta;
- data->defvalue = field->centerdelta;
+ data->defvalue = field->centerdelta();
break;
case ANALOG_ITEM_REVERSE:
- text.printf("%s Reverse", input_field_name(field));
+ text.printf("%s Reverse", field->name());
subtext.cpy(settings.reverse ? "On" : "Off");
data->min = 0;
data->max = 1;
data->cur = settings.reverse;
- data->defvalue = ((field->flags & ANALOG_FLAG_REVERSE) != 0);
+ data->defvalue = field->analog_reverse();
break;
case ANALOG_ITEM_SENSITIVITY:
- text.printf("%s Sensitivity", input_field_name(field));
+ text.printf("%s Sensitivity", field->name());
subtext.printf("%d", settings.sensitivity);
data->min = 1;
data->max = 255;
data->cur = settings.sensitivity;
- data->defvalue = field->sensitivity;
+ data->defvalue = field->sensitivity();
break;
}