The SGADE Documentation

the SGADE The Socrates Gameboy Advance Development Engine

The SGADE is a development library for the Nintendo Gameboy Advance. It's free for all uses and is distributed without guarantees. For more information visit the SGADE page.


Main Page   Modules   Data Structures   File List   Data Fields   Globals   Related Pages  

SoKeys

Keypress handling stuff. More...

Files

file  SoKeys.c
file  SoKeys.h

Defines

#define SO_KEY_A
 A key identifier;.

#define SO_KEY_B
 B key identifier;.

#define SO_KEY_SELECT
 Select key identifier;.

#define SO_KEY_START
 Start key identifier;.

#define SO_KEY_RIGHT
 D-pad right key identifier;.

#define SO_KEY_LEFT
 D-pad left key identifier;.

#define SO_KEY_UP
 D-pad up key identifier;.

#define SO_KEY_DOWN
 D-pad down key identifier;.

#define SO_KEY_R
 R shoulder key identifier;.

#define SO_KEY_L
 L shoulder key identifier;.

#define SO_KEY_ANY
 All key identifiers, handy for any-key presses;.


Functions

void SoKeysUpdate (void)
 Updates the key status.

u16 SoKeysGetState (void)
 Returns the current key status bitmap.

bool SoKeysDown (u16 a_Keys)
 Returns true if the given keys are down at the moment;.

bool SoKeysPressed (u16 a_Keys)
 Tests the given keys have been pressed in between the last two calls to SoKeysUpdate.

bool SoKeysReleased (u16 a_Keys)
 Tests the given keys have been released in between the last two calls to SoKeysUpdate.

bool SoKeysPressedRepeat (u16 a_Keys)
 Not yet supported.

void SoKeysSetRepeatDelay (u16 a_nDelay)
 Not yet supported.

void SoKeysSetRepeatSpeed (u16 a_nSpeed)
 Not yet supported.


Detailed Description

Keypress handling stuff.

Singleton

This module handles everything key related. It contains macros for testing whether or not a key is pressed, down or released. See the different functions for the difference between down, pressed and released.


Function Documentation

bool SoKeysDown u16    a_Keys
 

Returns true if the given keys are down at the moment;.

Parameters:
a_Keys  Bitwise OR'ed SO_KEY_* defines. One for each key you want to test.
Returns :
TRUE if the key is or keys are down at the moment
Example usage:

    if ( SoKeysDown( SO_KEY_A | SO_KEY_B ) ) 
    {
        // Key A and/or B are down;
    }

u16 SoKeysGetState void   
 

Returns the current key status bitmap.

This function returns a bitmap containing the current up/down status of each key.

bool SoKeysPressed u16    a_Keys
 

Tests the given keys have been pressed in between the last two calls to SoKeysUpdate.

Parameters:
a_Keys  Bitwise OR'ed SO_KEY_* defines. One for each key you want to test.
Returns :
TRUE if the key has or keys have been pressed.
A key press means that the key has changed from a non-pressed situation (up position) to a pressed situation (down position).

bool SoKeysReleased u16    a_Keys
 

Tests the given keys have been released in between the last two calls to SoKeysUpdate.

Parameters:
a_Keys  Bitwise OR'ed SO_KEY_* defines. One for each key you want to test.
Returns :
TRUE if the key has or keys have been released.
A key release means that the key has changed from a pressed situation (down position) to a non-pressed situation (up position).

void SoKeysUpdate void   
 

Updates the key status.

This function should be called once each frame in order to maintain correct key status bitmaps. The less often this function is called, the more likely that some keypresses will be missed. Calling the function more often than once a frame provides no benefit and reduces the value of the key transition functions SoKeysPressed and SoKeysReleased.


Copyright 2002 by the SGADE authors. See SoLicense.h or Visit the SGADE page for more information.