aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJozanLeClerc <bousset.rudy@gmail.com>2020-01-24 16:51:34 +0100
committerJozanLeClerc <bousset.rudy@gmail.com>2020-01-24 16:51:34 +0100
commit090bda7406b0a3d1692624cf464dd46fb781d55f (patch)
treeadcb05fd965a98d1f4fda9a2cdf2168d103a5a80
parentIt ain't much but it's honest work (diff)
download42-cub3d-090bda7406b0a3d1692624cf464dd46fb781d55f.tar.gz
42-cub3d-090bda7406b0a3d1692624cf464dd46fb781d55f.tar.bz2
42-cub3d-090bda7406b0a3d1692624cf464dd46fb781d55f.tar.xz
42-cub3d-090bda7406b0a3d1692624cf464dd46fb781d55f.tar.zst
42-cub3d-090bda7406b0a3d1692624cf464dd46fb781d55f.zip
Key defines for compatibility between Linux/Darwin
-rw-r--r--Makefile4
-rw-r--r--inc/cub3d.h16
-rw-r--r--src/ft_get_tex.c0
-rw-r--r--src/ft_key_events.c15
-rw-r--r--src/ft_parse_map.c2
5 files changed, 29 insertions, 8 deletions
diff --git a/Makefile b/Makefile
index 7d7045d..f52c084 100644
--- a/Makefile
+++ b/Makefile
@@ -61,7 +61,9 @@ ${OBJS_DIR}%.o: ${SRCS_DIR}%.c ${INCS_DIR}${INCS}
ifeq (${OS}, Darwin)
${CC} -c ${CFLAGS} -I${LFT_DIR}${INCS_DIR} -I${MLX_DIR} -I${INCS_DIR} -o $@ $<
else
- ${CC} -c ${CFLAGS} -I${LFT_DIR}${INCS_DIR} -I${INCS_DIR} -o $@ $<
+ ${CC} -c ${CFLAGS} -I${LFT_DIR}${INCS_DIR} -I${INCS_DIR} \
+-DFT_W_KEY=119 -DFT_A_KEY=97 -DFT_S_KEY=115 -DFT_D_KEY=100 -DFT_ESC_KEY=65307 \
+-o $@ $<
endif
#------------------------------------------------------------------------------#
${NAME}: ${OBJS}
diff --git a/inc/cub3d.h b/inc/cub3d.h
index 0ca7128..4f495d4 100644
--- a/inc/cub3d.h
+++ b/inc/cub3d.h
@@ -3,6 +3,22 @@
#include <inttypes.h>
+#ifndef FT_W_KEY
+#define FT_W_KEY 13
+#endif
+#ifndef FT_A_KEY
+#define FT_A_KEY 0
+#endif
+#ifndef FT_S_KEY
+#define FT_S_KEY 1
+#endif
+#ifndef FT_D_KEY
+#define FT_D_KEY 2
+#endif
+#ifndef FT_ESC_KEY
+#define FT_ESC_KEY 53
+#endif
+
typedef struct s_win
{
void *wlx;
diff --git a/src/ft_get_tex.c b/src/ft_get_tex.c
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/src/ft_get_tex.c
diff --git a/src/ft_key_events.c b/src/ft_key_events.c
index 088df54..74d6346 100644
--- a/src/ft_key_events.c
+++ b/src/ft_key_events.c
@@ -35,14 +35,17 @@ ft_key_event(int keycode, 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;
+ fun_ptr[0] = ft_w_key;
+ fun_ptr[1] = ft_a_key;
+ fun_ptr[2] = ft_s_key;
+ fun_ptr[3] = ft_d_key;
ft_printf("Key [%d] pressed\n", keycode);
- (keycode == 13) ? (keycode = 3) : 0;
+ (keycode == FT_W_KEY) ? (keycode = 0) : 0;
+ (keycode == FT_A_KEY) ? (keycode = 1) : 0;
+ (keycode == FT_S_KEY) ? (keycode = 2) : 0;
+ (keycode == FT_D_KEY) ? (keycode = 3) : 0;
(keycode <= 3) ? ((*fun_ptr[keycode])()) : 0;
- if (keycode == 53)
+ if (keycode == FT_ESC_KEY)
{
ft_memdel(((t_win*)param)->winptr);
ft_memdel(((t_win*)param)->wlx);
diff --git a/src/ft_parse_map.c b/src/ft_parse_map.c
index 2fa5741..60726a2 100644
--- a/src/ft_parse_map.c
+++ b/src/ft_parse_map.c
@@ -5,7 +5,7 @@
#include <unistd.h>
/*
-** I can't close
+** I can't close fd
*/
void