home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Fish 'n' More 2
/
fishmore-publicdomainlibraryvol.ii1991xetec.iso
/
fish
/
libraries
/
input_446
/
src
/
devicetoolkits
/
input
/
test_proto
/
test3.c
< prev
next >
Wrap
C/C++ Source or Header
|
1991-01-05
|
3KB
|
151 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;
struct InputEvent event;
main(argc,argv)
int argc;
char *argv[];
{
long status;
int i;
#ifdef TESTSHARED
/* Open the Input library */
DTInputOpen(DTINPUTREV);
#endif
/* Try to initialize unit 0 of the Input */
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);
/* Do some fun stuff with the mouse */
for (i=0; i<1; i++) {
do_box();
}
/* Free the stuff */
cleanup:
DTInputFree(Unit0);
#ifdef TESTSHARED
DTInputClose();
#endif
}
do_box()
{
long status;
int i;
for (i=0; i<300; i++) {
mouse_event(i,0);
}
if ((status = DTInputStop(Unit0)) != 0) {
fprintf(stderr,"Error stopping unit 0 = %ld,%ld.\n",
status,Unit0->in_error);
fflush(stderr);
DTInputStart(Unit0);
DTInputFree(Unit0);
exit(0);
}
printf("Stopped - Try moving the mouse\n");
fflush(stdout);
Delay(5L*60L);
if ((status = DTInputStart(Unit0)) != 0) {
fprintf(stderr,"Error starting unit 0 = %ld,%ld.\n",
status,Unit0->in_error);
fflush(stderr);
DTInputFree(Unit0);
exit(0);
}
printf("Started\n");
fflush(stdout);
for (i=0; i<300; i++) {
mouse_event(300,i);
}
for (i=300; i>=0; i--) {
mouse_event(i,300);
}
if ((status = DTInputStop(Unit0)) != 0) {
fprintf(stderr,"Error stopping unit 0 = %ld,%ld.\n",
status,Unit0->in_error);
fflush(stderr);
DTInputStart(Unit0);
DTInputFree(Unit0);
exit(0);
}
printf("Stopped - Try moving the mouse\n");
fflush(stdout);
Delay(5L*60L);
if ((status = DTInputFlush(Unit0)) != 0) {
fprintf(stderr,"Error flusing unit 0 = %ld,%ld.\n",
status,Unit0->in_error);
fflush(stderr);
DTInputStart(Unit0);
DTInputFree(Unit0);
exit(0);
}
printf("Flushed\n");
fflush(stdout);
if ((status = DTInputStart(Unit0)) != 0) {
fprintf(stderr,"Error starting unit 0 = %ld,%ld.\n",
status,Unit0->in_error);
fflush(stderr);
DTInputFree(Unit0);
exit(0);
}
printf("Started\n");
fflush(stdout);
for (i=300; i>=0; i--) {
mouse_event(0,i);
}
return (0);
}
mouse_event(x,y)
int x;
int y;
{
long status;
event.ie_NextEvent = NULL;
event.ie_Class = IECLASS_POINTERPOS;
event.ie_SubClass = 0;
event.ie_Code = 0;
event.ie_Qualifier = 0;
event.ie_position.ie_xy.ie_x = x;
event.ie_position.ie_xy.ie_y = y;
event.ie_TimeStamp.tv_secs = 0;
event.ie_TimeStamp.tv_micro = 0;
if ((status = DTInputWriteEvent(Unit0,(BYTE *) &event,
sizeof(event))) != 0) {
fprintf(stderr,"Error writing event to unit 0 = %ld,%ld.\n",
status,Unit0->in_error);
fflush(stderr);
DTInputDestroy(Unit0);
exit(0);
}
return (0);
}