Hi,
I'm trying to create a Kodi addon that uses USB touchpanel input to make choices about what video to play.
I have python code that reads the touchpanel events and extracts raw x and y values.
To make it non-blocking, I use select.select() to first test to see if there is a touch event to read, and to set a timeout.
Everything works fine when I test it on Armbian, but when I embed the code into my Kodi addon, I never see any touchpanel events.
The program below represents my code.
On Armbian, the print (r) statement returns a data structure that points to the USB device file, whenever there is a touch event to read.
On LibreElec, the print [r] statement always returns []
Is there something stripped out of LibreElec that is making select.select not work right?
Note: from a python shell, "import select" succeeds, so I don't think it is a missing library.
Are there any other LibreElec restrictions that would inhibit a direct read of an input device?
Configuration:
Rock64 4GB
LibreELEC/Kodi (LibreELEC 9.1.002)
Confluence skin
Thanks,
-Jeff
#python touchscreen reader test
import os
import sys
import time
import struct
import select
#my touch panel
usbname = "/dev/input/by-id/usb-Touch_Touch_Device_FB60WH00D-CT-A1-10P-event-if00"
EV_ABS=3 #I extracted this enum from a previous test
touch_timeout = 0.050
while True:
if (os.access(usbname, os.R_OK)):
fd=open(usbname, "rb")
event=1 # force the while loop to start
while event: #as long as there is event data, keep reading
r,w,e = select.select([fd], [], [],touch_timeout)
print (r)
if fd in r:
event=os.read(fd.fileno(),EVENT_SIZE)
(tv_sec, tv_usec, type, code, value) = struct.unpack(FORMAT, event)
if (type == EV_ABS and code == 0 and value > 0):
rawX = value
if (type == EV_ABS and code == 1 and value > 0):
rawY = value
print("X " + str(rawX) + " Y " +str(rawY))
else: #else, there is no event data right now, so set event to jump out of loop
event=0
fd.close()
Display More