diff options
| author | Sungyoon Cho <sungyoon@sungyooncho.dev> | 2024-07-28 19:46:38 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-07-28 11:46:38 +0100 |
| commit | 9b6ae4f77b95fef271c2e21abba5e05b4cc47719 (patch) | |
| tree | 6ffe52a271da61803684009ae6697f8ad5bb1b3b /src/devices/IKeyboard.cpp | |
| parent | bc86afea7e177a7ad4335737417fc0e468698dc4 (diff) | |
input: fix keyboard leds with multiple keyboards (#7079)
Diffstat (limited to 'src/devices/IKeyboard.cpp')
| -rw-r--r-- | src/devices/IKeyboard.cpp | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/src/devices/IKeyboard.cpp b/src/devices/IKeyboard.cpp index e3517bf1..e05cbd04 100644 --- a/src/devices/IKeyboard.cpp +++ b/src/devices/IKeyboard.cpp @@ -274,9 +274,9 @@ std::string IKeyboard::getActiveLayout() { return "none"; } -void IKeyboard::updateLEDs() { +std::optional<uint32_t> IKeyboard::getLEDs() { if (xkbState == nullptr) - return; + return {}; uint32_t leds = 0; for (uint32_t i = 0; i < LED_COUNT; ++i) { @@ -284,7 +284,16 @@ void IKeyboard::updateLEDs() { leds |= (1 << i); } - updateLEDs(leds); + return leds; +} + +void IKeyboard::updateLEDs() { + std::optional<uint32_t> leds = getLEDs(); + + if (!leds.has_value()) + return; + + updateLEDs(leds.value()); } void IKeyboard::updateLEDs(uint32_t leds) { |
