use windows subsystem attach console on release builds

This commit is contained in:
griffi-gh 2023-02-10 01:20:54 +01:00
parent 6354d8bab4
commit 4e357af959
4 changed files with 20 additions and 7 deletions

View file

@ -19,3 +19,6 @@ nohash-hasher = "0.2.0"
anyhow = "1.0" anyhow = "1.0"
flume = "0.10" flume = "0.10"
gilrs = { version = "0.10", default_features = false, features = ["xinput"] } gilrs = { version = "0.10", default_features = false, features = ["xinput"] }
[target.'cfg(target_os = "windows")'.dependencies]
winapi = { version = "0.3" }

View file

@ -13,7 +13,7 @@ pub fn update_controllers() -> Workload {
).into_workload() ).into_workload()
} }
const MAX_PITCH: f32 = PI/2. - 0.025; const MAX_PITCH: f32 = PI/2. - 0.05;
fn update_look( fn update_look(
controllers: View<FlyController>, controllers: View<FlyController>,

View file

@ -5,10 +5,8 @@ use log::Level;
use std::io::Write; use std::io::Write;
pub fn init() { pub fn init() {
let mut env = Env::default(); let env = Env::default()
if cfg!(debug_assertions) { .filter_or("RUST_LOG", "trace,gilrs=warn,rusty_xinput=warn");
env = env.filter_or("RUST_LOG", "trace,gilrs=warn,rusty_xinput=warn");
}
Builder::from_env(env) Builder::from_env(env)
.format(|buf, record| { .format(|buf, record| {
let mut level_style = buf.style(); let mut level_style = buf.style();

View file

@ -1,5 +1,8 @@
// allowed because systems often need a lot of arguments #![cfg_attr(
#![allow(clippy::too_many_arguments)] all(windows, not(debug_assertions)),
windows_subsystem = "windows"
)]
#![allow(clippy::too_many_arguments)] // allowed because systems often need a lot of arguments
use shipyard::{ use shipyard::{
World, Workload, IntoWorkload, World, Workload, IntoWorkload,
@ -127,7 +130,16 @@ fn after_frame_end() -> Workload {
).into_workload() ).into_workload()
} }
#[cfg(all(windows, not(debug_assertions)))]
fn attach_console() {
use winapi::um::wincon::{AttachConsole, ATTACH_PARENT_PROCESS};
unsafe { AttachConsole(ATTACH_PARENT_PROCESS); }
}
fn main() { fn main() {
//Attach console on release builds on windows
#[cfg(all(windows, not(debug_assertions)))] attach_console();
//Init env_logger //Init env_logger
logging::init(); logging::init();