| 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 |
|
| 346ca3ee Andy McCall ↶ |
30 |
|
| 31 |
|
| 32 |
|
| 33 |
#define RETRO_CONTROL_CONTRACT "0.4.0" |
| 961b3c61 Andy McCall |
34 |
|
| 35 |
|
| 36 |
typedef enum { |
| 37 |
RETRO_PIX_RGB888 = 0, |
| 38 |
RETRO_PIX_RGBA8888, |
| 39 |
RETRO_PIX_BGRA8888 |
| 40 |
} retro_pix_fmt_t; |
| 41 |
|
| 42 |
typedef struct { |
| 43 |
const uint8_t *pixels; |
| 44 |
int width; |
| 45 |
int height; |
| 46 |
retro_pix_fmt_t fmt; |
| 47 |
} retro_framebuffer_t; |
| 48 |
|
| 689a9ccb Andy McCall ↶ |
49 |
|
| 50 |
typedef enum { |
| 51 |
RETRO_KEY_TAP = 0, |
| 52 |
RETRO_KEY_DOWN = 1, |
| 53 |
RETRO_KEY_UP = 2 |
| 54 |
} retro_key_action_t; |
| 55 |
|
| 961b3c61 Andy McCall |
56 |
|
| 57 |
|
| 58 |
typedef struct retro_control_backend { |
| 59 |
const char *platform; |
| 60 |
const char *emulator; |
| 61 |
|
| 62 |
|
| 63 |
|
| 64 |
|
| 65 |
uint32_t (*read_mem)(uint32_t addr, int32_t bank, uint32_t len, |
| 66 |
uint8_t *out, uint32_t out_cap); |
| 67 |
|
| 68 |
|
| 69 |
void (*get_regs_json)(char *buf, size_t cap); |
| 70 |
|
| 71 |
|
| 72 |
void (*get_framebuffer)(retro_framebuffer_t *out); |
| 73 |
|
| 74 |
|
| 75 |
uint64_t (*get_frame_count)(void); |
| 689a9ccb Andy McCall ↶ |
76 |
|
| 77 |
|
| 78 |
|
| 79 |
|
| 80 |
|
| 81 |
int (*inject_key)(int is_text, uint32_t value, int action); |
| 82 |
|
| 83 |
|
| 84 |
void (*reset)(void); |
| 674b8447 Andy McCall ↶ |
85 |
|
| 86 |
|
| 87 |
|
| 88 |
|
| 89 |
uint32_t (*write_mem)(uint32_t addr, int32_t bank, uint32_t len, |
| 90 |
const uint8_t *in); |
| 91 |
|
| 92 |
|
| 93 |
|
| 94 |
|
| 95 |
|
| 96 |
uint32_t (*capture_audio)(int16_t *out, uint32_t cap, |
| 97 |
int *rate, int *channels, uint32_t *dropped); |
| 346ca3ee Andy McCall ↶ |
98 |
|
| 99 |
|
| 100 |
|
| 101 |
|
| 102 |
|
| 103 |
|
| 104 |
|
| 105 |
|
| 106 |
int (*set_pointer)(int absolute, int32_t x, int32_t y, int buttons); |
| 107 |
|
| 108 |
|
| 109 |
|
| 110 |
|
| 111 |
int (*get_pointer)(int32_t *x, int32_t *y, int *buttons); |
| 961b3c61 Andy McCall |
112 |
} retro_control_backend_t; |
| 113 |
|
| 114 |
|
| 115 |
|
| 116 |
int retro_control_start(int port, const retro_control_backend_t *backend); |
| 117 |
|
| 118 |
|
| 119 |
|
| 120 |
void retro_control_service(void); |
| 121 |
|
| 122 |
|
| 123 |
|
| 124 |
|
| 125 |
int retro_control_running(void); |
| 126 |
|
| 127 |
|
| 128 |
|
| 129 |
void retro_control_on_frame(void); |
| 130 |
|
| 131 |
|
| 132 |
void retro_control_stop(void); |
| 133 |
|
| 134 |
#endif |