vbox5: drop KEY_CAPSLOCK events on capslock="rom"

Guests are easily confused by spurious KEY_CAPSLOCK input events in
caps="rom" mode. These spurious events may reach the VMM if KEY_CAPSLOCK
is not pressed as first key in a combination and, therefore, is not
filtered as global key. Now, we filter KEY_CAPSLOCK in ROM mode in the
VMM explicitly, but let it pass in non-ROM mode.

Fixes #4087
This commit is contained in:
Christian Helmuth 2021-06-07 14:35:33 +02:00
parent 002037ce15
commit 37f1873f2e
2 changed files with 8 additions and 1 deletions

View File

@ -150,8 +150,14 @@ void GenodeConsole::_handle_input()
if (!_vbox_keyboard || !_vbox_mouse)
return;
bool const caps_lock_from_rom { _caps_lock.constructed() };
auto keyboard_submit = [&] (Input::Keycode key, bool release) {
/* don't confuse guests and drop CapsLock events in ROM mode */
if (caps_lock_from_rom && key == Input::KEY_CAPSLOCK)
return;
Scan_code scan_code(key);
unsigned char const release_bit = release ? 0x80 : 0;
@ -552,6 +558,7 @@ void GenodeConsole::_handle_sticky_keys()
/* remember last seen host caps lock state */
host_caps_lock = caps_lock;
/* CapsLock was toggled in ROM - inject press-release events */
if (trigger_caps_lock) {
_vbox_keyboard->PutScancode(Input::KEY_CAPSLOCK);
_vbox_keyboard->PutScancode(Input::KEY_CAPSLOCK | 0x80);

View File

@ -160,7 +160,7 @@ class GenodeConsole : public Console {
_input_sticky_keys_dispatcher(genode_env().ep(), *this, &GenodeConsole::handle_sticky_keys)
{
for (unsigned i = 0; i <= Input::KEY_MAX; i++)
_key_status[i] = 0;
_key_status[i] = false;
_input.sigh(_input_signal_dispatcher);