osContStartQuery, osContGetQuery
Gets status and type of SI device
#include <ultra64.h> /* os.h */ s32
osContStartQuery(OSMesgQueue *mq); void
osContGetQuery(OSContStatus *status);
The osContStartQuery function starts to read the values for SI device status and type which is connected to the controller port and the joyport connector. The osContGetQuery function returns those values to status. By calling these two functions, such statuses can be obtained saying whether a standard Controller is connected to the controller port or that a Controller Pak is inserted to the joyport connector. These two functions must be paired for use.
The message queue, mq, must be the initialized message queue linked to OS_EVENT_SI. See the osSetEventMesg function in the N64 Online Function Reference Manual to learn how to create this link.
The osContStartQuery function is called only to issue read command, and the message for completed data reading is returned to the message queue mq. Therefore, the osContGetQuery function should be called to obtain data after the osContStartQuery function is called, and osRecvMesg receives a message indicating data reading is completed. The osContStartQuery function takes around 2 milliseconds to complete its data reading and for osRecvMesg to receive a final message. Other processing, such as re-drawing the screen, can be performed while you are waiting.
You must supply a memory block large enough for MAXCONTROLLER structures of type osContStatus. Regarding the osContSetCh function, it is fine to set the number of direct-type SI devices to be used, to a value less than the value set for MAXCONTROLLERS, as long as the number of direct-type devices used will not be changed in the future.
typedef struct {
u16 type; /* Controller Type */
u8 status; /* Joyport Status */
u8 errno; /* error from device */
}OSContStatus;
One of the following bits is set to 1 for the value of status->type, depending on which kind of direct- SI device is inserted to the controller port. 0 is returned when no device is inserted to the controller port.
Confirm which kind of direct-type SI device is connected to the Controller Port in the following way:
If the direct-type SI device connected to the Controller Port is a Standard Controller, then the status of that joyport can be checked with status->status. The lower bit in status->status is set to 1. If nothing is inserted in either the Controller Port or the joyport connector, or if a direct-type SI device that is not a Controller is inserted, then 0 is returned.
An Error value is set to status->errno when the function fails to read the status value of SI device. 0 is returned if the function was successful. One of the follwing values is returned should an error occur.
void
mainproc(void)
{
OSMesgQueue intMesgQueue;
OSMesg intMesgBuf[1];
OSContStatus sdata[MAXCONTROLLERS];
u8 pattern;
osCreateMesgQueue(&intMesgQueue, intMesgBuf, 1);
osSetEventMesg(OS_EVENT_SI, &intMesgQueue, NULL);
/* Initialize SI device */
osContInit(&intMesgQueue, &pattern, &sdata[0]);
/* start reading SI device status and type */
osContStartQuery(&intMesgQueue);
%
%
/* Confirm the end of reading */
osRecvMesg(&intMesgQueue, NULL, OS_MESG_BLOCK);
/* Obtain SI device status and type */
osContGetQuery(&sdata[0]);
}
osContInit, osContReset, osContStartReadData, osContGetReadData, osContSetCh, and osSetEventMesg
1999/02/01 Completely revised
1999/04/30 Changed format