LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel
User Name
Password
Linux - Kernel This forum is for all discussion relating to the Linux kernel.

Notices


Reply
  Search this Thread
Old 06-02-2021, 04:27 PM   #1
makeevolution
LQ Newbie
 
Registered: Jun 2021
Posts: 1

Rep: Reputation: Disabled
Simulating touch events library


Is there a sort of a Python library like PyAutoGUI that can simulate touch events like swiping, two-finger zoom etc.? PyAutoGUI is limited to only keyboard and mouse. Or it doesn't even have to be a Python library; something like xdo would suffice too. Thank you.
 
Old 09-26-2021, 06:18 PM   #2
miltmobley
LQ Newbie
 
Registered: Aug 2013
Posts: 5

Rep: Reputation: Disabled
You should have asked this at python.org.

But kivy package supposedly supports touch.
 
Old 09-26-2021, 07:05 PM   #3
dugan
LQ Guru
 
Registered: Nov 2003
Location: Canada
Distribution: distro hopper
Posts: 11,221

Rep: Reputation: 5319Reputation: 5319Reputation: 5319Reputation: 5319Reputation: 5319Reputation: 5319Reputation: 5319Reputation: 5319Reputation: 5319Reputation: 5319Reputation: 5319
https://python-evdev.readthedocs.io/en/latest/

You find out what the touch events are (use evtest or script your own tester), and then you open a uinput device and send those events to it.

As a demonstration of how to use it: this sends a press of the "A" key on the keyboard each time I press the "A" key on my gamepad. I can start it, switch to a text editor m, press “a” on my gamepad, and watch “a” appear in the text editor.

Code:
#!/usr/bin/env python3

import evdev

# determine this before running the program
gamepad = '/dev/input/event6'

dev = evdev.InputDevice(gamepad)


with evdev.UInput() as ui:
    for event in dev.read_loop():
        if (event.code == evdev.ecodes.BTN_A):
            ui.write(evdev.ecodes.EV_KEY, evdev.ecodes.KEY_A, event.value)
            ui.syn()

Last edited by dugan; 09-27-2021 at 09:59 AM.
 
1 members found this post helpful.
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
user space profiling events enable parameter behaviour not clear: /sys/kernel/debug/tracing/events/enable reset to X when set to 1 barz_83_LQ Linux - Kernel 1 11-30-2017 07:28 AM
simulation of touch events ashg Linux - Newbie 1 05-05-2014 07:21 AM
ACPI events in /etc/acpi/events alienDog Ubuntu 0 12-22-2010 06:30 PM
Keyboard events interrupting mouse events. miner49er Linux - Hardware 3 11-04-2008 04:16 AM
Hang on triggering udev events- is there a buildup of events? sonichedgehog Slackware 20 07-11-2008 02:49 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel

All times are GMT -5. The time now is 01:00 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration