Pad Functions

The Pad-System can be used to query the joypad to find out if a button is held, for how many ticks it is held or if it has been pressed. More...

Functions


Detailed Description

The Pad-System can be used to query the joypad to find out if a button is held, for how many ticks it is held or if it has been pressed.

You can specify a repeat delay as well as repeat rate which triggers the pressed state to simulate button presses.

The pad supports two behaviors. The so called 'pressed state', which is either set when the button is pushed or released. The default press-behaviour after initializing or resetting the Pad-System is when the button is pushed.

The pad information structure is defined as followed:

typedef struct ATTR_PACKED _TPadButtons
{
    union
    {
        struct 
        {
            u8 A:1;      // -A-
            u8 B:1;      // -B-
            u8 Select:1; // -Select-
            u8 Start:1;  // -Start-
            u8 Right:1;  // -Right-
            u8 Left:1;   // -Left-
            u8 Up:1;     // -Up-
            u8 Down:1;   // -Down-
            u8 R:1;      // -R-, ShoulderButton
            u8 L:1;      // -L-, ShoulderButton
        };

        u16 States;
        u8 Data[];     // Memory to hold key repeat information and such
    };
}TPadButtons, *PPadButtons;

typedef struct _TPad
{
   TPadButtons Pressed; // Holds information about what buttons have been pressed, since last #hel_PadCapture call
   TPadButtons Held;    // Holds information about what buttons are held down, since last #hel_PadCapture call
   u8 Mode;             // Specifies the pad mode, if you want the Pressed-State on button push or release
}TPad, *PPad;

Function Documentation

void hel_PadCapture ( void   ) 

Capture current pad state.

The hel_PadCapture function captures the current Pad states. This function must be called only once per frame and before querying the pad.

See also:
hel_PadQuery

u32 hel_PadGetTicks ( u32  Button  ) 

Get ticks.

The hel_PadGetTicks function returns the ticks of the button in question.

Parameters:
[in] Button Button to retrieve the ticks for. Must be one of the PAD_BUTTON_* defines.
Returns:
Returns the amount of ticks the button is held.
Note:
The function refers to ticks, because it is unspecified what format the ticks represent. It depends on how often you call hel_PadCapture. hel_PadCapture increases every time the button ticks, provided that the button in question is down. So if you call hel_PadCapture every frame, the ticks are also specified in frames.
Button must not be a combination, it must represent the value of only one button instead.

Valid:

    u32 Ticks = hel_PadGetTicks(PAD_BUTTON_A);

Invalid:

    u32 Ticks = hel_PadGetTicks(PAD_BUTTON_A | PAD_BUTTON_B);

void hel_PadInit ( void   ) 

Initialize the pad system.

The hel_PadInit function must be called once before using any of the Pad-System-Functions.

See also:
hel_PadSetMode

const TPad* hel_PadQuery ( void   ) 

Query Pad.

The hel_PadQuery function can be used to query the pad.

Here is an example to query the pad:

    if(hel_PadQuery()->Held.Left)
    {
        // Left direction button held
    }

    if(hel_PadQuery()->Pressed.A)
    {
        // -A- button pressed
    }

Returns:
It returns a pointer to the last captured pad information.
See also:
hel_PadCapture

void hel_PadQuit ( void   ) 

Uninitialize pad system.

The hel_PadQuit uninitializes the Pad-System and clears all current states set in hel_Pad.

void hel_PadSetMode ( u32  Mode  ) 

Set Pad mode.

The Pad-mode has only impact on the Pressed state. It can be specified if the pad button is marked as pressed when it is either pushed (button down) or released (button up).

Parameters:
[in] Mode Specifies the new behaviour. This must be one of these values:
  • PAD_MODE_UP
  • PAD_MODE_DOWN
  • PAD_MODE_DEFAULT

void hel_PadSetRepeatDelay ( u32  Buttons,
u8  Ticks 
)

Set repeat delay.

The hel_PadSetRepeatDelay function can be used to set the button repeat delay. The repeat delay represent the ticks that have to elapse until the repeat rate takes place. For more information about ticks, please see hel_PadGetTicks.

Parameters:
[in] Buttons Button(s) to set the repeat rate for. Must be one or a combination of the PAD_BUTTON_* defines.
[in] Ticks Ticks that have to elapse until the repeat rate takes place. To turn off repeat delay, pass 0 (zero).
See also:
hel_PadSetRepeatRate, hel_PadGetTicks

void hel_PadSetRepeatRate ( u32  Buttons,
u8  Ticks 
)

Set repeat rate.

The hel_PadSetRepeatRate function can be used to set the button repeat rate. The repeat rate is the amount of ticks that have to elapse, until a button pressed state gets triggered. For more information about ticks, please see hel_PadGetTicks.

Parameters:
[in] Buttons Button(s) to set the repeat rate for. Must be one or a combination of the PAD_BUTTON_* defines.
[in] Ticks Ticks that have to elapse until a button pressed state gets triggered. To turn off repeat rate, pass 0 (zero).
See also:
hel_PadSetRepeatDelay, hel_PadGetTicks


Generated on Fri Aug 17 12:12:38 2007 for HEL Library by  doxygen 1.5.3