diff options
| author | 1992414357@qq.com <1992414357@qq.com> | 2025-05-29 07:55:41 +0800 |
|---|---|---|
| committer | 1992414357@qq.com <1992414357@qq.com> | 2025-05-29 07:55:41 +0800 |
| commit | 9d3d6d4195e58c51166811d8357a331d53c4cdd4 (patch) | |
| tree | 2e1d8abfee06a05b3ded9c6d5cd99574412af665 /release | |
| parent | 7bf8e1f24f95d87e1a30765b1904473cf75b435b (diff) | |
正在编写 C# 绑定部分
Diffstat (limited to 'release')
| -rw-r--r-- | release/0.1.0/bin/nogpadc.exe | bin | 2237440 -> 2237440 bytes | |||
| -rw-r--r-- | release/0.1.0/bin/nogpads.exe | bin | 2194432 -> 2195456 bytes | |||
| -rw-r--r-- | release/0.1.0/bridge/nogamepads.h | 106 | ||||
| -rw-r--r-- | release/0.1.0/bridge/nogamepads_cpp.h | 94 | ||||
| -rw-r--r-- | release/0.1.0/bridge/nogamepads_lib_c.dll | bin | 2114560 -> 2128896 bytes |
5 files changed, 132 insertions, 68 deletions
diff --git a/release/0.1.0/bin/nogpadc.exe b/release/0.1.0/bin/nogpadc.exe Binary files differindex 5cf21ea..5fea05c 100644 --- a/release/0.1.0/bin/nogpadc.exe +++ b/release/0.1.0/bin/nogpadc.exe diff --git a/release/0.1.0/bin/nogpads.exe b/release/0.1.0/bin/nogpads.exe Binary files differindex 03fe069..9774267 100644 --- a/release/0.1.0/bin/nogpads.exe +++ b/release/0.1.0/bin/nogpads.exe diff --git a/release/0.1.0/bridge/nogamepads.h b/release/0.1.0/bridge/nogamepads.h index 959475d..997b73d 100644 --- a/release/0.1.0/bridge/nogamepads.h +++ b/release/0.1.0/bridge/nogamepads.h @@ -30,6 +30,32 @@ typedef enum LeaveReasonData { YouAreBanned, } LeaveReasonData; +typedef struct GameProfileC { + const char *game_name; + const char *game_description; + const char *organization; + const char *version; + const char *website; + const char *email; +} GameProfileC; + +typedef 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; +} PlayerInfoC; + +typedef struct PadClientC { + const char *target_address; + uint16_t target_port; + struct PlayerInfoC bind_player; + bool enable_console; + bool quiet; +} PadClientC; + typedef struct KeyData { uint8_t key; } KeyData; @@ -57,10 +83,10 @@ typedef union CtrlMsgCUnion { struct StrData str; } CtrlMsgCUnion; -typedef struct CtrlMsgC { +typedef struct ControlMessageC { enum CtrlMsgCTag tag; union CtrlMsgCUnion data; -} CtrlMsgC; +} ControlMessageC; typedef union GameMsgCUnion { void *nul; @@ -68,60 +94,66 @@ typedef union GameMsgCUnion { enum LeaveReasonData reason; } GameMsgCUnion; -typedef struct GameMsgC { +typedef struct GameMessageC { enum GameMsgCTag tag; union GameMsgCUnion data; -} GameMsgC; +} GameMessageC; typedef struct PlayerList { - PlayerInfo *players; + struct PlayerInfoC *players; uintptr_t len; uintptr_t capacity; } PlayerList; -GameProfile *init_game_profile(void); +struct GameProfileC init_game_profile(void); -void set_game_profile_name(GameProfile *game_profile, const char *value); +struct GameProfileC set_game_profile_name(struct GameProfileC game_profile, const char *value); -void set_game_profile_description(GameProfile *game_profile, const char *value); +struct GameProfileC set_game_profile_description(struct GameProfileC game_profile, + const char *value); -void set_game_profile_organization(GameProfile *game_profile, const char *value); +struct GameProfileC set_game_profile_organization(struct GameProfileC game_profile, + const char *value); -void set_game_profile_version(GameProfile *game_profile, const char *value); +struct GameProfileC set_game_profile_version(struct GameProfileC game_profile, const char *value); -void set_game_profile_website(GameProfile *game_profile, const char *value); +struct GameProfileC set_game_profile_website(struct GameProfileC game_profile, const char *value); -void set_game_profile_email(GameProfile *game_profile, const char *value); +struct GameProfileC set_game_profile_email(struct GameProfileC game_profile, const char *value); -PlayerInfo *init_player_info(void); +struct PlayerInfoC init_player_info(void); -void set_player_info_account(PlayerInfo *info, const char *id, const char *password); +struct PlayerInfoC set_player_info_account(struct PlayerInfoC info, + const char *id, + const char *password); -void set_player_info_color(PlayerInfo *info, int32_t h, double s, double v); +struct PlayerInfoC set_player_info_color(struct PlayerInfoC info, int32_t h, double s, double v); -void set_player_info_nickname(PlayerInfo *info, const char *nickname); +struct PlayerInfoC set_player_info_nickname(struct PlayerInfoC info, const char *nickname); uint16_t get_default_port(void); -PadClient *init_client(const char *address); +struct PadClientC init_client(const char *address); + +struct PadClientC init_client_with_port(const char *address, uint16_t port); -PadClient *init_client_with_port(const char *address, uint16_t port); +struct PadClientC set_client_quiet(struct PadClientC client); -void set_client_quiet(PadClient *client); +struct PadClientC enable_client_console(struct PadClientC client); -void enable_client_console(PadClient *client); +struct PadClientC bind_player_to_client(struct PadClientC client, struct PlayerInfoC info); -void bind_player_to_client(PadClient *client, PlayerInfo *info); +PadClient *complete(struct 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, struct CtrlMsgC msg); +void put_a_msg_to_server(const PadClient *client, struct ControlMessageC msg); -struct GameMsgC pop_a_msg_from_server(const PadClient *client); +struct GameMessageC pop_a_msg_from_server(const PadClient *client); -struct GameMsgC pop_msg_from_server_or(const PadClient *client, struct GameMsgC or); +struct GameMessageC pop_msg_from_server_or(const PadClient *client, struct GameMessageC or); PadServer *init_server(const char *address); @@ -131,7 +163,7 @@ void set_server_quiet(PadServer *server); void enable_server_console(PadServer *server); -void bind_profile_to_server(PadServer *server, GameProfile *profile); +void bind_profile_to_server(PadServer *server, const struct GameProfileC *profile); void start_server(PadServer *server); @@ -143,25 +175,27 @@ void unlock_game_on_server(PadServer *server); bool is_server_game_locked(PadServer *server); -void put_a_msg_to_player(PadServer *server, struct GameMsgC msg, const PlayerInfo *player); +void put_a_msg_to_player(PadServer *server, + struct GameMessageC msg, + const struct PlayerInfoC *player); -void put_msg_to_all_players(PadServer *server, struct GameMsgC msg); +void put_msg_to_all_players(PadServer *server, struct GameMessageC msg); -struct CtrlMsgC pop_a_msg_from_player(PadServer *server, const PlayerInfo *player); +struct ControlMessageC pop_a_msg_from_player(PadServer *server, const struct PlayerInfoC *player); -struct CtrlMsgC pop_msg_from_player_or(PadServer *server, - const PlayerInfo *player, - struct CtrlMsgC or); +struct ControlMessageC pop_msg_from_player_or(PadServer *server, + const struct PlayerInfoC *player, + struct ControlMessageC or); -bool is_player_online(PadServer *server, const PlayerInfo *player); +bool is_player_online(PadServer *server, const struct PlayerInfoC *player); -bool is_player_banned(PadServer *server, const PlayerInfo *player); +bool is_player_banned(PadServer *server, const struct PlayerInfoC *player); -void kick_player(PadServer *server, const PlayerInfo *player); +void kick_player(PadServer *server, const struct PlayerInfoC *player); -void ban_player(PadServer *server, const PlayerInfo *player); +void ban_player(PadServer *server, const struct PlayerInfoC *player); -void pardon_player(PadServer *server, const PlayerInfo *player); +void pardon_player(PadServer *server, const struct PlayerInfoC *player); struct PlayerList list_online_players(PadServer *server); diff --git a/release/0.1.0/bridge/nogamepads_cpp.h b/release/0.1.0/bridge/nogamepads_cpp.h index ab27981..77469fb 100644 --- a/release/0.1.0/bridge/nogamepads_cpp.h +++ b/release/0.1.0/bridge/nogamepads_cpp.h @@ -35,6 +35,32 @@ enum class LeaveReasonData { YouAreBanned, }; +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; }; @@ -62,7 +88,7 @@ union CtrlMsgCUnion { StrData str; }; -struct CtrlMsgC { +struct ControlMessageC { CtrlMsgCTag tag; CtrlMsgCUnion data; }; @@ -73,62 +99,64 @@ union GameMsgCUnion { LeaveReasonData reason; }; -struct GameMsgC { +struct GameMessageC { GameMsgCTag tag; GameMsgCUnion data; }; struct PlayerList { - PlayerInfo *players; + PlayerInfoC *players; uintptr_t len; uintptr_t capacity; }; extern "C" { -GameProfile *init_game_profile(); +GameProfileC init_game_profile(); -void set_game_profile_name(GameProfile *game_profile, const char *value); +GameProfileC set_game_profile_name(GameProfileC game_profile, const char *value); -void set_game_profile_description(GameProfile *game_profile, const char *value); +GameProfileC set_game_profile_description(GameProfileC game_profile, const char *value); -void set_game_profile_organization(GameProfile *game_profile, const char *value); +GameProfileC set_game_profile_organization(GameProfileC game_profile, const char *value); -void set_game_profile_version(GameProfile *game_profile, const char *value); +GameProfileC set_game_profile_version(GameProfileC game_profile, const char *value); -void set_game_profile_website(GameProfile *game_profile, const char *value); +GameProfileC set_game_profile_website(GameProfileC game_profile, const char *value); -void set_game_profile_email(GameProfile *game_profile, const char *value); +GameProfileC set_game_profile_email(GameProfileC game_profile, const char *value); -PlayerInfo *init_player_info(); +PlayerInfoC init_player_info(); -void set_player_info_account(PlayerInfo *info, const char *id, const char *password); +PlayerInfoC set_player_info_account(PlayerInfoC info, const char *id, const char *password); -void set_player_info_color(PlayerInfo *info, int32_t h, double s, double v); +PlayerInfoC set_player_info_color(PlayerInfoC info, int32_t h, double s, double v); -void set_player_info_nickname(PlayerInfo *info, const char *nickname); +PlayerInfoC set_player_info_nickname(PlayerInfoC info, const char *nickname); uint16_t get_default_port(); -PadClient *init_client(const char *address); +PadClientC init_client(const char *address); + +PadClientC init_client_with_port(const char *address, uint16_t port); -PadClient *init_client_with_port(const char *address, uint16_t port); +PadClientC set_client_quiet(PadClientC client); -void set_client_quiet(PadClient *client); +PadClientC enable_client_console(PadClientC client); -void enable_client_console(PadClient *client); +PadClientC bind_player_to_client(PadClientC client, PlayerInfoC info); -void bind_player_to_client(PadClient *client, PlayerInfo *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, CtrlMsgC msg); +void put_a_msg_to_server(const PadClient *client, ControlMessageC msg); -GameMsgC pop_a_msg_from_server(const PadClient *client); +GameMessageC pop_a_msg_from_server(const PadClient *client); -GameMsgC pop_msg_from_server_or(const PadClient *client, GameMsgC or); +GameMessageC pop_msg_from_server_or(const PadClient *client, GameMessageC or); PadServer *init_server(const char *address); @@ -138,7 +166,7 @@ void set_server_quiet(PadServer *server); void enable_server_console(PadServer *server); -void bind_profile_to_server(PadServer *server, GameProfile *profile); +void bind_profile_to_server(PadServer *server, const GameProfileC *profile); void start_server(PadServer *server); @@ -150,23 +178,25 @@ void unlock_game_on_server(PadServer *server); bool is_server_game_locked(PadServer *server); -void put_a_msg_to_player(PadServer *server, GameMsgC msg, const PlayerInfo *player); +void put_a_msg_to_player(PadServer *server, GameMessageC msg, const PlayerInfoC *player); -void put_msg_to_all_players(PadServer *server, GameMsgC msg); +void put_msg_to_all_players(PadServer *server, GameMessageC msg); -CtrlMsgC pop_a_msg_from_player(PadServer *server, const PlayerInfo *player); +ControlMessageC pop_a_msg_from_player(PadServer *server, const PlayerInfoC *player); -CtrlMsgC pop_msg_from_player_or(PadServer *server, const PlayerInfo *player, CtrlMsgC or); +ControlMessageC pop_msg_from_player_or(PadServer *server, + const PlayerInfoC *player, + ControlMessageC or); -bool is_player_online(PadServer *server, const PlayerInfo *player); +bool is_player_online(PadServer *server, const PlayerInfoC *player); -bool is_player_banned(PadServer *server, const PlayerInfo *player); +bool is_player_banned(PadServer *server, const PlayerInfoC *player); -void kick_player(PadServer *server, const PlayerInfo *player); +void kick_player(PadServer *server, const PlayerInfoC *player); -void ban_player(PadServer *server, const PlayerInfo *player); +void ban_player(PadServer *server, const PlayerInfoC *player); -void pardon_player(PadServer *server, const PlayerInfo *player); +void pardon_player(PadServer *server, const PlayerInfoC *player); PlayerList list_online_players(PadServer *server); diff --git a/release/0.1.0/bridge/nogamepads_lib_c.dll b/release/0.1.0/bridge/nogamepads_lib_c.dll Binary files differindex f9fa81d..1dcd807 100644 --- a/release/0.1.0/bridge/nogamepads_lib_c.dll +++ b/release/0.1.0/bridge/nogamepads_lib_c.dll |
