Coder Social home page Coder Social logo

python-touchscreen-rightclick's People

Contributors

rp4rk avatar zyell avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

python-touchscreen-rightclick's Issues

Inconsistent long press right click

Long press right click does not always bring up the context menu when clicking on desktop and in nautilus. Furthermore, when it does bring up the context menu, the items are not then clickable via touch. Double tap succeeds in all contexts. Long press without brining up context menu while pressed succeeds. Issue must be in the grabing and ungrabing of events.

ui.write and device capabilities issues

Hello,
Your script is really nice.
I have a convertible Toshiba laptop with ELAN Screen running Debian 8.5 Sid & XFCE, but i had some issues with the UInput and ui.write method.

In my system , the code as described in _initiate_right_click does not work.
The problem turned out to be the device capabilites declaration.
Instead of this:

    capabilities = {ecodes.EV_ABS: (ecodes.ABS_X, ecodes.ABS_Y),
                    ecodes.EV_KEY: (ecodes.BTN_LEFT, ecodes.BTN_RIGHT)}

I had to use this:

    capabilities = {
  ecodes.EV_KEY : [ecodes.BTN_LEFT, ecodes.BTN_RIGHT],
  ecodes.EV_ABS : [(ecodes.ABS_X, AbsInfo(value=1900, min=0, max=3264, fuzz=0, flat=0, resolution=13)), (ecodes.ABS_Y, AbsInfo(1050, 0, 1856, 0, 0, 13))]
   }

I had to apply to AbsInfo min,max,fuzz,flat and resolution values same as my ELAN screen capabilites.

PS1: In any case, i forked your script and i used pymouse for right click injection insted of UInput.

PS2: I also had to modify the position_event part of your script, since in my screen when i'm working with fingers i have a slight change in ABS_X and ABS_Y values when i keep pressing my screen in one point probably due to the high resolution of the screen.
This small change cancels the right click event to be injected , so i modified like bellow to allow +/- 50 pixels movement without cancelling right click:

if self.position[event_code] is None:
    self.position[event_code] = value
else:
    OldValue = self.position[event_code] 
    NewValue = value
    diff = OldValue - NewValue
    if abs(diff) > 50:   
        self._moved_event()

After above modifications, your script works great for me.
The touchscreen gestures trap works like a charm.

_input.ioctl_EVIOCGRAB(self.fd, 0)

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

How to calculate touch unit resolution

I have other Tablet with wacom digitizer
res_x = 13 # touch unit resolution # units/mm in x direction ?
Does it cause this?

tracking started!!!
('Total Fingers used: ', 2)
tracking started!!!
('Total Fingers used: ', 2)
tracking started!!!
('Total Fingers used: ', 2)
tracking started!!!
('Total Fingers used: ', 1)
('Total Fingers used: ', 2)
Traceback (most recent call last):
File "Python_Touchscreen_RightClick.py", line 191, in
initiate_gesture_find(args.use_pymouse, args.long_press_workaround)
File "Python_Touchscreen_RightClick.py", line 172, in initiate_gesture_find
MT_event.remove_fingers()
File "Python_Touchscreen_RightClick.py", line 62, in remove_fingers
self._initiate_right_click()
File "Python_Touchscreen_RightClick.py", line 111, in _initiate_right_click
with UInput(self.abilities) as ui:
File "/usr/lib/python2.7/dist-packages/evdev/uinput.py", line 83, in init
_uinput.create(self.fd, name, vendor, product, version, bustype, absinfo)
IOError: [Errno 22] Invalid argument

Update:
For some unkown reason, uinput doesnt work for my device.
Switch to PyMouse=true doesnt work too
Fortunately @gevasiliou's fork work for me
However due to bug, in xlib I have to run $xhost + then the script
2 fingers taps is not consistent
Hard to stimulate tap at horizontal and vertical edges
The position of the context menu is not precisely determined by any finger of the 2
Thanks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.