home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Club Amiga de Montreal - CAM
/
CAM_CD_1.iso
/
files
/
499.lha
/
InputDeviceToolKit
/
input.lzh
/
src
/
DeviceToolKits
/
Input
/
test_shared
/
test6.c
< prev
next >
Wrap
C/C++ Source or Header
|
1991-01-05
|
3KB
|
139 lines
#include <stdio.h>
#include "DeviceToolKits/Input.h"
#ifndef TESTPROTO
#define NO_PRAGMAS 1
#endif
#include "DeviceToolKits/proto/Input.h"
#include "DeviceToolKits/InputBase.h"
DTInput_t Unit0;
BYTE port;
BYTE type;
struct GamePortTrigger trigger;
main(argc,argv)
int argc;
char *argv[];
{
int timeout;
int xdelta;
int ydelta;
long status;
if (argc != 4) {
fprintf(stderr,"Usage: %s timeout x-delta y-delta\n",argv[0]);
fflush(stderr);
exit(1);
}
timeout = atoi(argv[1]);
xdelta = atoi(argv[2]);
ydelta = atoi(argv[3]);
#ifdef TESTSHARED
/* Open the Input library */
DTInputOpen(DTINPUTREV);
#endif
/* Try to initialize unit 0 of the Input */
printf("Make sure a joystick is connected to the right port\n");
printf("for this test.\n");
fflush(stdout);
if ((Unit0 = DTInputCreate(&status)) == NULL) {
fprintf(stderr,"Error initializing unit 0 = %ld.\n",status);
fflush(stderr);
goto cleanup;
}
fprintf(stderr,"Unit0 = %lX\n",(long) Unit0);
fflush(stderr);
/* Set the input port to the right port */
port = 1;
if ((status = DTInputSetMPort(Unit0,&port)) != 0) {
fprintf(stderr,"Error setting unit 0 port = %ld,%ld.\n",
status,Unit0->in_error);
fflush(stderr);
goto cleanup;
}
/* Set the input controller to an absolute joystick */
type = GPCT_ABSJOYSTICK;
if ((status = DTInputSetMType(Unit0,&type)) != 0) {
fprintf(stderr,"Error setting unit 0 type = %ld,%ld.\n",
status,Unit0->in_error);
fflush(stderr);
goto cleanup;
}
/* Set the input trigger for an absolute joystick */
trigger.gpt_Keys = GPTF_UPKEYS | GPTF_DOWNKEYS;
trigger.gpt_Timeout = timeout;
trigger.gpt_XDelta = xdelta;
trigger.gpt_YDelta = ydelta;
if ((status = DTInputSetMTrigger(Unit0,&trigger)) != 0) {
fprintf(stderr,"Error setting unit 0 trigger = %ld,%ld.\n",
status,Unit0->in_error);
fflush(stderr);
goto cleanup;
}
/* Wait while the user plays */
printf("In 30 seconds, the pointer control will revert to the mouse.\n");
printf("Try moving the pointer with the joystick.\n");
fflush(stdout);
Delay(30L*60L);
/* Set the input port back to the left port */
port = 0;
if ((status = DTInputSetMPort(Unit0,&port)) != 0) {
fprintf(stderr,"Error setting unit 0 port = %ld,%ld.\n",
status,Unit0->in_error);
fflush(stderr);
goto cleanup;
}
/* Set the input controller to a mouse */
type = GPCT_MOUSE;
if ((status = DTInputSetMType(Unit0,&type)) != 0) {
fprintf(stderr,"Error setting unit 0 type = %ld,%ld.\n",
status,Unit0->in_error);
fflush(stderr);
goto cleanup;
}
/* Set the input trigger for a mouse */
trigger.gpt_Keys = GPTF_UPKEYS | GPTF_DOWNKEYS;
trigger.gpt_Timeout = 0;
trigger.gpt_XDelta = 1;
trigger.gpt_YDelta = 1;
if ((status = DTInputSetMTrigger(Unit0,&trigger)) != 0) {
fprintf(stderr,"Error setting unit 0 trigger = %ld,%ld.\n",
status,Unit0->in_error);
fflush(stderr);
goto cleanup;
}
/* Free the stuff */
cleanup:
DTInputFree(Unit0);
#ifdef TESTSHARED
DTInputClose();
#endif
}