2024-05-03 23:34:10 +02:00
|
|
|
#include "VirtualKeyboard.hpp"
|
|
|
|
#include "../defines.hpp"
|
|
|
|
#include "../protocols/VirtualKeyboard.hpp"
|
|
|
|
|
|
|
|
SP<CVirtualKeyboard> CVirtualKeyboard::create(SP<CVirtualKeyboardV1Resource> keeb) {
|
|
|
|
SP<CVirtualKeyboard> pKeeb = SP<CVirtualKeyboard>(new CVirtualKeyboard(keeb));
|
|
|
|
|
|
|
|
pKeeb->self = pKeeb;
|
|
|
|
|
|
|
|
return pKeeb;
|
|
|
|
}
|
|
|
|
|
|
|
|
CVirtualKeyboard::CVirtualKeyboard(SP<CVirtualKeyboardV1Resource> keeb_) : keyboard(keeb_) {
|
|
|
|
if (!keeb_)
|
|
|
|
return;
|
|
|
|
|
2024-07-21 13:09:54 +02:00
|
|
|
listeners.destroy = keeb_->events.destroy.registerListener([this](std::any d) {
|
2024-05-03 23:34:10 +02:00
|
|
|
keyboard.reset();
|
2024-07-21 13:09:54 +02:00
|
|
|
events.destroy.emit();
|
|
|
|
});
|
|
|
|
|
|
|
|
listeners.key = keeb_->events.key.registerListener([this](std::any d) { keyboardEvents.key.emit(d); });
|
|
|
|
listeners.modifiers = keeb_->events.modifiers.registerListener([this](std::any d) {
|
|
|
|
auto E = std::any_cast<SModifiersEvent>(d);
|
|
|
|
updateModifiers(E.depressed, E.latched, E.locked, E.group);
|
|
|
|
keyboardEvents.modifiers.emit(SModifiersEvent{
|
|
|
|
.depressed = modifiersState.depressed,
|
|
|
|
.latched = modifiersState.latched,
|
|
|
|
.locked = modifiersState.locked,
|
|
|
|
.group = modifiersState.group,
|
2024-05-03 23:34:10 +02:00
|
|
|
});
|
2024-07-21 13:09:54 +02:00
|
|
|
});
|
|
|
|
listeners.keymap = keeb_->events.keymap.registerListener([this](std::any d) {
|
2024-07-25 13:02:05 +02:00
|
|
|
auto E = std::any_cast<SKeymapEvent>(d);
|
|
|
|
if (xkbKeymap)
|
|
|
|
xkb_keymap_unref(xkbKeymap);
|
|
|
|
xkbKeymap = xkb_keymap_ref(E.keymap);
|
|
|
|
keymapOverridden = true;
|
|
|
|
updateXKBTranslationState(xkbKeymap);
|
|
|
|
updateKeymapFD();
|
2024-07-21 13:09:54 +02:00
|
|
|
keyboardEvents.keymap.emit(d);
|
|
|
|
});
|
|
|
|
|
|
|
|
deviceName = keeb_->name;
|
2024-05-03 23:34:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
bool CVirtualKeyboard::isVirtual() {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2024-07-21 13:09:54 +02:00
|
|
|
SP<Aquamarine::IKeyboard> CVirtualKeyboard::aq() {
|
|
|
|
return nullptr;
|
2024-05-03 23:34:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
wl_client* CVirtualKeyboard::getClient() {
|
2024-05-04 13:35:56 +02:00
|
|
|
if (keyboard.expired())
|
|
|
|
return nullptr;
|
2024-05-05 18:16:00 +02:00
|
|
|
return keyboard->client();
|
2024-05-03 23:34:10 +02:00
|
|
|
}
|