touchscreen.py 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757
  1. #!/usr/bin/python3
  2. #cat touchscreen_pointer_mapping_5.py
  3. # xte is in part of xautomation
  4. # apt install xautomation
  5. import os, tempfile
  6. import time
  7. import subprocess
  8. from _thread import start_new_thread
  9. import sys
  10. sys.stdout.write("\x1b]2;TOUCHSCREEN EVENT\x07")
  11. debug = 0
  12. def mapFromTo_(x,a,b,c,d):
  13. y=(x-a)/(b-a)*(d-c)+c
  14. return y
  15. def mapFromTo(value,in_min,in_max,out_min,out_max):
  16. #out_max -= 10
  17. #out_min += 10
  18. #y=(value-in_min)/(in_max-in_min)*(out_max-out_min)+out_min
  19. y= (value - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
  20. padding = 8 #px
  21. if y < out_min+padding:
  22. y = out_min+padding
  23. if y > out_max-padding:
  24. y = out_max-padding
  25. return y
  26. class PIPE():
  27. def __init__(self):
  28. self.tmpdir = tempfile.mkdtemp()
  29. try:os.mkdir(self.tmpdir)
  30. except:pass
  31. self.filename = os.path.join(self.tmpdir, 'myfifo')
  32. def init(self):
  33. print()
  34. print( "create ifio file")
  35. print( self.filename)
  36. try:
  37. os.mkfifo(self.filename)
  38. except OSError as e:
  39. print( "Failed to create FIFO: %s" % e)
  40. print( "ende")
  41. return self.filename
  42. def __del__(self):
  43. print( "PIPE DESTRUKTOR")
  44. #self.fifo.close()
  45. os.remove(self.filename)
  46. os.rmdir(self.tmpdir)
  47. def get_touch_id():
  48. cmd = ["xinput"]
  49. sub = subprocess.Popen(cmd, stdout=subprocess.PIPE)
  50. output = sub.communicate()[0]
  51. #print( output)
  52. data = output.split("\n")
  53. odata = []
  54. pattern = "TouchController"
  55. print( "GET INPUT TUCHSCREEN ID")
  56. for line in data:
  57. if pattern in line:
  58. print( line,end="")
  59. if "id=" in line:
  60. idx = line.index("id=")
  61. idx = line.index("id=")
  62. line = line[idx+3:]
  63. line = line.split(" ")[0]
  64. line = line.split("\t")[0]
  65. print( [line])
  66. odata.append(line)
  67. return odata
  68. def enabel_xinput_touch(name,output):
  69. # not implemented
  70. # cmd = "xinput map-to-output {} VGA1".format( i )
  71. # cmd = "xinput test {} > {} ".format(str(i),filename)
  72. pass
  73. def disable_xinput_touch(name):
  74. cmd="xinput list"
  75. print("cmd",cmd)
  76. r=os.popen(cmd)
  77. lines = r.readlines()
  78. for line in lines:
  79. if name in line:
  80. line = line.strip()
  81. line = line.split("\t")
  82. print("DISABLE !!",[line])
  83. _id =""
  84. for l in line:
  85. if "id=" in l:
  86. _id = l.replace("id=","")
  87. if _id:
  88. cmd="xinput disable {}".format(_id) # disable touch as normal input
  89. print("cmd:",cmd)
  90. os.system(cmd)
  91. #exit()
  92. def cleanup_multipointer(prefix="multipointer_"):
  93. import os
  94. cmd="xinput list | grep '{}'".format(prefix)
  95. print(" cleanup multipointer:", cmd)
  96. r=os.popen(cmd )
  97. lines = r.readlines()
  98. for line in lines:
  99. line = line.strip()
  100. line = line.replace("\t"," " )
  101. if " " in line:
  102. line = line.replace(" "," ")
  103. if "id=" in line and "pointer" in line:
  104. line = line.split()
  105. print(" LINE",[line])
  106. _id = line[-4]
  107. _id = _id.replace("id=","")
  108. cmd= "xinput remove-master '{}'".format(_id)
  109. print(" ",cmd)
  110. print(" kill X11 ")
  111. os.system(cmd)
  112. """traps: xfce4-terminal[283904] trap int3 ip:7f784386cabb sp:7ffebb961c10 error:0 in libglib-2.0.so.0.6600.8[7f784382e000+88000]
  113. [24187.974998] xfce4-terminal[306138]: segfault at 90 ip 00007f1b725ac838 sp 00007ffd8e83b940 error 4 in libgdk-3.so.0.2404.20[7f1b72573000+7f000]
  114. [24187.975015] Code: 41 0f 10 4f 60 48 89 5d 38 f2 0f 5e c8 f2 0f 11 4d 48 e8 8b 72 fd ff 48 89 df e8 93 fb fc ff 48 89 ef 48 89 c6 e8 38 7f fd ff <49> 8b b5 90 00 00 00 48 89 ef e8 89 7f fd ff 49 8d 97 b8 00 00 00
  115. """
  116. class Action():
  117. def __init__(self, output=""):
  118. self._X = 0
  119. self._Y = 0
  120. self._Xmin = 10000000000
  121. self._Ymin = 10000000000
  122. self._Xmax = 0
  123. self._Ymax = 0
  124. self.touch_config= {"x_max":1024,"y_max":"768"}
  125. self.touch = ""
  126. self.screen_config = {}
  127. self.screen = output # "DP-2"
  128. self.timer = time.time()
  129. self.motion_changeX =0
  130. self.motion_changeY =0
  131. self.motion_change = 0
  132. self.btn_cmd = ""
  133. self.btn_timer = time.time()
  134. self.btn_down = 0
  135. self.btn_up = 0
  136. self._btn_timer = 0
  137. self._config_ok = 0
  138. self._config_data = []
  139. self.pointer_config = []
  140. self.pointer_create_count = 0
  141. self.MT_SLOT = 0 #int(ix)
  142. self.mode = "touchpad" # or touchscreen
  143. self.refresh_screen_config()
  144. self.refresh_multipointer_config(cleanup=1)
  145. def check_monitor(self):
  146. if self.screen not in self.screen_config:
  147. #for k,v in self.screen_config.items():
  148. # print(k,v)
  149. #print("x() key ",self.screen," not in CONFIG")
  150. return 0
  151. return 1
  152. def system(self,cmd):
  153. if self.check_monitor():
  154. #print("my_system CMD:",cmd)
  155. os.system(cmd)
  156. else:
  157. pass
  158. #print("my_system CMD:",cmd ,"NO MONITOR:",self.screen,"!!!!!")
  159. def refresh_multipointer_config(self,cleanup=0):
  160. print()
  161. print("refresh_multipointer_config")
  162. self.pointer_config = []
  163. prefix = "multipointer_"
  164. prefix = "librelight_pointer_z"
  165. if cleanup:
  166. cleanup_multipointer(prefix=prefix)
  167. cmd = "xinput list | grep '{}' | grep 'XTEST pointer'".format(prefix)
  168. print(" CMD:",cmd)
  169. r = os.popen(cmd)
  170. lines = r.readlines()
  171. for line in lines:
  172. cfg = {}
  173. line = line.strip().split()
  174. print([line])
  175. _id = line[5]
  176. _id = _id.replace(")","")
  177. _id = _id.replace("(","")
  178. _id = _id.replace("id=","")
  179. cfg["id"] = _id
  180. cfg["name"] = line[2]
  181. self.pointer_config.append( cfg )
  182. multipointer_off = 1
  183. # error with window manager
  184. # - window-ontop not working properly
  185. # - window-focus not working properly
  186. # error !!! ???
  187. # creat 5 pointer on screen for Mutlitouch input
  188. # pointer jump's around on X11
  189. #print()
  190. create = []
  191. for i in [1]: #range(1,5+1):
  192. ok = 0
  193. n = "{}{}".format(prefix,i)
  194. for j in self.pointer_config:
  195. print(" pt",i,j)
  196. print(" pt",n, j["name"])
  197. if n == j["name"]:
  198. ok = 1
  199. if multipointer_off:
  200. j["id"] = "xx"
  201. cmd = "xte -i {} 'mousemove {:8} {:8}' ".format(j["id"],4000,4000)
  202. print(" ",cmd)
  203. self.system(cmd)
  204. #cmd = "xinput list-props {} ".format(j["id"])
  205. #print(cmd)
  206. #self.system(cmd)
  207. #cmd = "xinput set-prop {} \"Device Enabled\" 1".format(j["id"])
  208. #print(cmd)
  209. #self.system(cmd)
  210. break
  211. if not ok:
  212. create.append(n)
  213. for i in create:
  214. if not multipointer_off:
  215. cmd = "xinput create-master '{}'".format(i)
  216. print(" CMD:",cmd)
  217. self.system(cmd)
  218. if multipointer_off:
  219. print(" multipointer ist OFF !")
  220. return
  221. if len(create) and self.pointer_create_count < 10: # recursion !!
  222. print(" self.refresh_multipointer_config() # recursion !!!")
  223. self.pointer_create_count += 1
  224. #print(self.pointer_create_count)
  225. self.refresh_multipointer_config()
  226. #for p in range(12):
  227. #for p in self.pointer_config:
  228. # cmd = "xte -i {} 'mousemove {:8} {:8}' ".format(p,10,20)
  229. # self.system(cmd)
  230. def refresh_screen_config(self):
  231. #self.screen_config = {}
  232. cmd = "xrandr --listmonitors"
  233. r = os.popen(cmd)
  234. lines = r.readlines()
  235. lines = lines[1:] # remove header
  236. for line in lines:
  237. cfg = {}
  238. line = line.strip().split()
  239. #print("scr_cfg",[line])
  240. cfg["id"] = line[0]
  241. cfg["name"] = line[1]
  242. cfg["res"] = line[2]
  243. output = line[3]
  244. cfg["output"] = output
  245. if "*" in cfg["name"]:
  246. cfg["primary"] = 1
  247. else:
  248. cfg["primary"] = 0
  249. x,y = cfg["res"].split("x")
  250. cfg["x"] = x.split("/")[0]
  251. cfg["y"] = y.split("/")[0]
  252. pos = y.split("/")
  253. pos = pos[-1]
  254. pos = pos.split("+")
  255. cfg["x_pos"] = pos[1]
  256. cfg["y_pos"] = pos[2]
  257. for k in cfg:
  258. v = cfg[k]
  259. try:
  260. cfg[k] = int(v)
  261. except ValueError:
  262. pass
  263. print(" cfg:",cfg)
  264. self.screen_config[ output] = cfg
  265. #exit()
  266. def x(self):
  267. v = self._X
  268. if not self.check_monitor():
  269. return v
  270. if self.mode == "touchpad":
  271. scr = self.screen_config[self.screen]
  272. v = mapFromTo(self._X,0,self.touch_config["ABS_X"]["Max"],scr["x_pos"],scr["x_pos"]+scr["x"])
  273. elif self.mode == "touchscreen":
  274. v = mapFromTo(self._X,10,4000,0,1600)
  275. return round(v,2)
  276. def y(self):
  277. v = self._Y
  278. if not self.check_monitor():
  279. return v
  280. if self.mode == "touchpad":
  281. scr = self.screen_config[self.screen]
  282. v = mapFromTo(self._Y,0,self.touch_config["ABS_Y"]["Max"],scr["y_pos"],scr["y_pos"]+scr["y"])
  283. elif self.mode == "touchscreen":
  284. v = mapFromTo(self._Y,0,1400,0,1600)
  285. return round(v,2)
  286. def _parse_config(self):
  287. print()
  288. print("_parse_config",[self.screen,self.touch])
  289. code = ""
  290. lines = self._config_data
  291. for i,line in enumerate(lines):
  292. #print(i,[line])
  293. cfg = {}
  294. if "Event code" in line:
  295. line = line.strip()
  296. if " " in line:
  297. line = line.replace(" "," ")
  298. tmp = line.split()
  299. key = tmp[3]
  300. key = key.replace("(","").replace(")","")
  301. cfg["key"] = key
  302. cfg["code"] = tmp[2]
  303. for j in range(1,10):
  304. tmp = lines[i+j]
  305. if not tmp.startswith(" "): #sub config
  306. break
  307. tmp = tmp.strip()
  308. if " " in tmp:
  309. tmp = tmp.replace(" "," ")
  310. tmp = tmp.split()
  311. k = tmp[0]
  312. v = tmp[1]
  313. try:
  314. v = int(v)
  315. except ValueError:
  316. pass
  317. cfg[k] = v
  318. #print(" ADD CFG",key,[k,v])
  319. print(" t_cfg",cfg)
  320. self.touch_config[key] = cfg
  321. def check_config(self,line):
  322. if not self._config_ok:
  323. self._config_data.append( line)
  324. #print("CONFIG:",[line])
  325. if "Testing ... (interrupt to exit)" in line:
  326. self._config_ok = 1
  327. self._parse_config()
  328. return 0
  329. else: #init touch screen config
  330. if "Input driver version is" in line:
  331. self._config_ok = 0
  332. elif "Input device ID:" in line:
  333. self._config_ok = 0
  334. return 1
  335. def cur_pointer_id(self):
  336. i = self.MT_SLOT
  337. #return "xxx"
  338. #print("cur_pointer_id:", self.pointer_config,i)
  339. if i < len(self.pointer_config):
  340. return self.pointer_config[i]["id"]
  341. return "xxx"
  342. def _check_ABS(self,line):
  343. #print([line])
  344. if "ABS_MT_SLOT" in line:
  345. key =", value "
  346. #print("ABS_MT_SLOT", line)
  347. line = line.strip()
  348. if key in line:
  349. ix = line.split()[-1] #.index(key)
  350. try:
  351. ix = int(ix)
  352. if ix > 5:
  353. ix = 5
  354. self.MT_SLOT = ix
  355. #print("++++++++++++++++++++++++++++++++++++++++++++++++++++ NEW SLOT",ix)
  356. #self.cur_pointer_id()
  357. except ValueError:
  358. pass
  359. if "ABS_X" in line or "ABS_Y" in line:# or "ABS_MT_POSITION_X" in line or "ABS_MT_POSITION_Y" in line:
  360. key =", value "
  361. #print("ABS", [line])
  362. if key in line:
  363. ix = line.index(key)
  364. try:
  365. c = line[ix+len(key):]
  366. c = int(c)
  367. if "_X" in line:
  368. self._X =c
  369. if c > self._Xmax:
  370. self._Xmax = c
  371. if c < self._Xmin:
  372. self._Xmin = c
  373. self.motion_changeX += 1
  374. else:
  375. self._Y =c
  376. if debug:print( [c , self._Ymin,c < self._Ymin])
  377. if c > self._Ymax:
  378. self._Ymax = c
  379. if c < self._Ymin:
  380. self._Ymin = c
  381. self.motion_changeY += 1
  382. #cmd = "xdotool mousemove {} {}".format(self.x(),self.y())
  383. # 3 position changes to acept position
  384. if self.motion_changeX >0 and self.motion_changeY >0:
  385. self.motion_changeX =0
  386. self.motion_changeY =0
  387. self.motion_change = 1
  388. if debug:
  389. print( line)
  390. print( cmd)
  391. print( self._Xmin,self._Xmax,self._Ymin,self._Ymax)
  392. #self.system(cmd)
  393. except Exception as e:
  394. print( "ERR:",e)
  395. print( "E:", [line])
  396. def action(self,line):
  397. """GET DEVICE INPUT LINE AND DECODE IT
  398. xinput test
  399. motion a[0]=366 a[1]=558
  400. evtestEvent:
  401. time 1556826444.499763, type 2 (EV_REL), code 0 (REL_X), value 8
  402. """
  403. if "motion" in line: #xinput test id
  404. if "a[2]=1" in line:
  405. #cmd = "xdotool click 1"
  406. cmd = "xdotool mouseup 1"
  407. p = self.cur_pointer_id()
  408. cmd = "xte -i {} mouseup 1 # Monitor:{}".format(p,self.screen)
  409. print("\033[92m{}\033[0m".format( cmd))
  410. #print( line,cmd)
  411. self.system(cmd)
  412. #self.system("ls -l")
  413. if "a[2]=0" in line:
  414. #cmd = "xdotool click 1"
  415. cmd = "xdotool mousedown 1"
  416. print("\033[95m{}\033[0m".format( cmd))
  417. #print( line,cmd)
  418. #self.system(cmd)
  419. #self.system("ls -l")
  420. if "BTN_LEFT" in line or "BTN_TOUCH" in line: #evtest /dev/input/eventX
  421. " Mouse Button Click "
  422. key =", value "
  423. if key in line:
  424. ix = line.index(key)
  425. try:
  426. c = line[ix+len(key):]
  427. c = int(c)
  428. if c:
  429. self.btn_down = 1
  430. else:
  431. self.btn_up = 1
  432. #RESET MOTION CHANGE
  433. self.motion_changeX =0
  434. self.motion_changeY =0
  435. self.motion_change = 0
  436. self.btn_timer = time.time()
  437. #print( line)
  438. #print( self.btn_cmd )
  439. except Exception as e:
  440. print( "ERR:",e)
  441. print( "E:", [line])
  442. if not self.check_config(line):
  443. return
  444. self._check_ABS(line)
  445. self.run()
  446. def btn(self,val):
  447. if val:
  448. #time.sleep(0.01)
  449. cmd = "xdotool mousedown 1"
  450. p = self.cur_pointer_id()
  451. cmd = "xte -i {} 'mousedown 1' # MONITOR:{} OK:{}".format(p,self.screen,self.check_monitor())
  452. msg =""
  453. if self.check_monitor():
  454. msg = "\033[95m{:33}\033[0m {:8} {:8} "
  455. else:
  456. msg = "\033[41m{:33}\033[0m {:8} {:8} "
  457. print(msg.format(cmd,self.x(),self.y()) , self.screen ,"MT_SLOT", self.MT_SLOT)
  458. #print("\033[92m{:30}\033[0m".format( cmd),"{:8} {:8} "
  459. #.format(self.x(),self.y()) , self.screen ,"MT_SLOT",self.MT_SLOT)
  460. if self.MT_SLOT == 0:
  461. pass
  462. self.system(cmd)
  463. self.btn_down = 0
  464. self._btn_timer = time.time()
  465. else:
  466. cmd = "xdotool mouseup 1"
  467. p = self.cur_pointer_id()
  468. cmd = "xte -i {} 'mouseup 1' #MONITOR:{} OK:{}".format(p,self.screen,self.check_monitor())
  469. #print( cmd)
  470. t = time.time() - self._btn_timer
  471. msg =""
  472. if self.check_monitor():
  473. msg = "\033[95m{:33}\033[0m {:8} {:8} "
  474. else:
  475. msg = "\033[41m{:33}\033[0m {:8} {:8} "
  476. print(msg.format(cmd,self.x(),self.y()) , self.screen ,"MT_SLOT", self.MT_SLOT,"t:",round(t,2))
  477. self.system(cmd)
  478. self.btn_up = 0
  479. self._btn_timer = time.time()
  480. time.sleep(0.001)
  481. def set_pointer(self):
  482. #cmd = "xdotool mousemove {:8} {:8} ".format(self.x(),self.y())
  483. p = self.cur_pointer_id()
  484. cmd = "xte -i {} 'mousemove {:8} {:8}' # MONITOR:{}".format(p,int(self.x()),int(self.y()),self.screen)
  485. t = int((time.time() - self._btn_timer)*10)/10.
  486. #print(t,"\033[95m{}\033[0m".format( cmd),self.mode)
  487. if self.MT_SLOT == 0:
  488. self.system(cmd)
  489. #self.system(cmd)
  490. self.motion_changeX =0
  491. self.motion_changeY =0
  492. self.motion_change = 0
  493. self.timer = time.time()
  494. #time.sleep(0.000001)
  495. def run(self):
  496. #print "RUN"
  497. if self.btn_up:
  498. if time.time() - self._btn_timer > 0.05: # long press
  499. self.set_pointer()
  500. self.btn(0)
  501. #self.btn(0)
  502. if self.motion_change and self.timer+0.01 < time.time():
  503. if self.btn_down:
  504. #self.btn(0)
  505. self.set_pointer()
  506. self.btn(1)
  507. if self.motion_change and self.timer+0.01 < time.time():
  508. if time.time() - self._btn_timer > 0.05: # long press
  509. self.set_pointer()
  510. def ist_input(devpath):
  511. devpath = devpath.replace("'","")
  512. cmd="udevadm info --query=all '{}' | grep ID_INPUT_TOUCHSCREEN".format(devpath)
  513. #print("is_input:",cmd)
  514. r=os.popen(cmd)
  515. txt = r.readlines()
  516. ok = 0
  517. for l in txt:
  518. l=l.strip()
  519. #print(" ",l)
  520. ok+=1
  521. #print()
  522. return ok
  523. def get_touch_list():
  524. cmd = 'echo "\n" | evtest 2>&1 | grep event'
  525. print("get_touch_list", [cmd])
  526. r = os.popen(cmd)
  527. lines = r.readlines()
  528. out = []
  529. for line in lines:
  530. line = line.strip()
  531. #line = line.replace("\t"," ")
  532. line = line.split("\t")
  533. if len(line) >= 2:
  534. path = line[0][:-1]
  535. name = line[1]
  536. if ist_input(path):
  537. out.append([name,path])
  538. return out
  539. def touch_filter(name,lines):
  540. out = []
  541. for line in lines:
  542. if name == line[0]:
  543. out = line
  544. return out
  545. def loop(cmd="",output="",name=""):
  546. a = Action(output)
  547. line = ""
  548. #cmd="evtest /dev/input/event5"
  549. #cmd="evtest /dev/input/event24"
  550. while 1:
  551. print()
  552. print("="*40)
  553. print("loop cmd: ",cmd)
  554. r = os.popen(cmd)
  555. while 1:
  556. line = r.readline()
  557. if not line:
  558. print("loop cmd r.readline return NONE !",int(time.time()))
  559. print("losst touchscteen connection",output)
  560. print()
  561. break
  562. try:
  563. a.action(line)
  564. except Exception as e:
  565. print("ERROR:a.action EXCEPTION:",[e])
  566. print("ERROR: >>",output,name)
  567. print("ERROR: >>",line)
  568. time.sleep(1)
  569. # rescan touch input's
  570. touch_list = get_touch_list()
  571. x= touch_filter(name,touch_list)
  572. print(x)
  573. if len(x):
  574. disable_xinput_touch(name)
  575. #cmd="evtest /dev/input/event5"
  576. cmd="evtest {}".format(x[1])
  577. if __name__ == "__main__":
  578. cmd="xset -display :0.0 r rate 240 15"
  579. os.system(cmd)
  580. touch_list = get_touch_list()
  581. touch_ok = []
  582. touchscreen_count = 0
  583. #TOUCH 1 a
  584. print()
  585. name = "iSolution multitouch"
  586. x= touch_filter(name,touch_list)
  587. print(x)
  588. print("TOUCH 0",x)
  589. touch_ok.append(x)
  590. if len(x):
  591. disable_xinput_touch(name)
  592. #cmd="evtest /dev/input/event24"
  593. cmd="evtest {}".format(x[1])
  594. #start_new_thread(loop,(cmd,"DP-2"))
  595. start_new_thread(loop,(cmd,"HDMI-1",name))#),name)
  596. touchscreen_count +=1
  597. #TOUCH 1
  598. print()
  599. name = "iSolution multitouch"
  600. x= touch_filter(name,touch_list)
  601. print("TOUCH 1",x)
  602. touch_ok.append(x)
  603. print("--",x,name)
  604. if len(x):
  605. disable_xinput_touch(name)
  606. #cmd="evtest /dev/input/event24"
  607. cmd="evtest {}".format(x[1])
  608. start_new_thread(loop,(cmd,"DP-2",name))#),name)
  609. #start_new_thread(loop,(cmd,"HDMI-1"))
  610. touchscreen_count +=1
  611. #TOUCH 1
  612. print()
  613. name="ELAN Touchscreen"
  614. x= touch_filter(name,touch_list)
  615. print("TOUCH 2",x)
  616. touch_ok.append(x)
  617. print("--",x,name)
  618. if len(x):
  619. disable_xinput_touch(name)
  620. #cmd="evtest /dev/input/event5"
  621. cmd="evtest {}".format(x[1])
  622. start_new_thread(loop,(cmd,"eDP-1",name))#),name)
  623. #start_new_thread(loop,(cmd,"HDMI-1"))
  624. touchscreen_count +=1
  625. time.sleep(1)
  626. print()
  627. print("touch_ok",touch_ok,touchscreen_count)
  628. while 1:
  629. time.sleep(1)