From 8db4f6af3421392fb75d4a2257d39a10bcefa493 Mon Sep 17 00:00:00 2001 From: "1992414357@qq.com" <1992414357@qq.com> Date: Mon, 9 Jun 2025 01:46:26 +0800 Subject: 重构所有部分 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .idea/inspectionProfiles/Project_Default.xml | 6 + .../Run_NoGamepads_Client__Bevy_.xml | 17 ++ .obsidian/app.json | 1 + .obsidian/appearance.json | 1 + .obsidian/core-plugins.json | 31 +++ .obsidian/graph.json | 22 ++ .obsidian/workspace.json | 191 +++++++++++++++ export/dev/bin/padc.exe | Bin 0 -> 2452992 bytes export/dev/bridge/nogamepads.h | 249 ++++++++++++++++++++ export/dev/bridge/nogamepads_cpp.h | 257 +++++++++++++++++++++ export/dev/bridge/nogamepads_lib_c.dll | Bin 0 -> 2018816 bytes 11 files changed, 775 insertions(+) create mode 100644 .idea/inspectionProfiles/Project_Default.xml create mode 100644 .idea/runConfigurations/Run_NoGamepads_Client__Bevy_.xml create mode 100644 .obsidian/app.json create mode 100644 .obsidian/appearance.json create mode 100644 .obsidian/core-plugins.json create mode 100644 .obsidian/graph.json create mode 100644 .obsidian/workspace.json create mode 100644 export/dev/bin/padc.exe create mode 100644 export/dev/bridge/nogamepads.h create mode 100644 export/dev/bridge/nogamepads_cpp.h create mode 100644 export/dev/bridge/nogamepads_lib_c.dll diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml new file mode 100644 index 0000000..40155f0 --- /dev/null +++ b/.idea/inspectionProfiles/Project_Default.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/.idea/runConfigurations/Run_NoGamepads_Client__Bevy_.xml b/.idea/runConfigurations/Run_NoGamepads_Client__Bevy_.xml new file mode 100644 index 0000000..5ee42e9 --- /dev/null +++ b/.idea/runConfigurations/Run_NoGamepads_Client__Bevy_.xml @@ -0,0 +1,17 @@ + + + + \ No newline at end of file diff --git a/.obsidian/app.json b/.obsidian/app.json new file mode 100644 index 0000000..9e26dfe --- /dev/null +++ b/.obsidian/app.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/.obsidian/appearance.json b/.obsidian/appearance.json new file mode 100644 index 0000000..9e26dfe --- /dev/null +++ b/.obsidian/appearance.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/.obsidian/core-plugins.json b/.obsidian/core-plugins.json new file mode 100644 index 0000000..b977c25 --- /dev/null +++ b/.obsidian/core-plugins.json @@ -0,0 +1,31 @@ +{ + "file-explorer": true, + "global-search": true, + "switcher": true, + "graph": true, + "backlink": true, + "canvas": true, + "outgoing-link": true, + "tag-pane": true, + "properties": false, + "page-preview": true, + "daily-notes": true, + "templates": true, + "note-composer": true, + "command-palette": true, + "slash-command": false, + "editor-status": true, + "bookmarks": true, + "markdown-importer": false, + "zk-prefixer": false, + "random-note": false, + "outline": true, + "word-count": true, + "slides": false, + "audio-recorder": false, + "workspaces": false, + "file-recovery": true, + "publish": false, + "sync": true, + "webviewer": false +} \ No newline at end of file diff --git a/.obsidian/graph.json b/.obsidian/graph.json new file mode 100644 index 0000000..42a46ec --- /dev/null +++ b/.obsidian/graph.json @@ -0,0 +1,22 @@ +{ + "collapse-filter": true, + "search": "", + "showTags": false, + "showAttachments": false, + "hideUnresolved": false, + "showOrphans": true, + "collapse-color-groups": true, + "colorGroups": [], + "collapse-display": true, + "showArrow": false, + "textFadeMultiplier": 0, + "nodeSizeMultiplier": 1, + "lineSizeMultiplier": 1, + "collapse-forces": true, + "centerStrength": 0.518713248970312, + "repelStrength": 10, + "linkStrength": 1, + "linkDistance": 250, + "scale": 1, + "close": true +} \ No newline at end of file diff --git a/.obsidian/workspace.json b/.obsidian/workspace.json new file mode 100644 index 0000000..0016205 --- /dev/null +++ b/.obsidian/workspace.json @@ -0,0 +1,191 @@ +{ + "main": { + "id": "a0056f92bdc64f6d", + "type": "split", + "children": [ + { + "id": "fc3609b0f0318eda", + "type": "tabs", + "children": [ + { + "id": "1e9c5e9fbcfb0e16", + "type": "leaf", + "state": { + "type": "markdown", + "state": { + "file": "README.md", + "mode": "source", + "source": false + }, + "icon": "lucide-file", + "title": "README" + } + } + ] + } + ], + "direction": "vertical" + }, + "left": { + "id": "6cde324fca0fc667", + "type": "split", + "children": [ + { + "id": "64265198a9ce5aac", + "type": "tabs", + "children": [ + { + "id": "70c5b38cff9cdddc", + "type": "leaf", + "state": { + "type": "file-explorer", + "state": { + "sortOrder": "alphabetical", + "autoReveal": false + }, + "icon": "lucide-folder-closed", + "title": "文件列表" + } + }, + { + "id": "04a128176f90e83a", + "type": "leaf", + "state": { + "type": "search", + "state": { + "query": "", + "matchingCase": false, + "explainSearch": false, + "collapseAll": false, + "extraContext": false, + "sortOrder": "alphabetical" + }, + "icon": "lucide-search", + "title": "搜索" + } + }, + { + "id": "44e2df1962ca7851", + "type": "leaf", + "state": { + "type": "bookmarks", + "state": {}, + "icon": "lucide-bookmark", + "title": "书签" + } + } + ] + } + ], + "direction": "horizontal", + "width": 300 + }, + "right": { + "id": "3824e4164ed4d9df", + "type": "split", + "children": [ + { + "id": "8a18ce67d19fb459", + "type": "tabs", + "children": [ + { + "id": "0c0d507eb8ea7b53", + "type": "leaf", + "state": { + "type": "backlink", + "state": { + "file": "未命名.md", + "collapseAll": false, + "extraContext": false, + "sortOrder": "alphabetical", + "showSearch": false, + "searchQuery": "", + "backlinkCollapsed": false, + "unlinkedCollapsed": true + }, + "icon": "links-coming-in", + "title": "未命名 的反向链接列表" + } + }, + { + "id": "f9bf37aeee2cb12b", + "type": "leaf", + "state": { + "type": "outgoing-link", + "state": { + "file": "未命名.md", + "linksCollapsed": false, + "unlinkedCollapsed": true + }, + "icon": "links-going-out", + "title": "未命名 的出链列表" + } + }, + { + "id": "5bed5e8aaf8b9996", + "type": "leaf", + "state": { + "type": "tag", + "state": { + "sortOrder": "frequency", + "useHierarchy": true, + "showSearch": false, + "searchQuery": "" + }, + "icon": "lucide-tags", + "title": "标签" + } + }, + { + "id": "9ccacef0149d1612", + "type": "leaf", + "state": { + "type": "outline", + "state": { + "file": "未命名.md", + "followCursor": false, + "showSearch": false, + "searchQuery": "" + }, + "icon": "lucide-list", + "title": "未命名 的大纲" + } + } + ] + } + ], + "direction": "horizontal", + "width": 300, + "collapsed": true + }, + "left-ribbon": { + "hiddenItems": { + "switcher:打开快速切换": false, + "graph:查看关系图谱": false, + "canvas:新建白板": false, + "daily-notes:打开/创建今天的日记": false, + "templates:插入模板": false, + "command-palette:打开命令面板": false + } + }, + "active": "1e9c5e9fbcfb0e16", + "lastOpenFiles": [ + "core/src/service/tcp_network/duplex.rs~", + "core/src/service/tcp_network/server.rs~", + "core/src/service/tcp_network/mod.rs~", + "core/src/service/tcp_network/duplex.rs", + "core/src/service/tcp_network/long_connection.rs", + "core/src/data/player/structs.rs~", + "core/src/service/tcp_network/client.rs~", + "src/macros.rs~", + "core/src/data/game/runtime/implements.rs~", + "core/src/data/player/implements.rs~", + "core/src/data/message/enums.rs~", + "core/core.canvas", + "README.md", + "documents/临时/About Toolchain - 关于 Rust 工具链.md", + "documents/临时/路线.md", + "未命名.md", + "欢迎.md" + ] +} \ No newline at end of file diff --git a/export/dev/bin/padc.exe b/export/dev/bin/padc.exe new file mode 100644 index 0000000..4630768 Binary files /dev/null and b/export/dev/bin/padc.exe differ diff --git a/export/dev/bridge/nogamepads.h b/export/dev/bridge/nogamepads.h new file mode 100644 index 0000000..f8b58cf --- /dev/null +++ b/export/dev/bridge/nogamepads.h @@ -0,0 +1,249 @@ +/* NoGamepads C Bindings. */ + +#include +#include +#include +#include + +typedef enum ConnCallbackMsgCTag { + Profile, + Deny, + Fail, + Ok, + Welcome, + Err, +} ConnCallbackMsgCTag; + +typedef enum ConnErrTypeC { + ContainSamePlayer, + PlayerBanned, + Timeout, + GameLocked, + WhatTheHell, +} ConnErrTypeC; + +typedef enum ConnMsgCTag { + Connection, + RequestProfile, + RequestLayoutConfigure, + RequestSkinPackage, + Ready, + Err, +} ConnMsgCTag; + +typedef enum CtrlMsgCTag { + Msg, + Pressed, + Released, + Axis, + Dir, + Exit, + Err, +} CtrlMsgCTag; + +typedef enum GameMsgCTag { + SkinEventTrigger, + DisableKey, + EnableKey, + Leave, + Err, +} GameMsgCTag; + +typedef enum LeaveReasonData { + GameOver, + ServerClosed, + YouAreKicked, + 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; + +typedef struct AxisData { + uint8_t key; + double ax; +} AxisData; + +typedef struct DirData { + uint8_t key; + double x; + double y; +} DirData; + +typedef struct StrData { + const char *str; +} StrData; + +typedef union CtrlMsgCUnion { + void *nul; + struct KeyData key; + struct AxisData axis; + struct DirData dir; + struct StrData str; +} CtrlMsgCUnion; + +typedef struct ControlMessageC { + enum CtrlMsgCTag tag; + union CtrlMsgCUnion data; +} ControlMessageC; + +typedef union GameMsgCUnion { + void *nul; + struct KeyData key; + enum LeaveReasonData reason; +} GameMsgCUnion; + +typedef struct GameMessageC { + enum GameMsgCTag tag; + union GameMsgCUnion data; +} GameMessageC; + +typedef struct PlayerList { + struct PlayerInfoC *players; + uintptr_t len; + uintptr_t capacity; +} PlayerList; + +typedef union ConnMsgCUnion { + void *nul; + PlayerInfo info; +} ConnMsgCUnion; + +typedef struct ConnectionMessageC { + enum ConnMsgCTag tag; + union ConnMsgCUnion data; +} ConnectionMessageC; + +typedef union ConnCallbackMsgCUnion { + void *nul; + struct GameProfileC profile; + enum ConnErrTypeC conn_err; +} ConnCallbackMsgCUnion; + +typedef struct ConnectionCallbackMessageC { + enum ConnCallbackMsgCTag tag; + union ConnCallbackMsgCUnion data; +} ConnectionCallbackMessageC; + +struct GameProfileC init_game_profile(void); + +struct GameProfileC set_game_profile_name(struct GameProfileC game_profile, const char *value); + +struct GameProfileC set_game_profile_description(struct GameProfileC game_profile, + const char *value); + +struct GameProfileC set_game_profile_organization(struct GameProfileC game_profile, + const char *value); + +struct GameProfileC set_game_profile_version(struct GameProfileC game_profile, const char *value); + +struct GameProfileC set_game_profile_website(struct GameProfileC game_profile, const char *value); + +struct GameProfileC set_game_profile_email(struct GameProfileC game_profile, const char *value); + +struct PlayerInfoC init_player_info(void); + +struct PlayerInfoC set_player_info_account(struct PlayerInfoC info, + const char *id, + const char *password); + +struct PlayerInfoC set_player_info_color(struct PlayerInfoC info, int32_t h, double s, double v); + +struct PlayerInfoC set_player_info_nickname(struct PlayerInfoC info, const char *nickname); + +uint16_t get_default_port(void); + +struct PadClientC init_client(const char *address); + +struct PadClientC init_client_with_port(const char *address, uint16_t port); + +struct PadClientC set_client_quiet(struct PadClientC client); + +struct PadClientC enable_client_console(struct PadClientC client); + +struct PadClientC bind_player_to_client(struct PadClientC client, struct PlayerInfoC 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 ControlMessageC msg); + +struct GameMessageC pop_a_msg_from_server(const PadClient *client); + +struct GameMessageC pop_msg_from_server_or(const PadClient *client, struct 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 struct 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, + struct GameMessageC msg, + const struct PlayerInfoC *player); + +void put_msg_to_all_players(PadServer *server, struct GameMessageC msg); + +struct ControlMessageC pop_a_msg_from_player(PadServer *server, const struct PlayerInfoC *player); + +struct ControlMessageC pop_msg_from_player_or(PadServer *server, + const struct PlayerInfoC *player, + struct ControlMessageC or); + +bool is_player_online(PadServer *server, const struct PlayerInfoC *player); + +bool is_player_banned(PadServer *server, const struct PlayerInfoC *player); + +void kick_player(PadServer *server, const struct PlayerInfoC *player); + +void ban_player(PadServer *server, const struct PlayerInfoC *player); + +void pardon_player(PadServer *server, const struct PlayerInfoC *player); + +struct PlayerList list_online_players(PadServer *server); + +struct PlayerList list_banned_players(PadServer *server); diff --git a/export/dev/bridge/nogamepads_cpp.h b/export/dev/bridge/nogamepads_cpp.h new file mode 100644 index 0000000..cd31b65 --- /dev/null +++ b/export/dev/bridge/nogamepads_cpp.h @@ -0,0 +1,257 @@ +/* NoGamepads C++ Bindings. */ + +/* Generated with cbindgen:0.29.0 */ + +#include +#include +#include +#include +#include + +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 +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 info; +}; + +struct ConnectionMessageC { + ConnMsgCTag tag; + ConnMsgCUnion data; +}; + +union ConnCallbackMsgCUnion { + void *nul; + ManuallyDrop 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 diff --git a/export/dev/bridge/nogamepads_lib_c.dll b/export/dev/bridge/nogamepads_lib_c.dll new file mode 100644 index 0000000..6c376db Binary files /dev/null and b/export/dev/bridge/nogamepads_lib_c.dll differ -- cgit