Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members

KeyPad Class Reference

Provides an interface to access the DS keypad more like a normal keyboard. More...

#include <KeyPad.hpp>

Collaboration diagram for KeyPad:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 KeyPad (int repeat_delay, int repeat_rate)
 KeyPad constructor.

uint16 Update (int buttons=-1, int x=-1, int y=-1, int z1=-1, int z2=-1)
 Update the current keypresses.

uint16 GetKeys (void)
 Get the "unadulterated" current keypresses.

bool TouchPos (uint16 &x, uint16 &y)
 If the touchscreen has been pressed, returns the calculated touch position.


Static Public Member Functions

bool TouchPos (int buttons, int x, int y, int z1, int z2, uint16 &x, uint16 &y)
 Mechanism to convert the raw coordinates into calculated coordinates. Static member so that the KeyPad object is not required.


Protected Member Functions

bool updateKey (uint16 keys, uint16 counter, keyData &key)
 Using the keys that are currently read and the current key state, determine if a keypress should be reported.


Private Attributes

uint16 repeat_delay
 Counter ticks before reporting first repated key.

uint16 repeat_rate
 Counter ticks between reporting repeated keypress.

uint16 counter
 The number of times Update has been called.

uint16 current_keys
 The results of the most recent READ_KEYS query.

keyData kd [KP_NUM_KEYS]
 Data for each key.

uint16 touchX
 The current raw touch X position.

uint16 touchY
 The current raw touch Y position.

uint16 touchZ1
 The current x-panel measurements.

uint16 touchZ2
 The current x-panel measurements.

uint16 buttons
 X, Y, /PENIRQ buttons.


Detailed Description

Provides an interface to access the DS keypad more like a normal keyboard.

Typical usage is to call Update on each VBlank interrupt, providing approximately 60 calls per second. This can be used to calculate an appropriate repeat_delay and repeat_rate. For example, values of 30, 10 would cause half a second to pass before repeating the keypress. It would then be reported as pressed every 1/6th of a second thereafter.


Constructor & Destructor Documentation

KeyPad::KeyPad int  repeat_delay,
int  repeat_rate
 

KeyPad constructor.

Parameters:
repeat_delay How long to wait, in calls to Update, after a key is pressed to reported that the key is pressed again.
repeat_rate How long to wait, in calls to Update, to delay before reporting a keypress for a key that is being held down.


Member Function Documentation

bool KeyPad::updateKey uint16  keys,
uint16  counter,
keyData key
[protected]
 

Using the keys that are currently read and the current key state, determine if a keypress should be reported.

Parameters:
keys The current keypresses.
counter The current update counter.
key The keyData to use/update to determine if a keypress should be reported.
Return values:
true Report that this key was just pressed.
false Do not report that this key was just pressed.

uint16 KeyPad::Update int  buttons = -1,
int  x = -1,
int  y = -1,
int  z1 = -1,
int  z2 = -1
 

Update the current keypresses.

Parameters:
buttons The current buttons settings.
x The touchscreen touchX setting.
y The touchscreen touchY setting.
z1 The touchscreen touchZ1 setting.
z2 The touchscreen touchZ2 setting.
Return values:
The READ_KEYS value after taking the repeat_delay/repeat_rate into account.

bool KeyPad::TouchPos uint16 &  x,
uint16 &  y
 

If the touchscreen has been pressed, returns the calculated touch position.

Parameters:
x Reference to the place to store the calculated x position.
y Reference to the place to store the calculated y postiion.
Return values:
true The touch screen is currently pressed, values are valid.
false The touch screen is not being pressed.

bool KeyPad::TouchPos int  buttons,
int  x,
int  y,
int  z1,
int  z2,
uint16 &  x,
uint16 &  y
[static]
 

Mechanism to convert the raw coordinates into calculated coordinates. Static member so that the KeyPad object is not required.

Parameters:
buttons The current buttons settings.
x The touchscreen touchX setting.
y The touchscreen touchY setting.
z1 The touchscreen touchZ1 setting.
z2 The touchscreen touchZ2 setting.
x Reference to the place to store the calculated x position.
y Reference to the place to store the calculated y postiion.
Return values:
true The touch screen is currently pressed, values are valid.
false The touch screen is not being pressed.


The documentation for this class was generated from the following files:
Generated on Fri Apr 22 13:53:32 2005 for Sprite01 Example Application by doxygen 1.3.6