1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-12-25 18:30:21 +00:00

Adds a reference to the calling keyboard in reset_all_keys.

This commit is contained in:
Thomas Harte 2017-10-14 22:07:11 -04:00
parent 4f289ab10b
commit 3a05ce36de
4 changed files with 6 additions and 6 deletions

View File

@ -24,7 +24,7 @@ void Keyboard::set_key_pressed(Key key, bool is_pressed) {
void Keyboard::reset_all_keys() {
std::fill(key_states_.begin(), key_states_.end(), false);
if(delegate_) delegate_->reset_all_keys();
if(delegate_) delegate_->reset_all_keys(this);
}
void Keyboard::set_delegate(Delegate *delegate) {

View File

@ -46,11 +46,11 @@ class Keyboard {
// Delegate interface.
struct Delegate {
virtual void keyboard_did_change_key(Keyboard *keyboard, Key key, bool is_pressed) = 0;
virtual void reset_all_keys() = 0;
virtual void reset_all_keys(Keyboard *keyboard) = 0;
};
void set_delegate(Delegate *delegate);
bool get_key_state(Key key);
private:
std::vector<bool> key_states_;
Delegate *delegate_ = nullptr;

View File

@ -19,7 +19,7 @@ void Machine::keyboard_did_change_key(Inputs::Keyboard *keyboard, Inputs::Keyboa
if(mapped_key != KeyNotMapped) set_key_state(mapped_key, is_pressed);
}
void Machine::reset_all_keys() {
void Machine::reset_all_keys(Inputs::Keyboard *keyboard) {
// TODO: unify naming.
clear_all_keys();
}

View File

@ -59,8 +59,8 @@ class Machine: public Inputs::Keyboard::Delegate {
virtual KeyboardMapper &get_keyboard_mapper() = 0;
private:
void keyboard_did_change_key(Inputs::Keyboard *keyboard, Inputs::Keyboard::Key key, bool is_pressed);
void reset_all_keys();
void keyboard_did_change_key(Inputs::Keyboard *keyboard, Inputs::Keyboard::Key key, bool is_pressed) override;
void reset_all_keys(Inputs::Keyboard *keyboard) override;
Inputs::Keyboard keyboard_;
};