Hi All!

Suppose in the middle of a Linux session, I have pulled out the mouse (a
PS/2) cable. How do I detect that the mouse is no longer intact? I tried
the following C code, but with no result. All the time the status
remains same, whether I plug in or out  the mouse cable. I also tried
writing a BIT to the device with write, but write did not complain, even
if mouse is no longer connected.

  #include <sys/types.h>
  #include <sys/ioctl.h>
  #include <fcntl.h>
  #include <errno.h>
  #include <stdlib.h>
  #include <unistd.h>
  #include <stdio.h>
  #include <signal.h>

  int main(int argc,char **argv)
  {
    int  fd,flags,status;

    /* Open the the device */
    if ((fd = open("/dev/cua1", O_RDWR | O_NDELAY)) < 0) /* /dev/cua1 is
the mouse port */
    {
        fprintf(stderr, "%s\n",sys_errlist[errno]);
        exit(1);
    }
     ioctl(fd, TIOCMGET, &flags);
     status = (flags & TIOCM_CTS);
     printf("%d\n",status);

************************ END OF CODE ************************

Could anybody help?

Madhurjya

--
----------------------------------------------------------------------
Dr. Madhurjya P. Bora

Office :                               Home :

Physics Department                     Flat-2, Unit-12
Gauhati University                     Gauhati University Campus
Guwahati, Assam 781 014, India.        Gauhati University
                                       Guwahati, Assam 781 014, India.

Phone  : +91-361-570531 (O)
         +91-361-574165 (H)
Fax    : +91-361-570133
E-mail : [EMAIL PROTECTED]
         [EMAIL PROTECTED]
----------------------------------------------------------------------






-----------------------------------------------------------------------
LIH is all for free speech.  But it was created for a purpose - to help
people discuss issues about installing and running Linux.  If your
messages are counterproductive to this purpose, your privileges to
submit messages can and will be revoked.

Reply via email to