2024-05-03 23:34:10 +02:00
|
|
|
#include "VirtualPointer.hpp"
|
|
|
|
#include "../protocols/VirtualPointer.hpp"
|
2024-07-21 13:09:54 +02:00
|
|
|
#include <aquamarine/input/Input.hpp>
|
2024-05-03 23:34:10 +02:00
|
|
|
|
|
|
|
SP<CVirtualPointer> CVirtualPointer::create(SP<CVirtualPointerV1Resource> resource) {
|
|
|
|
SP<CVirtualPointer> pPointer = SP<CVirtualPointer>(new CVirtualPointer(resource));
|
|
|
|
|
|
|
|
pPointer->self = pPointer;
|
|
|
|
|
|
|
|
return pPointer;
|
|
|
|
}
|
|
|
|
|
|
|
|
CVirtualPointer::CVirtualPointer(SP<CVirtualPointerV1Resource> resource) : pointer(resource) {
|
|
|
|
if (!resource->good())
|
|
|
|
return;
|
|
|
|
|
2024-07-21 13:09:54 +02:00
|
|
|
listeners.destroy = pointer->events.destroy.registerListener([this](std::any d) {
|
|
|
|
pointer.reset();
|
2024-05-03 23:34:10 +02:00
|
|
|
events.destroy.emit();
|
2024-07-21 13:09:54 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
listeners.motion = pointer->events.move.registerListener([this](std::any d) { pointerEvents.motion.emit(d); });
|
2024-07-22 17:24:24 +02:00
|
|
|
listeners.motionAbsolute = pointer->events.warp.registerListener([this](std::any d) {
|
|
|
|
// we need to unpack the event and add our device here because it's required to calculate the position correctly
|
|
|
|
auto E = std::any_cast<SMotionAbsoluteEvent>(d);
|
|
|
|
E.device = self.lock();
|
|
|
|
pointerEvents.motionAbsolute.emit(E);
|
|
|
|
});
|
2024-07-21 13:09:54 +02:00
|
|
|
listeners.button = pointer->events.button.registerListener([this](std::any d) { pointerEvents.button.emit(d); });
|
|
|
|
listeners.axis = pointer->events.axis.registerListener([this](std::any d) { pointerEvents.axis.emit(d); });
|
|
|
|
listeners.frame = pointer->events.frame.registerListener([this](std::any d) { pointerEvents.frame.emit(); });
|
|
|
|
listeners.swipeBegin = pointer->events.swipeBegin.registerListener([this](std::any d) { pointerEvents.swipeBegin.emit(d); });
|
|
|
|
listeners.swipeEnd = pointer->events.swipeEnd.registerListener([this](std::any d) { pointerEvents.swipeEnd.emit(d); });
|
|
|
|
listeners.swipeUpdate = pointer->events.swipeUpdate.registerListener([this](std::any d) { pointerEvents.swipeUpdate.emit(d); });
|
|
|
|
listeners.pinchBegin = pointer->events.pinchBegin.registerListener([this](std::any d) { pointerEvents.pinchBegin.emit(d); });
|
|
|
|
listeners.pinchEnd = pointer->events.pinchEnd.registerListener([this](std::any d) { pointerEvents.pinchEnd.emit(d); });
|
|
|
|
listeners.pinchUpdate = pointer->events.pinchUpdate.registerListener([this](std::any d) { pointerEvents.pinchUpdate.emit(d); });
|
|
|
|
listeners.holdBegin = pointer->events.holdBegin.registerListener([this](std::any d) { pointerEvents.holdBegin.emit(d); });
|
|
|
|
listeners.holdEnd = pointer->events.holdEnd.registerListener([this](std::any d) { pointerEvents.holdEnd.emit(d); });
|
|
|
|
|
2024-11-11 14:45:33 +01:00
|
|
|
boundOutput = resource->boundOutput ? resource->boundOutput->szName : "";
|
2024-07-29 16:27:09 +02:00
|
|
|
|
2024-07-21 13:09:54 +02:00
|
|
|
deviceName = pointer->name;
|
2024-05-03 23:34:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
bool CVirtualPointer::isVirtual() {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2024-07-21 13:09:54 +02:00
|
|
|
SP<Aquamarine::IPointer> CVirtualPointer::aq() {
|
|
|
|
return nullptr;
|
2024-05-03 23:34:10 +02:00
|
|
|
}
|