blob: 317715d0cf46135b6d28c5e347bd3148c17d8d72 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_key_events.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: rbousset <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/02/14 17:28:55 by rbousset #+# #+# */
/* Updated: 2020/02/14 17:28:55 by rbousset ### ########lyon.fr */
/* */
/* ************************************************************************** */
#include <libft.h>
#include <cub3d.h>
#include <stdlib.h>
#include <stdint.h>
static void
ft_insert_key(uint16_t keycode, t_cub *clist)
{
uint8_t i;
i = 0;
while (i < 5 && clist->key_input[i] != keycode && clist->key_input[i] != -1)
i++;
clist->key_input[i] = keycode;
}
int
ft_key_event(int keycode, t_cub *clist)
{
const int32_t tmp_code = keycode;
keycode = ft_convert_keycode(tmp_code);
if (keycode == FT_ESC_KEY)
return (ft_exit(0, (clist)));
else if (keycode == FT_F1_KEY || keycode == FT_TAB_KEY)
return (ft_f1_key(clist));
ft_insert_key(keycode, clist);
return (0);
}
|