N64® Functions Menu

al - Audio Library Functions
gDP - DP GBI Macros
gdSP - General GBI Macros
gSP - SP GBI Macros
gt - Turbo Microcode RDP
gu - Graphics Utilities
Math - Math Functions
nuSys - NuSystem
os - N64 Operating System
sp - Sprite Library Functions
uh - Host to Target IO
64DD - N64 Disk Drive

Nintendo® Confidential

   

osContStartQuery osContGetQuery

Format
#include <ultra64.h>
s32 osContStartQuery(OSMesgQueue *mq);
void osContGetQuery(OSContStatus *status);


What This Function Does
The osContStartQuery and osContGetQuery functions obtain the game Controller's status and type. When you call the osContStartQuery function, the query command is issued to the Controller to obtain the Controller's status and type. As the result of the osContGetQuery call, the Controller's status and type are returned to the location pointed to by the status argument.

Notes
You must supply a memory block large enough for MAXCONTROLLER structures of type osContStatus.

The message queue, mq, must be the initialized message queue linked to OS_EVENT_SI. See the osSetEventMesg function to learn how to create this link.

It takes approximately two milliseconds for the query command to retrieve the return value from the Controller. Therefore, the purpose of the osRecvMesg call at the message queue in the example shown below is to wait for this event.

Following is the definition for the structure:
typedef struct {
   u16type;  /* Controller Type */
   u8status; /* Controller Status */
   u8errno;
}OSContStatus;
The Controller's type can be one of the following:
  • CONT_ABSOLUTE - The Controller contains an internal counter, and sends the control stick (A, B, X, Y, Z, L, R, Start buttons) data using the absolute value.
  • CONT_RELATIVE - The Controller contains an internal counter, and sends the control stick (A, B, X, Y, Z, L, R, Start buttons) data using a relative value.
  • CONT_JOYPORT - The Controller is equipped with a Conroller socket for a Controller Pak.
The Controller's status is used for the Controller Pak and it can be one of the following:
  • CONT_CARD_ON - This bit is set when a Controller Pak is connected to the Controller.
  • CONT_CARD_PULL - This bit is set when the Controller Pak is removed after the Controller is reset.
  • CONT_ADDR_CRC_ER - This bit is set when the address was not transferred to the Controller socket properly.
The error value from the Controller will be one of the following<:
  • CONT_NO_RESPONSE_ERROR - No response from the Controller.
  • CONT_OVERRUN_ERROR This bit is set when the data is sent at a higher rate than the hardware can handle.
The user should ignore the data when CONT_OVERRUN_ERROR is detected.

Example
main()

{
OSMesgQueue intMesgQueue;
OSMesg intMesgBuf[NUM_MESSAGE];
OSContStatus sdata[MAXCONTROLLERS];

osCreateMesgQueue(&intMesgQueue,
   intMesgBuf, NUM_MESSAGE);
osSetEventMesg(OS_EVENT_SI,
   &intMesgQueue, dummyMessage);
osContInit(&intMesgQueue,
   &pattern, &sdata[0]);
osContStartQuery(&intMesgQueue);
        .
        .
osRecvMesg(&intMesgQueue,
   &actualMesg, OS_MESG_BLOCK);
osContGetQuery(&sdata[0]);
}
See Also
osContInit
osContReset
osContStartReadData
osContGetReadData
osContSetCh
osSetEventMesg


Nintendo® Confidential

Warning: all information in this document is confidential and covered by a non-disclosure agreement. You are responsible for keeping this information confidential and protected. Nintendo will vigorously enforce this responsibility.


Copyright © 1998
Nintendo of America Inc. All rights reserved
Nintendo and N64 are registered trademarks of Nintendo
Last updated January 1998