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 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
14 * implied. See the License for the specific language governing
15 * permissions and limitations under the License.
16 *
17 * SPDX-License-Identifier: Apache-2.0
18 */
19
28#include "nilorea/n_common.h"
29#include "nilorea/n_allegro5.h"
30
37int get_keyboard(ALLEGRO_USTR* str, ALLEGRO_EVENT event) {
38 __n_assert(str, return FALSE);
39 if (event.type == ALLEGRO_EVENT_KEY_CHAR) {
40 if (event.keyboard.unichar >= 32) {
41 al_ustr_append_chr(str, event.keyboard.unichar);
42 return TRUE;
43 } else if (event.keyboard.keycode == ALLEGRO_KEY_BACKSPACE) {
44 int pos = (int)al_ustr_size(str);
45 if (al_ustr_prev(str, &pos))
46 al_ustr_truncate(str, pos);
47 return TRUE;
48 }
49 }
50 return FALSE;
51}
int get_keyboard(ALLEGRO_USTR *str, ALLEGRO_EVENT event)
update a keyboard buffer from an event
Definition n_allegro5.c:37
#define __n_assert(__ptr, __ret)
macro to assert things
Definition n_common.h:279
Allegro5 helpers.
Common headers and low-level functions & define.