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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
|
/* NoGamepads C++ Bindings. */
/* Generated with cbindgen:0.29.0 */
#include <cstdarg>
#include <cstdint>
#include <cstdlib>
#include <ostream>
#include <new>
namespace nogamepads {
enum class ConnCallbackMsgCTag {
Profile,
Deny,
Fail,
Ok,
Welcome,
Err,
};
enum class ConnErrTypeC {
ContainSamePlayer,
PlayerBanned,
Timeout,
GameLocked,
WhatTheHell,
};
enum class ConnMsgCTag {
Connection,
RequestProfile,
RequestLayoutConfigure,
RequestSkinPackage,
Ready,
Err,
};
enum class CtrlMsgCTag {
Msg,
Pressed,
Released,
Axis,
Dir,
Exit,
Err,
};
enum class GameMsgCTag {
SkinEventTrigger,
DisableKey,
EnableKey,
Leave,
Err,
};
enum class LeaveReasonData {
GameOver,
ServerClosed,
YouAreKicked,
YouAreBanned,
};
template<typename T = void>
struct ManuallyDrop;
struct GameProfileC {
const char *game_name;
const char *game_description;
const char *organization;
const char *version;
const char *website;
const char *email;
};
struct PlayerInfoC {
const char *account_id;
const char *account_hash;
const char *customize_nickname;
int32_t customize_color_hue;
double customize_color_saturation;
double customize_color_value;
};
struct PadClientC {
const char *target_address;
uint16_t target_port;
PlayerInfoC bind_player;
bool enable_console;
bool quiet;
};
struct KeyData {
uint8_t key;
};
struct AxisData {
uint8_t key;
double ax;
};
struct DirData {
uint8_t key;
double x;
double y;
};
struct StrData {
const char *str;
};
union CtrlMsgCUnion {
void *nul;
KeyData key;
AxisData axis;
DirData dir;
StrData str;
};
struct ControlMessageC {
CtrlMsgCTag tag;
CtrlMsgCUnion data;
};
union GameMsgCUnion {
void *nul;
KeyData key;
LeaveReasonData reason;
};
struct GameMessageC {
GameMsgCTag tag;
GameMsgCUnion data;
};
struct PlayerList {
PlayerInfoC *players;
uintptr_t len;
uintptr_t capacity;
};
union ConnMsgCUnion {
void *nul;
ManuallyDrop<PlayerInfo> info;
};
struct ConnectionMessageC {
ConnMsgCTag tag;
ConnMsgCUnion data;
};
union ConnCallbackMsgCUnion {
void *nul;
ManuallyDrop<GameProfileC> profile;
ConnErrTypeC conn_err;
};
struct ConnectionCallbackMessageC {
ConnCallbackMsgCTag tag;
ConnCallbackMsgCUnion data;
};
extern "C" {
GameProfileC init_game_profile();
GameProfileC set_game_profile_name(GameProfileC game_profile, const char *value);
GameProfileC set_game_profile_description(GameProfileC game_profile, const char *value);
GameProfileC set_game_profile_organization(GameProfileC game_profile, const char *value);
GameProfileC set_game_profile_version(GameProfileC game_profile, const char *value);
GameProfileC set_game_profile_website(GameProfileC game_profile, const char *value);
GameProfileC set_game_profile_email(GameProfileC game_profile, const char *value);
PlayerInfoC init_player_info();
PlayerInfoC set_player_info_account(PlayerInfoC info, const char *id, const char *password);
PlayerInfoC set_player_info_color(PlayerInfoC info, int32_t h, double s, double v);
PlayerInfoC set_player_info_nickname(PlayerInfoC info, const char *nickname);
uint16_t get_default_port();
PadClientC init_client(const char *address);
PadClientC init_client_with_port(const char *address, uint16_t port);
PadClientC set_client_quiet(PadClientC client);
PadClientC enable_client_console(PadClientC client);
PadClientC bind_player_to_client(PadClientC client, PlayerInfoC info);
PadClient *complete(PadClientC client);
void connect_client_to_server(PadClient *client);
void exit_client_from_server(const PadClient *client);
void put_a_msg_to_server(const PadClient *client, ControlMessageC msg);
GameMessageC pop_a_msg_from_server(const PadClient *client);
GameMessageC pop_msg_from_server_or(const PadClient *client, GameMessageC or);
PadServer *init_server(const char *address);
PadServer *init_server_with_port(const char *address, uint16_t port);
void set_server_quiet(PadServer *server);
void enable_server_console(PadServer *server);
void bind_profile_to_server(PadServer *server, const GameProfileC *profile);
void start_server(PadServer *server);
void stop_server(PadServer *server);
void lock_game_on_server(PadServer *server);
void unlock_game_on_server(PadServer *server);
bool is_server_game_locked(PadServer *server);
void put_a_msg_to_player(PadServer *server, GameMessageC msg, const PlayerInfoC *player);
void put_msg_to_all_players(PadServer *server, GameMessageC msg);
ControlMessageC pop_a_msg_from_player(PadServer *server, const PlayerInfoC *player);
ControlMessageC pop_msg_from_player_or(PadServer *server,
const PlayerInfoC *player,
ControlMessageC or);
bool is_player_online(PadServer *server, const PlayerInfoC *player);
bool is_player_banned(PadServer *server, const PlayerInfoC *player);
void kick_player(PadServer *server, const PlayerInfoC *player);
void ban_player(PadServer *server, const PlayerInfoC *player);
void pardon_player(PadServer *server, const PlayerInfoC *player);
PlayerList list_online_players(PadServer *server);
PlayerList list_banned_players(PadServer *server);
} // extern "C"
} // namespace nogamepads
|