home *** CD-ROM | disk | FTP | other *** search
/ Photo CD Demo 1 / Demo.bin / gle / gle / mouse.c < prev    next >
C/C++ Source or Header  |  1992-11-29  |  2KB  |  101 lines

  1. #include <dos.h>
  2. #include <stdlib.h>
  3. #include <stdio.h>
  4. #define false (0)
  5. #define true (!0)
  6. void mousecursor( int toggle);
  7. /*
  8. main()
  9. {
  10.     for (;;) {
  11.         mousecursor(true);
  12.         printf("Mouse col %d  %d \n",mousecol(),mouserow());
  13.         delay(1000);
  14.     }
  15. }
  16.  
  17. */
  18.  
  19. int mousebuttons()                    /* see if mouse buttons are pressed */
  20. {
  21.    union REGS inregs;
  22.    union REGS outregs;
  23.    inregs.x.ax = 6;
  24.    int86(0x33,&inregs,&outregs);
  25.    return(outregs.x.ax & 3);
  26. }
  27.  
  28.  
  29.  
  30. int mousecheck()                      /* see if mouse exists, & # of buttons */
  31. {
  32.    union REGS inregs;
  33.    union REGS outregs;
  34.    inregs.x.ax = 0;
  35.    int86(0x33,&inregs,&outregs);
  36.    return(outregs.x.ax ? outregs.x.bx : 0);
  37. }
  38.  
  39.  
  40.  
  41. int mouseclick()                      /* see if mouse buttons were clicked */
  42. {
  43.    int click = 0;
  44.    union REGS inregs;
  45.    union REGS outregs;
  46.    inregs.x.ax = 5;
  47.    inregs.x.bx = 1;
  48.    int86(0x33,&inregs,&outregs);
  49.    click = outregs.x.bx << 1;
  50.    inregs.x.bx--;
  51.    int86(0x33,&inregs,&outregs);
  52.    return(click | outregs.x.bx);
  53. }
  54.  
  55.  
  56.  
  57. int mousecol()                        /* get column where mouse cursor is */
  58. {
  59.    union REGS inregs;
  60.    union REGS outregs;
  61.    inregs.x.ax = 3;
  62.    int86(0x33,&inregs,&outregs);
  63.    return(outregs.x.cx);
  64. }
  65.  
  66.  
  67.  
  68. void mousecursor(toggle)              /* turn mouse cursor on or off */
  69.    int toggle;
  70. {
  71.    union REGS inregs;
  72.    union REGS outregs;
  73.    if (toggle) inregs.x.ax = 1;
  74.    else inregs.x.ax = 2;
  75.    int86(0x33,&inregs,&outregs);
  76. }
  77.  
  78.  
  79.  
  80. void mouseloc(column,row)             /* set location of mouse cursor */
  81.    int column, row;
  82. {
  83.    union REGS inregs;
  84.    union REGS outregs;
  85.    inregs.x.ax = 4;
  86.    inregs.x.cx = column;
  87.    inregs.x.dx = row;
  88.    int86(0x33,&inregs,&outregs);
  89. }
  90.  
  91.  
  92.  
  93. int mouserow()                        /* get row where mouse cursor is */
  94. {
  95.    union REGS inregs;
  96.    union REGS outregs;
  97.    inregs.x.ax = 3;
  98.    int86(0x33,&inregs,&outregs);
  99.    return(outregs.x.dx);
  100. }
  101.