summaryrefslogtreecommitdiffstatshomepage
path: root/src/emu/input.cpp
diff options
context:
space:
mode:
author Vas Crabb <vas@vastheman.com>2020-12-16 02:18:52 +1100
committer Vas Crabb <vas@vastheman.com>2020-12-16 02:18:52 +1100
commit503332a9867f9aa27fc77cd9e762626d22d213ef (patch)
treee60fba6664a3d980d5f62846982bde381a25c3f7 /src/emu/input.cpp
parentb5f78fe38358b68fc54416328f764cf4e2bf3333 (diff)
-Lua cleanup and documentation migration checkpoint.
* Cleaned up some more of the Lua inteface. Mostly replacing methods with properties, some consistency fixes, a few renames, some more exposed functionality, and a couple of properties that have no business being set from scripts made read-only. * Moved a lot more Lua documentation out of source comments into the documentation, and expanded on it in the process. * Got more UI code out of the input manager. * Changed input sequence poller to a polymorphic class where you specify your intention upfront. * Changed the cheat plugin to use UI Clear to clear hotkey assignments and leave them unchanged if the user starts assignment but doesn't press any switches. * Ported AJR's fix for over-eager double-click recognition from SDL to Windows OSD. -goldnpkr.cpp: Cleaned up inputs, using standard keyout and payout types and key assignments.
Diffstat (limited to 'src/emu/input.cpp')
-rw-r--r--src/emu/input.cpp198
1 files changed, 4 insertions, 194 deletions
diff --git a/src/emu/input.cpp b/src/emu/input.cpp
index 36f6e3f5fe6..ffcdaf722be 100644
--- a/src/emu/input.cpp
+++ b/src/emu/input.cpp
@@ -672,7 +672,7 @@ bool input_manager::code_pressed_once(input_code code)
if (m_switch_memory[memnum] == code)
{
// if no longer pressed, clear entry
- if (curvalue == false)
+ if (!curvalue)
m_switch_memory[memnum] = INPUT_CODE_INVALID;
// always return false
@@ -684,11 +684,11 @@ bool input_manager::code_pressed_once(input_code code)
empty = memnum;
}
- // if we get here, we were not previously pressed; if still not pressed, return 0
- if (curvalue == false)
+ // if we get here, we were not previously pressed; if still not pressed, return false
+ if (!curvalue)
return false;
- // otherwise, add ourself to the memory and return 1
+ // otherwise, add the code to the memory and return true
assert(empty != -1);
if (empty != -1)
m_switch_memory[empty] = code;
@@ -697,196 +697,6 @@ bool input_manager::code_pressed_once(input_code code)
//-------------------------------------------------
-// reset_polling - reset memories in preparation
-// for polling
-//-------------------------------------------------
-
-void input_manager::reset_polling()
-{
- // reset switch memory
- reset_memory();
-
- // iterate over device classes and devices
- for (input_device_class devclass = DEVICE_CLASS_FIRST_VALID; devclass <= DEVICE_CLASS_LAST_VALID; ++devclass)
- for (int devnum = 0; devnum <= m_class[devclass]->maxindex(); devnum++)
- {
- // fetch the device; ignore if nullptr
- input_device *device = m_class[devclass]->device(devnum);
- if (device == nullptr)
- continue;
-
- // iterate over items within each device
- for (input_item_id itemid = ITEM_ID_FIRST_VALID; itemid <= device->maxitem(); ++itemid)
- {
- // for any non-switch items, set memory equal to the current value
- input_device_item *item = device->item(itemid);
- if (item != nullptr && item->itemclass() != ITEM_CLASS_SWITCH)
- item->set_memory(code_value(item->code()));
- }
- }
-}
-
-
-//-------------------------------------------------
-// poll_switches - poll for any input
-//-------------------------------------------------
-
-input_code input_manager::poll_switches()
-{
- // iterate over device classes and devices
- for (input_device_class devclass = DEVICE_CLASS_FIRST_VALID; devclass <= DEVICE_CLASS_LAST_VALID; ++devclass)
- {
- // skip device class if disabled
- if (!m_class[devclass]->enabled())
- continue;
-
- for (int devnum = 0; devnum <= m_class[devclass]->maxindex(); devnum++)
- {
- // fetch the device; ignore if nullptr
- input_device *device = m_class[devclass]->device(devnum);
- if (device == nullptr)
- continue;
-
- // iterate over items within each device
- for (input_item_id itemid = ITEM_ID_FIRST_VALID; itemid <= device->maxitem(); ++itemid)
- {
- input_device_item *item = device->item(itemid);
- if (item != nullptr)
- {
- input_code code = item->code();
-
- // if the item is natively a switch, poll it
- if (item->itemclass() == ITEM_CLASS_SWITCH)
- {
- if (code_pressed_once(code))
- return code;
- else
- continue;
- }
-
- // skip if there is not enough axis movement
- if (!item->check_axis(code.item_modifier()))
- continue;
-
- // otherwise, poll axes digitally
- code.set_item_class(ITEM_CLASS_SWITCH);
-
- // if this is a joystick X axis, check with left/right modifiers
- if (devclass == DEVICE_CLASS_JOYSTICK && code.item_id() == ITEM_ID_XAXIS)
- {
- code.set_item_modifier(ITEM_MODIFIER_LEFT);
- if (code_pressed_once(code))
- return code;
- code.set_item_modifier(ITEM_MODIFIER_RIGHT);
- if (code_pressed_once(code))
- return code;
- }
-
- // if this is a joystick Y axis, check with up/down modifiers
- else if (devclass == DEVICE_CLASS_JOYSTICK && code.item_id() == ITEM_ID_YAXIS)
- {
- code.set_item_modifier(ITEM_MODIFIER_UP);
- if (code_pressed_once(code))
- return code;
- code.set_item_modifier(ITEM_MODIFIER_DOWN);
- if (code_pressed_once(code))
- return code;
- }
-
- // any other axis, check with pos/neg modifiers
- else
- {
- code.set_item_modifier(ITEM_MODIFIER_POS);
- if (code_pressed_once(code))
- return code;
- code.set_item_modifier(ITEM_MODIFIER_NEG);
- if (code_pressed_once(code))
- return code;
- }
- }
- }
- }
- }
-
- // if nothing, return an invalid code
- return INPUT_CODE_INVALID;
-}
-
-
-//-------------------------------------------------
-// poll_keyboard_switches - poll for any
-// keyboard-specific input
-//-------------------------------------------------
-
-input_code input_manager::poll_keyboard_switches()
-{
- // iterate over devices within each class
- input_class &keyboard_class = device_class(DEVICE_CLASS_KEYBOARD);
- for (int devnum = 0; devnum < keyboard_class.maxindex(); devnum++)
- {
- // fetch the device; ignore if nullptr
- input_device *device = keyboard_class.device(devnum);
- if (device == nullptr)
- continue;
-
- // iterate over items within each device
- for (input_item_id itemid = ITEM_ID_FIRST_VALID; itemid <= device->maxitem(); ++itemid)
- {
- input_device_item *item = device->item(itemid);
- if (item != nullptr && item->itemclass() == ITEM_CLASS_SWITCH)
- {
- input_code code = item->code();
- if (code_pressed_once(code))
- return code;
- }
- }
- }
-
- // if nothing, return an invalid code
- return INPUT_CODE_INVALID;
-}
-
-
-//-------------------------------------------------
-// poll_axes - poll for any input
-//-------------------------------------------------
-
-input_code input_manager::poll_axes()
-{
- // iterate over device classes and devices
- for (input_device_class devclass = DEVICE_CLASS_FIRST_VALID; devclass <= DEVICE_CLASS_LAST_VALID; ++devclass)
- {
- // skip device class if disabled
- if (!m_class[devclass]->enabled())
- continue;
-
- for (int devnum = 0; devnum <= m_class[devclass]->maxindex(); devnum++)
- {
- // fetch the device; ignore if nullptr
- input_device *device = m_class[devclass]->device(devnum);
- if (device == nullptr)
- continue;
-
- // iterate over items within each device
- for (input_item_id itemid = ITEM_ID_FIRST_VALID; itemid <= device->maxitem(); ++itemid)
- {
- input_device_item *item = device->item(itemid);
- if (item != nullptr && item->itemclass() != ITEM_CLASS_SWITCH)
- {
- input_code code = item->code();
- if (item->check_axis(code.item_modifier()))
- return code;
- }
- }
- }
- }
-
- // if nothing, return an invalid code
- return INPUT_CODE_INVALID;
-}
-
-
-//-------------------------------------------------
// device_from_code - given an input_code return
// a pointer to the associated device
//-------------------------------------------------