how to control Linux mouse cursor movement in C -


I'm trying to make an app for the remote control of the mouse on the Linux server via the Android application. As a beginner, I have many problems ... Before writing the Linux server with C, I tried to check whether I can control and move the mouse over Linux according to the code:

  Include # lt; Unistd.h & gt; #include & lt; String.h & gt; # Include & lt; Stdio.h & gt; # Include & lt; Errno.h & gt; # Include & lt; Fcntl.h & gt; # Include & lt; Stdlib.h & gt; # Include & lt; Sys / stat.h & gt; # Include & lt; Sys / time.h & gt; # Include & lt; Sys / types.h & gt; #include & lt; Linux / input.h & gt; Int main () {struct input_event event, event_end; Int i = 0; Int fd = -1; FD = Open ("/ dev / input / event4", O_RDWR | O_NONBLOCK); If (FD & lt; 0) {mirror ("error"); } Memorandum (& amp; event, 0, size (incident)); Memc (& amp; event, 0, size (event_end)); Gettimeofday (& amp; event.time, NULL); Event.type = EV_REL; Event.code = REL_X; Event.value = 100; Gettimeofday (& amp; event_end.time, NULL); Event_end.type = EV_SYN; Event_end.code = SYN_REPORT; Event_end.value = 0; For (i = 0; i <5; i ++) {Write (FD, and event, size (event)); Write a mouse (fd, and event_and, size (event_end)); Sleep (1); } Closed (FD); Return 0; }  

After executing the compile. .. The cursor never moves. Will this be a type of virtualbox setting problem?

Shows the strange strings of the sudo cat / dev / input / event4 symbol when I physically move the mouse over it means that what event 4 is not able to use the mouse cursor movement ?

/ Div>

You can not just write on the device file and expect drivers to send the actual hardware these incidents.

If you are only related to the X Windows environment then you are in luck. You can use this function to send an event to the window:

If you do not know which windows should receive your events, then send it in the root window. Just keep in mind that there is a flag in the events of the X window that shows whether the incident took place from the actual hardware or above. Was synthesized by one of the methods. In most cases, the program only ignores this flag and whether it behaves the same way. But sometimes you may be weird surprises.


Comments

Popular posts from this blog

Pass DB Connection parameters to a Kettle a.k.a PDI table Input step dynamically from Excel -

multithreading - PhantomJS-Node in a for Loop -

c++ - MATLAB .m file to .mex file using Matlab Compiler -