diff options
author | 2023-02-05 04:50:30 +1100 | |
---|---|---|
committer | 2023-02-05 05:01:40 +1100 | |
commit | b98fb7c98e5e44d436808eac46c927d3d0dc1f3f (patch) | |
tree | cd411d4fe24cd36862c78165723833e42de27303 /src/emu/input.cpp | |
parent | 519554c8464ba8e8641e474bc949a2a0beae77ae (diff) |
Small batch of input refactoring:
emu/input.cpp: Fixed regression in display of some joystick inputs.
osd/interface: Split up interface classes into a few more files to
reduce where the input device interface class needs to be included.
Made OSD independent of concrete input_device class.
osd/modules/input, emu/inputdev.cpp, emu/ioport.cpp: Allow input devices
to provide tokens for controls without standard item types and
additional default input assignments. Fixes issues assigning Yen and
Backslash on Japanese keyboards.
ui/textbox.cpp: Added a fixed-content text box menu class for future
use.
Got main.h out of emu.h as it’s only used in a very small number of
places, mostly for getting the application name. Added eminline.h to
attotime.h as it's used without emu.h. Cleaned up forward declarations
in emufwd.h a little.
Diffstat (limited to 'src/emu/input.cpp')
-rw-r--r-- | src/emu/input.cpp | 36 |
1 files changed, 27 insertions, 9 deletions
diff --git a/src/emu/input.cpp b/src/emu/input.cpp index 11ec532e69b..5775290d9f7 100644 --- a/src/emu/input.cpp +++ b/src/emu/input.cpp @@ -437,6 +437,18 @@ input_manager::~input_manager() //------------------------------------------------- +// class_enabled - return whether input device +// class is enabled +//------------------------------------------------- + +bool input_manager::class_enabled(input_device_class devclass) const +{ + assert(devclass >= DEVICE_CLASS_FIRST_VALID && devclass <= DEVICE_CLASS_LAST_VALID); + return m_class[devclass]->enabled(); +} + + +//------------------------------------------------- // add_device - add a representation of a host // input device //------------------------------------------------- @@ -659,16 +671,22 @@ std::string input_manager::code_name(input_code code) const } // append item name - redundant with joystick switch left/right/up/down - if ((device_class != DEVICE_CLASS_JOYSTICK) || (code.item_class() == ITEM_CLASS_SWITCH)) + bool const joydir = + (device_class == DEVICE_CLASS_JOYSTICK) && + (code.item_class() == ITEM_CLASS_SWITCH) && + (code.item_modifier() >= ITEM_MODIFIER_LEFT) && + (code.item_modifier() <= ITEM_MODIFIER_DOWN); + if (joydir) { - if ((code.item_modifier() < ITEM_MODIFIER_LEFT) || (code.item_modifier() > ITEM_MODIFIER_DOWN)) - str.append(item->name()); + str.append((*modifier_string_table)[code.item_modifier()]); + } + else + { + str.append(item->name()); + char const *const modifier = (*modifier_string_table)[code.item_modifier()]; + if (modifier && *modifier) + str.append(" ").append(modifier); } - - // append the modifier - char const *const modifier = (*modifier_string_table)[code.item_modifier()]; - if (modifier && *modifier) - str.append(" ").append(modifier); return str; } @@ -969,7 +987,7 @@ s32 input_manager::seq_axis_value(const input_seq &seq, input_item_class &itemcl // saturate mixed absolute values, report neutral type if (ITEM_CLASS_ABSOLUTE == itemclass) - result = std::clamp(result, osd::INPUT_ABSOLUTE_MIN, osd::INPUT_ABSOLUTE_MAX); + result = std::clamp(result, osd::input_device::ABSOLUTE_MIN, osd::input_device::ABSOLUTE_MAX); else if (ITEM_CLASS_INVALID == itemclass) itemclass = itemclasszero; return result; |