libinput: get event time from libinput_event 93/278193/1
authorduna.oh <duna.oh@samsung.com>
Thu, 19 May 2022 01:03:25 +0000 (10:03 +0900)
committerSooChan Lim <sc1.lim@samsung.com>
Mon, 18 Jul 2022 05:58:41 +0000 (14:58 +0900)
Change-Id: I51c5ef5ca3d3a7b1bd27172617e484303205c46c

src/libds/backend/libinput/backend.c
src/libds/backend/libinput/backend.h
src/libds/backend/libinput/keyboard.c
src/libds/backend/libinput/pointer.c
src/libds/backend/libinput/touch.c

index f3ee044b091515c2945579a9033c47e0891b3c66..b6dc4f11842fa6a544b7a8c89e8faa84f7513c77 100644 (file)
@@ -225,3 +225,7 @@ libinput_backend_handle_display_destroy(struct wl_listener *listener,
             wl_container_of(listener, libinput_backend, display_destroy);
     libinput_backend_destroy(libinput_backend);
 }
+
+uint32_t usec_to_msec(uint64_t usec) {
+       return (uint32_t)(usec / 1000);
+}
\ No newline at end of file
index 6fa212220fbbee40ff409742b5eaef878f09d238..4d1c0ce282fe48a736a7d867ea30a207d17cf115 100644 (file)
@@ -34,6 +34,8 @@ struct ds_libinput_input_device
     struct wl_list link; //ds_libinput_backend.devices
 };
 
+uint32_t usec_to_msec(uint64_t usec);
+
 struct ds_libinput_backend *
         libinput_backend_from_backend(struct ds_backend *backend);
 
index 53db0c97536f42eba38a2360afccd1c7707b728a..9376f1197f92f7aa5089bf33beafd244fa04ce88 100644 (file)
@@ -9,6 +9,7 @@ handle_keyboard_key(struct libinput_event *event,
     uint32_t key;
     enum libinput_key_state li_state;
     enum wl_keyboard_key_state state = WL_KEYBOARD_KEY_STATE_PRESSED;
+    struct ds_event_keyboard_key ds_event = {0};
 
     kbevent = libinput_event_get_keyboard_event(event);
 
@@ -24,12 +25,11 @@ handle_keyboard_key(struct libinput_event *event,
     ds_log(DS_DBG, "Keyboard(%p) key event key:%d, state:%s", kbd, key,
             (state == WL_KEYBOARD_KEY_STATE_PRESSED) ? "PRESSED":"RELEASED");
 
-    struct ds_event_keyboard_key ds_event = {
-        .keycode = key,
-        .state = state,
-        .time_msec = -1,
-        .update_state = false,
-    };
+    ds_event.keycode = key;
+    ds_event.state = state;
+    ds_event.time_msec = usec_to_msec(
+                libinput_event_keyboard_get_time_usec(kbevent));
+    ds_event.update_state = false;
 
     ds_keyboard_notify_key(kbd, &ds_event);
 }
index c118d06ccbd760a109f789a7698e17dcac078ea8..efdbaa733b22ce8d942d3cd3a14210465f9e9b13 100644 (file)
@@ -17,7 +17,8 @@ handle_pointer_motion(struct libinput_event *event,
     ds_log(DS_DBG, "pointer motion event delta_x:%f, delta_y:%f", delta_x, delta_y);
 
     ds_event.device = NULL;
-    ds_event.time_msec = -1;
+    ds_event.time_msec = usec_to_msec(
+                libinput_event_pointer_get_time_usec(pevent));
     ds_event.delta_x = delta_x;
     ds_event.delta_y = delta_y;
 
@@ -40,7 +41,8 @@ handle_pointer_motion_abs(struct libinput_event *event,
     ds_log(DS_DBG, "Pointer(%p) motion abs event x:%f, y:%f", pointer, x, y);
 
     ds_event.device = NULL;
-    ds_event.time_msec = -1;
+    ds_event.time_msec = usec_to_msec(
+                libinput_event_pointer_get_time_usec(pevent));
     ds_event.x = x;
     ds_event.y = y;
 
@@ -75,7 +77,8 @@ handle_pointer_button(struct libinput_event *event,
             (state == DS_BUTTON_PRESSED) ? "PRESSED" : "RELEASED");
 
     ds_event.device = NULL;
-    ds_event.time_msec = -1;
+    ds_event.time_msec = usec_to_msec(
+                libinput_event_pointer_get_time_usec(pevent));
     ds_event.button = button;
     ds_event.state = state;
 
index 08b7b8062a5e3004f1b05a6fe442f2a02c354a90..fd94c0b55adabe3b9337d1d6acabfeb827d23050 100644 (file)
@@ -19,7 +19,8 @@ handle_touch_down(struct libinput_event *event,
     ds_log(DS_DBG, "touch down event id:%d, x:%f, y:%f", touch_id, x, y);
 
     ds_event.device = NULL;
-    ds_event.time_msec = -1;
+    ds_event.time_msec = usec_to_msec(
+                libinput_event_touch_get_time_usec(tevent));
     ds_event.id = touch_id;
     ds_event.x = x;
     ds_event.y = y;
@@ -42,7 +43,8 @@ handle_touch_up(struct libinput_event *event,
     ds_log(DS_DBG, "touch up event id:%d", touch_id);
 
     ds_event.device = NULL;
-    ds_event.time_msec = -1;
+    ds_event.time_msec = usec_to_msec(
+                libinput_event_touch_get_time_usec(tevent));
     ds_event.id = touch_id;
 
     wl_signal_emit(&touch->events.up, &ds_event);
@@ -66,7 +68,8 @@ handle_touch_motion(struct libinput_event *event,
     ds_log(DS_DBG, "touch motion event id:%d, x:%f, y:%f", touch_id, x, y);
 
     ds_event.device = NULL;
-    ds_event.time_msec = -1;
+    ds_event.time_msec = usec_to_msec(
+                libinput_event_touch_get_time_usec(tevent));
     ds_event.id = touch_id;
     ds_event.x = x;
     ds_event.y = y;