home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 11 Util / 11-Util.zip / MOUSCALE.ZIP / MOUSCALE.C next >
Text File  |  1991-04-29  |  3KB  |  112 lines

  1. /* Written 3/25/91 by Joel Apisdorf
  2.  *
  3.  * (703) 437-1837
  4.  * Reston, Virginia
  5.  *
  6.  * You are free to use and modify it as you like.
  7.  */
  8.  
  9. /* Usage: MOUSCALE X Y
  10.  *
  11.  * Where: X and Y are scale factors for mouse
  12.  *        in X and Y directions, respectively.
  13.  *
  14.  *        The larger the value, the slower
  15.  *        the mouse moves in that direction.
  16.  *
  17.  * I typically use MOUSCALE 5 5 with my 200 dpi Microspeed trackball
  18.  * and the MSSER01.SYS mouse device driver set up for MODEL=199.
  19.  *
  20.  * This program only affects the PM graphics mouse movement,
  21.  * NOT the full-screen mouse movement, such as you have
  22.  * in the CodeView debugger.
  23.  */
  24.  
  25.  
  26. #define INCL_DOSFILEMGR
  27. #define INCL_DOSDEVICES
  28. #include <os2.h>
  29. #include <stdio.h>
  30. #include <stdlib.h>
  31.  
  32. CHAR szMouse[] = "MOUSE$";
  33.  
  34. void main( int argc, char *argv[] )
  35. {
  36.     HFILE   hfMouse;
  37.     USHORT  usResult;
  38.     USHORT  usAction;
  39.     USHORT  usFileAttributes = FILE_NORMAL;
  40.     USHORT  usOpenFlags = OPEN_ACTION_OPEN_IF_EXISTS
  41.                         | OPEN_ACTION_FAIL_IF_NEW;
  42.     USHORT  usOpenMode = OPEN_ACCESS_READWRITE
  43.                        | OPEN_SHARE_DENYNONE
  44.                        | OPEN_FLAGS_NOINHERIT
  45.                        | OPEN_FLAGS_NO_LOCALITY
  46.                        | OPEN_FLAGS_FAIL_ON_ERROR;
  47.     USHORT  usFunction;
  48.     PVOID   pData, pParm;
  49.     BOOL    fArgsGood = FALSE;
  50.     struct  {
  51.         SHORT y, x;
  52.     } MouseScaling;
  53.  
  54.  
  55.     /* If there are 2 and only 2 arguments...
  56.      */
  57.     if( argc == 3 )
  58.     {
  59.  
  60.         /* Convert the scale factors to numbers.
  61.          *
  62.          * These are in units of mickeys per pixel.
  63.          */
  64.         MouseScaling.x = atoi( argv[ 1 ] );
  65.         MouseScaling.y = atoi( argv[ 2 ] );
  66.  
  67.         /* If the scale factors are both
  68.          * between 1 and 32767...
  69.          */
  70.         if( MouseScaling.x > 0 && MouseScaling.y > 0 )
  71.  
  72.             /* The arguments are valid.
  73.              */
  74.             fArgsGood = TRUE;
  75.  
  76.     }
  77.  
  78.     if( !fArgsGood )
  79.         return;
  80.  
  81.  
  82.  
  83.  
  84.  
  85.     /* Open the mouse device.
  86.      */
  87.     usResult = DosOpen( szMouse, &hfMouse,
  88.                         &usAction, 0L,
  89.                         usFileAttributes,
  90.                         usOpenFlags,
  91.                         usOpenMode,
  92.                         0L
  93.                       );
  94.     if( usResult )
  95.         return;
  96.  
  97.  
  98.  
  99.  
  100.     /* Set the mouse scaling factors.
  101.      */
  102.     usResult = DosDevIOCtl( NULL, &MouseScaling, 0x53, 7, hfMouse );
  103.  
  104.  
  105.  
  106.  
  107.     /* Close the mouse device.
  108.      */
  109.     DosClose( hfMouse );
  110.  
  111. }
  112.