Nilorea Library
C utilities for networking, threading, graphics
Loading...
Searching...
No Matches
n_allegro5.c
Go to the documentation of this file.
1
8#include "nilorea/n_common.h"
10
17int get_keyboard(ALLEGRO_USTR* str, ALLEGRO_EVENT event) {
18 __n_assert(str, return FALSE);
19 if (event.type == ALLEGRO_EVENT_KEY_CHAR) {
20 if (event.keyboard.unichar >= 32) {
21 al_ustr_append_chr(str, event.keyboard.unichar);
22 return TRUE;
23 } else if (event.keyboard.keycode == ALLEGRO_KEY_BACKSPACE) {
24 int pos = (int)al_ustr_size(str);
25 if (al_ustr_prev(str, &pos))
26 al_ustr_truncate(str, pos);
27 return TRUE;
28 }
29 }
30 return FALSE;
31}
int get_keyboard(ALLEGRO_USTR *str, ALLEGRO_EVENT event)
update a keyboard buffer from an event
Definition n_allegro5.c:17
#define __n_assert(__ptr, __ret)
macro to assert things
Definition n_common.h:258
Allegro5 helpers.
Common headers and low-level functions & define.