Coder Social home page Coder Social logo

vi / virtual_touchscreen Goto Github PK

View Code? Open in Web Editor NEW
90.0 9.0 33.0 32 KB

Simple evdev linux device driver and GUI program to simulate multitouch touchscreen

Makefile 1.83% Perl 13.99% C 44.67% Clojure 39.50%
linux linux-kernel-module touchscreen virtual gui

virtual_touchscreen's Introduction

virtual_touchscreen

Simple virtual input device for testing things in Linux. Creates a character device and an input device.

screenshot.

Building

module

Building for current kernel:

make

Building for custom kernel (from a configured kernel directory):

make modules M=/path/to/virtual_touchscreen/

application

Use run virtual_touchscreen.clj or just use pre-built virtual_touchscreen.jar from Github releases

Using

Some testing

# insmod virtual_touchscreen.ko
# dmesg | grep virtual_touchscreen
virtual_touchscreen: Major=250
# cat /dev/virtual_touchscreen
Usage: write the following commands to /dev/virtual_touchscreen:
    x num  - move to (x, ...)
    y num  - move to (..., y)
    d 0    - touch down
    u 0    - touch up
    s slot - select multitouch slot (0 to 9)
    a flag - report if the selected slot is being touched
    e 0   - trigger input_mt_report_pointer_emulation
    X num - report x for the given slot
    Y num - report y for the given slot
    S 0   - sync (should be after every block of commands)
    M 0   - multitouch sync
    T num - tracking ID
    also 0123456789:; - arbitrary ABS_MT_ command (see linux/input.h)
  each command is char and int: sscanf("%c%d",...)
  <s>x and y are from 0 to 1023</s> Probe yourself range of x and y
  Each command is terminated with '\n'. Short writes == dropped commands.
  Read linux Documentation/input/multi-touch-protocol.txt to read about events

1# printf 'x 200\ny 300\nS 0\n' > /dev/virtual_touchscreen
1# printf 'd 0\nS 0\n' > /dev/virtual_touchscreen
1# printf 'u 0\nS 0\n' > /dev/virtual_touchscreen

2# hd /dev/input/event11 # or whatever udev assigns
# printf 'x 200\ny 300\nS 0\n' > /dev/virtual_touchscreen
# printf 'd 0\nS 0\n' > /dev/virtual_touchscreen
# printf 'u 0\nS 0\n' > /dev/virtual_touchscreen

And events should flow from the newly created input device:

# hd /dev/input/event11 # or whatever udev assigns
00000000  df 32 48 4f a6 10 02 00  03 00 00 00 c8 00 00 00  |.2HO............|
00000010  df 32 48 4f ab 10 02 00  03 00 01 00 2c 01 00 00  |.2HO........,...|
00000020  df 32 48 4f bf 10 02 00  00 00 00 00 00 00 00 00  |.2HO............|
00000030  e3 32 48 4f af af 09 00  01 00 4a 01 01 00 00 00  |.2HO......J.....|
00000040  e3 32 48 4f bc af 09 00  00 00 00 00 00 00 00 00  |.2HO............|
00000050  e7 32 48 4f 3d bb 05 00  01 00 4a 01 00 00 00 00  |.2HO=.....J.....|
00000060  e7 32 48 4f 50 bb 05 00  00 00 00 00 00 00 00 00  |.2HOP...........|

GUI

There is a GUI application that can also provide data for virtual touchscreen: virtual_touchscreen.clj. (pre-built bundled version; SHA256=917698e287e1b707e09c3040d6347f5f041d7a60fef0a6f5e51c2b93ccd39f3c, also available on Github Releases)

It listens port 9494 and provides virtual_touchscreen input for connected clients.

Example (checked with Clojure 1.3, may need updating):

hostA$  java -cp clojure.jar clojure.main virtual_touchscreen.clj

hostB#  nc hostA 9494 > /dev/virtual_touchscreen

Misc

There is also experimental script to read /dev/input/eventX of some real device and output data for virtual_touchscreen. It is long unmaintained although. Maybe see forks for alternative script.

Licence

Kernel module's licence is GPL. GUI app's license is MIT or Apache 2.0.

virtual_touchscreen's People

Contributors

atmouse- avatar baronmsk avatar vi avatar weber-software avatar

Stargazers

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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

virtual_touchscreen's Issues

Script just says "killed"

Hi,

I know this is old, but I figured I'd ask anyway. I installed the kernel and can see the device (and the cat command returns the instructions), however when I did a test of simulating touch:

1# printf 'x 200\ny 300\nS 0\n' > /dev/virtual_touchscreen

I get back "Killed".

This is running Ubuntu 16.04 4.10.0-37 generic kernel.

Any suggestions for why this might be failing?

Can not find any event device

I'm running Ubuntu 14.04, with 3.x kernel.
After inserting the kernel module, I can't find any new event device

hd /dev/input/event11 # or whatever udev assigns

Would you give me some help? Thanks for your nice code.

install on a raspberry pi

Hello, I just have tried to install the virtual_touchscreen on a raspberry (raspbian), but I'm stumbling still on the first step "make". (I already have done apt-get update, and I tried sudo apt-get install raspberrypi-kernel-headers)

pi@raspberrypi:~/virtual_ctp/virtual_touchscreen-master $ make
make -C /lib/modules/`uname -r`/build M=$PWD modules
make[1]: *** /lib/modules/4.9.59-v7+/build: No such file or directory.  Stop.
Makefile:10: recipe for target 'default' failed
make: *** [default] Error 2

OR

pi@raspberrypi:~/virtual_ctp/virtual_touchscreen-master $ make modules M=/path/to/virtual_touchscreen/
make: *** No rule to make target 'modules'.  Stop.
pi@raspberrypi:~/virtual_ctp/virtual_touchscreen-master $ 

EDIT:
I suppose "make" is for building kernel, so I simply tried to compile the file, but now I think I have to add the "mt.h" File? Is that correct? I don't want build the kernel or such thing (to complicated for me)

pi@raspberrypi:~/virtual_ctp/virtual_touchscreen-master $ gcc -Wall -pthread -o virtual_touchscreen virtual_touchscreen.c
virtual_touchscreen.c:2:28: fatal error: linux/input/mt.h: No such file or directory
 #include <linux/input/mt.h>
                            ^
compilation terminated.
pi@raspberrypi:~/virtual_ctp/virtual_touchscreen-master $ 

evdev throwing an error

After the insmod or modprobe, the device appears and I can use libinput record or evtest for testing it and it works great, but it doesn't work in X. The X log shows this error

[    12.650] (EE) evdev: Touchscreen Virtual Device: Unable to query fd: Inappropriate ioctl for device

Which I think is connected to the TVD not working in the X.

What would have to be changed in the code to make the module work within X?

printf command does not do anything

Hi,

So I cloned the repo and tried to follow your instructions. I run "make" on the repo, run insmod on the .ko file, and saw the virtual touchscreen is there on /dev/input/event7. However, when I printf to this event, nothing happens and when I listen using hd, there is nothing being output (please see screenshot below). I also did not get anything when I do dmesg | grep virtual_touchscreen. Do you perhaps know why? Could you perhaps tell me what am I supposed to see on dmesg and hd everytime I run a command on the virtual touchscreen? I am using Ubuntu 20.04. Thank you!

afbeelding

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.