diff options
author | Rudy Bousset <rbousset@z2r4p3.le-101.fr> | 2020-02-17 20:45:15 +0100 |
---|---|---|
committer | Rudy Bousset <rbousset@z2r4p3.le-101.fr> | 2020-02-17 20:45:15 +0100 |
commit | 75f4768974461a9f3ee51b920c8c8f2e22c5693b (patch) | |
tree | b51fa6c849fdc2810e79c1966a624e7fc07ee9bd /src/ft_key_release.c | |
parent | on est la (diff) | |
download | 42-cub3d-75f4768974461a9f3ee51b920c8c8f2e22c5693b.tar.gz 42-cub3d-75f4768974461a9f3ee51b920c8c8f2e22c5693b.tar.bz2 42-cub3d-75f4768974461a9f3ee51b920c8c8f2e22c5693b.tar.xz 42-cub3d-75f4768974461a9f3ee51b920c8c8f2e22c5693b.tar.zst 42-cub3d-75f4768974461a9f3ee51b920c8c8f2e22c5693b.zip |
Read to merge
Diffstat (limited to '')
-rw-r--r-- | src/ft_key_release.c | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/src/ft_key_release.c b/src/ft_key_release.c new file mode 100644 index 0000000..58eb2bc --- /dev/null +++ b/src/ft_key_release.c @@ -0,0 +1,55 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_key_release.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: rbousset <marvin@42.fr> +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2020/02/17 18:43:56 by rbousset #+# #+# */ +/* Updated: 2020/02/17 18:43:59 by rbousset ### ########lyon.fr */ +/* */ +/* ************************************************************************** */ + +#include <libft.h> +#include <cub3d.h> +#include <stdint.h> + +static void + ft_decale(t_cub *cl) +{ + uint8_t i; + + i = 0; + while (i < 3) + { + if (cl->key_input[i] == -1 && cl->key_input[i + 1] != -1) + { + cl->key_input[i] = cl->key_input[i + 1]; + cl->key_input[i + 1] = -1; + } + i++; + } +} + +static void + ft_pop_key(uint16_t keycode, t_cub *clist) +{ + uint8_t i; + + i = 0; + while (i < 5) + { + if (clist->key_input[i] == keycode) + clist->key_input[i] = -1; + i++; + } + ft_decale(clist); +} + +int + ft_key_release(int keycode, t_cub *clist) +{ + keycode = ft_convert_keycode(keycode); + ft_pop_key(keycode, clist); + return (0); +} |