[ back to toc ]

Serial Programming

Date: 2002/04/07 13:01

Q:
Platform: Linux, Redhat 7.0
Compiler: GCC 2.96

I am trying to write the skeleton of an application that simply responds
(say by printing "click" to stdout) when a mouse button is clicked.
I found several options for this: open/read, fopen/fread accessing
/dev/ttyS0, /dev/psaux, or the hex address 0x3f8 (among the many tutorials
I have read).
Now, I want to use fopen/fread because it must be portable (the man pages
said syscalls were not portable).
Ok, I am able to successfully open the file with:

if((fd=fopen("/dev/ttyS0", "r")) != NULL)
printf("Port open...\n");

the problem comes at reading from file...

while((X=fread(buffer, sizeof(int), size, fd))
!= size)
printf("Click...\n");

Sometimes nothing happens when I click the mouse button and sometimes
random lines of source code (from my program) will output to screen.
I just started in Linux and have been going crazy trying to figure this
out. I cannot find anything on the internet related to specifically
capturing/responding mouse input. This is going to be a console
application (for now). I want it as low level as possible (no GPM) while
still be portable (no sys calls). I'd appreciate any help, thanks,

*NAME-DELETED*

A:
This is a linux specific question that I am not expert in. It will not,
however be portable as such thing can not be portable. Low leve and
portable are contradictious.

I could not answer sooner, because the Allexpert server was not reachable
via http.

regards,
Peter

[ back to toc ]