Raw handling of mouse events using a device file would require :
- elevated privileges such that you should not expose to a client application
- enough knowledge of the inner workings of the mouse device, to basically build your own mouse driver, which of course could be a loadable kernel module and it could be made accessible via a local service of your own creation that would receive commands from the network and send them to the kernel module over a custom protocol, or
- you could simply make an application that exposes the functionality of the loaded mouse driver to some sort of external network interface, in which case the simplest solution for the client would be to make it a
REST
interface and operate it via either curl
or a browser
But none of the above solutions seem safe...
Fortunately there are tools that would spare you from such a painstaking effort... and provide you with a safe solution to your problem.
I suppose that when you say that, "you want to control the mouse remotely", you mean to control the mouse as displayed in the target graphical user interface. This is a service provided by the X-Windows server and can be easily and safely controlled via command line using ssh.
Excuse me but, I really do not know how netcat
fits into this picture...
So what you could do is simply use the xdotool
to simulate a mouse event over an ssh connection with:
$ ssh user@machine xdotool mousemove 0 0 click 1
Yes, it is really that simple!
See:
How do mouse events work in linux?
https://stackoverflow.com/questions/1029027/x11-move-an-existing-window-via-command-line
That is in case, you want to control the mouse cursor as seen in the target operating system. Because if your goal is to create a terminal application that uses the mouse (this is the mouse that is physically attached to the client) then you should definitely go for a program that is based on ncurses
. ncurses
makes use of an open source terminal mouse server and can also be used to provide an elaborate gui interface all over ssh and a simple terminal. Also, ncurses does not depend on x-server running, because it does not affect the server's mouse in any manner, it simply uses the client's mouse to control the application.
In any case, if your goal is to simply play with linux device files, try sending a document to the audio device and see how it sounds... a simple cat and pipe with root privileges will work.