Jump to content

Issue with touch using SDL on Linux


Tobias Schenk

Recommended Posts

Hello,

first of all I wanted to say I really enjoy working with the ugfx library, its really fun. I m really new to embedded programming or actually programming at all and working on some project for college (studying mechatronics) and this is my first post here since so far I could find a solution for every problem I faced in here quite fast :)

Right now I m stuck getting the touch to work in my GUI application.

I m running my application on my Lenovo Yoga 900 on Ubuntu using the SDL multiple Driver, those should also support touch right?

In my application I have 2 Buttons using GWIN which I would like to press with my touchscreen but so far I can only press them with my mouse, same goes for any Widget demo (I am only able to move my mouse by touching somewhere), not  sure if there are some more things to be setup to get the tough to work using the SDL drivers.

Thats how my code looks like:

    geventListenerInit(&gl);
    gwinAttachListener(&gl);
    geventListenerInit(&gl2);
    gwinAttachListener(&gl2);

    GEvent *pe;

    while(1){
            //Get an Event
            pe = (GEvent *)geventEventWait(&gl, TIME_INFINITE);
            updateTime();
            displayTime();

            switch(pe->type) {
                case GEVENT_GWIN_BUTTON:
                    if (((GEventGWinButton*)pe)->gwin == ghSettingsButton){
                        // Our button has been pressed
                        updateTime();
                        gwinPrintf(GWConsole, "[%s%] Settings entered!\n", consoletime);
                    }
                    else if ((((GEventGWinButton*)pe)->gwin == ghStartStopButton) && (!engine_running)){
                        updateTime();
                        gwinPrintf(GWConsole, "[%s%] Engine started!\n", consoletime);
                        engine_running = TRUE;
                        createStartStopButton();
                        gwinClear(ghSettingsButton);
                    pe = (GEvent *)geventEventWait(&gl2, TIME_INFINITE);
                        while((((GEventGWinButton*)pe)->gwin != ghStartStopButton)){
                            setVariablesRandom();
                            drawDisplayInit();
                            createParking();
                            createSettingsButton();
                            updateTime();
                            displayTime();
                            if(hour == 0 && min == 0 && sec == 0)
                                displayDate();
                            if(driving_state < 7)
                            driving_state++;
                            else
                            driving_state--;
                            createDscale();
                            if (speed < 60)
                            speed += 5;
                            else
                            speed = 0;
                            gfxSleepMilliseconds(3000);

                            //setVariablesInit();
                            //updateTime();
                            //drawDisplayInit();
                            //gfxSleepMilliseconds(1000);

                        }
                        updateTime();
                        gwinPrintf(GWConsole, "[%s%] Engine stopped!\n", consoletime);
                        setVariablesInit();
                        drawDisplayInit();

                    }
                    else if ((((GEventGWinButton*)pe)->gwin == ghStartStopButton) && (engine_running)){

                        }
                        break;
                    default:
                        break;

                        }
                    }

 

Thank you in advance

Tobi

Link to comment
Share on other sites

Hello Tobi,

Thank you for your feedback - we appreciate it a lot!

There's nothing wrong in your code. This must be an issue in the SDL driver itself (the one in /drivers/multiple/SDL). I haven't written the SDL driver myself so this is primarily wild guessing but I assume the in the SDL initialization there is some configuration flag that lets you choose whether touchscreen events are being processed as mouse events (in case of SDL can distinguish the two). There's definitely no other magic involved in other parts of µGFX.

I don't have time to dive into this right now - could you take a look?

Link to comment
Share on other sites

This is a problem in the SDL mouse driver.

If you look at line 209 in drivers/multiple/SDL/gdisp_lld_SDL.c you will see that explicit touch support has been turned off with a #if 0.

It looks like the reason that this has been turned off is because on some equipment (eg osx touchpads) the coordinates returned are completely wrong. It also looks like the coordinates can come in different forms (0 to 1.0, or 0 to screen size) depending on the SDL version although the code looks like it can handle that.

You can try re-enabling that code - maybe it will work for you on your hardware.

 

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...