From 4b435614b4b5f340ae5246f9fe33b042cd3aebb3 Mon Sep 17 00:00:00 2001 From: TechiePi Date: Thu, 20 Oct 2022 22:17:52 +0200 Subject: [PATCH] Add ``mii_selector`` example --- ctru-rs/examples/mii_selector.rs | 41 ++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 ctru-rs/examples/mii_selector.rs diff --git a/ctru-rs/examples/mii_selector.rs b/ctru-rs/examples/mii_selector.rs new file mode 100644 index 0000000..a9d8779 --- /dev/null +++ b/ctru-rs/examples/mii_selector.rs @@ -0,0 +1,41 @@ +use ctru::applets::mii_selector::MiiSelector; +use ctru::prelude::*; + +fn main() { + ctru::init(); + + let gfx = Gfx::init().expect("Couldn't obtain GFX controller"); + let hid = Hid::init().expect("Couldn't obtain HID controller"); + let apt = Apt::init().expect("Couldn't obtain APT controller"); + let _console = Console::init(gfx.top_screen.borrow_mut()); + + let mut mii_selector = MiiSelector::init(); + mii_selector.set_initial_index(3); + mii_selector.blacklist_user_mii(0.into()); + mii_selector.set_title("Great Mii Selector!"); + + let result = mii_selector.launch(); + + println!("\x1b[0;0HIs Mii selected?: {:?}", result.is_mii_selected); + println!("\x1b[2;0HValid checksum?: {:?}", result.valid_checksum()); + println!("\x1b[4;0HMii type: {:?}", result.mii_type); + println!("\x1b[6;0HMii checksum: {:?}", result.checksum); + println!("\x1b[8;0HName: {:?}", result.name()); + println!("\x1b[12;0HAuthor: {:?}", result.author()); + + // Main loop + while apt.main_loop() { + //Scan all the inputs. This should be done once for each frame + hid.scan_input(); + + if hid.keys_down().contains(KeyPad::KEY_START) { + break; + } + // Flush and swap framebuffers + gfx.flush_buffers(); + gfx.swap_buffers(); + + //Wait for VBlank + gfx.wait_for_vblank(); + } +} \ No newline at end of file