summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
author Vas Crabb <cuavas@users.noreply.github.com>2017-01-01 18:18:13 +1100
committer GitHub <noreply@github.com>2017-01-01 18:18:13 +1100
commit9d329bfc0c830341dced0bf7b7a3777b0cac4d8b (patch)
tree6cca7dbe0ea0add48805a7d5afdb21022585e309
parent1ded75e685bd3f9a460eb64abfbe88132c8f3892 (diff)
parentdd1d40b9fd415fd08a8fdbbfa6fb4c9786c1e768 (diff)
Merge pull request #1901 from ajrhacker/natkeytoggle
Correct natural keyboard handling of toggle keys
-rw-r--r--src/emu/natkeyboard.cpp25
1 files changed, 23 insertions, 2 deletions
diff --git a/src/emu/natkeyboard.cpp b/src/emu/natkeyboard.cpp
index fd39bc7b5e0..a5d856a20e9 100644
--- a/src/emu/natkeyboard.cpp
+++ b/src/emu/natkeyboard.cpp
@@ -372,7 +372,13 @@ void natural_keyboard::set_in_use(bool usage)
for (auto &port : machine().ioport().ports())
for (ioport_field &field : port.second->fields())
if (field.type() == IPT_KEYBOARD)
+ {
field.live().lockout = usage;
+
+ // clear pressed status when going out of use
+ if (!usage)
+ field.set_value(0);
+ }
}
}
@@ -722,8 +728,23 @@ void natural_keyboard::timer(void *ptr, int param)
const bool new_keydown = !m_status_keydown;
const keycode_map_entry *const code = find_code(m_buffer[m_bufbegin]);
if (code != nullptr)
- for (int fieldnum = 0; fieldnum < ARRAY_LENGTH(code->field) && code->field[fieldnum] != nullptr; fieldnum++)
- code->field[fieldnum]->set_value(new_keydown);
+ {
+ for (int fieldnum = 0; fieldnum < ARRAY_LENGTH(code->field); fieldnum++)
+ {
+ ioport_field *const field = code->field[fieldnum];
+ if (field == nullptr)
+ break;
+
+ // special handling for toggle fields
+ if (field->live().toggle)
+ {
+ if (new_keydown)
+ field->set_value(!field->digital_value());
+ }
+ else
+ field->set_value(new_keydown);
+ }
+ }
// proceed to next character when keydown expires
if (!new_keydown)