# DoControlPad

Queries the specified control pad and de-bounces specified key presses.

### Synopsis

`int32 DoControlPad (int32 whichPad, uint32 *pButton,int32 continuousBits)`

### Description

Queries the state of the specified control pad, and de-bounces the keys, based upon which keys the user is interested in receiving continuous data on button presses, or discrete data.

This function fills pButton with the current state of the control pad. That is, it returns values defined in event.h:

ControlUp ControlDown ControlLeft ControlRight ControlA ControlB ControlC ControlStart ControlX ControlLeftShift ControlRightShift

### Arguments

whichPad
  Index of the control pad to query

pButton
  Pointer to a uint32, in which the state of the requested control pad is returned.

continuousBits
  Events from event.h for which the user would like to get a continuous stream of event states.

### Return Value

Returns 0 if successful or a negative error code if an error occurs.

### Caveats

This function is neither multi-thread or multi-task capable or safe. You should call this from the task or thread which has already called `InitControlPad()`. This is because of system restrictions on item ownership and using items. `InitControlPad()` and `InitEventUtility()` create message ports and message items, which only the task which has created them can use. Hence, `DoControlPad()` can only be called by that same task. Other tasks or threads which attempt this, will get errors due to not owning the appropriate message ports and messages.

To make this multi-thread capable, you would need to spawn off a thread that communicates directly with the event broker, and with all the other tasks that will consume event information.

### Associated Files

controlpad.c, controlpad.h

### Location

examples/ExamplesLib

### See Also

`InitControlPad`, KillControlPad