Swadge 2024 2.0.0
APIs to develop games for the Magfest Swadge
Loading...
Searching...
No Matches
textEntry.h
Go to the documentation of this file.
1
95#pragma once
96
97//==============================================================================
98// Includes
99//==============================================================================
100
101#include "swadge2024.h"
102
103//==============================================================================
104// Defines
105//==============================================================================
106
107// Selection position
108#define KB_LINES 5
109#define ENTER_X 12
110#define ENTER_Y 2
111
112// Graphics
113#define CORNER_MARGIN 20 // Margin to clear the rounded corners
114#define SHADOWBOX_MARGIN 4 // Margin around shadowboxes
115#define RETURN_WIDTH 16 // Width of return symbol
116#define KEY_SPACING 5 // Space between keys
117#define MAX_WIDTH_CHAR 32 // @ symbol, due to size in fonts tested.
118
119// Timers
120#define BLINK_RATE 500000 // Time in Us before blinker toggles
121
122//==============================================================================
123// Enums
124//==============================================================================
125
134
135typedef enum
136{
137 KEY_SHIFT = 0x01,
140 KEY_SPACE = 0x20,
141 KEY_EOL = 0x05,
142 KEY_TAB = 0x09,
143 KEY_ENTER = 0x0A,
145
146typedef enum
147{
151} bgMode_t;
152
153//==============================================================================
154// Function declarations
155//==============================================================================
156
164void textEntryInit(font_t* useFont, int max_len, char* buffer);
165
172bool textEntryDraw(int64_t elapsedUs);
173
182bool textEntryInput(uint8_t down, uint8_t button);
183
184// Setters
185
191void textEntrySetFont(font_t* newFont);
192
198void textEntrySetBgWsg(wsg_t* BG);
199
205void textEntrySetBGColor(uint8_t color);
206
212
219void textEntrySetTextColor(uint8_t color, bool emphasis);
220
226void textEntrySetEmphasisColor(uint8_t color);
227
234void textEntrySetShadowboxColor(bool active, uint8_t color);
235
241void textEntrySetNewEnterStyle(bool newStyle);
242
248void textEntrySetNewCapsStyle(bool newStyle);
249
256void textEntrySetMultiline(bool multiline);
257
262void textEntrySoftReset(void);
263
269void textEntrySetPrompt(char* prompt);
270
275void textEntrySetCapMode(void);
276
281void textEntrySetNoShiftMode(void);
282
287void textEntrySetShiftMode(void);
288
293void textEntrySetNounMode(void);
A font is a collection of font_ch_t for all ASCII characters. Each character has the same height and ...
Definition font.h:66
controlChar_t
Definition textEntry.h:136
@ KEY_SPACE
Definition textEntry.h:140
@ KEY_ENTER
Definition textEntry.h:143
@ KEY_TAB
Definition textEntry.h:142
@ KEY_SHIFT
Definition textEntry.h:137
@ KEY_BACKSPACE
Definition textEntry.h:139
@ KEY_CAPS_LOCK
Definition textEntry.h:138
@ KEY_EOL
Definition textEntry.h:141
void textEntrySetShadowboxColor(bool active, uint8_t color)
Sets the color of the shadowbox.
Definition textEntry.c:435
bgMode_t
Definition textEntry.h:147
@ COLOR_BG
Definition textEntry.h:149
@ CLEAR_BG
Definition textEntry.h:150
@ WSG_BG
Definition textEntry.h:148
void textEntrySetEmphasisColor(uint8_t color)
Set the emphasis color for the text.
Definition textEntry.c:430
void textEntrySetBgWsg(wsg_t *BG)
Sets a background image and sets the BG Mode to use the WSG.
Definition textEntry.c:404
void textEntrySetFont(font_t *newFont)
A new font to load into the text entry screen.
Definition textEntry.c:398
void textEntrySetNewEnterStyle(bool newStyle)
Sets the style of the Enter key.
Definition textEntry.c:441
void textEntrySetNoShiftMode(void)
Sets the starting mode to lowercase text.
Definition textEntry.c:471
void textEntrySetPrompt(char *prompt)
Sets the prompt text to be displayed. Use an empty string ("") to disable.
Definition textEntry.c:461
void textEntrySetCapMode(void)
Sets the starting mode to capslock.
Definition textEntry.c:466
void textEntryInit(font_t *useFont, int max_len, char *buffer)
Initialize the text entry with prettier graphics.
Definition textEntry.c:156
void textEntrySetTextColor(uint8_t color, bool emphasis)
Set the main text color for the keyboard and entry text.
Definition textEntry.c:421
void textEntrySoftReset(void)
Allow the text box to continue without a full reset.
Definition textEntry.c:456
void textEntrySetNounMode(void)
Sets the starting mode to Porper Nouns (Auto capitalizes first letter after a space)
Definition textEntry.c:481
bool textEntryDraw(int64_t elapsedUs)
Draw the text entry UI.
Definition textEntry.c:184
void textEntrySetBGColor(uint8_t color)
Sets the background to use a solid color.
Definition textEntry.c:410
keyModifier_t
Definition textEntry.h:127
@ SHIFT
Definition textEntry.h:129
@ SPECIAL_DONE
Definition textEntry.h:132
@ NO_SHIFT
Definition textEntry.h:128
@ PROPER_NOUN
Definition textEntry.h:131
@ CAPS_LOCK
Definition textEntry.h:130
void textEntrySetMultiline(bool multiline)
Sets the text entry mode from single line to multi-line.
Definition textEntry.c:451
void textEntrySetShiftMode(void)
Sets the starting mode to Shift, does one capital letter.
Definition textEntry.c:476
bool textEntryInput(uint8_t down, uint8_t button)
Handle button input for text entry.
Definition textEntry.c:214
void textEntrySetNewCapsStyle(bool newStyle)
Sets the style of the caps lock key.
Definition textEntry.c:446
void textEntrySetBGTransparent(void)
Sets the background to be transparent.
Definition textEntry.c:416
A sprite using paletteColor_t colors that can be drawn to the display.
Definition wsg.h:57