Previous 199869 Revisions Next

r44645 Tuesday 2nd February, 2016 at 21:18:57 UTC by Victor Vasiliev
Allow saved states to be bound to joystick buttons
[src/emu/ui]ui.cpp

trunk/src/emu/ui/ui.cpp
r253156r253157
3737   LOADSAVE_SAVE
3838};
3939
40#define MAX_SAVED_STATE_JOYSTICK   4
4041
42
4143/***************************************************************************
4244    LOCAL VARIABLES
4345***************************************************************************/
r253156r253157
17591761         if (machine.input().code_pressed_once(input_code(DEVICE_CLASS_KEYBOARD, 0, ITEM_CLASS_SWITCH, ITEM_MODIFIER_NONE, id)))
17601762            file = id - ITEM_ID_0_PAD + '0';
17611763   if (file == 0)
1762      return state;
1764   {
1765      bool found = false;
17631766
1767      for (int joy_index = 0; joy_index <= MAX_SAVED_STATE_JOYSTICK; joy_index++)
1768         for (input_item_id id = ITEM_ID_BUTTON1; id <= ITEM_ID_BUTTON32; ++id)
1769            if (machine.input().code_pressed_once(input_code(DEVICE_CLASS_JOYSTICK, joy_index, ITEM_CLASS_SWITCH, ITEM_MODIFIER_NONE, id)))
1770            {
1771               snprintf(filename, sizeof(filename), "joy%i-%i", joy_index, id - ITEM_ID_BUTTON1 + 1);
1772               found = true;
1773               break;
1774            }
1775
1776      if (!found)
1777         return state;
1778   }
1779   else
1780   {
1781      sprintf(filename, "%c", file);
1782   }
1783
17641784   // display a popup indicating that the save will proceed
1765   sprintf(filename, "%c", file);
17661785   if (state == LOADSAVE_SAVE)
17671786   {
1768      machine.popmessage("Save to position %c", file);
1787      machine.popmessage("Save to position %s", filename);
17691788      machine.schedule_save(filename);
17701789   }
17711790   else
17721791   {
1773      machine.popmessage("Load from position %c", file);
1792      machine.popmessage("Load from position %s", filename);
17741793      machine.schedule_load(filename);
17751794   }
17761795


Previous 199869 Revisions Next


© 1997-2024 The MAME Team