Nilorea Library
C utilities for networking, threading, graphics
Loading...
Searching...
No Matches
n_allegro5.c
Go to the documentation of this file.
1/*
2 * Nilorea Library
3 * Copyright (C) 2005-2026 Castagnier Mickael
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <https://www.gnu.org/licenses/>.
17 */
18
27#include "nilorea/n_common.h"
28#include "nilorea/n_allegro5.h"
29
36int get_keyboard(ALLEGRO_USTR* str, ALLEGRO_EVENT event) {
37 __n_assert(str, return FALSE);
38 if (event.type == ALLEGRO_EVENT_KEY_CHAR) {
39 if (event.keyboard.unichar >= 32) {
40 al_ustr_append_chr(str, event.keyboard.unichar);
41 return TRUE;
42 } else if (event.keyboard.keycode == ALLEGRO_KEY_BACKSPACE) {
43 int pos = (int)al_ustr_size(str);
44 if (al_ustr_prev(str, &pos))
45 al_ustr_truncate(str, pos);
46 return TRUE;
47 }
48 }
49 return FALSE;
50}
int get_keyboard(ALLEGRO_USTR *str, ALLEGRO_EVENT event)
update a keyboard buffer from an event
Definition n_allegro5.c:36
#define __n_assert(__ptr, __ret)
macro to assert things
Definition n_common.h:278
Allegro5 helpers.
Common headers and low-level functions & define.