-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbutton_logic.c
More file actions
75 lines (65 loc) · 1.61 KB
/
button_logic.c
File metadata and controls
75 lines (65 loc) · 1.61 KB
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
71
72
73
74
75
#pragma once
#include <stdio.h>
#include <stdbool.h>
#include <stdlib.h>
#include "game_state.h"
#include "gesture_injector.c"
#include "config.h"
int process_button_A(int event_fd, int game_state)
{
switch(game_state)
{
case GAME_STATE_PLAYING:
inject_tap_gesture(event_fd, ROTATE_LEFT_ACTION);
break;
}
return game_state;
}
int process_button_B(int event_fd, int game_state)
{
switch(game_state)
{
case GAME_STATE_PAUSED:
inject_tap_gesture(event_fd, CONTINUE_GAME_ACTION);
return GAME_STATE_PLAYING;
case GAME_STATE_PLAYING:
inject_tap_gesture(event_fd, ROTATE_RIGHT_ACTION);
break;
}
return game_state;
}
int process_button_START(int event_fd, int game_state)
{
switch(game_state)
{
case GAME_STATE_MENU:
return GAME_STATE_PLAYING;
case GAME_STATE_PAUSED:
inject_tap_gesture(event_fd, CONTINUE_GAME_ACTION);
return GAME_STATE_PLAYING;
case GAME_STATE_PLAYING:
inject_tap_gesture(event_fd, PAUSE_GAME_ACTION);
return GAME_STATE_PAUSED;
}
return game_state;
}
int process_button_LB(int event_fd, int game_state)
{
switch(game_state)
{
case GAME_STATE_PLAYING:
inject_tap_gesture(event_fd, HOLD_BLOCK_ACTION);
break;
}
return game_state;
}
int process_button_RB(int event_fd, int game_state)
{
switch(game_state)
{
case GAME_STATE_PLAYING:
inject_tap_gesture(event_fd, HOLD_BLOCK_ACTION);
break;
}
return game_state;
}