aboutsummaryrefslogtreecommitdiff
path: root/core/src/data/controller/cli
diff options
context:
space:
mode:
author1992414357@qq.com <1992414357@qq.com>2025-06-09 10:28:16 +0800
committer1992414357@qq.com <1992414357@qq.com>2025-06-09 10:28:16 +0800
commit7093b08b8efd6e35a434b2923c40b763b51e675b (patch)
treefe46f65e50effe5a89055febd9af4c8d456241e1 /core/src/data/controller/cli
parenta75ee4f12e78b880f6d008a5e72d70b0c7f997b4 (diff)
将控制台的关闭改为了自动
Diffstat (limited to 'core/src/data/controller/cli')
-rw-r--r--core/src/data/controller/cli/cli_command.rs29
1 files changed, 10 insertions, 19 deletions
diff --git a/core/src/data/controller/cli/cli_command.rs b/core/src/data/controller/cli/cli_command.rs
index d5cda07..b918d47 100644
--- a/core/src/data/controller/cli/cli_command.rs
+++ b/core/src/data/controller/cli/cli_command.rs
@@ -1,13 +1,9 @@
-use std::process::exit;
use std::sync::{Arc, Mutex};
use clap::{Args, Parser, Subcommand};
use clearscreen::clear;
use log::info;
use nogamepads::entry_mutex;
use crate::data::controller::runtime::structs::ControllerRuntime;
-use crate::data::message::enums::ControlMessage;
-use crate::data::message::traits::MessageManager;
-use crate::service::service_types::ServiceType::TCPConnection;
#[derive(Parser, Debug)]
#[command(author, version, about, long_about = None)]
@@ -25,9 +21,6 @@ enum Commands {
#[command(about = "Close the controller")]
Close,
- #[command(about = "Exit the console")]
- Exit,
-
#[command(about = "Send a message")]
Message(MessageArgs),
@@ -71,7 +64,7 @@ struct DirectionArgs {
y: f64
}
-pub fn process_controller_cli(runtime: Arc<Mutex<ControllerRuntime>>, cmd: ControllerCli) {
+pub fn process_controller_cli(runtime: Arc<Mutex<ControllerRuntime>>, cmd: ControllerCli) -> bool {
match cmd.command {
Commands::Clear => {
@@ -82,40 +75,37 @@ pub fn process_controller_cli(runtime: Arc<Mutex<ControllerRuntime>>, cmd: Contr
entry_mutex!(runtime, |guard| {
guard.close();
});
- }
-
- Commands::Exit => {
- exit(1);
+ return false;
}
Commands::Message(args) => {
entry_mutex!(runtime, |guard| {
guard.message(args.message);
- })
+ });
}
Commands::Press(args) => {
entry_mutex!(runtime, |guard| {
guard.press_button(args.button_key);
- })
+ });
}
Commands::Release(args) => {
entry_mutex!(runtime, |guard| {
guard.release_button(args.button_key);
- })
+ });
}
Commands::Axis(args) => {
entry_mutex!(runtime, |guard| {
guard.change_axis(args.axis_key, args.axis_value);
- })
+ });
}
Commands::Direction(args) => {
entry_mutex!(runtime, |guard| {
guard.change_direction(args.dir_key, args.x, args.y);
- })
+ });
}
Commands::Pop => {
@@ -125,7 +115,7 @@ pub fn process_controller_cli(runtime: Arc<Mutex<ControllerRuntime>>, cmd: Contr
} else {
info!("None!");
}
- })
+ });
}
Commands::PopAll => {
@@ -133,7 +123,8 @@ pub fn process_controller_cli(runtime: Arc<Mutex<ControllerRuntime>>, cmd: Contr
while let Some(msg) = guard.pop() {
info!("Pop: {:?}", msg);
}
- })
+ });
}
}
+ true
} \ No newline at end of file