virtualkeyboard: Add options to skip releasing pressed keys on close and to skip sharing key states (#11214)

This commit is contained in:
JS Deck 2025-08-04 16:29:39 -03:00 committed by GitHub
parent 6491bb4fb7
commit 2be309de1d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
23 changed files with 416 additions and 137 deletions

View file

@ -378,19 +378,6 @@ bool IKeyboard::updateModifiersState() {
}
void IKeyboard::updateXkbStateWithKey(uint32_t xkbKey, bool pressed) {
const auto contains = std::ranges::find(m_pressedXKB, xkbKey) != m_pressedXKB.end();
if (contains && pressed)
return;
if (!contains && !pressed)
return;
if (contains)
std::erase(m_pressedXKB, xkbKey);
else
m_pressedXKB.emplace_back(xkbKey);
xkb_state_update_key(m_xkbState, xkbKey, pressed ? XKB_KEY_DOWN : XKB_KEY_UP);
if (updateModifiersState()) {
@ -405,3 +392,27 @@ void IKeyboard::updateXkbStateWithKey(uint32_t xkbKey, bool pressed) {
});
}
}
bool IKeyboard::updatePressed(uint32_t key, bool pressed) {
const auto contains = getPressed(key);
if (contains && pressed)
return false;
if (!contains && !pressed)
return false;
if (contains)
std::erase(m_pressed, key);
else
m_pressed.emplace_back(key);
return true;
}
bool IKeyboard::getPressed(uint32_t key) {
return std::ranges::contains(m_pressed, key);
}
bool IKeyboard::shareStates() {
return m_shareStates;
}