-
Notifications
You must be signed in to change notification settings - Fork 0
/
keys.c
70 lines (64 loc) · 2.07 KB
/
keys.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* keys.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: mmouhiid <mmouhiid@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/12/20 04:59:30 by mmouhiid #+# #+# */
/* Updated: 2023/12/23 08:45:26 by mmouhiid ### ########.fr */
/* */
/* ************************************************************************** */
#include "fractol.h"
void handle_max_iteration(int keycode, t_program *program)
{
if (keycode == 24)
program->max_iteration += 10;
else if (keycode == 27 && program->max_iteration > 10)
program->max_iteration -= 10;
}
void handle_y_movement(int keycode, t_program *program, long double offset)
{
if (keycode == 126)
{
program->top_y += offset;
program->bottom_y += offset;
}
else if (keycode == 125)
{
program->top_y -= offset;
program->bottom_y -= offset;
}
}
void handle_x_movement(int keycode, t_program *program, long double offset)
{
if (keycode == 124)
{
program->right_x += offset;
program->left_x += offset;
}
else if (keycode == 123)
{
program->right_x -= offset;
program->left_x -= offset;
}
}
void handle_color_pallete(int keycode, t_program *program)
{
if (keycode == 8)
{
if (program->color_pallete == 1)
program->color_pallete = 2;
else
program->color_pallete = 1;
}
}
void key_hook_helper(int keycode, t_program *program, long double offset)
{
handle_max_iteration(keycode, program);
handle_y_movement(keycode, program, offset);
handle_x_movement(keycode, program, offset);
handle_color_pallete(keycode, program);
if (keycode == 53)
exit_handler(program);
}