# PADi_SetIrq

## C Specification

    	#include <nitro/pad/pad.h>

    	void PADi_SetIrq( PADLogic logic, BOOL enable, u16 padMask )

## Description

Performs settings for generation of an interrupt corresponding to key input.
The generated interrupt corresponds to the IRQ interrupt trigger `OS_IE_KEY`.
This function uses the IO register `REG_KEYCNT` (Key Control).

When enable is TRUE, interrupts are enabled. When it is FALSE, interrupts are not generated, regardless of the other settings.

The argument logic specifies how an interrupt is generated according to the key state.
If `PAD_OR_INTR` is specified, when any of the keys/buttons specified with padMask are pressed, an interrupt is generated.
If `PAD_AND_INTR` is specified, when all of the keys/buttons specified with padMask are pressed, an interrupt is generated.

The argument padMask specifies the keys/buttons targeted by the process. The specification is the same as the button press information in PAD_Read().
However, the X, Y, and DEBUG buttons are not targeted. Specify only the buttons in the range of `PAD_KEYPORT_MASK`. (A check is done in the `DEBUG` build using `SDK_ASSERT`.)

For example:

    void nitroMain()
    {
    // ---- Key Interrupt Handler Setting
       OS_SetIrqFunction( OS_IE_KEY, keyintr );

    // ---- Generate Interrupt if the A or B Button is Pressed
       PADi_SetIrq( PAD_LOGIC_OR, TRUE, PAD_BUTTON_A | PAD_BUTTON_B );

    // ---- Permit Interrupts
       OS_SetIrqMask( OS_IE_KEY );
       OS_EnableIrq();
    }

    void keyintr( void )
    {
      // Key Interrupt Process
    }

## Arguments

logic | Logic specification flag for interrupt generation
enable | Enable flag for interrupt request generation
padMask | Button/Key Selection

## Return Values

None.

## See Also

`PAD_Read, PADi_ClearIrq`

## Revision History

04/13/2004 Added description about DEBUG button.
19/02/2004 Added X, Y button description.
12/01/2003 Initial version.