summaryrefslogtreecommitdiffstatshomepage
path: root/src/emu/inputdev.cpp
diff options
context:
space:
mode:
author Vas Crabb <vas@vastheman.com>2020-12-18 15:54:52 +1100
committer Vas Crabb <vas@vastheman.com>2020-12-18 15:54:52 +1100
commit1df245cb99882892678216c3d0c6e243611d627c (patch)
treea8f3563a74d58755f4a82d4cbfc2406cf79543b3 /src/emu/inputdev.cpp
parentff9c1a0ca91f925e5c23b22a92a53c83f9f655ba (diff)
More Lua engine clean-up and documentation, resulting in core cleanup.
More Lua interface cleanup, additional properties and methods, and documentation migration/expansion. Emulated switch inputs can have "not" codes applied to host input axis directions. It works the same way as host switch inputs - push twice for a "not" prefix. Input polling helpers no longer need to store state in the input device items. There’s less leakage, and less chance of things interfering with each other. Allow snapshot view options to be configured through the internal UI via the video options menu. Made video options menus place initial focus on the currently selected view item. Removed some crud from the menu base class. Fixed the description of the "snapview" option. The value to get raw screen pixels was changed to "native" a long time ago but the description was never updated. Re-arranged the Golden Poker button lamps so that the 6-button layouts for Jolli Witch and Wild Witch make sense. In 6-button mode, the hold buttons double as bonus game and bet buttons, but the lamp outputs don't change. The simplest way to deal with this without requiring the user to switch views or using layout scripting is to place the dedicated buttons directly below the hold buttons that correspond to them. Removed some software list data that was redundantly copied into device_image_interface (m_supported was never even set, so it didn't even work), and made crc() work better (previously it wasn't recalculuated after unloading and loading another image). Made strformat.h and devcb.h play nicer with C++17 and pre-standard C++20. Format precision now correctly limits the length of string views. Confirmed that strformat.{h,cpp} works with pre-standard C++20 support in GCC 9. Removed an auto_alloc from cpu/arm7.
Diffstat (limited to 'src/emu/inputdev.cpp')
-rw-r--r--src/emu/inputdev.cpp50
1 files changed, 21 insertions, 29 deletions
diff --git a/src/emu/inputdev.cpp b/src/emu/inputdev.cpp
index 4c2afdd7e7a..66a0794f6cd 100644
--- a/src/emu/inputdev.cpp
+++ b/src/emu/inputdev.cpp
@@ -31,7 +31,7 @@ public:
virtual s32 read_as_switch(input_item_modifier modifier) override;
virtual s32 read_as_relative(input_item_modifier modifier) override;
virtual s32 read_as_absolute(input_item_modifier modifier) override;
- virtual bool item_check_axis(input_item_modifier modifier) override;
+ virtual bool item_check_axis(input_item_modifier modifiers, s32 memory) override;
// steadykey helper
bool steadykey_changed();
@@ -57,7 +57,7 @@ public:
virtual s32 read_as_switch(input_item_modifier modifier) override;
virtual s32 read_as_relative(input_item_modifier modifier) override;
virtual s32 read_as_absolute(input_item_modifier modifier) override;
- virtual bool item_check_axis(input_item_modifier modifier) override;
+ virtual bool item_check_axis(input_item_modifier modifier, s32 memory) override;
};
@@ -74,7 +74,7 @@ public:
virtual s32 read_as_switch(input_item_modifier modifier) override;
virtual s32 read_as_relative(input_item_modifier modifier) override;
virtual s32 read_as_absolute(input_item_modifier modifier) override;
- virtual bool item_check_axis(input_item_modifier modifier) override;
+ virtual bool item_check_axis(input_item_modifier modifier, s32 memory) override;
};
@@ -675,16 +675,17 @@ input_device_item::input_device_item(input_device &device, const char *name, voi
m_itemid(itemid),
m_itemclass(itemclass),
m_getstate(getstate),
- m_current(0),
- m_memory(0)
+ m_current(0)
{
- // use a standard token name for know item IDs
const char *standard_token = manager().standard_token(itemid);
- if (standard_token != nullptr)
+ if (standard_token)
+ {
+ // use a standard token name for know item IDs
m_token.assign(standard_token);
-
- // otherwise, create a tokenized name
- else {
+ }
+ else
+ {
+ // otherwise, create a tokenized name
m_token.assign(name);
strmakeupper(m_token);
strdelchr(m_token, ' ');
@@ -707,19 +708,10 @@ input_device_item::~input_device_item()
// to trigger a read when polling
//-------------------------------------------------
-bool input_device_item::check_axis(input_item_modifier modifier)
+bool input_device_item::check_axis(input_item_modifier modifier, s32 memory)
{
- // if we've already reported this one, don't bother
- if (m_memory == INVALID_AXIS_VALUE)
- return false;
-
- if (item_check_axis(modifier))
- {
- m_memory = INVALID_AXIS_VALUE;
- return true;
- }
-
- return false;
+ // use INVALID_AXIS_VALUE as a short-circuit
+ return (memory != INVALID_AXIS_VALUE) && item_check_axis(modifier, memory);
}
@@ -801,7 +793,7 @@ s32 input_device_switch_item::read_as_absolute(input_item_modifier modifier)
// enough to trigger a read when polling
//-------------------------------------------------
-bool input_device_switch_item::item_check_axis(input_item_modifier modifier)
+bool input_device_switch_item::item_check_axis(input_item_modifier modifier, s32 memory)
{
return false;
}
@@ -889,12 +881,12 @@ s32 input_device_relative_item::read_as_absolute(input_item_modifier modifier)
// enough to trigger a read when polling
//-------------------------------------------------
-bool input_device_relative_item::item_check_axis(input_item_modifier modifier)
+bool input_device_relative_item::item_check_axis(input_item_modifier modifier, s32 memory)
{
- s32 curval = read_as_relative(modifier);
+ const s32 curval = read_as_relative(modifier);
// for relative axes, look for ~20 pixels movement
- return std::abs(curval - memory()) > 20 * INPUT_RELATIVE_PER_PIXEL;
+ return std::abs(curval - memory) > (20 * INPUT_RELATIVE_PER_PIXEL);
}
@@ -1002,15 +994,15 @@ s32 input_device_absolute_item::read_as_absolute(input_item_modifier modifier)
// enough to trigger a read when polling
//-------------------------------------------------
-bool input_device_absolute_item::item_check_axis(input_item_modifier modifier)
+bool input_device_absolute_item::item_check_axis(input_item_modifier modifier, s32 memory)
{
// ignore min/max for lightguns
// so the selection will not be affected by a gun going out of range
- s32 curval = read_as_absolute(modifier);
+ const s32 curval = read_as_absolute(modifier);
if (m_device.devclass() == DEVICE_CLASS_LIGHTGUN &&
(curval == INPUT_ABSOLUTE_MAX || curval == INPUT_ABSOLUTE_MIN))
return false;
// for absolute axes, look for 25% of maximum
- return std::abs(curval - memory()) > (INPUT_ABSOLUTE_MAX - INPUT_ABSOLUTE_MIN) / 4;
+ return std::abs(curval - memory) > ((INPUT_ABSOLUTE_MAX - INPUT_ABSOLUTE_MIN) / 4);
}