| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
#ifndef RETRO_CONTROL_H |
| 24 |
#define RETRO_CONTROL_H |
| 25 |
|
| 26 |
#include <stdint.h> |
| 27 |
#include <stddef.h> |
| 28 |
|
| 29 |
#ifdef __cplusplus |
| 30 |
extern "C" { |
| 31 |
#endif |
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
#define RETRO_CONTROL_CONTRACT "0.6.0" |
| 41 |
|
| 42 |
|
| 43 |
typedef enum { |
| 44 |
RETRO_PIX_RGB888 = 0, |
| 45 |
RETRO_PIX_RGBA8888, |
| 46 |
RETRO_PIX_BGRA8888 |
| 47 |
} retro_pix_fmt_t; |
| 48 |
|
| 49 |
typedef struct { |
| 50 |
const uint8_t *pixels; |
| 51 |
int width; |
| 52 |
int height; |
| 53 |
retro_pix_fmt_t fmt; |
| 54 |
} retro_framebuffer_t; |
| 55 |
|
| 56 |
|
| 57 |
typedef enum { |
| 58 |
RETRO_KEY_TAP = 0, |
| 59 |
RETRO_KEY_DOWN = 1, |
| 60 |
RETRO_KEY_UP = 2 |
| 61 |
} retro_key_action_t; |
| 62 |
|
| 63 |
|
| 64 |
|
| 65 |
typedef struct retro_control_backend { |
| 66 |
const char *platform; |
| 67 |
const char *emulator; |
| 68 |
|
| 69 |
|
| 70 |
|
| 71 |
|
| 72 |
uint32_t (*read_mem)(uint32_t addr, int32_t bank, uint32_t len, |
| 73 |
uint8_t *out, uint32_t out_cap); |
| 74 |
|
| 75 |
|
| 76 |
void (*get_regs_json)(char *buf, size_t cap); |
| 77 |
|
| 78 |
|
| 79 |
void (*get_framebuffer)(retro_framebuffer_t *out); |
| 80 |
|
| 81 |
|
| 82 |
uint64_t (*get_frame_count)(void); |
| 83 |
|
| 84 |
|
| 85 |
|
| 86 |
|
| 87 |
|
| 88 |
int (*inject_key)(int is_text, uint32_t value, int action); |
| 89 |
|
| 90 |
|
| 91 |
void (*reset)(void); |
| 92 |
|
| 93 |
|
| 94 |
|
| 95 |
|
| 96 |
uint32_t (*write_mem)(uint32_t addr, int32_t bank, uint32_t len, |
| 97 |
const uint8_t *in); |
| 98 |
|
| 99 |
|
| 100 |
|
| 101 |
|
| 102 |
|
| 103 |
uint32_t (*capture_audio)(int16_t *out, uint32_t cap, |
| 104 |
int *rate, int *channels, uint32_t *dropped); |
| 105 |
|
| 106 |
|
| 107 |
|
| 108 |
|
| 109 |
|
| 110 |
|
| 111 |
|
| 112 |
|
| 113 |
int (*set_pointer)(int absolute, int32_t x, int32_t y, int buttons); |
| 114 |
|
| 115 |
|
| 116 |
|
| 117 |
|
| 118 |
int (*get_pointer)(int32_t *x, int32_t *y, int *buttons); |
| 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 |
int (*set_pad)(int index, int buttons, int connected); |
| 144 |
|
| 145 |
|
| 146 |
|
| 147 |
|
| 148 |
int (*get_pad)(int index, int *buttons, int *connected); |
| 149 |
|
| 150 |
|
| 151 |
|
| 152 |
|
| 153 |
|
| 154 |
|
| 155 |
|
| 156 |
|
| 157 |
char *(*get_perf)(const char *query); |
| 158 |
|
| 159 |
|
| 160 |
|
| 161 |
|
| 162 |
|
| 163 |
|
| 164 |
char *(*set_perf)(const char *body, int *status); |
| 165 |
} retro_control_backend_t; |
| 166 |
|
| 167 |
|
| 168 |
|
| 169 |
int retro_control_start(int port, const retro_control_backend_t *backend); |
| 170 |
|
| 171 |
|
| 172 |
|
| 173 |
void retro_control_service(void); |
| 174 |
|
| 175 |
|
| 176 |
|
| 177 |
|
| 178 |
int retro_control_running(void); |
| 179 |
|
| 180 |
|
| 181 |
|
| 182 |
void retro_control_on_frame(void); |
| 183 |
|
| 184 |
|
| 185 |
void retro_control_stop(void); |
| 186 |
|
| 187 |
#ifdef __cplusplus |
| 188 |
} |
| 189 |
#endif |
| 190 |
|
| 191 |
#endif |