home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 455.lha / StickMouse_v1.0 / Stickmouse.c < prev    next >
C/C++ Source or Header  |  1990-12-10  |  5KB  |  138 lines

  1. /***************************************************\
  2.  *                                                 *
  3.  *              S T I C K M O U S E                *
  4.  *                                                 *
  5.  * 901002 V 1.0 written and released by Dr. Music  *
  6.  *                                                 *
  7.  * Dr. Music is:                                   *
  8.  * Henning Schmiedehausen                          *
  9.  * Glueckstrasse 3                                 *
  10.  * D-8520 Erlangen                                 *
  11.  * GERMANY                                         *
  12.  * hgschmie@faui41.informatik.uni-erlangen.de      *
  13.  *                                                 *
  14.  * This program is placed in the public domain     *
  15.  * It may be distributed freely as long as this    *
  16.  * message is left unchanged.                      *
  17.  * You may add it to any PD-Disk you want, as long *
  18.  * as you don't charge more money than necessary   *
  19.  * to distribute the Disk.                         *
  20.  *                                                 *
  21. \***************************************************/
  22.  
  23. /* This program will switch the intuition-input.device
  24.    to use different ports and Devices at the external ports to
  25.    control the mouse-pointer. The trigger button will simulate
  26.    the left mouse button, the right button must be simulated via
  27.    Right-Amiga and ALT
  28. */
  29.  
  30. /* Usage of this program: STICKMOUSE <port> <device> */
  31. /*                                     just  STICKMOUSE
  32.    will set the port to 0 and the device to MOUSE (default) */
  33.  
  34. #include <ctype.h>
  35. #include <exec/types.h>
  36. #include <devices/input.h>
  37. #include <devices/gameport.h>
  38.  
  39. void SetMousePort(request,port)
  40. struct IOStdReq        *request;
  41. UBYTE  port;
  42.        {
  43. UBYTE  MyPort;
  44.        MyPort              = port;
  45.        request->io_Command = (UWORD)IND_SETMPORT;
  46.        request->io_Data    = (APTR)&MyPort;
  47.        request->io_Length  = 1L;
  48.        DoIO(request);
  49.        }
  50.  
  51. void SetMouseDev(request,dev)
  52. struct IOStdReq        *request;
  53. UBYTE  dev;
  54.        {
  55. UBYTE  MyDev;
  56.        MyDev               = dev;
  57.        request->io_Command = (UWORD)IND_SETMTYPE;
  58.        request->io_Data    = (APTR)&MyDev;
  59.        request->io_Length  = 1L;
  60.        DoIO(request);
  61.        }
  62.  
  63. static struct          IOStdReq        *StickMouseReq;
  64. static struct          MsgPort         *StickMousePort;
  65.  
  66. main(argc,argv)
  67. int argc;
  68. STRPTR argv[];
  69.        {
  70.  
  71. register COUNT i;                              /* for our loops */
  72.  
  73. UBYTE          Stick_Port,             /* This will keep the Port-Number */
  74.                        Stick_Dev;              /* and this one the Device-Type */
  75.  
  76.        if((argc<3))
  77.                {
  78.                if(argc==1)
  79.                        {
  80.                        Stick_Port = 0;
  81.                        Stick_Dev  = GPCT_MOUSE; /* Default-Settings for MOUSE */
  82.                        }
  83.                else
  84.                        if((argc==2) && (argv[1][0] == '?'))
  85.                                {
  86.                                printf("\n\n STICKMOUSE: switches the Mouse-Pointer-Device\n");
  87.                                printf(" USAGE: STICKMOUSE <port> <device>\n");
  88.                                printf(" <port> = 0/1 for the Joyports\n");
  89.                                printf(" <device> = MOUSE/JOY for the Device\n");
  90.                                printf(" STICKMOUSE without params will set to default\n");
  91.                                printf(" written by Dr. Music 1990\n");
  92.                                exit(10);
  93.                                }
  94.                        else
  95.                                {
  96.                                printf("Useage: StickMouse <port> <dev> or StickMouse ? for help\n");
  97.                                exit(10);
  98.                                }
  99.                }
  100.        else
  101.                {
  102.                Stick_Port = (short)((char)argv[1][0] - '0');
  103.                if((Stick_Port < 0) || (Stick_Port > 1))
  104.                        {
  105.                        printf("Port-Number must be 0 or 1\n");
  106.                        exit(10);
  107.                        }
  108.                for(i=0;i<strlen(argv[2]);i++)
  109.                        argv[2][i] = toupper((char)argv[2][i]);
  110.                if(!strcmp(argv[2],"JOY"))
  111.                        Stick_Dev = GPCT_RELJOYSTICK;
  112.                else
  113.                        if(!strcmp(argv[2],"MOUSE"))
  114.                                Stick_Dev = GPCT_MOUSE;
  115.                        else
  116.                                {
  117.                                printf("Device must be either MOUSE or JOY\n");
  118.                                exit(10);
  119.                                }
  120.                }
  121. /* ok, end of parsing: 0 / 1 is port-number, GPCT_MOUSE / RELJOYSTICK is type
  122. */
  123.                StickMousePort          =       (struct MsgPort *)CreatePort("StickMouse_is_here",NULL);
  124.                StickMouseReq           =       (struct IOStdReq *)CreateStdIO(StickMousePort);
  125.                OpenDevice("input.device",0,StickMouseReq,0);
  126.  
  127.  
  128.                SetMousePort(StickMouseReq,Stick_Port);
  129.                SetMouseDev(StickMouseReq,Stick_Dev);
  130.  
  131.                CloseDevice(StickMouseReq);
  132.                DeleteStdIO(StickMouseReq);
  133.                DeletePort(StickMousePort);
  134.  
  135.        }
  136.  
  137.  
  138.