mirror of
https://github.com/TomHarte/CLK.git
synced 2025-02-05 05:34:20 +00:00
Implements register 2 listen.
This commit is contained in:
parent
99c21925f4
commit
e773b331cd
@ -51,10 +51,25 @@ void Keyboard::perform_command(const Command &command) {
|
|||||||
}
|
}
|
||||||
break;
|
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;
|
default: break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Keyboard::did_receive_data(const Command &, const std::vector<uint8_t> &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) {
|
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.
|
// 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_);
|
std::lock_guard lock_guard(keys_mutex_);
|
||||||
|
@ -104,6 +104,7 @@ class Keyboard: public ReactiveDevice {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
void perform_command(const Command &command) override;
|
void perform_command(const Command &command) override;
|
||||||
|
void did_receive_data(const Command &, const std::vector<uint8_t> &) override;
|
||||||
|
|
||||||
std::mutex keys_mutex_;
|
std::mutex keys_mutex_;
|
||||||
std::array<bool, 128> pressed_keys_;
|
std::array<bool, 128> pressed_keys_;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user