Allow saved states to be bound to joystick buttons

This commit is contained in:
Victor Vasiliev 2016-02-02 15:27:21 -05:00
parent c626466050
commit f6331aaf65

View File

@ -37,6 +37,8 @@ enum
LOADSAVE_SAVE LOADSAVE_SAVE
}; };
#define MAX_SAVED_STATE_JOYSTICK 4
/*************************************************************************** /***************************************************************************
LOCAL VARIABLES 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))) 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'; file = id - ITEM_ID_0_PAD + '0';
if (file == 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 // display a popup indicating that the save will proceed
sprintf(filename, "%c", file);
if (state == LOADSAVE_SAVE) if (state == LOADSAVE_SAVE)
{ {
machine.popmessage("Save to position %c", file); machine.popmessage("Save to position %s", filename);
machine.schedule_save(filename); machine.schedule_save(filename);
} }
else else
{ {
machine.popmessage("Load from position %c", file); machine.popmessage("Load from position %s", filename);
machine.schedule_load(filename); machine.schedule_load(filename);
} }