pub->touchUp(index, x, y, devIdentifier, devClass);
}
+int DSInput::DS_INPUT_EVENT_KEY_DOWN = 0;
+int DSInput::DS_INPUT_EVENT_KEY_UP = 0;
+int DSInput::DS_INPUT_EVENT_MOUSE_DOWN = 0;
+int DSInput::DS_INPUT_EVENT_MOUSE_MOVE = 0;
+int DSInput::DS_INPUT_EVENT_MOUSE_UP = 0;
+int DSInput::DS_INPUT_EVENT_TOUCH_DOWN = 0;
+int DSInput::DS_INPUT_EVENT_TOUCH_MOVE = 0;
+int DSInput::DS_INPUT_EVENT_TOUCH_UP = 0;
+
+void DSInput::__initiaiize_ecore_event_types()
+{
+ if (!DS_INPUT_EVENT_KEY_DOWN)
+ DS_INPUT_EVENT_KEY_DOWN = ecore_event_type_new();
+ if (!DS_INPUT_EVENT_KEY_UP)
+ DS_INPUT_EVENT_KEY_UP = ecore_event_type_new();
+ if (!DS_INPUT_EVENT_MOUSE_DOWN)
+ DS_INPUT_EVENT_MOUSE_DOWN = ecore_event_type_new();
+ if (!DS_INPUT_EVENT_MOUSE_MOVE)
+ DS_INPUT_EVENT_MOUSE_MOVE = ecore_event_type_new();
+ if (!DS_INPUT_EVENT_MOUSE_UP)
+ DS_INPUT_EVENT_MOUSE_UP = ecore_event_type_new();
+ if (!DS_INPUT_EVENT_TOUCH_DOWN)
+ DS_INPUT_EVENT_TOUCH_DOWN = ecore_event_type_new();
+ if (!DS_INPUT_EVENT_TOUCH_MOVE)
+ DS_INPUT_EVENT_TOUCH_MOVE = ecore_event_type_new();
+ if (!DS_INPUT_EVENT_TOUCH_UP)
+ DS_INPUT_EVENT_TOUCH_UP = ecore_event_type_new();
+}
DSInput::DSInput()
: DS_INIT_PRIVATE_PTR(DSInput),
__seat(nullptr)
{
+ __initiaiize_ecore_event_types();
}
DSInput::DSInput(DSSeat *seat)
DSLOG_ERR("DSInput", "DSSeat ptr is required.");
return;
}
+
+ __initiaiize_ecore_event_types();
}
DSInput::~DSInput()
{
+ for (auto eventHandler : __eventHandlerList)
+ {
+ ecore_event_handler_del(eventHandler);
+ }
+ __eventHandlerList.clear();
}
void DSInput::init()
delete device;
}
+DSInputDevice *DSInput::findDevice(std::string devIdentifier, DSInput::DeviceClass devClass)
+{
+ for (auto dev : devList)
+ {
+ if ((dev->getClass() == devClass) && (dev->getIdentifier().compare(devIdentifier) == 0))
+ {
+ return dev;
+ }
+ }
+ return nullptr;
+}
+
void DSInput::keyDown(int keycode, std::string devIdentifier, DSInput::DeviceClass devClass)
{
- std::cout << "[keyDown] keycode: " << keycode << ", identifier: " << devIdentifier << std::endl;
+ DSLOG_DBG("DSInput", "[keyDown] keycode: %d, identifier: %d\n", keycode, devIdentifier);
+ DSInputDevice *device = findDevice(devIdentifier, devClass);
+ DSInputKeyboardEvent *ev = new DSInputKeyboardEvent(std::make_shared<DSInputDevice>(*device), DSInputEvent::KeyDownEvent, 0, keycode);
+ ecore_event_add(DS_INPUT_EVENT_KEY_DOWN, (void *)ev, nullptr, nullptr);
}
void DSInput::keyUp(int keycode, std::string devIdentifier, DSInput::DeviceClass devClass)
{
- std::cout << "[keyUp] keycode: " << keycode << ", identifier: " << devIdentifier << std::endl;
+ DSLOG_DBG("DSInput", "[keyUp] keycode: %d, identifier: %d\n", keycode, devIdentifier);
+ DSInputDevice *device = findDevice(devIdentifier, devClass);
+ DSInputKeyboardEvent *ev = new DSInputKeyboardEvent(std::make_shared<DSInputDevice>(*device), DSInputEvent::KeyUpEvent, 0, keycode);
+ ecore_event_add(DS_INPUT_EVENT_KEY_UP, (void *)ev, nullptr, nullptr);
}
void DSInput::mouseDown(int button, int x, int y, int z, std::string devIdentifier, DSInput::DeviceClass devClass)
{
- std::cout << "[mouseDown] button: " << button << " (" << x << ", " << y << "), " << ", identifier: " << devIdentifier << std::endl;
+ DSLOG_DBG("DSInput", "[mouseDown] button: %d (%d, %d, %d), identifier: %d\n", button, x, y, z, devIdentifier);
+ DSInputDevice *device = findDevice(devIdentifier, devClass);
+ DSInputMouseEvent *ev = new DSInputMouseEvent(std::make_shared<DSInputDevice>(*device), DSInputEvent::MouseDownEvent, 0, button, x, y, z);
+ ecore_event_add(DS_INPUT_EVENT_MOUSE_DOWN, (void *)ev, nullptr, nullptr);
}
void DSInput::mouseMove(int button, int x, int y, int z, std::string devIdentifier, DSInput::DeviceClass devClass)
{
- std::cout << "[mouseMove] button: " << button << " (" << x << ", " << y << "), " << ", identifier: " << devIdentifier << std::endl;
+ DSLOG_DBG("DSInput", "[mouseMove] button: %d (%d, %d, %d), identifier: %d\n", button, x, y, z, devIdentifier);
+ DSInputDevice *device = findDevice(devIdentifier, devClass);
+ DSInputMouseEvent *ev = new DSInputMouseEvent(std::make_shared<DSInputDevice>(*device), DSInputEvent::MouseMoveEvent, 0, button, x, y, z);
+ ecore_event_add(DS_INPUT_EVENT_MOUSE_MOVE, (void *)ev, nullptr, nullptr);
}
void DSInput::mouseUp(int button, int x, int y, int z, std::string devIdentifier, DSInput::DeviceClass devClass)
{
- std::cout << "[mouseUp] button: " << button << " (" << x << ", " << y << "), " << ", identifier: " << devIdentifier << std::endl;
+ DSLOG_DBG("DSInput", "[mouseUp] button: %d (%d, %d, %d), identifier: %d\n", button, x, y, z, devIdentifier);
+ DSInputDevice *device = findDevice(devIdentifier, devClass);
+ DSInputMouseEvent *ev = new DSInputMouseEvent(std::make_shared<DSInputDevice>(*device), DSInputEvent::MouseUpEvent, 0, button, x, y, z);
+ ecore_event_add(DS_INPUT_EVENT_MOUSE_UP, (void *)ev, nullptr, nullptr);
}
void DSInput::touchDown(int index, int x, int y, std::string devIdentifier, DSInput::DeviceClass devClass)
{
- std::cout << "[touchDown] index: " << index << " (" << x << ", " << y << "), " << ", identifier: " << devIdentifier << std::endl;
+ DSLOG_DBG("DSInput", "[touchDown] index: %d (%d, %d), identifier: %d\n", index, x, y, devIdentifier);
+ DSInputDevice *device = findDevice(devIdentifier, devClass);
+ DSInputTouchEvent *ev = new DSInputTouchEvent(std::make_shared<DSInputDevice>(*device), DSInputEvent::TouchDownEvent, 0, index, x, y);
+ ecore_event_add(DS_INPUT_EVENT_TOUCH_DOWN, (void *)ev, nullptr, nullptr);
}
void DSInput::touchMove(int index, int x, int y, std::string devIdentifier, DSInput::DeviceClass devClass)
{
- std::cout << "[touchMove] index: " << index << " (" << x << ", " << y << "), " << ", identifier: " << devIdentifier << std::endl;
+ DSLOG_DBG("DSInput", "[touchMove] index: %d (%d, %d), identifier: %d\n", index, x, y, devIdentifier);
+ DSInputDevice *device = findDevice(devIdentifier, devClass);
+ DSInputTouchEvent *ev = new DSInputTouchEvent(std::make_shared<DSInputDevice>(*device), DSInputEvent::TouchMoveEvent, 0, index, x, y);
+ ecore_event_add(DS_INPUT_EVENT_TOUCH_MOVE, (void *)ev, nullptr, nullptr);
}
void DSInput::touchUp(int index, int x, int y, std::string devIdentifier, DSInput::DeviceClass devClass)
{
- std::cout << "[touchUp] index: " << index << " (" << x << ", " << y << "), " << ", identifier: " << devIdentifier << std::endl;
+ DSLOG_DBG("DSInput", "[touchUp] index: %d (%d, %d), identifier: %d\n", index, x, y, devIdentifier);
+ DSInputDevice *device = findDevice(devIdentifier, devClass);
+ DSInputTouchEvent *ev = new DSInputTouchEvent(std::make_shared<DSInputDevice>(*device), DSInputEvent::TouchUpEvent, 0, index, x, y);
+ ecore_event_add(DS_INPUT_EVENT_TOUCH_UP, (void *)ev, nullptr, nullptr);
}
this->__deviceRemoveSignal.connect(slot, func);
}
-void DSInput::registerCallbackKeyDown(DSObject *slot, std::function<Eina_Bool(void *,int,void *)> func)
+void DSInput::registerCallbackKeyDown(DSObject *slot, Ecore_Event_Handler_Cb func)
{
+ __eventHandlerList.push_back(ecore_event_handler_add(DS_INPUT_EVENT_KEY_DOWN, func, slot));
}
-void DSInput::registerCallbackKeyUp(DSObject *slot, std::function<Eina_Bool(void *,int,void *)> func)
+void DSInput::registerCallbackKeyUp(DSObject *slot, Ecore_Event_Handler_Cb func)
{
+ __eventHandlerList.push_back(ecore_event_handler_add(DS_INPUT_EVENT_KEY_UP, func, slot));
}
-void DSInput::registerCallbackMouseDown(DSObject *slot, std::function<Eina_Bool(void *,int,void *)> func)
+void DSInput::registerCallbackMouseDown(DSObject *slot, Ecore_Event_Handler_Cb func)
{
+ __eventHandlerList.push_back(ecore_event_handler_add(DS_INPUT_EVENT_MOUSE_DOWN, func, slot));
}
-void DSInput::registerCallbackMouseMove(DSObject *slot, std::function<Eina_Bool(void *,int,void *)> func)
+void DSInput::registerCallbackMouseMove(DSObject *slot, Ecore_Event_Handler_Cb func)
{
+ __eventHandlerList.push_back(ecore_event_handler_add(DS_INPUT_EVENT_MOUSE_MOVE, func, slot));
}
-void DSInput::registerCallbackMouseUp(DSObject *slot, std::function<Eina_Bool(void *,int,void *)> func)
+void DSInput::registerCallbackMouseUp(DSObject *slot, Ecore_Event_Handler_Cb func)
{
+ __eventHandlerList.push_back(ecore_event_handler_add(DS_INPUT_EVENT_MOUSE_UP, func, slot));
}
-void DSInput::registerCallbackTouchDown(DSObject *slot, std::function<Eina_Bool(void *,int,void *)> func)
+void DSInput::registerCallbackTouchDown(DSObject *slot, Ecore_Event_Handler_Cb func)
{
+ __eventHandlerList.push_back(ecore_event_handler_add(DS_INPUT_EVENT_TOUCH_DOWN, func, slot));
}
-void DSInput::registerCallbackTouchMove(DSObject *slot, std::function<Eina_Bool(void *,int,void *)> func)
+void DSInput::registerCallbackTouchMove(DSObject *slot, Ecore_Event_Handler_Cb func)
{
+ __eventHandlerList.push_back(ecore_event_handler_add(DS_INPUT_EVENT_TOUCH_MOVE, func, slot));
}
-void DSInput::registerCallbackTouchUp(DSObject *slot, std::function<Eina_Bool(void *,int,void *)> func)
+void DSInput::registerCallbackTouchUp(DSObject *slot, Ecore_Event_Handler_Cb func)
{
+ __eventHandlerList.push_back(ecore_event_handler_add(DS_INPUT_EVENT_TOUCH_UP, func, slot));
}
void registerCallbackDeviceAdd(DSObject *slot, std::function<void(std::shared_ptr<DSInputDevice>)> func);
void registerCallbackDeviceRemove(DSObject *slot, std::function<void(std::shared_ptr<DSInputDevice>)> func);
- void registerCallbackKeyDown(DSObject *slot, std::function<Eina_Bool(void *,int,void *)> func);
- void registerCallbackKeyUp(DSObject *slot, std::function<Eina_Bool(void *,int,void *)> func);
- void registerCallbackMouseDown(DSObject *slot, std::function<Eina_Bool(void *,int,void *)> func);
- void registerCallbackMouseMove(DSObject *slot, std::function<Eina_Bool(void *,int,void *)> func);
- void registerCallbackMouseUp(DSObject *slot, std::function<Eina_Bool(void *,int,void *)> func);
- void registerCallbackTouchDown(DSObject *slot, std::function<Eina_Bool(void *,int,void *)> func);
- void registerCallbackTouchMove(DSObject *slot, std::function<Eina_Bool(void *,int,void *)> func);
- void registerCallbackTouchUp(DSObject *slot, std::function<Eina_Bool(void *,int,void *)> func);
+ void registerCallbackKeyDown(DSObject *slot, Ecore_Event_Handler_Cb func);
+ void registerCallbackKeyUp(DSObject *slot, Ecore_Event_Handler_Cb func);
+ void registerCallbackMouseDown(DSObject *slot, Ecore_Event_Handler_Cb func);
+ void registerCallbackMouseMove(DSObject *slot, Ecore_Event_Handler_Cb func);
+ void registerCallbackMouseUp(DSObject *slot, Ecore_Event_Handler_Cb func);
+ void registerCallbackTouchDown(DSObject *slot, Ecore_Event_Handler_Cb func);
+ void registerCallbackTouchMove(DSObject *slot, Ecore_Event_Handler_Cb func);
+ void registerCallbackTouchUp(DSObject *slot, Ecore_Event_Handler_Cb func);
+
+ DSInputDevice *findDevice(std::string devIdentifier, DSInput::DeviceClass devClass);
private:
DSSeat* __seat;
DSSignal<std::shared_ptr<DSInputDevice>> __deviceAddSignal;
DSSignal<std::shared_ptr<DSInputDevice>> __deviceRemoveSignal;
+
+ std::list<Ecore_Event_Handler*> __eventHandlerList;
+
+ static int DS_INPUT_EVENT_KEY_DOWN;
+ static int DS_INPUT_EVENT_KEY_UP;
+ static int DS_INPUT_EVENT_MOUSE_DOWN;
+ static int DS_INPUT_EVENT_MOUSE_MOVE;
+ static int DS_INPUT_EVENT_MOUSE_UP;
+ static int DS_INPUT_EVENT_TOUCH_DOWN;
+ static int DS_INPUT_EVENT_TOUCH_MOVE;
+ static int DS_INPUT_EVENT_TOUCH_UP;
+
+ void __initiaiize_ecore_event_types();
};
class DSInputDevice