home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 499.lha / GamePortDeviceToolKit / gameport.lzh / src / DeviceToolKits / GamePort / test_shared / test3.c < prev    next >
C/C++ Source or Header  |  1991-01-03  |  2KB  |  77 lines

  1. #include <stdio.h>
  2.  
  3. #include "DeviceToolKits/GamePort.h"
  4. #ifndef  TESTPROTO
  5. #define  NO_PRAGMAS  1
  6. #endif
  7. #include "DeviceToolKits/proto/GamePort.h"
  8. #include "DeviceToolKits/GamePortBase.h"
  9.  
  10. DTGamePort_t   Unit1;
  11. BYTE           type;
  12.  
  13. main(argc,argv)
  14. int   argc;
  15. char  *argv[];
  16. {
  17.    long  status;
  18.  
  19. #ifdef   TESTSHARED
  20. /*  Open the GamePort library  */
  21.  
  22.    DTGamePortOpen(DTGAMEPORTREV);
  23. #endif
  24.  
  25. /*  Try to initialize unit 1 of the GamePort  */
  26.  
  27.    if ((Unit1 = DTGamePortCreate(1L,&status)) == NULL) {
  28.       fprintf(stderr,"Error initializing unit 1 = %ld.\n",status);
  29.       fflush(stderr);
  30.       goto cleanup;
  31.    }
  32.  
  33.    fprintf(stderr,"Unit1 = %lX\n",(long) Unit1);
  34.    fflush(stderr);
  35.  
  36. /*  Find out what kind of controller is on unit 1  */
  37.  
  38.    if ((status = DTGamePortGetType(Unit1,&type)) != 0) {
  39.       fprintf(stderr,"Error getting unit 1 type = %ld,%ld.\n",
  40.                status,Unit1->gp_error);
  41.       fflush(stderr);
  42.       goto cleanup;
  43.    }
  44.  
  45.    printf("Unit 1 controller type = %d.\n",type);
  46.  
  47. /*  Set the controller for an absolute joystick  */
  48.  
  49.    type = GPCT_ABSJOYSTICK;
  50.    if ((status = DTGamePortSetType(Unit1,&type)) != 0) {
  51.       fprintf(stderr,"Error setting unit 1 type = %ld,%ld.\n",
  52.                status,Unit1->gp_error);
  53.       fflush(stderr);
  54.       goto cleanup;
  55.    }
  56.  
  57. /*  Find out what kind of controller is on unit 1  */
  58.  
  59.    if ((status = DTGamePortGetType(Unit1,&type)) != 0) {
  60.       fprintf(stderr,"Error getting unit 1 type = %ld,%ld.\n",
  61.                status,Unit1->gp_error);
  62.       fflush(stderr);
  63.       goto cleanup;
  64.    }
  65.  
  66.    printf("Unit 1 controller type = %d.\n",type);
  67.  
  68. /*  Free the stuff  */
  69.  
  70. cleanup:
  71.    DTGamePortFree(Unit1);
  72. #ifdef   TESTSHARED
  73.    DTGamePortClose();
  74. #endif
  75. }
  76.  
  77.