SDL2 and Hyperpixel Input Event Support


#1

Hi!

The touch screen serves as a mouse in X11, but is there intended to be support for use in SDL2 without X11? (e.g. SDL2 driving the display for OpenGLES and handling input itself?

At present, I get

INFO: The key you just pressed is not recognized by SDL. To help get this fixed, please report this to the SDL mailing list sdl@libsdl.org EVDEV KeyCode 330

messages returned

Cheers,
George Russell


#2

There’s no way, to my knowledge, for us to support SDL. The touchscreen is emitting the correct events for a uinput touchscreen device- in fact it’s an event-by-event clone of the Official Raspberry Pi Touchscreen driver, just implemented in Python. If SDL doesn’t work with it, then I guess SDL simply doesn’t support multitouch devices?

My solution for input- since Python’s PyGame has similar issues working with touchscreens (presumably because it’s SDL under the hood) - is to read the uinput device directly. I wrote a Python library to this end for the Official Touchscreen which also happens to work with Hyper Pixel, but may not be much use if you’re using any other language: https://github.com/pimoroni/python-multitouch

Depending on what you’re doing, you might as well kill the uinput driver altogether and just read either the touch position data, or the raw ADC data right out of Hyper Pixel directly over I2C. The whole touch driver is just Python, laid bare for you to integrate right into your app: https://github.com/pimoroni/hyperpixel/blob/master/requirements/usr/bin/hyperpixel-touch

Reading the touch x1/y1 and x2/y2 positions is easy enough: https://github.com/pimoroni/hyperpixel/blob/master/requirements/usr/bin/hyperpixel-touch#L227-L232

Although we read directly from the touchscreens ADC to determine when a touch finishes: https://github.com/pimoroni/hyperpixel/blob/master/requirements/usr/bin/hyperpixel-touch#L187-L202


#3

Now that I look closer at the SDL touch screen support, it is working; the complaint is merely a warning.

I can seem to happily read finger up / down / motion in SDL 2.0.5+ (SDL trunk, but should also work in 2.0.5)


#4

Nice! I need to tinker with this stuff again sometime.