From e773b331cd382b1168e20c56779d5664f26b6c0d Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Mon, 15 Feb 2021 15:05:46 -0500 Subject: [PATCH] Implements register 2 listen. --- Machines/Apple/ADB/Keyboard.cpp | 15 +++++++++++++++ Machines/Apple/ADB/Keyboard.hpp | 1 + 2 files changed, 16 insertions(+) diff --git a/Machines/Apple/ADB/Keyboard.cpp b/Machines/Apple/ADB/Keyboard.cpp index c76faee32..1c3ef4d94 100644 --- a/Machines/Apple/ADB/Keyboard.cpp +++ b/Machines/Apple/ADB/Keyboard.cpp @@ -51,10 +51,25 @@ void Keyboard::perform_command(const Command &command) { } break; + case Command::Type::Listen: + // If a listen is incoming for register 2, prepare to capture LED statuses. + if(command.reg == 2) { + receive_bytes(2); + } + break; + + default: break; } } +void Keyboard::did_receive_data(const Command &, const std::vector &data) { + // This must be a register 2 listen; update the LED statuses. + // TODO: and possibly display these. + modifiers_ = (modifiers_ & 0xfff8) | (data[1] & 7); +} + + bool Keyboard::set_key_pressed(Key key, bool is_pressed) { // ADB keyboard events: low 7 bits are a key code; bit 7 is either 0 for pressed or 1 for released. std::lock_guard lock_guard(keys_mutex_); diff --git a/Machines/Apple/ADB/Keyboard.hpp b/Machines/Apple/ADB/Keyboard.hpp index 47adf1f4e..a8213dd28 100644 --- a/Machines/Apple/ADB/Keyboard.hpp +++ b/Machines/Apple/ADB/Keyboard.hpp @@ -104,6 +104,7 @@ class Keyboard: public ReactiveDevice { private: void perform_command(const Command &command) override; + void did_receive_data(const Command &, const std::vector &) override; std::mutex keys_mutex_; std::array pressed_keys_;