Main Page | Modules | Related Pages

Pad Functions

The Pad-System is intended to indicate if a button is pressed or held. It supports two behaviours. The so called 'pressed state', which is either set when the button is pushed or released. More...

Functions

Variables


Detailed Description

The Pad-System is intended to indicate if a button is pressed or held. It supports two behaviours. The so called 'pressed state', which is either set when the button is pushed or released.


Function Documentation

void hel_PadInit void   ) 
 

Initialize the pad system.

Call this once at the beginning, to initialize the pad system. The pad behavior is set to PAD_BEHAVIOUR_PRESSED_ON_BUTTON_UP.

See also:
hel_PadReset, hel_PadReadState

void hel_PadReadState void   ) 
 

Read pad state.

The hel_PadReadState function should be only called once per frame.

After calling the hel_PadReadState function, the global variable hel_Pad holds the current states.

See also:
hel_PadInit, hel_PadReset

void hel_PadReset void   ) 
 

Reset the pad system.

Call this to clear the pad states in the global variable hel_Pad. This also sets the pad behavior to PAD_BEHAVIOUR_PRESSED_ON_BUTTON_UP.

See also:
hel_PadInit, hel_PadReadState

void hel_PadSetBehaviour u32  NewBehaviour  ) 
 

Set Pad behaviour.

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

Parameters:
NewBehaviour Specifies the new behaviour. This must be one of these defines:
  • PAD_BEHAVIOUR_PRESSED_ON_BUTTON_UP
  • PAD_BEHAVIOUR_PRESSED_ON_BUTTON_DOWN
See also:
hel_PadReadState


Variable Documentation

TPad ATTR_MEM_IN_EWRAM hel_Pad
 

Variable which holds the Pad states.

After hel_PadReadState has been called, the golbal variable hel_Pad holds the current pad states.

Here is an example program:

void main()
{
    // Initialize pad system
    hel_PadInit();

    // Set pad behavior
    hel_PadSetBehaviour(PAD_BEHAVIOUR_PRESSED_ON_BUTTON_DOWN);
    
    
    // Infinite loop
    while(TRUE)
    {
        // Make sure its a new frame
        if(IsNewFrame)
        {
            // Read pad states
            hel_PadReadState();

            // Access pad variable
            // Check if button down has been pressed
            if(hel_Pad.Pressed.Down)
            {
                Go_One_Menu_Item_Down();
            }
            else
            if(hel_Pad.Pressed.Up)
            {
                Go_One_Menu_Item_Up();
            }

            IsNewFrame = FALSE;
        }
    }

    // reset pad system
    hel_PadReset();
}


Generated on Sun Oct 9 20:21:01 2005 by DoxyGen 1.4.4