-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathget_hook.c
57 lines (54 loc) · 1.91 KB
/
get_hook.c
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
55
56
57
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* get_hook.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: lbrandy <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/03/21 10:35:49 by lbrandy #+# #+# */
/* Updated: 2021/03/21 13:10:03 by lbrandy ### ########.fr */
/* */
/* ************************************************************************** */
#include "cub3d.h"
int ft_press_but(int keycode, t_all *all)
{
if (keycode == 13)
all->hooks->key_w = 1;
if (keycode == 0)
all->hooks->key_a = 1;
if (keycode == 1)
all->hooks->key_s = 1;
if (keycode == 2)
all->hooks->key_d = 1;
if (keycode == 53)
all->hooks->key_esc = 1;
if (keycode == 124)
all->hooks->key_rot_right = 1;
if (keycode == 123)
all->hooks->key_rot_left = 1;
all->hooks->flag = 1;
return (0);
}
int ft_release_but(int keycode, t_all *all)
{
if (keycode == 13)
all->hooks->key_w = 0;
if (keycode == 0)
all->hooks->key_a = 0;
if (keycode == 1)
all->hooks->key_s = 0;
if (keycode == 2)
all->hooks->key_d = 0;
if (keycode == 53)
all->hooks->key_esc = 0;
if (keycode == 124)
all->hooks->key_rot_right = 0;
if (keycode == 123)
all->hooks->key_rot_left = 0;
if (all->hooks->key_rot_left == 0 && all->hooks->key_rot_left == 0 &&
all->hooks->key_esc == 0 && all->hooks->key_d == 0 &&
all->hooks->key_s == 0 && all->hooks->key_a == 0 &&
all->hooks->key_w == 0)
all->hooks->flag = 0;
return (0);
}