Public Access
Keys: which ones are held, not only which were pressed
Apps heard a key once, when it went down. A Game that moves something for as long as a key is held (issue #101) asks the key mapper instead. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0162FokPdvY2KsS4NBfwyWPk
This commit is contained in:
@@ -54,6 +54,24 @@ KeyEvent keyEvent(Key key, const RawKeys& keys) {
|
||||
|
||||
} // namespace
|
||||
|
||||
bool KeyMapper::heldChar(char c) const {
|
||||
return std::find(previous_.chars.begin(), previous_.chars.end(), c) != previous_.chars.end();
|
||||
}
|
||||
|
||||
bool KeyMapper::held(Key key) const {
|
||||
bool arrows = previous_.fn || !textEntry_;
|
||||
switch (key) {
|
||||
case Key::Up: return arrows && heldChar(';');
|
||||
case Key::Down: return arrows && heldChar('.');
|
||||
case Key::Left: return arrows && heldChar(',');
|
||||
case Key::Right: return arrows && heldChar('/');
|
||||
case Key::Select: return previous_.enter;
|
||||
case Key::Delete: return previous_.del;
|
||||
case Key::Tab: return previous_.tab;
|
||||
default: return false;
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<KeyEvent> KeyMapper::update(const RawKeys& keys) {
|
||||
std::vector<KeyEvent> out;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user