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