osContStartReadData.3p 2.37 KB
.TH osContStartReadData 3P local "Silicon Graphics, Inc."
.SH NAME
.upperok
osContStartReadData, osContGetReadData \- obtain game controller input settings
.SH SYNOPSIS
.nf
\f3
.Op c
#include <ultra64.h>
.sp .8v
s32 osContStartReadData(OSMesgQueue \(**mq);
.sp .8v
void osContGetReadData(OSContPad \(**pad);
.Op
\f1
.fi
.SH DESCRIPTION
The
.I osContStartReadData
call issues a read data command to obtain game controller input settings,
and the
.I osContGetReadData
call returns 3D Stick data and button settings to
.I pad.
The user must supply a block of memory large enough for 
.I MAXCONTROLLERS
structures of type
.I OSContStatus.
The message queue
.I mq
must be an initialized message queue associated with the
.I OS_EVENT_SI
event.
See
.IR osSetEventMesg (3P)
for details on how to create this association.
The read data command will take around 2 milliseconds to pull data back 
from game controllers.
Thus, the
.I osRecvMesg
call on the message queue
.I mq
can be used to wait for this event.
.sp
The 3D Stick data is of type signed char and in the range between 80 and -80. 
The game controller's input settings can be the following defined constants:
.PP
.nf
.ta 5 20 
	START_BUTTON	Start Button
	A_BUTTON	A Button
	B_BUTTON	B Button 
	U_CBUTTONS	C Button Unit Up
	D_CBUTTONS	C Button Unit Down
	L_CBUTTONS	C Button Unit Left
	R_CBUTTONS	C Button Unit Right
	U_JPAD	Joy Pad Up
	D_JPAD	Joy Pad Down
	L_JPAD	Joy Pad Left
	R_JPAD	Joy Pad Right
	Z_TRIG	Z Trigger
	L_TRIG	L Trigger
	R_TRIG	R Trigger
.fi
.sp
The error number return from game controllers can be:
.PP
.nf
.ta 5 28
	CONT_NO_RESPONSE_ERROR	The controller doesn't respond.
	CONT_OVERRUN_ERROR	The controller sends data at higher
				data transfer rate than the hardware
				handling capability.
.fi
.PP
The user should ignore the data when detects
.I CONT_OVERRUN_ERROR.
.sp
.SH EXAMPLE
.nf
.ta 5 20
main()
{
	OSMesgQueue      intMesgQueue;
	OSMesg		 intMesgBuf[NUM_MESSAGE];
	OSContStatus     sdata[MAXCONTROLLERS];
	OSContPad        rdata[MAXCONTROLLERS];
.sp
	osCreateMesgQueue(&intMesgQueue, intMesgBuf, NUM_MESSAGE);
	osSetEventMesg(OS_EVENT_SI, &intMesgQueue, dummyMessage);
	osContInit(&intMesgQueue, &pattern, &sdata[0]);
	osContStartReadData(&intMesgQueue);
		.
		.
	osRecvMesg(&intMesgQueue, &actualMesg, OS_MESG_BLOCK);
	osContGetReadData(&rdata[0]);
}
.fi
.SH "SEE ALSO"
osContInit (3P),
osContReset (3P),
osContStartQuery (3P),
osContSetCh (3P)