Delivering touch events to Lua #422
Replies: 18 comments 16 replies
-
I think that a straightforward interface would be to deliver touch events in the same argument that delivers key events, i.e. add the following to the list of possible events:
Also add a touchState argument to refresh(...). If we did not get one of the above events, then touchState == nil, otherwise it is a table with the relevant coordinates. |
Beta Was this translation helpful? Give feedback.
-
Just linking this here for consideration also, as there is also recent discussion on this in OpenTX... Issue: opentx/opentx#8598 |
Beta Was this translation helpful? Give feedback.
-
I think there should be also a higher level interface. For slide events I propse the same as with key events something like slide-left/rifht/up/down events as a simple technic for simple use cases. Raw tap events with coordinates may be useful. |
Beta Was this translation helpful? Give feedback.
-
I'm primarily interested in getting touch events converted to key events with the same functionality. That might ask some thinking in how to link what to what, but would at least solve touch enabling in one go for all current use cases. A little bit similar to windows, where in the end all mouse actions are also executable using keystrokes. I could think of tap for enter, swipe left/right page up/down, swipe up/down plus/minus. Although the last one would be better with two finger slide. Supported? I don't know. What to use for exit? Tap on another editable item? Double tap on popupped items? Just some thoughts |
Beta Was this translation helpful? Give feedback.
-
I agree that we should keep different events. If we started adding code to support a specific use case, then we would also be limiting people who want something different. Let's build on what is already there, and add OllieW's "extended" events also.
The latter is returned if EVT_TOUCH_BREAK happens within 250ms after another touch event.
That way, people can choose if they want to swipe or slide in their script :-) |
Beta Was this translation helpful? Give feedback.
-
For the lua scripts I don't have any issues with the approach. I was just trying to think of what I would do to enable touch for my scripts, which is exactly as Jesper suggests (I use the same approach to mimic buttons with switches for widgets). But the same approach would also work for the entire GUI if you could do the same event replacement trick. |
Beta Was this translation helpful? Give feedback.
-
I have started working on a Lua GUI design for SoarETX, and I wonder if there is interest in developing a common Lua utility library with GUI functions etc. that comes preloaded on the SD card? |
Beta Was this translation helpful? Give feedback.
-
Well, I'm interested, but at the same time cautious. Cautious because I now have the freedom to make my own choices regarding everything in my justfly project. I'm a little bit stubborn and like to progress in the way I think is best. Opensourcing is a one way track, some companies have found out the hard way. So unless I really are convinced by arguments put forward that opensource is the best way to manage my project, I will not opensource my project. The added value of such a lib would thus be limited to me, because you then really enter a gray zone, of using lua libraries developed as opensource specifically for edgetx, for a closed source project. Is still defendable, but I don't even want to start the discussion. So either people must convince me, or my support is limited in a sense that I'm always willing to share my time and knowledge, as it is fun. But I wont be pushed because I would use it myself. I hope you understand my position. Opensource is not a holy grail suitable for all projects. |
Beta Was this translation helpful? Give feedback.
-
Ok.lets help people. Fully in favour of that. I think a widget loader would be nice. Loading a telemetry script or even a simpler format. Just a function script Lua. Forget about background and run, and certainly init. Just a script that is called. So basically have them run a 'BASIC' script. This is what could invite people to write their own scripts for widgets. For me, that is something I would like to invest in. |
Beta Was this translation helpful? Give feedback.
-
Ok, well, two steps back on my wild ideas. But yes, still interested to help. Just try to set out a goal, a basic design, ... What you want to achieve. I'm sure we can make something that will help people do things easier with such a library. So yes please, share your first ideas. |
Beta Was this translation helpful? Give feedback.
-
OK, I have uploaded the widget scripts that I made so far here: https://github.com/jfrickmann/SoarOTX/tree/SoarETX/SD-CARD/WIDGETS |
Beta Was this translation helpful? Give feedback.
-
Ok, just checked the scripts. I am not sure I understand where you're intending to go. Perhaps we need to have a chat so we can share thoughts first. Is discord open for voice chat? Guido |
Beta Was this translation helpful? Give feedback.
-
We found it. Thanks! |
Beta Was this translation helpful? Give feedback.
-
Okay I had some research about touchUI APIs in other platforms. First approach is to include only 4 basic events TOUCH_START, TOUCH_MOVE, TOUCH_END, TOUCH_CANCEL. Still I think It may be better to code some of additional functional events in C++ leaving possibility for LUA dev to write customised solution using those basic four above mentioned. From what I read those additional events need timing configuration that should be set and tested with specific hardware. |
Beta Was this translation helpful? Give feedback.
-
I have no issues if I need to convert touch myself to the corresponding key events. That's a standard function I had to make to allow switched to simulate buttons. So no issue there:) |
Beta Was this translation helpful? Give feedback.
-
It would just have been my first approach if the entire opentx GUI including scripts would have to be prepared for touch. But the opentx GUI is already following a custom approach. So that's fine. |
Beta Was this translation helpful? Give feedback.
-
I have moved this to a new pull request: #489 |
Beta Was this translation helpful? Give feedback.
-
The PR have been merged into the main branch! So please check the nightlies, if you want to play with events 🎉 |
Beta Was this translation helpful? Give feedback.
-
Before we start coding, I think that it would be good to have a general discussion among the Lua script writers about how we would like to have touch events delivered to the scripts.
I have looked around in the code to find out how the touch system is implemented. I found the basic interface definition in touch.h:
And I found some onTouch functions implemented in libopengui in the Window class, which AFAIK is the base class for most other GUI elements:
Beta Was this translation helpful? Give feedback.
All reactions