diff options
author | Rudy Bousset <rbousset@z2r4p3.le-101.fr> | 2020-02-09 14:55:43 +0100 |
---|---|---|
committer | Rudy Bousset <rbousset@z2r4p3.le-101.fr> | 2020-02-09 14:55:43 +0100 |
commit | 7768d43410b72815c241b74e46476a4896f12b41 (patch) | |
tree | 4af3ea7bc2dd203040fb1e8d543506c9d5d90332 | |
parent | Norme (diff) | |
download | 42-cub3d-7768d43410b72815c241b74e46476a4896f12b41.tar.gz 42-cub3d-7768d43410b72815c241b74e46476a4896f12b41.tar.bz2 42-cub3d-7768d43410b72815c241b74e46476a4896f12b41.tar.xz 42-cub3d-7768d43410b72815c241b74e46476a4896f12b41.tar.zst 42-cub3d-7768d43410b72815c241b74e46476a4896f12b41.zip |
Smooth
Diffstat (limited to '')
-rw-r--r-- | inc/cub3d.h | 2 | ||||
-rw-r--r-- | src/ft_key_events.c | 7 | ||||
-rw-r--r-- | src/main.c | 3 |
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); } @@ -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); |