From 6180219a0357ce501e96d12fe08fc69b86d2633b Mon Sep 17 00:00:00 2001 From: Sung-Jin Park Date: Wed, 12 Aug 2020 21:55:06 +0900 Subject: [PATCH] DSInput: add/get timestamp for pointer/touch events propagation Change-Id: Icc4e167ba5be37e504cf574e855de087120163c6 Signed-off-by: Sung-Jin Park --- src/DSInput/DSInput.cpp | 40 ++++++++++++++++++++-------------------- src/DSInput/DSInput.h | 16 ++++++---------- src/DSInput/DSInputPrivate.h | 4 ++-- src/DSInput/DSLibinput.cpp | 16 ++++++++++------ 4 files changed, 38 insertions(+), 38 deletions(-) diff --git a/src/DSInput/DSInput.cpp b/src/DSInput/DSInput.cpp index cb61726..7a34779 100644 --- a/src/DSInput/DSInput.cpp +++ b/src/DSInput/DSInput.cpp @@ -73,28 +73,28 @@ void DSInputPrivate::PostKeyboardEvent(int keycode, bool pressed, std::string de pub->keyUp(keycode, devIdentifier, devClass, timestamp); } -void DSInputPrivate::PostPointerEvent(int button, int x, int y, int z, DSInputEvent::Type type, std::string devIdentifier, DSInput::DeviceClass devClass) +void DSInputPrivate::PostPointerEvent(int button, int x, int y, int z, DSInputEvent::Type type, std::string devIdentifier, DSInput::DeviceClass devClass, uint32_t timestamp) { DS_GET_PUB(DSInput); if (type == DSInputEvent::MouseDownEvent) - pub->mouseDown(button, x, y, z, devIdentifier, devClass); + pub->mouseDown(button, x, y, z, devIdentifier, devClass, timestamp); else if (type == DSInputEvent::MouseMoveEvent) - pub->mouseMove(button, x, y, z, devIdentifier, devClass); + pub->mouseMove(button, x, y, z, devIdentifier, devClass, timestamp); else if (type == DSInputEvent::MouseUpEvent) - pub->mouseUp(button, x, y, z, devIdentifier, devClass); + pub->mouseUp(button, x, y, z, devIdentifier, devClass, timestamp); } -void DSInputPrivate::PostTouchEvent(int index, int x, int y, DSInputEvent::Type type, std::string devIdentifier, DSInput::DeviceClass devClass) +void DSInputPrivate::PostTouchEvent(int index, int x, int y, DSInputEvent::Type type, std::string devIdentifier, DSInput::DeviceClass devClass, uint32_t timestamp) { DS_GET_PUB(DSInput); if (type == DSInputEvent::TouchDownEvent) - pub->touchDown(index, x, y, devIdentifier, devClass); + pub->touchDown(index, x, y, devIdentifier, devClass, timestamp); else if (type == DSInputEvent::TouchMoveEvent) - pub->touchMove(index, x, y, devIdentifier, devClass); + pub->touchMove(index, x, y, devIdentifier, devClass, timestamp); else if (type == DSInputEvent::TouchUpEvent) - pub->touchUp(index, x, y, devIdentifier, devClass); + pub->touchUp(index, x, y, devIdentifier, devClass, timestamp); } int DSInput::DS_INPUT_EVENT_KEY_DOWN = 0; @@ -254,51 +254,51 @@ void DSInput::keyUp(int keycode, std::string devIdentifier, DSInput::DeviceClass 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) +void DSInput::mouseDown(int button, int x, int y, int z, std::string devIdentifier, DSInput::DeviceClass devClass, uint32_t timestamp) { 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(*device), DSInputEvent::MouseDownEvent, 0, button, x, y, z); + DSInputMouseEvent *ev = new DSInputMouseEvent(std::make_shared(*device), DSInputEvent::MouseDownEvent, timestamp, 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) +void DSInput::mouseMove(int button, int x, int y, int z, std::string devIdentifier, DSInput::DeviceClass devClass, uint32_t timestamp) { 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(*device), DSInputEvent::MouseMoveEvent, 0, button, x, y, z); + DSInputMouseEvent *ev = new DSInputMouseEvent(std::make_shared(*device), DSInputEvent::MouseMoveEvent, timestamp, 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) +void DSInput::mouseUp(int button, int x, int y, int z, std::string devIdentifier, DSInput::DeviceClass devClass, uint32_t timestamp) { 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(*device), DSInputEvent::MouseUpEvent, 0, button, x, y, z); + DSInputMouseEvent *ev = new DSInputMouseEvent(std::make_shared(*device), DSInputEvent::MouseUpEvent, timestamp, 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) +void DSInput::touchDown(int index, int x, int y, std::string devIdentifier, DSInput::DeviceClass devClass, uint32_t timestamp) { 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(*device), DSInputEvent::TouchDownEvent, 0, index, x, y); + DSInputTouchEvent *ev = new DSInputTouchEvent(std::make_shared(*device), DSInputEvent::TouchDownEvent, timestamp, 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) +void DSInput::touchMove(int index, int x, int y, std::string devIdentifier, DSInput::DeviceClass devClass, uint32_t timestamp) { 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(*device), DSInputEvent::TouchMoveEvent, 0, index, x, y); + DSInputTouchEvent *ev = new DSInputTouchEvent(std::make_shared(*device), DSInputEvent::TouchMoveEvent, timestamp, 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) +void DSInput::touchUp(int index, int x, int y, std::string devIdentifier, DSInput::DeviceClass devClass, uint32_t timestamp) { 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(*device), DSInputEvent::TouchUpEvent, 0, index, x, y); + DSInputTouchEvent *ev = new DSInputTouchEvent(std::make_shared(*device), DSInputEvent::TouchUpEvent, timestamp, index, x, y); ecore_event_add(DS_INPUT_EVENT_TOUCH_UP, (void *)ev, nullptr, nullptr); } diff --git a/src/DSInput/DSInput.h b/src/DSInput/DSInput.h index 7d13d50..f8c89ab 100644 --- a/src/DSInput/DSInput.h +++ b/src/DSInput/DSInput.h @@ -26,11 +26,7 @@ #include #include -#include -#include -#include #include -#include #include @@ -67,12 +63,12 @@ public: void deviceRemove(std::string name, std::string identifier, DSInput::DeviceClass devClass, DSInput::DeviceSubclass devSubclass); void keyDown(int keycode, std::string devIdentifier, DSInput::DeviceClass devClass, uint32_t timestamp); void keyUp(int keycode, std::string devIdentifier, DSInput::DeviceClass devClass, uint32_t timestamp); - void mouseDown(int button, int x, int y, int z, std::string devIdentifier, DSInput::DeviceClass devClass); - void mouseMove(int button, int x, int y, int z, std::string devIdentifier, DSInput::DeviceClass devClass); - void mouseUp(int button, int x, int y, int z, std::string devIdentifier, DSInput::DeviceClass devClass); - void touchDown(int index, int x, int y, std::string devIdentifier, DSInput::DeviceClass devClass); - void touchMove(int index, int x, int y, std::string devIdentifier, DSInput::DeviceClass devClass); - void touchUp(int index, int x, int y, std::string devIdentifier, DSInput::DeviceClass devClass); + void mouseDown(int button, int x, int y, int z, std::string devIdentifier, DSInput::DeviceClass devClass, uint32_t timestamp); + void mouseMove(int button, int x, int y, int z, std::string devIdentifier, DSInput::DeviceClass devClass, uint32_t timestamp); + void mouseUp(int button, int x, int y, int z, std::string devIdentifier, DSInput::DeviceClass devClass, uint32_t timestamp); + void touchDown(int index, int x, int y, std::string devIdentifier, DSInput::DeviceClass devClass, uint32_t timestamp); + void touchMove(int index, int x, int y, std::string devIdentifier, DSInput::DeviceClass devClass, uint32_t timestamp); + void touchUp(int index, int x, int y, std::string devIdentifier, DSInput::DeviceClass devClass, uint32_t timestamp); void registerCallbackDeviceAdd(DSObject *slot, std::function)> func); void registerCallbackDeviceRemove(DSObject *slot, std::function)> func); diff --git a/src/DSInput/DSInputPrivate.h b/src/DSInput/DSInputPrivate.h index 59b6741..377db91 100644 --- a/src/DSInput/DSInputPrivate.h +++ b/src/DSInput/DSInputPrivate.h @@ -46,8 +46,8 @@ public: void PostDeviceAddEvent(std::string seat, std::string name, std::string identifier, DSInput::DeviceClass devClass); void PostDeviceRemoveEvent(std::string seat, std::string name, std::string identifier, DSInput::DeviceClass devClass); void PostKeyboardEvent(int keycode, bool pressed, std::string devIdentifier, DSInput::DeviceClass devClass, uint32_t timestamp); - void PostPointerEvent(int button, int x, int y, int z, DSInputEvent::Type type, std::string devIdentifier, DSInput::DeviceClass devClass); - void PostTouchEvent(int index, int x, int y, DSInputEvent::Type type, std::string devIdentifier, DSInput::DeviceClass devClass); + void PostPointerEvent(int button, int x, int y, int z, DSInputEvent::Type type, std::string devIdentifier, DSInput::DeviceClass devClass, uint32_t timestamp); + void PostTouchEvent(int index, int x, int y, DSInputEvent::Type type, std::string devIdentifier, DSInput::DeviceClass devClass, uint32_t timestamp); private: DSLibinput *__dsLibinput; diff --git a/src/DSInput/DSLibinput.cpp b/src/DSInput/DSLibinput.cpp index dd43408..7e7ede9 100644 --- a/src/DSInput/DSLibinput.cpp +++ b/src/DSInput/DSLibinput.cpp @@ -221,14 +221,14 @@ void DSLibinput::__processPointerMotionEvent(struct ::libinput_event *event) { struct:: libinput_event_pointer *pointer_event = libinput_event_get_pointer_event(event); int dx, dy; - + uint32_t timestamp = libinput_event_pointer_get_time(pointer_event); struct ::libinput_device *device = libinput_event_get_device(event); std::string identifier = (std::string)"/dev/input/" + (std::string)libinput_device_get_sysname(device); dx = libinput_event_pointer_get_dx(pointer_event); dy = libinput_event_pointer_get_dy(pointer_event); - inputPrivate->PostPointerEvent(0, dx, dy, 0, DSInputEvent::MouseMoveEvent, identifier, DSInput::PointerClass); + inputPrivate->PostPointerEvent(0, dx, dy, 0, DSInputEvent::MouseMoveEvent, identifier, DSInput::PointerClass, timestamp); } void DSLibinput::__processPointerMotionAbsoluteEvent(struct ::libinput_event *event) @@ -242,6 +242,7 @@ void DSLibinput::__processPointerButtonEvent(struct ::libinput_event *event) DSInputEvent::Type eventType; int button; int state; + uint32_t timestamp = libinput_event_pointer_get_time(pointer_event); struct ::libinput_device *device = libinput_event_get_device(event); std::string identifier = (std::string)"/dev/input/" + (std::string)libinput_device_get_sysname(device); @@ -254,7 +255,7 @@ void DSLibinput::__processPointerButtonEvent(struct ::libinput_event *event) else eventType = DSInputEvent::MouseUpEvent; - inputPrivate->PostPointerEvent(button, 0, 0, 0, eventType, identifier, DSInput::PointerClass); + inputPrivate->PostPointerEvent(button, 0, 0, 0, eventType, identifier, DSInput::PointerClass, timestamp); } void DSLibinput::__processPointerAxisEvent(struct ::libinput_event *event) @@ -266,6 +267,7 @@ void DSLibinput::__processTouchDownEvent(struct ::libinput_event *event) { struct:: libinput_event_touch *touch_event = libinput_event_get_touch_event(event); int index, x, y; + uint32_t timestamp = libinput_event_touch_get_time(touch_event); struct ::libinput_device *device = libinput_event_get_device(event); std::string identifier = (std::string)"/dev/input/" + (std::string)libinput_device_get_sysname(device); @@ -274,13 +276,14 @@ void DSLibinput::__processTouchDownEvent(struct ::libinput_event *event) x = libinput_event_touch_get_x(touch_event); y = libinput_event_touch_get_y(touch_event); - inputPrivate->PostTouchEvent(index, x, y, DSInputEvent::TouchDownEvent, identifier, DSInput::TouchClass); + inputPrivate->PostTouchEvent(index, x, y, DSInputEvent::TouchDownEvent, identifier, DSInput::TouchClass, timestamp); } void DSLibinput::__processTouchMotionEvent(struct ::libinput_event *event) { struct:: libinput_event_touch *touch_event = libinput_event_get_touch_event(event); int index, x, y; + uint32_t timestamp = libinput_event_touch_get_time(touch_event); struct ::libinput_device *device = libinput_event_get_device(event); std::string identifier = (std::string)"/dev/input/" + (std::string)libinput_device_get_sysname(device); @@ -289,13 +292,14 @@ void DSLibinput::__processTouchMotionEvent(struct ::libinput_event *event) x = libinput_event_touch_get_x(touch_event); y = libinput_event_touch_get_y(touch_event); - inputPrivate->PostTouchEvent(index, x, y, DSInputEvent::TouchMoveEvent, identifier, DSInput::TouchClass); + inputPrivate->PostTouchEvent(index, x, y, DSInputEvent::TouchMoveEvent, identifier, DSInput::TouchClass, timestamp); } void DSLibinput::__processTouchUpEvent(struct ::libinput_event *event) { struct:: libinput_event_touch *touch_event = libinput_event_get_touch_event(event); int index, x, y; + uint32_t timestamp = libinput_event_touch_get_time(touch_event); struct ::libinput_device *device = libinput_event_get_device(event); std::string identifier = (std::string)"/dev/input/" + (std::string)libinput_device_get_sysname(device); @@ -304,7 +308,7 @@ void DSLibinput::__processTouchUpEvent(struct ::libinput_event *event) x = 0; y = 0; - inputPrivate->PostTouchEvent(index, x, y, DSInputEvent::TouchUpEvent, identifier, DSInput::TouchClass); + inputPrivate->PostTouchEvent(index, x, y, DSInputEvent::TouchUpEvent, identifier, DSInput::TouchClass, timestamp); } void DSLibinput::__processTouchCancelEvent(struct ::libinput_event *event) -- 2.7.4