home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / comp / os / msdos / programm / 10668 < prev    next >
Encoding:
Text File  |  1992-11-16  |  2.2 KB  |  74 lines

  1. Newsgroups: comp.os.msdos.programmer
  2. Path: sparky!uunet!gumby!wupost!cs.utexas.edu!tamsun.tamu.edu!ski8032
  3. From: ski8032@tamsun.tamu.edu (The Man Behind The Curtain)
  4. Subject: Re: Capturing Mouse Interrupts
  5. Message-ID: <1992Nov16.185802.8557@tamsun.tamu.edu>
  6. Keywords: mouse capture interrupt IRQ
  7. Organization: Texas A&M University, College Station
  8. References: <ua#@byu.edu>
  9. Date: Mon, 16 Nov 1992 18:58:02 GMT
  10. Lines: 62
  11.  
  12. Thus spake $dougn@sasb.byu.edu (Douglas R. Nebeker - MIS_SAS):
  13. >I am trying to hook the mouse interrupts so that each time the mouse is 
  14. >moved, my routine can be notified.  I've tried hooking Int 33h, [...]
  15. Instead of doing that, try this:
  16.  
  17. [..other mouse code removed..]
  18.  
  19. /*  Define interrupt subroutine parameters - This function allows you to
  20.     specify your own interrupt routine to take over the handling of mouse
  21.     activities when any given event specified by the bit mask in event
  22.     occurs.
  23.         Call mask : Word whose first five bits indicate on which events
  24.         the interrupt should be invoked.
  25.             0    Mouse moves
  26.             1    Left mouse button pressed
  27.             2    Left mouse button released
  28.             3    Right mouse button pressed
  29.             4    Right mouse button released
  30. */
  31.  
  32. void install_mouse_interrupt(void far *mouse_handler, int callmask) {
  33.  
  34.     asm    mov  ax,12;            /* Install user-interrupt service */
  35.     asm    mov  cx,callmask
  36.     asm    mov  dx, mouse_handler
  37.     asm    mov  es, dx
  38.     asm    mov  dx, mouse_handler+2
  39.     asm    int  0x33
  40. }
  41.  
  42. This should work just fine.  You can use it like this:
  43.  
  44.  
  45. #include <conio.h>
  46. #include "mouse.h"
  47.  
  48. void far mouse_handler(void) {
  49.     /*  Your code here */
  50.     /*  Note that this is not an ISR; it is a simple function */
  51.     return;
  52. }
  53.  
  54. int main(void) {
  55.     install_mouse_interrupt(mouse_handler, 31);  /* all events trapped */
  56.     getch();
  57.     putch(7);
  58.     install_mouse_interrupt(mouse_handler, 0);  /* disable trapping */
  59.     return 0;
  60. }
  61.  
  62. >Thanks in advance for ANY help!
  63.  
  64. If you would like the rest of the mouse routines (though they are
  65. fairly simple) send me email.
  66.  
  67. >Douglas R. Nebeker         Internet: $dougn@sasb.byu.edu
  68.  
  69. -- 
  70. Till next time,                \o/   \o/
  71.                                 V \o/ V     email:pinky@tamu.edu
  72. <>  Sam  Inala  <>                 V
  73.  
  74.