diff options
author | Rudy Bousset <rbousset@z2r4p3.le-101.fr> | 2020-02-17 20:24:57 +0100 |
---|---|---|
committer | Rudy Bousset <rbousset@z2r4p3.le-101.fr> | 2020-02-17 20:24:57 +0100 |
commit | be34d7c8b2565ac055f9dc77111a1029ebd87d77 (patch) | |
tree | 750ceb2402800c855c04c3e66a7294f11c09a7b1 /src/ft_key_release.c | |
parent | Multi-key in progress (diff) | |
download | 42-cub3d-be34d7c8b2565ac055f9dc77111a1029ebd87d77.tar.gz 42-cub3d-be34d7c8b2565ac055f9dc77111a1029ebd87d77.tar.bz2 42-cub3d-be34d7c8b2565ac055f9dc77111a1029ebd87d77.tar.xz 42-cub3d-be34d7c8b2565ac055f9dc77111a1029ebd87d77.tar.zst 42-cub3d-be34d7c8b2565ac055f9dc77111a1029ebd87d77.zip |
sex
Diffstat (limited to 'src/ft_key_release.c')
-rw-r--r-- | src/ft_key_release.c | 26 |
1 files changed, 19 insertions, 7 deletions
diff --git a/src/ft_key_release.c b/src/ft_key_release.c index e56b9d0..58eb2bc 100644 --- a/src/ft_key_release.c +++ b/src/ft_key_release.c @@ -15,6 +15,23 @@ #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; @@ -22,10 +39,11 @@ static void i = 0; while (i < 5) { - if (clist->key_input[i] != keycode) + if (clist->key_input[i] == keycode) clist->key_input[i] = -1; i++; } + ft_decale(clist); } int @@ -33,11 +51,5 @@ int { keycode = ft_convert_keycode(keycode); ft_pop_key(keycode, clist); - ft_printf("keys [%d][%d][%d][%d][%d]\n", - clist->key_input[0], - clist->key_input[1], - clist->key_input[2], - clist->key_input[3], - clist->key_input[4]); return (0); } |