home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / listings / v_01_02 / 1n02078a < prev    next >
Text File  |  1990-07-09  |  1KB  |  44 lines

  1.  
  2. /* mouse_read() reads the current condition of the mouse, and returns -1 */
  3. /* if there is "nothing to report", the value is the keyboard equivalent */
  4. /* to the mouse reading significance otherwise. */
  5.  
  6. static int mouse_read()
  7. {
  8.     int ret_val= -1;
  9.     mstruc m;
  10.     if(button_read().status == RIGHT_BUTTON)
  11.         ret_val=CARRIAGE_RETURN;
  12.     else
  13.     {
  14.         /* clear mouse position counter, pause to let user feel positive lock */
  15.         /* on selected position, like keyboard repeat delay */
  16.         pause(off_time);
  17.         mdpos_read();
  18.         pause(duty_time);
  19.         m=mdpos_read();
  20.         m.dx /=mouse_sensitivity;
  21.         m.dy /=mouse_sensitivity;
  22.     /* the mouse will only respond left/right or up/down on a given read */
  23.         if(m.dx || m.dy)
  24.         {
  25.             if(abs(m.dx) >= abs(m.dy))
  26.             {
  27.                  if(m.dx>0)
  28.                      ret_val=RIGHT_MOVE;
  29.                   else
  30.                      ret_val=LEFT_MOVE;
  31.             }
  32.             else
  33.             {
  34.                 if(m.dy>0)
  35.                     ret_val=DOWN_MOVE;
  36.                 else
  37.                     ret_val=UP_MOVE;
  38.             }
  39.         }
  40.     }
  41.  
  42.     return ret_val;
  43. }
  44.