Browse Source

Alternative panic hook exit

pull/28/head
Andrea Ciliberti 3 years ago
parent
commit
85f901f36e
  1. 2
      ctru-rs/examples/thread-basic.rs
  2. 12
      ctru-rs/src/lib.rs

2
ctru-rs/examples/thread-basic.rs

@ -16,7 +16,7 @@ fn main() { @@ -16,7 +16,7 @@ fn main() {
let prio = thread::current().priority();
println!("Main thread prio: {}\n", prio);
for ix in 0..3 {
thread::Builder::new()
.priority(prio - 1)

12
ctru-rs/src/lib.rs

@ -16,15 +16,9 @@ pub fn init() { @@ -16,15 +16,9 @@ pub fn init() {
let new_hook = Box::new(move |info: &PanicInfo| {
println!("\x1b[1;31m\n--------------------------------------------------");
default_hook(info);
println!("\nPress SELECT to exit the software");
let hid = services::hid::Hid::init().unwrap();
loop {
hid.scan_input();
if hid.keys_down().contains(services::hid::KeyPad::KEY_SELECT) {
break;
}
}
println!("\nThe thread will exit in 5 seconds");
thread::sleep(std::time::Duration::from_secs(5));
});
std::panic::set_hook(new_hook);
}

Loading…
Cancel
Save