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
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);
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);
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);
}
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;
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;
(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;
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;
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);
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;