mirror of
https://github.com/TomHarte/CLK.git
synced 2024-11-26 08:49:37 +00:00
Adds a reference to the calling keyboard in reset_all_keys
.
This commit is contained in:
parent
4f289ab10b
commit
3a05ce36de
@ -24,7 +24,7 @@ void Keyboard::set_key_pressed(Key key, bool is_pressed) {
|
|||||||
|
|
||||||
void Keyboard::reset_all_keys() {
|
void Keyboard::reset_all_keys() {
|
||||||
std::fill(key_states_.begin(), key_states_.end(), false);
|
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) {
|
void Keyboard::set_delegate(Delegate *delegate) {
|
||||||
|
@ -46,7 +46,7 @@ class Keyboard {
|
|||||||
// Delegate interface.
|
// Delegate interface.
|
||||||
struct Delegate {
|
struct Delegate {
|
||||||
virtual void keyboard_did_change_key(Keyboard *keyboard, Key key, bool is_pressed) = 0;
|
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);
|
void set_delegate(Delegate *delegate);
|
||||||
bool get_key_state(Key key);
|
bool get_key_state(Key key);
|
||||||
|
@ -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);
|
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.
|
// TODO: unify naming.
|
||||||
clear_all_keys();
|
clear_all_keys();
|
||||||
}
|
}
|
||||||
|
@ -59,8 +59,8 @@ class Machine: public Inputs::Keyboard::Delegate {
|
|||||||
virtual KeyboardMapper &get_keyboard_mapper() = 0;
|
virtual KeyboardMapper &get_keyboard_mapper() = 0;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void keyboard_did_change_key(Inputs::Keyboard *keyboard, Inputs::Keyboard::Key key, bool is_pressed);
|
void keyboard_did_change_key(Inputs::Keyboard *keyboard, Inputs::Keyboard::Key key, bool is_pressed) override;
|
||||||
void reset_all_keys();
|
void reset_all_keys(Inputs::Keyboard *keyboard) override;
|
||||||
Inputs::Keyboard keyboard_;
|
Inputs::Keyboard keyboard_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user