aboutsummaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
author1992414357@qq.com <1992414357@qq.com>2025-05-28 09:11:31 +0800
committer1992414357@qq.com <1992414357@qq.com>2025-05-28 09:11:31 +0800
commitc0244a9d6f657934313e03f67a4b9fa9d93d34b7 (patch)
tree2da30c3984f5182e1bd3369de148abaa05afcbf8 /core
parentadc42fdf2050e77de50952bc8629684f1b3cf0ce (diff)
.
Diffstat (limited to 'core')
-rw-r--r--core/Cargo.toml7
-rw-r--r--core/src/lib.rs3
-rw-r--r--core/src/pad_data/game_profile.rs1
-rw-r--r--core/src/pad_data/pad_player_info.rs1
-rw-r--r--core/src/pad_service/client.rs2
-rw-r--r--core/src/pad_service/server.rs9
6 files changed, 14 insertions, 9 deletions
diff --git a/core/Cargo.toml b/core/Cargo.toml
index fade27a..e41697e 100644
--- a/core/Cargo.toml
+++ b/core/Cargo.toml
@@ -5,7 +5,6 @@ homepage = "https://github.com/CatilGrass/NoGamepads"
repository = "https://github.com/CatilGrass/NoGamepads"
readme = "../README.md"
-version = "0.1.0"
edition = "2024"
[dependencies]
@@ -17,4 +16,8 @@ tokio = { version = "1.45.0", features = ["full"] }
serde = { version = "1.0.219", features = ["derive"] }
clap = { version = "4.5.38", features = ["derive"] }
sha1 = "0.10.6"
-log = "0.4.27" \ No newline at end of file
+log = "0.4.27"
+
+[lib]
+name = "nogamepads_lib_rs"
+crate-type = [ "rlib"] \ No newline at end of file
diff --git a/core/src/lib.rs b/core/src/lib.rs
index 1abb191..0c8cf83 100644
--- a/core/src/lib.rs
+++ b/core/src/lib.rs
@@ -6,5 +6,4 @@ pub mod pad_data;
pub const DEFAULT_PORT : u16 = 5989;
pub const BINCODE_CONVERT_FAILED : Vec<u8> = Vec::new();
-pub const BINCODE_CONFIG : Configuration = config::standard();
-
+pub const BINCODE_CONFIG : Configuration = config::standard(); \ No newline at end of file
diff --git a/core/src/pad_data/game_profile.rs b/core/src/pad_data/game_profile.rs
index 8d6e279..cd2a175 100644
--- a/core/src/pad_data/game_profile.rs
+++ b/core/src/pad_data/game_profile.rs
@@ -3,6 +3,7 @@ pub mod game_profile {
use bincode::{Decode, Encode};
use serde::{Deserialize, Serialize};
+ #[repr(C)]
#[derive(Encode, Decode, Serialize, Deserialize, PartialEq, Debug)]
pub struct GameProfile {
diff --git a/core/src/pad_data/pad_player_info.rs b/core/src/pad_data/pad_player_info.rs
index ab0f6fd..1c8b7e0 100644
--- a/core/src/pad_data/pad_player_info.rs
+++ b/core/src/pad_data/pad_player_info.rs
@@ -7,6 +7,7 @@ pub mod nogamepads_player_info {
pub const ACCOUNT_HASH_SALT : &str = "Mr.Weicao";
+ #[repr(C)]
#[derive(Encode, Decode,
Serialize, Deserialize,
PartialEq, Debug)]
diff --git a/core/src/pad_service/client.rs b/core/src/pad_service/client.rs
index 3114330..be7784d 100644
--- a/core/src/pad_service/client.rs
+++ b/core/src/pad_service/client.rs
@@ -25,6 +25,7 @@ pub mod nogamepads_client {
type WriteList = Arc<Mutex<VecDeque<ControlMessage>>>;
type ReadList = Arc<Mutex<VecDeque<GameMessage>>>;
+ #[repr(C)]
pub struct PadClient {
// --- 主要参数 ---
@@ -108,7 +109,6 @@ pub mod nogamepads_client {
// 客户端消息管理
impl PadClient {
-
pub fn put_msg(&self, msg: ControlMessage) {
let mut guard = self.write_list.lock().unwrap();
guard.push_back(msg);
diff --git a/core/src/pad_service/server.rs b/core/src/pad_service/server.rs
index 3c60864..66ab56d 100644
--- a/core/src/pad_service/server.rs
+++ b/core/src/pad_service/server.rs
@@ -30,6 +30,7 @@ pub mod nogamepads_server {
type WriteList = Arc<Mutex<HashMap<String, VecDeque<GameMessage>>>>;
type ReadList = Arc<Mutex<HashMap<String, VecDeque<ControlMessage>>>>;
+ #[repr(C)]
pub struct PadServer {
// --- 主要参数 ---
@@ -237,7 +238,7 @@ pub mod nogamepads_server {
guard.contains_key(&player.account.player_hash)
}
- pub fn set_player_online (&self, player: &PlayerInfo, online: bool) {
+ fn set_player_online (&self, player: &PlayerInfo, online: bool) {
let online_current = self.is_player_online(player);
if online_current && !online {
let mut guard = self.online_players.lock().unwrap();
@@ -374,15 +375,15 @@ pub mod nogamepads_server {
}
}
- fn lock_game(&self) {
+ pub fn lock_game(&self) {
self.game_locked.store(true, SeqCst);
}
- fn unlock_game(&self) {
+ pub fn unlock_game(&self) {
self.game_locked.store(false, SeqCst);
}
- fn is_game_locked(&self) -> bool {
+ pub fn is_game_locked(&self) -> bool {
self.game_locked.load(SeqCst)
}