aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--inc/cub3d.h2
-rw-r--r--src/ft_key_events.c7
-rw-r--r--src/main.c3
3 files changed, 7 insertions, 5 deletions
diff --git a/inc/cub3d.h b/inc/cub3d.h
index d83f7c0..b2ba3b7 100644
--- a/inc/cub3d.h
+++ b/inc/cub3d.h
@@ -127,7 +127,7 @@ typedef struct s_cub
t_win *ft_init_win(void);
t_cub *ft_init_cub(void);
-int ft_key_event(int keycode, void *param);
+int ft_key_event(int keycode, t_cub *clist);
int ft_exit(uint8_t exit_code, t_cub *clist);
void ft_drawsquare(int a, int b, int rgb, t_cub *clist);
void ft_parse_map(const char *map_path, t_cub *clist);
diff --git a/src/ft_key_events.c b/src/ft_key_events.c
index 1b4b738..168d6c0 100644
--- a/src/ft_key_events.c
+++ b/src/ft_key_events.c
@@ -76,7 +76,7 @@ static int
}
int
- ft_key_event(int keycode, void *param)
+ ft_key_event(int keycode, t_cub *clist)
{
int (*fun_ptr[4])(t_cub*);
const int8_t tmp_code = keycode;
@@ -90,8 +90,9 @@ int
(tmp_code == FT_A_KEY) ? (keycode = 1) : 0;
(tmp_code == FT_S_KEY) ? (keycode = 2) : 0;
(tmp_code == FT_D_KEY) ? (keycode = 3) : 0;
- (keycode <= 3) ? ((*fun_ptr[keycode])((t_cub*)param)) : 0;
+ if (keycode <= 3)
+ return (*fun_ptr[keycode])(clist);
if (keycode == FT_ESC_KEY)
- ft_exit(0, ((t_cub*)param));
+ return (ft_exit(0, (clist)));
return (0);
}
diff --git a/src/main.c b/src/main.c
index 114912e..5e05c02 100644
--- a/src/main.c
+++ b/src/main.c
@@ -40,7 +40,8 @@ int
ft_parse_map(argv[1], clist);
if (ft_init_winlx(clist) < 0)
return (ft_exit(3, clist));
- mlx_key_hook(clist->wlist->winptr, ft_key_event, clist);
+ mlx_hook(clist->wlist->winptr, 2, 1L<<1, ft_key_event, clist);
+ /* mlx_key_hook(clist->wlist->winptr, ft_key_event, clist); */
ft_drawmap(clist);
mlx_loop(clist->wlist->wlx);
return (0);