Event Broker Convenience Calls


Portfolio provides a set of convenience calls that allow a task to easily monitor events on controller pads or mice.

Note: The convenience calls are "single threaded." Only one thread within any application can use them at a time.

Connecting to the Event Broker

This call connects the task to the event broker, sets the task's focus interest, and determines how many controller pads and mice the task wants to monitor:

Err InitEventUtility(int32 numControlPads, int32 numMice,int32 focusListener);
Where:

When the call executes, it creates a reply port and a message, sends a configuration message to the event broker that asks the event broker to report appropriate mouse and controller pad events, and deals with the event broker's configuration reply. The call returns 0 if successful, and a negative number (an error code) if unsuccessful.

Monitoring a Control Pad or a Mouse

This call specifies a controller pad or mouse to monitor, specifies whether the event broker should respond immediately or wait until something happens on the controller pad, and provides a data structure for data from the controller pad:

Err GetControlPad(int32 padNumber, int32 wait, ControlPadEventData *data);
When the call executes, it either returns immediately with event information, or waits to return with event information until there is a change in the controller pad. It returns a 1 if an event has occurred on the pad, a 0 if no event has occurred on the pad, or a negative number (an error code) if there was a problem retrieving an event. If an event has occurred, the task must check the ControlPadEventData data structure for details about the event.

This call performs the same function as GetControlPad(), but gets events from a specified mouse instead of a specified controller pad:

Err GetMouse(int32 mouseNumber, int32 wait, MouseEventData *data);
Its parameters are the same as those for GetControlPad(), but mouseNumber specifies a mouse on the control port instead of a controller pad, and the pointer data is now a pointer to a data structure for storing mouse event data instead of controller pad event data.

Disconnecting From the Event Broker

This call disconnects a task that was connected to the event broker with the InitEventUtility() call:

Err KillEventUtility(void);
When executed, it disconnects the task from the event broker, closes the reply port, and frees all resources used for the connection. It returns 0 if successful, and a negative number (error code) if unsuccessful.