diff options
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); } |