From 85d3408331fe61d9dbbeb2231ff10ada1c73017e Mon Sep 17 00:00:00 2001 From: Rudy Bousset Date: Thu, 23 Jan 2020 18:11:10 +0100 Subject: Pretty good --- src/ft_key_events.c | 44 ++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 40 insertions(+), 4 deletions(-) (limited to 'src/ft_key_events.c') diff --git a/src/ft_key_events.c b/src/ft_key_events.c index f333cd0..188a770 100644 --- a/src/ft_key_events.c +++ b/src/ft_key_events.c @@ -2,16 +2,52 @@ #include #include +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) { - (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(param->wlx); */ - /* ft_memdel(param->winptr); */ - /* ft_memdel(param); */ + 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); -- cgit v1.2.3