44 lines
752 B
C
44 lines
752 B
C
#include "cube3d.h"
|
|
|
|
// temp, to map all the keys on linux and mac
|
|
static int print_keycode(int keycode)
|
|
{
|
|
ft_putnbr_fd(keycode, 1);
|
|
ft_putchar_fd('\n', 1);
|
|
return(0);
|
|
}
|
|
// temp end
|
|
|
|
int keypress(int keycode, t_game *game)
|
|
{
|
|
unsigned i;
|
|
|
|
// temp
|
|
print_keycode(keycode);
|
|
// temp end
|
|
|
|
i = 0;
|
|
while (i < MAX_NB_KEY && game->k_hook[i] != 0 && game->k_hook[i] != keycode)
|
|
i++;
|
|
if (game->k_hook[i] == keycode && i < MAX_NB_KEY)
|
|
game->k_hook[i] = 0;
|
|
else if (i < MAX_NB_KEY)
|
|
game->k_hook[i] = keycode;
|
|
|
|
keypress_do_action(game);
|
|
return (0);
|
|
}
|
|
|
|
int keyrelease(int keycode, t_game *game)
|
|
{
|
|
unsigned i;
|
|
|
|
i = 0;
|
|
while (i < MAX_NB_KEY && game->k_hook[i] != keycode)
|
|
i++;
|
|
if (i < MAX_NB_KEY)
|
|
game->k_hook[i] = 0;
|
|
|
|
return (0);
|
|
}
|