diff --git a/ctru-rs/examples/gfx_wide_mode.rs b/ctru-rs/examples/gfx_wide_mode.rs new file mode 100644 index 0000000..e7a289c --- /dev/null +++ b/ctru-rs/examples/gfx_wide_mode.rs @@ -0,0 +1,33 @@ +extern crate ctru; + +use ctru::console::Console; +use ctru::Gfx; +use ctru::gfx::Screen; +use ctru::services::{Apt, Hid}; +use ctru::services::hid::KeyPad; + +fn main() { + ctru::init(); + let apt = Apt::init().unwrap(); + let hid = Hid::init().unwrap(); + let gfx = Gfx::default(); + let _console = Console::init(Screen::Top); + + println!("Press A to enable/disable wide screen mode."); + + while apt.main_loop() { + hid.scan_input(); + + if hid.keys_down().contains(KeyPad::KEY_START) { + break + } + + if hid.keys_down().contains(KeyPad::KEY_A) { + gfx.set_wide_mode(!gfx.get_wide_mode()); + } + + gfx.flush_buffers(); + gfx.swap_buffers(); + gfx.wait_for_vblank(); + } +} \ No newline at end of file diff --git a/ctru-rs/src/gfx.rs b/ctru-rs/src/gfx.rs index 749a69a..d02e3e1 100644 --- a/ctru-rs/src/gfx.rs +++ b/ctru-rs/src/gfx.rs @@ -49,6 +49,18 @@ impl Gfx { } } + /// Enable or disable the wide screen mode (top screen). + /// + /// This only works when 3D is disabled. + pub fn set_wide_mode(&self, enabled: bool) { + unsafe { libctru::gfxSetWide(enabled) }; + } + + /// Get the status of wide screen mode. + pub fn get_wide_mode(&self) -> bool { + unsafe { libctru::gfxIsWide() } + } + /// Sets whether to use double buffering. Enabled by default. /// /// Note that even when double buffering is disabled, one should still use the `swap_buffers`