Swadge 2024 2.0.0
APIs to develop games for the Magfest Swadge
|
Macros | |
#define | BTWN(chr, l, u) (l <= chr && chr <= u) |
Macro to check if a character is between two bounds. | |
#define | IS_UPPER(chr) BTWN(chr, 'A', 'Z') |
Macro to check if a character is an uppercase letter. | |
#define | IS_LOWER(chr) BTWN(chr, 'a', 'z') |
Macro to check if a character is a lowercase letter. | |
#define | IS_NUMBER(chr) BTWN(chr, '0', '9') |
Macro to check if a character is a decimal digit. | |
#define | IS_SYMBOL(chr) (BTWN(chr, '!', '/') || BTWN(chr, ':', '@') || BTWN(chr, '[', '`') || BTWN(chr, '{', '~')) |
Macro to check if a character is a symbol. | |
#define | IS_WHITESPACE(chr) (chr == '\n' || chr == ' ' || chr == '\t') |
Macro to check if a character is whitespace. | |
#define | IS_PRINTABLE(chr) BTWN(chr, ' ', '~') |
Macro to check if a character is printable. | |
#define | MATCH_CHAR(chr, mask) |
Macro to match a character against any mask value. | |
#define | SPIN_DEG_PER_CHAR 12 |
The number of degrees of spin required to advance the character. | |
#define | BLINK_TIME 400000 |
The time of each blink half cycle (on-to-off or off-to-on) | |
#define | REPEAT_DELAY 500000 |
The time a button must be held before it starts repeating. | |
#define | REPEAT_TIME 100000 |
The time between each repeated button press. | |
#define | REPEATABLE_BUTTONS (PB_UP | PB_DOWN | PB_LEFT | PB_RIGHT | PB_B | PB_A) |
Functions | |
textEntry_t * | initTextEntry (uint16_t x, uint16_t y, uint16_t w, uint16_t length, const font_t *font, textEntryCharMask_t mask, textEntryCb cbFn) |
Allocate and return a new text entry. The text entry must be freed with freeTextEntry() | |
void | freeTextEntry (textEntry_t *textEntry) |
Frees any memory associated with a text entry. | |
void | textEntrySetData (textEntry_t *textEntry, void *data) |
Sets the data pointer to be passed along to the callback function. | |
void | textEntrySetText (textEntry_t *textEntry, const char *text) |
Copy the given text into the text entry, replacing any text that was there and moving the cursor to the end of the new text. | |
void | textEntryMainLoop (textEntry_t *textEntry, int64_t elapsedUs) |
Update timer logic and handle touchpad for a text entry. | |
void | textEntryButton (textEntry_t *textEntry, const buttonEvt_t *evt) |
Handle a button event for a text entry to modify the text or confirm entry. | |
void | drawTextEntry (textEntry_t *textEntry, paletteColor_t fg, paletteColor_t bg, bool drawBox) |
Draw a text entry box. | |
#define BTWN | ( | chr, | |
l, | |||
u ) (l <= chr && chr <= u) |
Macro to check if a character is between two bounds.
#define IS_UPPER | ( | chr | ) | BTWN(chr, 'A', 'Z') |
Macro to check if a character is an uppercase letter.
#define IS_LOWER | ( | chr | ) | BTWN(chr, 'a', 'z') |
Macro to check if a character is a lowercase letter.
#define IS_NUMBER | ( | chr | ) | BTWN(chr, '0', '9') |
Macro to check if a character is a decimal digit.
#define IS_SYMBOL | ( | chr | ) | (BTWN(chr, '!', '/') || BTWN(chr, ':', '@') || BTWN(chr, '[', '`') || BTWN(chr, '{', '~')) |
Macro to check if a character is a symbol.
#define IS_WHITESPACE | ( | chr | ) | (chr == '\n' || chr == ' ' || chr == '\t') |
Macro to check if a character is whitespace.
#define IS_PRINTABLE | ( | chr | ) | BTWN(chr, ' ', '~') |
Macro to check if a character is printable.
#define MATCH_CHAR | ( | chr, | |
mask ) |
Macro to match a character against any mask value.
#define SPIN_DEG_PER_CHAR 12 |
The number of degrees of spin required to advance the character.
#define BLINK_TIME 400000 |
The time of each blink half cycle (on-to-off or off-to-on)
#define REPEAT_DELAY 500000 |
The time a button must be held before it starts repeating.
#define REPEAT_TIME 100000 |
The time between each repeated button press.
textEntry_t * initTextEntry | ( | uint16_t | x, |
uint16_t | y, | ||
uint16_t | w, | ||
uint16_t | length, | ||
const font_t * | font, | ||
textEntryCharMask_t | mask, | ||
textEntryCb | cbFn ) |
Allocate and return a new text entry. The text entry must be freed with freeTextEntry()
x | The X coordinate of the left edge of the text box |
y | The Y coordinate of the top of the text box |
w | The width of the text box, in pixels |
length | The maximum text length, or 0 for no limit |
font | The font to use when drawing the text entry |
mask | The mask of allowable character types, or 0 for all characters |
cbFn | The function to call once text entry is complete |
void freeTextEntry | ( | textEntry_t * | textEntry | ) |
Frees any memory associated with a text entry.
textEntry | The text entry to be deallocated |
void textEntrySetData | ( | textEntry_t * | textEntry, |
void * | data ) |
Sets the data pointer to be passed along to the callback function.
textEntry | The text entry to update the data for |
data | The void pointer to be passed when the callback is called |
void textEntrySetText | ( | textEntry_t * | textEntry, |
const char * | text ) |
Copy the given text into the text entry, replacing any text that was there and moving the cursor to the end of the new text.
textEntry | The text entry to update the text for |
text | The text to set as the text entry's value |
void textEntryMainLoop | ( | textEntry_t * | textEntry, |
int64_t | elapsedUs ) |
Update timer logic and handle touchpad for a text entry.
textEntry | The text entry to update |
elapsedUs | The number of nanoseconds elapsed since the last call |
void textEntryButton | ( | textEntry_t * | textEntry, |
const buttonEvt_t * | evt ) |
Handle a button event for a text entry to modify the text or confirm entry.
textEntry | The text entry to handle the button event |
evt | A pointer to the button event to be handled |
void drawTextEntry | ( | textEntry_t * | textEntry, |
paletteColor_t | fg, | ||
paletteColor_t | bg, | ||
bool | drawBox ) |
Draw a text entry box.
textEntry | The text entry to draw |
fg | The color to use for drawing text and "more" dots |
bg | The color to use for drawing inverted text and, if drawBox is enabled, the background |
drawBox | Whether to fill the text entry box area's background |