mirror of
https://github.com/TomHarte/CLK.git
synced 2025-04-16 16:38:41 +00:00
Implements clear_all_keys
.
This commit is contained in:
parent
8ef9a932aa
commit
eeaccb8ac0
@ -96,6 +96,7 @@ Keyboard::Keyboard(Serial::Line<true> &output) : output_(output) {
|
||||
}*/
|
||||
|
||||
void Keyboard::set_key_state(uint16_t key, bool is_pressed) {
|
||||
pressed_[key] = is_pressed;
|
||||
output_.write<false>(
|
||||
HalfCycles(60),
|
||||
uint8_t(((key << 1) | (is_pressed ? 0 : 1)) ^ 0xff)
|
||||
@ -103,6 +104,9 @@ void Keyboard::set_key_state(uint16_t key, bool is_pressed) {
|
||||
}
|
||||
|
||||
void Keyboard::clear_all_keys() {
|
||||
for(uint16_t c = 0; c < uint16_t(pressed_.size()); c++) {
|
||||
if(pressed_[c]) set_key_state(c, false);
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - KeyboardMapper.
|
||||
|
@ -9,6 +9,7 @@
|
||||
#ifndef Machines_Amiga_Keyboard_hpp
|
||||
#define Machines_Amiga_Keyboard_hpp
|
||||
|
||||
#include <array>
|
||||
#include <cstdint>
|
||||
#include "../KeyboardMachine.hpp"
|
||||
#include "../../Components/Serial/Line.hpp"
|
||||
@ -112,6 +113,7 @@ class Keyboard {
|
||||
uint8_t lines_ = 0;
|
||||
|
||||
Serial::Line<true> &output_;
|
||||
std::array<bool, 128> pressed_{};
|
||||
};
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user