diff --git a/Inputs/Keyboard.cpp b/Inputs/Keyboard.cpp index c479c6a7f..6acfec9bc 100644 --- a/Inputs/Keyboard.cpp +++ b/Inputs/Keyboard.cpp @@ -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) { diff --git a/Inputs/Keyboard.hpp b/Inputs/Keyboard.hpp index 7d480c8c8..0506be2b0 100644 --- a/Inputs/Keyboard.hpp +++ b/Inputs/Keyboard.hpp @@ -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 key_states_; Delegate *delegate_ = nullptr; diff --git a/Machines/KeyboardMachine.cpp b/Machines/KeyboardMachine.cpp index 36299cd13..c6562bee4 100644 --- a/Machines/KeyboardMachine.cpp +++ b/Machines/KeyboardMachine.cpp @@ -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(); } diff --git a/Machines/KeyboardMachine.hpp b/Machines/KeyboardMachine.hpp index a509002a6..0074a3ee2 100644 --- a/Machines/KeyboardMachine.hpp +++ b/Machines/KeyboardMachine.hpp @@ -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_; };