blob: 82235fc31029ddeadf70e066e1af5add9d6f69a6 (
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
42
43
44
45
46
47
48
49
50
51
52
53
54
|
#include <libft.h>
#include <cub3d.h>
#include <stdlib.h>
static int
ft_w_key(void)
{
ft_printf("w\n");
return (0);
}
static int
ft_a_key(void)
{
ft_printf("a\n");
return (0);
}
static int
ft_s_key(void)
{
ft_printf("s\n");
return (0);
}
static int
ft_d_key(void)
{
ft_printf("d\n");
return (0);
}
int
ft_key_event(int keycode, void *param)
{
int (*fun_ptr[4])(void);
fun_ptr[0] = ft_a_key;
fun_ptr[1] = ft_s_key;
fun_ptr[2] = ft_d_key;
fun_ptr[3] = ft_w_key;
ft_printf("Key [%d] pressed\n", keycode);
(keycode == 13) ? (keycode = 3) : 0;
(keycode <= 3) ? ((*fun_ptr[keycode])()) : 0;
if (keycode == 53)
{
ft_memdel(((t_winlist*)param)->wlx);
ft_memdel(((t_winlist*)param)->winptr);
ft_memdel((t_winlist*)param);
ft_printf("Exiting program\n");
exit(0);
}
return (0);
}
|