aboutsummaryrefslogtreecommitdiff
path: root/examples/src/bin/hello-both-screens.rs
diff options
context:
space:
mode:
Diffstat (limited to 'examples/src/bin/hello-both-screens.rs')
-rw-r--r--examples/src/bin/hello-both-screens.rs42
1 files changed, 42 insertions, 0 deletions
diff --git a/examples/src/bin/hello-both-screens.rs b/examples/src/bin/hello-both-screens.rs
new file mode 100644
index 0000000..ade33d4
--- /dev/null
+++ b/examples/src/bin/hello-both-screens.rs
@@ -0,0 +1,42 @@
+extern crate ctru;
+
+use ctru::gfx::{Gfx, Screen};
+use ctru::console::Console;
+use ctru::services::apt::Apt;
+use ctru::services::hid::{Hid, PadKey};
+
+fn main() {
+ // Initialize services
+ let apt = Apt::init().unwrap();
+ let hid = Hid::init().unwrap();
+ let mut gfx = Gfx::default();
+
+ // Start a console on the top screen
+ let mut top_screen = Console::init(Screen::Top);
+
+ // Start a console on the bottom screen.
+ // The most recently initialized console will be active by default
+ let mut bottom_screen = Console::init(Screen::Bottom);
+
+ // Let's print on the top screen first
+ top_screen.select();
+ println!("This is the top screen! We have a lot of space up here!");
+
+ // Now let's print something on the bottom screen
+ bottom_screen.select();
+ println!("\x1b[14;00HThis is the bottom screen.");
+ println!("There's not as much space down here, but that's okay.");
+
+ top_screen.select();
+ println!("\x1b[29;16HPress Start to exit");
+
+ while apt.main_loop() {
+ gfx.flush_buffers();
+ gfx.swap_buffers();
+
+ hid.scan_input();
+ if hid.key_down(PadKey::Start) {
+ break;
+ }
+ }
+}