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!

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.
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?

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.
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?

\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.
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?

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.
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

Have you tried using the GUI program to generate source events?
https://github.com/vi/virtual_touchscreen/releases/download/v1.0/virtual_touchscreen.jar
It says it can't find main class clojure.main

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.
Checked that virtual_touchscreen.clj still starts with Clojure 1.10.2.
$ clojure virtual_touchscreen.clj