From c2b59fdb56a87a1adc1c7fdab23b4deea55e1f23 Mon Sep 17 00:00:00 2001 From: Hanspeter Portner Date: Sun, 14 May 2023 21:40:56 +0200 Subject: [PATCH] Add libinput event types from >=1.19 --- .builds/alpine-latest.yml | 2 +- d2tk/config.h.in | 1 + meson.build | 14 ++++++++---- meson_options.txt | 2 +- src/frontend_fbdev.c | 48 +++++++++++++++++++++++++++++++++++++++ 5 files changed, 61 insertions(+), 6 deletions(-) diff --git a/.builds/alpine-latest.yml b/.builds/alpine-latest.yml index 5de1903..79ef537 100644 --- a/.builds/alpine-latest.yml +++ b/.builds/alpine-latest.yml @@ -25,7 +25,7 @@ packages: environment: project: d2tk - CI_SCAN_BUILD_OPTS: -disable-checker securiy.insecureAPI.vfork -disable-checker unix.Vfork --exclude nanovg + CI_SCAN_BUILD_OPTS: -disable-checker securiy.insecureAPI.vfork -disable-checker unix.Vfork --exclude nanovg --exclude pugl secrets: - 0545580c-42ac-4700-b322-4e9df924eb07 # runner-ssh diff --git a/d2tk/config.h.in b/d2tk/config.h.in index fca007a..da0ad91 100644 --- a/d2tk/config.h.in +++ b/d2tk/config.h.in @@ -5,6 +5,7 @@ #define D2TK_EVDEV @D2TK_EVDEV@ #define D2TK_INPUT_1_15 @D2TK_INPUT_1_15@ +#define D2TK_INPUT_1_19 @D2TK_INPUT_1_19@ #define D2TK_FONTCONFIG @D2TK_FONTCONFIG@ #define D2TK_DEBUG @D2TK_DEBUG@ #define D2TK_GLES_VERSION @D2TK_GLES_VERSION@ diff --git a/meson.build b/meson.build index 8db9e51..29937a1 100644 --- a/meson.build +++ b/meson.build @@ -176,10 +176,16 @@ else conf_data.set('D2TK_EVDEV', 0) endif -if input_dep.found() and input_dep.version().version_compare('>=1.15.0') - conf_data.set('D2TK_INPUT_1_15', 1) -else - conf_data.set('D2TK_INPUT_1_15', 0) +conf_data.set('D2TK_INPUT_1_15', 0) +conf_data.set('D2TK_INPUT_1_19', 0) +if input_dep.found() + if input_dep.version().version_compare('>=1.19.0') + conf_data.set('D2TK_INPUT_1_19', 1) + endif + + if input_dep.version().version_compare('>=1.15.0') + conf_data.set('D2TK_INPUT_1_15', 1) + endif endif if use_fontconfig.enabled() diff --git a/meson_options.txt b/meson_options.txt index e625b38..45ee07a 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -55,4 +55,4 @@ option('use-fontconfig', value : 'disabled', yield : true) -option('version', type : 'string', value : '0.1.1329') +option('version', type : 'string', value : '0.1.1331') diff --git a/src/frontend_fbdev.c b/src/frontend_fbdev.c index 2768aaa..ce60540 100644 --- a/src/frontend_fbdev.c +++ b/src/frontend_fbdev.c @@ -454,7 +454,55 @@ d2tk_frontend_step(d2tk_frontend_t *fbdev) } break; } } break; + +#if D2TK_INPUT_1_19 + case LIBINPUT_EVENT_GESTURE_HOLD_BEGIN: + { + //FIXME + } break; + case LIBINPUT_EVENT_GESTURE_HOLD_END: + { + //FIXME + } break; + case LIBINPUT_EVENT_POINTER_SCROLL_WHEEL: + // fall-through + case LIBINPUT_EVENT_POINTER_SCROLL_FINGER: + // fall-through + case LIBINPUT_EVENT_POINTER_SCROLL_CONTINUOUS: + { + struct libinput_event_pointer *evp = + libinput_event_get_pointer_event(ev); + + int32_t dx = 0; + int32_t dy = 0; + + if(libinput_event_get_type(ev) == LIBINPUT_EVENT_POINTER_SCROLL_WHEEL) + { + dx = libinput_event_pointer_get_scroll_value_v120(evp, + LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL); + dy = libinput_event_pointer_get_scroll_value_v120(evp, + LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL); + } + else + { + dx = libinput_event_pointer_get_scroll_value(evp, + LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL); + dy = libinput_event_pointer_get_scroll_value(evp, + LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL); + + dx /= 100.f; //FIXME + dy /= 100.f; //FIXME + } + + d2tk_base_add_mouse_scroll(fbdev->base, -dx, -dy); + } break; + case LIBINPUT_EVENT_POINTER_AXIS: + { + // nothing to do + } break; +#else case LIBINPUT_EVENT_POINTER_AXIS: +#endif { struct libinput_event_pointer *evp = libinput_event_get_pointer_event(ev); -- 2.38.5