Zyell / Python-Touchscreen-RightClick

Implements multitouch gestures for right click using evdev on Linux
MIT License
12 stars 7 forks source link

_input.ioctl_EVIOCGRAB(self.fd, 0) #3

Open gsgault opened 7 years ago

gsgault commented 7 years ago

Noob here, but learning as I go. I managed to install Python-Touchscreen-RightClick on my Lenovo Yoga 2 11. Both the two-finger tap and the long touch activate a right-click, but a normal one-finger tap results in the following error. I am wondering if someone could help me out. Here's what I get in the terminal:

$ sudo python2.7 ~/.scripts/Python-Touchscreen-RightClick-master/Python_Touchscreen_RightClick.py
[sudo] password for ******
('Total Fingers used: ', 2)
('Total Fingers used: ', 1)
Traceback (most recent call last):
  File "/home/glenn/.scripts/Python-Touchscreen-RightClick-master/Python_Touchscreen_RightClick.py", line 163, in <module>
    initiate_gesture_find()
  File "/home/glenn/.scripts/Python-Touchscreen-RightClick-master/Python_Touchscreen_RightClick.py", line 155, in initiate_gesture_find
    MT_event.remove_fingers()
  File "/home/glenn/.scripts/Python-Touchscreen-RightClick-master/Python_Touchscreen_RightClick.py", line 64, in remove_fingers
    self.dev.ungrab()
  File "/usr/local/lib/python2.7/dist-packages/evdev/device.py", line 299, in ungrab
    _input.ioctl_EVIOCGRAB(self.fd, 0)
IOError: [Errno 22] Invalid argument

The ('Total Fingers used: ', 2) is a successful two-finger right click. The ('Total Fingers used: ', 1) is a single-finger tap that results in a successful left click, but causes an error, and python exits.

More system details:

System:    Host: solydxk Kernel: 4.8.0-1-amd64 x86_64 (64 bit gcc: 5.4.1)
           Desktop: Xfce 4.12.3 (Gtk 2.24.30) Distro: SolydXK
Machine:   Device: laptop System: LENOVO product: 20332 v: Lenovo Yoga 2 11
           Mobo: LENOVO model: AIUU1 v: SDK0J407WIN
           UEFI: LENOVO v: 92CN94WW(V1.94) date: 08/19/2015
$ xinput list-props 11
Device 'Atmel Atmel maXTouch Digitizer':
    Device Enabled (140):   1
    Coordinate Transformation Matrix (142): 1.000000, 0.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 0.000000, 1.000000
    libinput Calibration Matrix (279):  1.000000, 0.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 0.000000, 1.000000
    libinput Calibration Matrix Default (280):  1.000000, 0.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 0.000000, 1.000000

    libinput Send Events Modes Available (261): 1, 0
    libinput Send Events Mode Enabled (262):    0, 0
    libinput Send Events Mode Enabled Default (263):    0, 0
    Device Node (264):  "/dev/input/event12"
    Device Product ID (265):    1003, 34904
    libinput Horizontal Scroll Enabled (266):   0
Zyell commented 7 years ago

Hello! Sorry for the delay. I am currently hunting down a couple of errors and rewriting some of this code. However, the error you have run into can be solved by adding an extra exception in line 65

 except (OSError, IOError):

Adding the IOError in there should solve that issue. Thanks to @gevasiliou for identifying that one. On my system it gives an OSError, but on others this is an IOError. There are some other bugs I'm working on at the moment, but that should get you going.

gsgault commented 7 years ago

Thank you @Zyell and @gevasiliou. This does seem to make long press for right-click work.