Swadge 2024 2.0.0
APIs to develop games for the Magfest Swadge
Loading...
Searching...
No Matches
textEntry.c File Reference

Data Structures

struct  textEntry_t
 Struct to store all state for a text entry. More...
 

Macros

#define NUM_KEYBOARD_SYMBOLS   ('~' - ' ' + 2)
 
#define KB_LINES   5
 
#define RETURN_WIDTH   16
 
#define CORNER_MARGIN   20
 
#define SHADOWBOX_MARGIN   4
 
#define KEY_SPACING   5
 
#define BLINK_RATE   500000
 

Enumerations

enum  controlChar_t {
  KEY_SHIFT = 0x01 , KEY_CAPS_LOCK = 0x02 , KEY_BACKSPACE = 0x03 , KEY_SPACE = 0x20 ,
  KEY_EOL = 0x05 , KEY_TAB = 0x09 , KEY_ENTER = 0x0A
}
 

Functions

void textEntryInit (const textEntrySettings_t *settings, char *entryText, font_t *font)
 
void textEntryDeinit ()
 Deletes the memory used by the text entry system.
 
bool textEntryInput (buttonEvt_t evt)
 Handle button input for text entry.
 
bool textEntryDraw (int64_t elapsedUs)
 Draws the text entry screen.
 
void textEntrySoftReset ()
 Resets the textEntry object.
 

Variables

textEntry_tte
 

Data Structure Documentation

◆ textEntry_t

struct textEntry_t
Data Fields
char * text
font_t * font
const textEntrySettings_t * tes
uint8_t widestChar
int selX
int selY
keyModifier_t kMod
char selChar
int64_t blinkTimer The number of nanoseconds remaining before the blink state changes.
bool blinkState Boolean value to keep track of whether the blinking cursor is shown.
char * value The buffer holding the actual entered text value. Can be accessed as a string.
uint16_t size The total size of the dynamic text buffer.
uint16_t cursor The position of the cursor.
bool overtype Whether the cursor will operate in overtype mode instead of insert mode.
bool pendingChar Whether a to-be-entered character should be shown.
char cur The current character pending addition at the cursor, when pendingChar is true.
uint16_t minLength The minimum length of text that will be accepted.
uint16_t maxLength The maximum length of text allowed, or 0 for no limit.
textEntryCharMask_t mask The mask of character types that are allowed.
touchSpinState_t spinState Struct to track the state of the touchpad for spins.
char spinCharStart The selected character at the start of the touchpad spin.
buttonBit_t heldButton The button that is currently being held, or 0 if none.
int64_t repeatTimer The number of nanoseconds remaining before the held button repeats.
uint16_t offset The first character to be drawn on-screen, if the whole value doesn't fit.
uint16_t x The X position of the text entry box.
uint16_t y The Y position of the text entry box.
uint16_t w The width of the text entry box.
const font_t * font The font to use for text entry.
void * data A pointer to be passed back into the callback.
textEntryCb cbFn The function to call when the text entry is completed.

Macro Definition Documentation

◆ NUM_KEYBOARD_SYMBOLS

#define NUM_KEYBOARD_SYMBOLS   ('~' - ' ' + 2)

◆ KB_LINES

#define KB_LINES   5

◆ RETURN_WIDTH

#define RETURN_WIDTH   16

◆ CORNER_MARGIN

#define CORNER_MARGIN   20

◆ SHADOWBOX_MARGIN

#define SHADOWBOX_MARGIN   4

◆ KEY_SPACING

#define KEY_SPACING   5

◆ BLINK_RATE

#define BLINK_RATE   500000

Enumeration Type Documentation

◆ controlChar_t

Enumerator
KEY_SHIFT 
KEY_CAPS_LOCK 
KEY_BACKSPACE 
KEY_SPACE 
KEY_EOL 
KEY_TAB 
KEY_ENTER 

Function Documentation

◆ textEntryInit()

void textEntryInit ( const textEntrySettings_t * settings,
char * entryText,
font_t * font )

◆ textEntryDeinit()

void textEntryDeinit ( void )

Deletes the memory used by the text entry system.

◆ textEntryInput()

bool textEntryInput ( buttonEvt_t evt)

Handle button input for text entry.

Parameters
evtbutton event to run
Returns
false if text entry is still ongoing
true if the enter key was pressed and text entry is done

◆ textEntryDraw()

bool textEntryDraw ( int64_t elapsedUs)

Draws the text entry screen.

Parameters
elapsedUsTIme for cursor blink
Returns
true If text entry is still being executed
false If text entry is done

◆ textEntrySoftReset()

void textEntrySoftReset ( void )

Resets the textEntry object.

Variable Documentation

◆ te