DSSeat: register input event handlers 65/241665/1
authorjeon <jhyuni.kang@samsung.com>
Fri, 24 Jul 2020 08:22:58 +0000 (17:22 +0900)
committerSung-Jin Park <sj76.park@samsung.com>
Thu, 20 Aug 2020 10:04:26 +0000 (19:04 +0900)
Change-Id: Ib42c9ce6e583399bc5e7c08253df5f01af589805

src/DSSeat/DSSeat.cpp
src/DSSeat/DSSeat.h

index de6f51e..b911c17 100644 (file)
@@ -4,10 +4,12 @@
 #include "DSCompositor.h"
 #include "DSWaylandSeat.h"
 #include "DSWaylandCompositor.h"
+#include "DSInputEvent.h"
 
 namespace display_server
 {
 
+
 DSSeat::DSSeat()
        : __input(nullptr),
          __keyboard(nullptr),
@@ -51,6 +53,14 @@ DSSeat::DSSeat(DSCompositor *compositor, std::string name)
 
        __input->registerCallbackDeviceAdd(this, std::bind(&DSSeat::slotDeviceAdd, this, std::placeholders::_1));
        __input->registerCallbackDeviceRemove(this, std::bind(&DSSeat::slotDeviceRemove, this, std::placeholders::_1));
+       __input->registerCallbackKeyDown(this, inputEventHandlerKey);
+       __input->registerCallbackKeyUp(this, inputEventHandlerKey);
+       __input->registerCallbackMouseDown(this, inputEventHandlerMouse);
+       __input->registerCallbackMouseMove(this, inputEventHandlerMouse);
+       __input->registerCallbackMouseUp(this, inputEventHandlerMouse);
+       __input->registerCallbackTouchDown(this, inputEventHandlerTouch);
+       __input->registerCallbackTouchMove(this, inputEventHandlerTouch);
+       __input->registerCallbackTouchUp(this, inputEventHandlerTouch);
        __input->init();
 }
 
@@ -125,4 +135,58 @@ void DSSeat::slotDeviceRemove(std::shared_ptr<DSInputDevice> device)
                __dswlSeat->setCapability((DSWaylandSeat::seatCapability)cap);
 }
 
+Eina_Bool DSSeat::inputEventHandlerKey(void *data, int type, void *event)
+{
+       //DSSeat *seat = static_cast< DSSeat* >(data);
+       DSInputKeyboardEvent *ev = static_cast< DSInputKeyboardEvent* >(event);
+       std::string typeString;
+
+       if (ev->getType() == DSInputEvent::KeyDownEvent)
+               typeString = "down";
+       else
+               typeString = "up";
+
+       DSLOG_DBG("DSSeat", "[key%s] keycode: %d, devicename: %s\n", typeString.c_str(), ev->getKeycode(), ev->getDevice()->getName().c_str());
+
+       return EINA_TRUE;
+}
+
+Eina_Bool DSSeat::inputEventHandlerMouse(void *data, int type, void *event)
+{
+       //DSSeat *seat = static_cast< DSSeat* >(data);
+       DSInputMouseEvent *ev = static_cast< DSInputMouseEvent* >(event);
+       std::string typeString;
+
+       if (ev->getType() == DSInputEvent::MouseDownEvent)
+               typeString = "down";
+       else if (ev->getType() == DSInputEvent::MouseMoveEvent)
+               typeString = "move";
+       else
+               typeString = "up";
+
+       DSLOG_DBG("DSSeat", "[mouse%s] button: %d (%d, %d, %d), devicename: %s\n", typeString.c_str(), ev->getButton(), ev->getX(), ev->getY(), ev->getZ(), ev->getDevice()->getName().c_str());
+
+       return EINA_TRUE;
+}
+
+Eina_Bool DSSeat::inputEventHandlerTouch(void *data, int type, void *event)
+{
+       //DSSeat *seat = static_cast< DSSeat* >(data);
+       DSInputTouchEvent *ev = static_cast< DSInputTouchEvent* >(event);
+       std::string typeString;
+
+       if (ev->getType() == DSInputEvent::TouchDownEvent)
+               typeString = "down";
+       else if (ev->getType() == DSInputEvent::TouchMoveEvent)
+               typeString = "move";
+       else
+               typeString = "up";
+
+       DSLOG_DBG("DSSeat", "[touch%s] index: %d (%d, %d), devicename: %s\n", typeString.c_str(), ev->getIndex(), ev->getX(), ev->getY(), ev->getDevice()->getName().c_str());
+
+       return EINA_TRUE;
+}
+
+
 } // namespace display_server
+
index fb1bd0e..a7347a0 100644 (file)
@@ -3,6 +3,7 @@
 
 #include <DSInput.h>
 #include <memory>
+#include <Ecore.h>
 
 namespace display_server
 {
@@ -37,6 +38,10 @@ private:
        uint32_t __numPointer;
        uint32_t __numKeyboard;
        uint32_t __numTouch;
+
+       static Eina_Bool inputEventHandlerKey(void *data, int type, void *event);
+       static Eina_Bool inputEventHandlerMouse(void *data, int type, void *event);
+       static Eina_Bool inputEventHandlerTouch(void *data, int type, void *event);
 };
 
 }