summaryrefslogtreecommitdiffstatshomepage
path: root/src/emu/input.cpp
diff options
context:
space:
mode:
author Vas Crabb <vas@vastheman.com>2021-11-06 13:52:48 +1100
committer Vas Crabb <vas@vastheman.com>2021-11-06 13:52:48 +1100
commit270276c4d30721dc397de6d8c92334469ce37243 (patch)
tree99e802773ecec08ade94f574fdca3d665d726901 /src/emu/input.cpp
parent07e55935cf49c94a94dcc75d8240d0733d1ed5d7 (diff)
-Enabled complex combinations for analog axes:
* Made it possible to add digital controls to axis settings as enables. * Mix multiple analog controls assigned to an axis setting. * Added a "reverse" modifier for analog controls (useful with mixing). * Fixed an issue assigning mouse axes using multiple mouse-like devices with -nomultimouse. -frontend: More cleanup: * Got rid of some abuse of "special main menus". * Added a helper class for auto-pause menus that don't spawn submenus. * Got rid of the fake menu that schedules an exit on the first frame. * Turned the confirm quit prompt into a menu, eliminated one more special-cased event loop. * Fixed the confirm quit prompt resuming if you return to emulation if you weren't paused to begin with. -bus/centronics: Fixed conflicting DIP locations, reversed order and inverted polarity for Epson printers. * Also added the LX-810 (without L suffix) DIP switches for reference - we don't have a device for this printer yet.
Diffstat (limited to 'src/emu/input.cpp')
-rw-r--r--src/emu/input.cpp78
1 files changed, 45 insertions, 33 deletions
diff --git a/src/emu/input.cpp b/src/emu/input.cpp
index b58958a6935..c8959349b88 100644
--- a/src/emu/input.cpp
+++ b/src/emu/input.cpp
@@ -97,6 +97,7 @@ static const code_string_table devclass_string_table[] =
// token strings for item modifiers
static const code_string_table modifier_token_table[] =
{
+ { ITEM_MODIFIER_REVERSE, "REVERSE" },
{ ITEM_MODIFIER_POS, "POS" },
{ ITEM_MODIFIER_NEG, "NEG" },
{ ITEM_MODIFIER_LEFT, "LEFT" },
@@ -109,6 +110,7 @@ static const code_string_table modifier_token_table[] =
// friendly strings for item modifiers
static const code_string_table modifier_string_table[] =
{
+ { ITEM_MODIFIER_REVERSE, "Reverse" },
{ ITEM_MODIFIER_POS, "+" },
{ ITEM_MODIFIER_NEG, "-" },
{ ITEM_MODIFIER_LEFT, "Left" },
@@ -632,21 +634,21 @@ s32 input_manager::code_value(input_code code)
// process items according to their native type
switch (targetclass)
{
- case ITEM_CLASS_ABSOLUTE:
- if (result == 0)
- result = item->read_as_absolute(code.item_modifier());
- break;
+ case ITEM_CLASS_ABSOLUTE:
+ if (result == 0)
+ result = item->read_as_absolute(code.item_modifier());
+ break;
- case ITEM_CLASS_RELATIVE:
- result += item->read_as_relative(code.item_modifier());
- break;
+ case ITEM_CLASS_RELATIVE:
+ result += item->read_as_relative(code.item_modifier());
+ break;
- case ITEM_CLASS_SWITCH:
- result |= item->read_as_switch(code.item_modifier());
- break;
+ case ITEM_CLASS_SWITCH:
+ result |= item->read_as_switch(code.item_modifier());
+ break;
- default:
- break;
+ default:
+ break;
}
}
} while (0);
@@ -1054,38 +1056,40 @@ s32 input_manager::seq_axis_value(const input_seq &seq, input_item_class &itemcl
bool enable = true;
for (int codenum = 0; ; codenum++)
{
- // handle NOT
input_code code = seq[codenum];
if (code == input_seq::not_code)
+ {
+ // handle NOT
invert = true;
-
- // handle OR and END
- else if (code == input_seq::or_code || code == input_seq::end_code)
+ }
+ else if (code == input_seq::end_code)
{
- // if we have a positive result from the previous set, we're done
- if (itemclass != ITEM_CLASS_INVALID || code == input_seq::end_code)
- break;
+ // handle END
+ break;
+ }
+ else if (code == input_seq::or_code)
+ {
+ // handle OR
- // otherwise, reset our state
- result = 0;
+ // reset invert and enable for the next group
invert = false;
enable = true;
}
-
- // handle everything else only if we're still enabled
else if (enable)
{
+ // handle everything else only if we're still enabled
+
// switch codes serve as enables
if (code.item_class() == ITEM_CLASS_SWITCH)
{
// AND against previous digital codes
if (enable)
- enable &= code_pressed(code) ^ invert;
+ enable = code_pressed(code) ^ invert;
+ // FIXME: need to clear current group value if enable became false
}
-
- // non-switch codes are analog values
else
{
+ // non-switch codes are analog values
s32 value = code_value(code);
// if we got a 0 value, don't do anything except remember the first type
@@ -1094,19 +1098,23 @@ s32 input_manager::seq_axis_value(const input_seq &seq, input_item_class &itemcl
if (itemclasszero == ITEM_CLASS_INVALID)
itemclasszero = code.item_class();
}
-
- // non-zero absolute values stick
else if (code.item_class() == ITEM_CLASS_ABSOLUTE)
{
+ // non-zero absolute values override relative values
+ if (itemclass == ITEM_CLASS_ABSOLUTE)
+ result += value;
+ else
+ result = value;
itemclass = ITEM_CLASS_ABSOLUTE;
- result = value;
}
-
- // non-zero relative values accumulate
else if (code.item_class() == ITEM_CLASS_RELATIVE)
{
- itemclass = ITEM_CLASS_RELATIVE;
- result += value;
+ // non-zero relative values accumulate in the absence of absolute values
+ if (itemclass != ITEM_CLASS_ABSOLUTE)
+ {
+ result += value;
+ itemclass = ITEM_CLASS_RELATIVE;
+ }
}
}
@@ -1115,6 +1123,10 @@ s32 input_manager::seq_axis_value(const input_seq &seq, input_item_class &itemcl
}
}
+ // saturate mixed absolute values
+ if (itemclass == ITEM_CLASS_ABSOLUTE)
+ result = std::clamp(result, INPUT_ABSOLUTE_MIN, INPUT_ABSOLUTE_MAX);
+
// if the caller wants to know the type, provide it
if (result == 0)
itemclass = itemclasszero;