summaryrefslogtreecommitdiffstatshomepage
path: root/src/emu/ui/ui.cpp
diff options
context:
space:
mode:
author Victor Vasiliev <vasilvv@mit.edu>2016-02-02 15:27:21 -0500
committer Victor Vasiliev <vasilvv@mit.edu>2016-02-02 16:18:57 -0500
commitf6331aaf656437913eb63e7c51439505aec6571f (patch)
treef84b1ab3630c0050b2c4eeb27da9d7982255f3bb /src/emu/ui/ui.cpp
parentc626466050146c9ddb8533222c5486dc3125e07b (diff)
Allow saved states to be bound to joystick buttons
Diffstat (limited to 'src/emu/ui/ui.cpp')
-rw-r--r--src/emu/ui/ui.cpp27
1 files changed, 23 insertions, 4 deletions
diff --git a/src/emu/ui/ui.cpp b/src/emu/ui/ui.cpp
index df16d384ebb..f32f35ca71a 100644
--- a/src/emu/ui/ui.cpp
+++ b/src/emu/ui/ui.cpp
@@ -37,6 +37,8 @@ enum
LOADSAVE_SAVE
};
+#define MAX_SAVED_STATE_JOYSTICK 4
+
/***************************************************************************
LOCAL VARIABLES
@@ -1759,18 +1761,35 @@ UINT32 ui_manager::handler_load_save(running_machine &machine, render_container
if (machine.input().code_pressed_once(input_code(DEVICE_CLASS_KEYBOARD, 0, ITEM_CLASS_SWITCH, ITEM_MODIFIER_NONE, id)))
file = id - ITEM_ID_0_PAD + '0';
if (file == 0)
- return state;
+ {
+ bool found = false;
+
+ for (int joy_index = 0; joy_index <= MAX_SAVED_STATE_JOYSTICK; joy_index++)
+ for (input_item_id id = ITEM_ID_BUTTON1; id <= ITEM_ID_BUTTON32; ++id)
+ if (machine.input().code_pressed_once(input_code(DEVICE_CLASS_JOYSTICK, joy_index, ITEM_CLASS_SWITCH, ITEM_MODIFIER_NONE, id)))
+ {
+ snprintf(filename, sizeof(filename), "joy%i-%i", joy_index, id - ITEM_ID_BUTTON1 + 1);
+ found = true;
+ break;
+ }
+
+ if (!found)
+ return state;
+ }
+ else
+ {
+ sprintf(filename, "%c", file);
+ }
// display a popup indicating that the save will proceed
- sprintf(filename, "%c", file);
if (state == LOADSAVE_SAVE)
{
- machine.popmessage("Save to position %c", file);
+ machine.popmessage("Save to position %s", filename);
machine.schedule_save(filename);
}
else
{
- machine.popmessage("Load from position %c", file);
+ machine.popmessage("Load from position %s", filename);
machine.schedule_load(filename);
}