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_proto
/
test4.c
< prev
next >
Wrap
C/C++ Source or Header
|
1991-01-03
|
3KB
|
120 lines
#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;
struct GamePortTrigger trigger;
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);
/* Set the controller for an absolute joystick */
type = GPCT_ABSJOYSTICK;
if ((status = DTGamePortSetType(Unit1,&type)) != 0) {
fprintf(stderr,"Error setting unit 1 type = %ld,%ld.\n",
status,Unit1->gp_error);
fflush(stderr);
goto cleanup;
}
/* 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);
/* Find out what kind of trigger is on unit 1 */
if ((status = DTGamePortGetTrigger(Unit1,&trigger)) != 0) {
fprintf(stderr,"Error getting unit 1 trigger = %ld,%ld.\n",
status,Unit1->gp_error);
fflush(stderr);
goto cleanup;
}
printf("Keys = %x\n",trigger.gpt_Keys);
printf("Timeout = %d\n",trigger.gpt_Timeout);
printf("XDelta = %d\n",trigger.gpt_XDelta);
printf("YDelta = %d\n",trigger.gpt_YDelta);
/* Set the trigger for an absolute joystick */
trigger.gpt_Keys = GPTF_UPKEYS | GPTF_DOWNKEYS;
trigger.gpt_Timeout = 0;
trigger.gpt_XDelta = 1;
trigger.gpt_YDelta = 1;
if ((status = DTGamePortSetTrigger(Unit1,&trigger)) != 0) {
fprintf(stderr,"Error setting unit 1 trigger = %ld,%ld.\n",
status,Unit1->gp_error);
fflush(stderr);
goto cleanup;
}
/* Find out what kind of trigger is on unit 1 */
if ((status = DTGamePortGetTrigger(Unit1,&trigger)) != 0) {
fprintf(stderr,"Error getting unit 1 trigger = %ld,%ld.\n",
status,Unit1->gp_error);
fflush(stderr);
goto cleanup;
}
printf("Keys = %x\n",trigger.gpt_Keys);
printf("Timeout = %d\n",trigger.gpt_Timeout);
printf("XDelta = %d\n",trigger.gpt_XDelta);
printf("YDelta = %d\n",trigger.gpt_YDelta);
/* Free the stuff */
cleanup:
DTGamePortFree(Unit1);
#ifdef TESTSHARED
DTGamePortClose();
#endif
}