Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

printf command does not do anything #8

Open
makeevolution opened this issue Jun 2, 2021 · 12 comments
Open

printf command does not do anything #8

makeevolution opened this issue Jun 2, 2021 · 12 comments

Comments

@makeevolution
Copy link

makeevolution commented Jun 2, 2021

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

@vi
Copy link
Owner

vi commented Jun 2, 2021

You need to issue multiple commands to /dev/virtual_touchscreen for it to actually emit some events.

In particular, you'll probably see nothing without S 0 (sync) command.

Note that even if you do see events in /dev/input/eventX, Xorg or other programs may seem to ignore it unless you issue correct commands into /dev/virtual_touchscreen. Use the GUI app and/or sample commands to try it before trying to make a generator of your own events.

cat /dev/virtual_touchscreen should output a short help for possible commands.

@makeevolution
Copy link
Author

Hi,

So I followed your suggestion and created multiple events and making sure I do sync before blocks of command. However, hd still doesn't print anything. On the left console you could see that the virtual touchscreen is indeed there. What could I be doing wrong?

afbeelding

@vi
Copy link
Owner

vi commented Jun 3, 2021

Syncing should come after commands, not before them.

In your second attempt the sync command was typed incorrectly:  S0\n instead of S 0\n.

@makeevolution
Copy link
Author

So I restarted my computer, ran all the required set up steps and re-did the examples with the mistakes fixed as shown below, but still I do not get any output. Is it because I am using Ubuntu 20.04, or is there a setting I forgot to unlock?

afbeelding

@vi
Copy link
Owner

vi commented Jun 3, 2021

\n S 0\n seems wrong - extra space character before S. Likewise for y command.

Try { printf 'x 200\ny 300\nd 0\nS 0' && sleep 0.2 && printf 'u 0\nS 0\n' } > /dev/virtual_touchscreen.

@makeevolution
Copy link
Author

makeevolution commented Jun 3, 2021

So I solved it by going into root; perhaps I could not print to evdev if I am not root. But now I am confused about another thing; as you can see I initiated a down touch on the bottom right console by moving the cursor to x 1580 annd y 830 as shown. But that console is not highlighted. Is this the problem you mentioned where the programs may ignore the touch commands? If so how could I make them recognize it?
afbeelding

@vi
Copy link
Owner

vi commented Jun 3, 2021

Have just built and loaded the module into 5.10.0-6-amd64 and checked that it works:

# hd /dev/input/event22
00000000  3d d4 b8 60 00 00 00 00  a3 66 0a 00 00 00 00 00  |=..`.....f......|
00000010  03 00 00 00 03 00 00 00  3d d4 b8 60 00 00 00 00  |........=..`....|
00000020  a3 66 0a 00 00 00 00 00  03 00 01 00 03 00 00 00  |.f..............|
00000030  3d d4 b8 60 00 00 00 00  a3 66 0a 00 00 00 00 00  |=..`.....f......|
00000040  00 00 00 00 00 00 00 00  45 d4 b8 60 00 00 00 00  |........E..`....|
00000050  e7 82 03 00 00 00 00 00  03 00 00 00 01 00 00 00  |................|
00000060  45 d4 b8 60 00 00 00 00  e7 82 03 00 00 00 00 00  |E..`............|
00000070  03 00 01 00 01 00 00 00  45 d4 b8 60 00 00 00 00  |........E..`....|
00000080  e7 82 03 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00000090  49 d4 b8 60 00 00 00 00  16 bb 06 00 00 00 00 00  |I..`............|
000000a0  03 00 00 00 00 00 00 00  49 d4 b8 60 00 00 00 00  |........I..`....|
000000b0  16 bb 06 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
^C
# printf 's 0\nx 3\ny 3\nS 0\n' > /dev/virtual_touchscreen
# printf 's 0\nx 3\ny 3\nS 0\n' > /dev/virtual_touchscreen
# printf 's 0\nx 1\ny 1\nS 0\n' > /dev/virtual_touchscreen
# printf 's 0\nx 0\ny 1\nS 0\n' > /dev/virtual_touchscreen

Each time I change coordinates, I see incoming event. If I issue the command with the same coordinates, there is no event.

Note that slot selection s 0\n and sync S 0\n are both required.

@makeevolution
Copy link
Author

Yes it worked for me too now; but when I try a down touch on an area (like the unhighlighted cmd console I showed in my previous post), it did not become highlighted. How can I make the OS or other programs actually recognize my touch inputs? I attach it here again for clarity

afbeelding

@vi
Copy link
Owner

vi commented Jun 3, 2021

Have you tried using the GUI program to generate source events?

https://github.com/vi/virtual_touchscreen/releases/download/v1.0/virtual_touchscreen.jar

@makeevolution
Copy link
Author

It says it can't find main class clojure.main

afbeelding

@vi
Copy link
Owner

vi commented Jun 3, 2021

The java -cp clojure.jar clojure.main virtual_touchscreen.clj command line may be obsolete. I was doing it in Clojure 1.3 and this clojure.main is probably changed since than.

Have you tried running the pre-built jar file I linked above?

java -jar virtual_touchscreen.jar?

Do don't need root access to run it, but you'll need to also start external program to forward events from a TCP socket to /dev/virtual_touchscreen.

@vi
Copy link
Owner

vi commented Jun 3, 2021

Checked that virtual_touchscreen.clj still starts with Clojure 1.10.2.

$ clojure virtual_touchscreen.clj

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants