Tobias Schenk Posted November 1, 2017 Report Posted November 1, 2017 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
Joel Bodenmann Posted November 2, 2017 Report Posted November 2, 2017 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?
inmarket Posted November 2, 2017 Report Posted November 2, 2017 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.
Tobias Schenk Posted November 2, 2017 Author Report Posted November 2, 2017 Hey, thanks for the answers, I found that line in the SDL driver too but wasn't completely aware of its function and didn't want to make changes on it, but that actually did the trick and now the touch is working fine on my Netbook, so thank you guys
inmarket Posted November 3, 2017 Report Posted November 3, 2017 As it works for your hardware we will make this a driver option in v3.0
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now