diff --git a/src/emu/inptport.c b/src/emu/inptport.c index 3ccbc1695e0..53b66434e6f 100644 --- a/src/emu/inptport.c +++ b/src/emu/inptport.c @@ -1582,6 +1582,21 @@ input_port_value input_port_read(running_machine *machine, const char *tag) } +/*------------------------------------------------- + input_port_read - return the value of + an device input port specified by tag +-------------------------------------------------*/ + +input_port_value input_port_read(running_machine *machine, device_t *device, const char *tag) +{ + astring tempstring; + const input_port_config *port = machine->port(device->baseconfig().subtag(tempstring, tag)); + if (port == NULL) + fatalerror("Unable to locate input port '%s'", tag); + return input_port_read_direct(port); +} + + /*------------------------------------------------- input_port_read_safe - return the value of an input port specified by tag, or a default diff --git a/src/emu/inptport.h b/src/emu/inptport.h index bd2159fa7de..01b04cfcca6 100644 --- a/src/emu/inptport.h +++ b/src/emu/inptport.h @@ -1137,6 +1137,9 @@ input_port_value input_port_read_direct(const input_port_config *port); /* return the value of an input port specified by tag */ input_port_value input_port_read(running_machine *machine, const char *tag); +/* return the value of an input port specified by tag */ +input_port_value input_port_read(running_machine *machine, device_t *device, const char *tag); + /* return the value of an input port specified by tag, or a default value if the port does not exist */ input_port_value input_port_read_safe(running_machine *machine, const char *tag, input_port_value defvalue);