| 961b3c61 Andy McCall |
1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 4c0b050e Andy McCall ↶ |
6 |
|
| 7 |
|
| 8 |
|
| 961b3c61 Andy McCall |
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 |
|
| 674b8447 Andy McCall ↶ |
29 |
|
| bed0f1e5 Andy McCall ↶ |
30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
#define RETRO_CONTROL_CONTRACT "0.5.0" |
| 961b3c61 Andy McCall |
35 |
|
| 36 |
|
| 37 |
typedef enum { |
| 38 |
RETRO_PIX_RGB888 = 0, |
| 39 |
RETRO_PIX_RGBA8888, |
| 40 |
RETRO_PIX_BGRA8888 |
| 41 |
} retro_pix_fmt_t; |
| 42 |
|
| 43 |
typedef struct { |
| 44 |
const uint8_t *pixels; |
| 45 |
int width; |
| 46 |
int height; |
| 47 |
retro_pix_fmt_t fmt; |
| 48 |
} retro_framebuffer_t; |
| 49 |
|
| 689a9ccb Andy McCall ↶ |
50 |
|
| 51 |
typedef enum { |
| 52 |
RETRO_KEY_TAP = 0, |
| 53 |
RETRO_KEY_DOWN = 1, |
| 54 |
RETRO_KEY_UP = 2 |
| 55 |
} retro_key_action_t; |
| 56 |
|
| 961b3c61 Andy McCall |
57 |
|
| 58 |
|
| 59 |
typedef struct retro_control_backend { |
| 60 |
const char *platform; |
| 61 |
const char *emulator; |
| 62 |
|
| 63 |
|
| 64 |
|
| 65 |
|
| 66 |
uint32_t (*read_mem)(uint32_t addr, int32_t bank, uint32_t len, |
| 67 |
uint8_t *out, uint32_t out_cap); |
| 68 |
|
| 69 |
|
| 70 |
void (*get_regs_json)(char *buf, size_t cap); |
| 71 |
|
| 72 |
|
| 73 |
void (*get_framebuffer)(retro_framebuffer_t *out); |
| 74 |
|
| 75 |
|
| 76 |
uint64_t (*get_frame_count)(void); |
| 689a9ccb Andy McCall ↶ |
77 |
|
| 78 |
|
| 79 |
|
| 80 |
|
| 81 |
|
| 82 |
int (*inject_key)(int is_text, uint32_t value, int action); |
| 83 |
|
| 84 |
|
| 85 |
void (*reset)(void); |
| 674b8447 Andy McCall ↶ |
86 |
|
| 87 |
|
| 88 |
|
| 89 |
|
| 90 |
uint32_t (*write_mem)(uint32_t addr, int32_t bank, uint32_t len, |
| 91 |
const uint8_t *in); |
| 92 |
|
| 93 |
|
| 94 |
|
| 95 |
|
| 96 |
|
| 97 |
uint32_t (*capture_audio)(int16_t *out, uint32_t cap, |
| 98 |
int *rate, int *channels, uint32_t *dropped); |
| 346ca3ee Andy McCall ↶ |
99 |
|
| 100 |
|
| 101 |
|
| 102 |
|
| 103 |
|
| 104 |
|
| 105 |
|
| 106 |
|
| 107 |
int (*set_pointer)(int absolute, int32_t x, int32_t y, int buttons); |
| 108 |
|
| 109 |
|
| 110 |
|
| 111 |
|
| 112 |
int (*get_pointer)(int32_t *x, int32_t *y, int *buttons); |
| bed0f1e5 Andy McCall ↶ |
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 |
int (*set_pad)(int index, int buttons, int connected); |
| 138 |
|
| 139 |
|
| 140 |
|
| 141 |
|
| 142 |
int (*get_pad)(int index, int *buttons, int *connected); |
| 961b3c61 Andy McCall |
143 |
} retro_control_backend_t; |
| 144 |
|
| 145 |
|
| 146 |
|
| 147 |
int retro_control_start(int port, const retro_control_backend_t *backend); |
| 148 |
|
| 149 |
|
| 150 |
|
| 151 |
void retro_control_service(void); |
| 152 |
|
| 153 |
|
| 154 |
|
| 155 |
|
| 156 |
int retro_control_running(void); |
| 157 |
|
| 158 |
|
| 159 |
|
| 160 |
void retro_control_on_frame(void); |
| 161 |
|
| 162 |
|
| 163 |
void retro_control_stop(void); |
| 164 |
|
| 165 |
#endif |