#include <stdio.h>

#include "DeviceToolKits/GamePort.h"
#ifndef  TESTPROTO
#define  NO_PRAGMAS  1
#endif
#include "DeviceToolKits/proto/GamePort.h"
#include "DeviceToolKits/GamePortBase.h"

DTGamePort_t   Unit1;
BYTE           type;

main(argc,argv)
int   argc;
char  *argv[];
{
   long  status;

#ifdef   TESTSHARED
/*  Open the GamePort library  */

   DTGamePortOpen(DTGAMEPORTREV);
#endif

/*  Try to initialize unit 1 of the GamePort  */

   if ((Unit1 = DTGamePortCreate(1L,&status)) == NULL) {
      fprintf(stderr,"Error initializing unit 1 = %ld.\n",status);
      fflush(stderr);
      goto cleanup;
   }

   fprintf(stderr,"Unit1 = %lX\n",(long) Unit1);
   fflush(stderr);

/*  Find out what kind of controller is on unit 1  */

   if ((status = DTGamePortGetType(Unit1,&type)) != 0) {
      fprintf(stderr,"Error getting unit 1 type = %ld,%ld.\n",
               status,Unit1->gp_error);
      fflush(stderr);
      goto cleanup;
   }

   printf("Unit 1 controller type = %d.\n",type);

/*  Free the stuff  */

cleanup:
   DTGamePortFree(Unit1);
#ifdef   TESTSHARED
   DTGamePortClose();
#endif
}

