tim@gistdev.gist.com (Tim Larson) (03/22/91)
I am developing an application which will be run on INTERACTIVE 386 UNIX systems which have a Microsoft serial mouse connected to a serial port. I understand that there is a /dev/mouse device driver that can be used with bus mice and that there is a /dev/kdmouse device driver that can be used with keyboard mice (such as exist on a PS/2 system). These devices are accessed with a simple ioctl call that returns information about the button status and mouse movement since the last ioctl call. However, in order to support the Microsoft serial mouse, I believe that I will need to communicate with the mouse through /dev/tty00. As I understand it I will need to open the device and send protocol of some sort to the mouse which will cause it to send back information about button status and mouse movement. Questions: 1) Is anything which I said above wrong? 2) Is there any sample source code available which could assist me? 3) Microsoft Press offers a book entitled "Mouse Programmers Reference Guide". Has anyone seen this book? Does it contain information on the protocols used to access the mouse or does it only document the DOS interrupts that are used the DOS TSR mouse driver? 4) Are there any other sources of documentation that I should look into. 5) Any other suggestions or information that you could offer... Thank you for your time Tim Larson tim@gistdev.gist.com Global Information Systems Technologies Inc. 1-217-352-1165
cpcahil@virtech.uucp (Conor P. Cahill) (03/24/91)
tim@gistdev.gist.com (Tim Larson) writes: >However, in order to support the Microsoft serial mouse, I believe that I will >need to communicate with the mouse through /dev/tty00. As I understand it I >will need to open the device and send protocol of some sort to the mouse which >will cause it to send back information about button status and mouse movement. To work with a serial mouse you need to: 1. open the tty port 2. configure the tty port (ioctls - termio(7)) 3. reset and configure the mouse 4. read and decrypt the port. I have attached a piece of code that (if I remember correctly) does steps 3&4 for a microsoft mouse (I'm sure you can figure out how to do steps 1&2). ***** DISCLAIMER ***** I haven't touched this code in over a year and I don't know for sure if it was still working with a microsoft mouse when I was done (I had been working with other devices at the time). Good luck. write(fd,"",1); /* reset */ sleep(1); write(fd,"@OTI*",5); /* report when pressed */ sleep(1); while( (rlen=read(fd,buffer,512)) > 0) { for(s=buffer, i=0; i < rlen; i++,s++) { if( (*s) & 0x40 ) { new_left_btn = ((*s) & 0x20) == 0x20; new_right_btn = ((*s) & 0x10) == 0x10; chng_x = ((*s) & 0x03) << 6; chng_y = ((*s) & 0x0c) << 4; was = 1; } else if( was == 1 ) { chng_x |= ( (*s) & 0x3f ); total_chng_x += chng_x; was = 2; } else if( was == 2 ) { chng_y |= ( (*s) & 0x3f ); was = 0; total_chng_y += chng_y; #ifdef ADJUST_GRANULARITY /* * If the button state changes, or we have * moved at least divisor pixels... * generate an output... */ if( (old_left_btn != new_left_btn) || (old_right_btn != new_right_btn) || (abs(total_chng_y) > divisor) || (abs(total_chng_x) > divisor) ) { chng_x = total_chng_x / divisor; total_chng_x %= divisor; chng_y = total_chng_y / divisor; total_chng_y %= divisor; fprintf(stdout,"l%d r%d dx=%d dy=%d\n", new_left_btn, new_right_btn, chng_x, chng_y); old_left_btn = new_left_btn; old_right_btn = new_right_btn; } #else fprintf(stdout," l=%d r=%d dx=%d dy=%d\n", new_left_btn, new_right_btn, chng_x, chng_y); #endif } } } -- Conor P. Cahill (703)430-9247 Virtual Technologies, Inc. uunet!virtech!cpcahil 46030 Manekin Plaza, Suite 160 Sterling, VA 22170