Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

touchscreen no work with sdl + drm #6138

Closed
Coloryr opened this issue Apr 28, 2024 · 8 comments · May be fixed by #6194
Closed

touchscreen no work with sdl + drm #6138

Coloryr opened this issue Apr 28, 2024 · 8 comments · May be fixed by #6194

Comments

@Coloryr
Copy link

Coloryr commented Apr 28, 2024

LVGL version

v9.1.0

What happened?

touchscreen no work runing in sdl + drm

/*==================
 * DEVICES
 *==================*/
/*Use SDL to open window on PC and handle mouse and keyboard*/
#define LV_USE_SDL              1
#if LV_USE_SDL
    #define LV_SDL_INCLUDE_PATH     <SDL2/SDL.h>
    #define LV_SDL_RENDER_MODE      LV_DISPLAY_RENDER_MODE_DIRECT   /*LV_DISPLAY_RENDER_MODE_DIRECT is recommended for best performance*/
    #define LV_SDL_BUF_COUNT        1    /*1 or 2*/
    #define LV_SDL_FULLSCREEN       0    /*1: Make the window full screen by default*/
    #define LV_SDL_DIRECT_EXIT      1    /*1: Exit the application when all SDL windows are closed*/
    #define LV_SDL_MOUSEWHEEL_MODE  LV_SDL_MOUSEWHEEL_MODE_ENCODER  /*LV_SDL_MOUSEWHEEL_MODE_ENCODER/CROWN*/
#endif

I touch the screen, it can go to

win_id = event->tfinger.windowID;

but, indev and disp always is null in
lv_display_t * disp = _lv_sdl_get_disp_from_win_id(win_id);
/*Find a suitable indev*/
lv_indev_t * indev = lv_indev_get_next(NULL);
while(indev) {
if(lv_indev_get_display(indev) == disp && lv_indev_get_type(indev) == LV_INDEV_TYPE_POINTER) {
break;
}
indev = lv_indev_get_next(indev);
}
if(indev == NULL) return;
From debug, I sew win_id is 0, but no window with id 0 exists.

How to reproduce?

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>

#include "lvgl.h"

#include "demos/lv_demos.h"

int main(int, char **)
{
    lv_init();

    lv_display_t *display = lv_sdl_window_create(640, 480);
    lv_indev_t *mouse = lv_sdl_mouse_create();
    lv_indev_t *mousewheel = lv_sdl_mousewheel_create();
    lv_indev_t *keyboard = lv_sdl_keyboard_create();

    lv_demo_widgets();

    for (;;)
    {
        uint32_t time = lv_timer_handler();
        usleep(time * 1000);
    }
}
@kisvegabor
Copy link
Member

I've checked in SDL's docs that for SDL_FINGER* events really event->tfinger shall be used. If SDL doesn't set the Window ID we cannot do much.

Can you ask it from the SDL developers?

@Coloryr
Copy link
Author

Coloryr commented Apr 30, 2024

I'm use is in DRM not X11, maybe these two are different.

@Coloryr
Copy link
Author

Coloryr commented Apr 30, 2024

/*Find a suitable indev*/
    lv_indev_t * indev = lv_indev_get_next(NULL);
    while(indev) {
        if(disp != NULL) {
            if(lv_indev_get_display(indev) == disp) {
                break;
            }
        }
        if(lv_indev_get_type(indev) == LV_INDEV_TYPE_POINTER) {
            break;
        }
        indev = lv_indev_get_next(indev);
    }

I have modified the lv_sdl_mouse.c code, that it can work properly.
after:
I found that my code was written incorrectly, and I have corrected it.

@kisvegabor
Copy link
Member

I have modified the lv_sdl_mouse.c code, that it can work properly.

What is the difference? It seems to your code does the same thing, just the if is split into 2 parts. Am I missing something?

@Coloryr
Copy link
Author

Coloryr commented May 6, 2024

In drm, disp is null, but lv_indev_get_display(indev) is not null.

@kisvegabor
Copy link
Member

This way always the first POINTER indev will be found. Which is better nothing, but worth mentioning.

I've opened #6194 to fix it.

@Coloryr
Copy link
Author

Coloryr commented May 8, 2024

I have tested it, this patch is work.

@kisvegabor
Copy link
Member

Great, thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants