-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinterface.h
164 lines (143 loc) · 2.33 KB
/
interface.h
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
#ifndef INTERFACE_H__
#define INTERFACE_H__
#include <stdint.h>
#include <stdbool.h>
#include <stdio.h>
#ifdef __cplusplus
extern "C"
{
#endif
#ifndef debug_log
#define debug_log printf
#endif
typedef struct
{
const char *filename;
} module_init_info_t;
typedef enum
{
screen_format_ARGB8888,
screen_format_RGB565,
screen_format_ARGB5551,
} screen_format_t;
typedef enum
{
PAD_BUTTON_A,
PAD_BUTTON_B,
PAD_BUTTON_X,
PAD_BUTTON_Y,
PAD_BUTTON_UP,
PAD_BUTTON_DOWN,
PAD_BUTTON_LEFT,
PAD_BUTTON_RIGHT,
PAD_BUTTON_L,
PAD_BUTTON_R,
PAD_BUTTON_START,
PAD_BUTTON_SELECT,
PAD_BUTTON_MAX,
}buttons_name_t;
typedef union
{
struct
{
int A :1;
int B :1;
int X :1;
int Y :1;
int up :1;
int down :1;
int left :1;
int right :1;
int L :1;
int R :1;
int start :1;
int select :1;
};
uint32_t mask;
}buttons_t;
typedef union
{
struct
{
int exit :1;
int menu :1;
int vsync :1;
int filter :1;
int console :1;
};
uint32_t mask;
}meta_buttons_t;
typedef struct
{
union
{
struct
{
buttons_t buttons;
meta_buttons_t meta;
};
uint64_t mask;
};
struct
{
float x;
float y;
}left_stick;
struct
{
float x;
float y;
}right_stick;
}pad_t;
typedef struct
{
int x;
int y;
int dx;
int dy;
bool touch1;
bool touch2;
bool touch3;
bool touch1_pressed;
bool touch2_pressed;
bool touch3_pressed;
bool touch1_released;
bool touch2_released;
bool touch3_released;
}pointer_t;
typedef struct
{
int output_width;
int output_height;
screen_format_t screen_format;
bool stereo;
float framerate;
float audio_rate;
} module_info_t;
typedef union
{
void* ptr;
uint8_t* u8;
uint16_t* u16;
uint32_t* u32;
int8_t* s8;
int16_t* s16;
int32_t* s32;
}generic_ptr_t;
typedef struct
{
generic_ptr_t screen;
int pitch;
generic_ptr_t sound_buffer;
unsigned max_samples;
bool frame_completed;
pad_t* pad;
} module_run_info_t;
void module_init(const module_init_info_t *init_info, module_info_t *module_info);
void module_destroy();
void module_run(module_run_info_t *run_info);
extern module_info_t module;
#ifdef __cplusplus
}
#endif
#endif // INTERFACE_H__