diff --git a/ctru-rs/examples/audio-filters.rs b/ctru-rs/examples/audio-filters.rs index 327ede4..e425793 100644 --- a/ctru-rs/examples/audio-filters.rs +++ b/ctru-rs/examples/audio-filters.rs @@ -37,10 +37,10 @@ fn fill_buffer(audio_data: &mut [u8], frequency: f32) { fn main() { ctru::use_panic_handler(); - let gfx = Gfx::init().expect("Couldn't obtain GFX controller"); - let mut 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 gfx = Gfx::new().expect("Couldn't obtain GFX controller"); + let mut hid = Hid::new().expect("Couldn't obtain HID controller"); + let apt = Apt::new().expect("Couldn't obtain APT controller"); + let _console = Console::new(gfx.top_screen.borrow_mut()); let mut note: usize = 4; @@ -68,7 +68,7 @@ fn main() { let mut wave_info1 = Wave::new(audio_data1, AudioFormat::PCM16Stereo, false); let mut wave_info2 = Wave::new(audio_data2, AudioFormat::PCM16Stereo, false); - let mut ndsp = Ndsp::init().expect("Couldn't obtain NDSP controller"); + let mut ndsp = Ndsp::new().expect("Couldn't obtain NDSP controller"); // This line isn't needed since the default NDSP configuration already sets the output mode to `Stereo` ndsp.set_output_mode(OutputMode::Stereo); diff --git a/ctru-rs/examples/buttons.rs b/ctru-rs/examples/buttons.rs index 39f24d9..5645915 100644 --- a/ctru-rs/examples/buttons.rs +++ b/ctru-rs/examples/buttons.rs @@ -3,10 +3,10 @@ use ctru::prelude::*; fn main() { ctru::use_panic_handler(); - let apt = Apt::init().unwrap(); - let mut hid = Hid::init().unwrap(); - let gfx = Gfx::init().unwrap(); - let console = Console::init(gfx.top_screen.borrow_mut()); + let apt = Apt::new().unwrap(); + let mut hid = Hid::new().unwrap(); + let gfx = Gfx::new().unwrap(); + let console = Console::new(gfx.top_screen.borrow_mut()); println!("Hi there! Try pressing a button"); println!("\x1b[29;16HPress Start to exit"); diff --git a/ctru-rs/examples/camera-image.rs b/ctru-rs/examples/camera-image.rs index 46a96d4..88526be 100644 --- a/ctru-rs/examples/camera-image.rs +++ b/ctru-rs/examples/camera-image.rs @@ -16,22 +16,22 @@ const WAIT_TIMEOUT: Duration = Duration::from_millis(300); fn main() { ctru::use_panic_handler(); - let apt = Apt::init().expect("Failed to initialize Apt service."); - let mut hid = Hid::init().expect("Failed to initialize Hid service."); - let gfx = Gfx::init().expect("Failed to initialize GFX service."); + let apt = Apt::new().expect("Failed to initialize Apt service."); + let mut hid = Hid::new().expect("Failed to initialize Hid service."); + let gfx = Gfx::new().expect("Failed to initialize GFX service."); gfx.top_screen.borrow_mut().set_double_buffering(true); gfx.top_screen .borrow_mut() .set_framebuffer_format(FramebufferFormat::Rgb565); gfx.bottom_screen.borrow_mut().set_double_buffering(false); - let _console = Console::init(gfx.bottom_screen.borrow_mut()); + let _console = Console::new(gfx.bottom_screen.borrow_mut()); let mut keys_down; println!("Initializing camera"); - let mut cam = Cam::init().expect("Failed to initialize CAM service."); + let mut cam = Cam::new().expect("Failed to initialize CAM service."); { let camera = &mut cam.outer_right_cam; diff --git a/ctru-rs/examples/file-explorer.rs b/ctru-rs/examples/file-explorer.rs index 5b256c9..8a3d639 100644 --- a/ctru-rs/examples/file-explorer.rs +++ b/ctru-rs/examples/file-explorer.rs @@ -11,14 +11,14 @@ use std::path::{Path, PathBuf}; fn main() { ctru::use_panic_handler(); - let apt = Apt::init().unwrap(); - let mut hid = Hid::init().unwrap(); - let gfx = Gfx::init().unwrap(); + let apt = Apt::new().unwrap(); + let mut hid = Hid::new().unwrap(); + let gfx = Gfx::new().unwrap(); #[cfg(all(feature = "romfs", romfs_exists))] - let _romfs = ctru::services::romfs::RomFS::init().unwrap(); + let _romfs = ctru::services::romfs::RomFS::new().unwrap(); - FileExplorer::init(&apt, &mut hid, &gfx).run(); + FileExplorer::new(&apt, &mut hid, &gfx).run(); } struct FileExplorer<'a> { @@ -32,10 +32,10 @@ struct FileExplorer<'a> { } impl<'a> FileExplorer<'a> { - fn init(apt: &'a Apt, hid: &'a mut Hid, gfx: &'a Gfx) -> Self { + fn new(apt: &'a Apt, hid: &'a mut Hid, gfx: &'a Gfx) -> Self { let mut top_screen = gfx.top_screen.borrow_mut(); top_screen.set_wide_mode(true); - let console = Console::init(top_screen); + let console = Console::new(top_screen); FileExplorer { apt, diff --git a/ctru-rs/examples/futures-basic.rs b/ctru-rs/examples/futures-basic.rs index ee2e3be..cb6a804 100644 --- a/ctru-rs/examples/futures-basic.rs +++ b/ctru-rs/examples/futures-basic.rs @@ -15,10 +15,10 @@ use std::os::horizon::thread::BuilderExt; fn main() { ctru::use_panic_handler(); - let gfx = Gfx::init().expect("Couldn't obtain GFX controller"); - let mut 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 gfx = Gfx::new().expect("Couldn't obtain GFX controller"); + let mut hid = Hid::new().expect("Couldn't obtain HID controller"); + let apt = Apt::new().expect("Couldn't obtain APT controller"); + let _console = Console::new(gfx.top_screen.borrow_mut()); // Give ourselves up to 30% of the system core's time apt.set_app_cpu_time_limit(30) diff --git a/ctru-rs/examples/futures-tokio.rs b/ctru-rs/examples/futures-tokio.rs index cbb446d..e42e9e9 100644 --- a/ctru-rs/examples/futures-tokio.rs +++ b/ctru-rs/examples/futures-tokio.rs @@ -8,10 +8,10 @@ use std::time::Duration; fn main() { ctru::use_panic_handler(); - let gfx = Gfx::init().expect("Couldn't obtain GFX controller"); - let mut 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 gfx = Gfx::new().expect("Couldn't obtain GFX controller"); + let mut hid = Hid::new().expect("Couldn't obtain HID controller"); + let apt = Apt::new().expect("Couldn't obtain APT controller"); + let _console = Console::new(gfx.top_screen.borrow_mut()); // Give ourselves up to 30% of the system core's time apt.set_app_cpu_time_limit(30) diff --git a/ctru-rs/examples/gfx-3d-mode.rs b/ctru-rs/examples/gfx-3d-mode.rs index 13b4d3c..c5b194c 100644 --- a/ctru-rs/examples/gfx-3d-mode.rs +++ b/ctru-rs/examples/gfx-3d-mode.rs @@ -12,10 +12,10 @@ static ZERO: &[u8] = &[0; IMAGE.len()]; fn main() { ctru::use_panic_handler(); - let gfx = Gfx::init().expect("Couldn't obtain GFX controller"); - let mut hid = Hid::init().expect("Couldn't obtain HID controller"); - let apt = Apt::init().expect("Couldn't obtain APT controller"); - let _console = Console::init(gfx.bottom_screen.borrow_mut()); + let gfx = Gfx::new().expect("Couldn't obtain GFX controller"); + let mut hid = Hid::new().expect("Couldn't obtain HID controller"); + let apt = Apt::new().expect("Couldn't obtain APT controller"); + let _console = Console::new(gfx.bottom_screen.borrow_mut()); println!("Press Start to exit.\nPress A to switch sides (be sure to have 3D mode enabled)."); diff --git a/ctru-rs/examples/gfx-wide-mode.rs b/ctru-rs/examples/gfx-wide-mode.rs index f781c89..53da6ea 100644 --- a/ctru-rs/examples/gfx-wide-mode.rs +++ b/ctru-rs/examples/gfx-wide-mode.rs @@ -3,10 +3,10 @@ use ctru::prelude::*; fn main() { ctru::use_panic_handler(); - let apt = Apt::init().unwrap(); - let mut hid = Hid::init().unwrap(); - let gfx = Gfx::init().unwrap(); - let mut console = Console::init(gfx.top_screen.borrow_mut()); + let apt = Apt::new().unwrap(); + let mut hid = Hid::new().unwrap(); + let gfx = Gfx::new().unwrap(); + let mut console = Console::new(gfx.top_screen.borrow_mut()); println!("Press A to enable/disable wide screen mode."); @@ -23,7 +23,7 @@ fn main() { let wide_mode = gfx.top_screen.borrow().is_wide(); gfx.top_screen.borrow_mut().set_wide_mode(!wide_mode); - console = Console::init(gfx.top_screen.borrow_mut()); + console = Console::new(gfx.top_screen.borrow_mut()); println!("Press A to enable/disable wide screen mode."); } diff --git a/ctru-rs/examples/graphics-bitmap.rs b/ctru-rs/examples/graphics-bitmap.rs index ebbf53e..55d4903 100644 --- a/ctru-rs/examples/graphics-bitmap.rs +++ b/ctru-rs/examples/graphics-bitmap.rs @@ -17,10 +17,10 @@ static IMAGE: &[u8] = include_bytes!("assets/ferris.rgb"); fn main() { ctru::use_panic_handler(); - let gfx = Gfx::init().expect("Couldn't obtain GFX controller"); - let mut 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 gfx = Gfx::new().expect("Couldn't obtain GFX controller"); + let mut hid = Hid::new().expect("Couldn't obtain HID controller"); + let apt = Apt::new().expect("Couldn't obtain APT controller"); + let _console = Console::new(gfx.top_screen.borrow_mut()); println!("\x1b[21;16HPress Start to exit."); diff --git a/ctru-rs/examples/hashmaps.rs b/ctru-rs/examples/hashmaps.rs index 87ad8be..e3726eb 100644 --- a/ctru-rs/examples/hashmaps.rs +++ b/ctru-rs/examples/hashmaps.rs @@ -8,10 +8,10 @@ fn main() { // HashMaps generate hashes thanks to the 3DS' cryptografically secure generator. // This generator is only active when activating the `PS` service. // This service is automatically initialized. - let apt = Apt::init().unwrap(); - let mut hid = Hid::init().unwrap(); - let gfx = Gfx::init().unwrap(); - let _console = Console::init(gfx.top_screen.borrow_mut()); + let apt = Apt::new().unwrap(); + let mut hid = Hid::new().unwrap(); + let gfx = Gfx::new().unwrap(); + let _console = Console::new(gfx.top_screen.borrow_mut()); let mut map = std::collections::HashMap::new(); map.insert("A Key!", 102); diff --git a/ctru-rs/examples/hello-both-screens.rs b/ctru-rs/examples/hello-both-screens.rs index 7395967..fa2e16d 100644 --- a/ctru-rs/examples/hello-both-screens.rs +++ b/ctru-rs/examples/hello-both-screens.rs @@ -3,16 +3,16 @@ use ctru::prelude::*; fn main() { ctru::use_panic_handler(); - let apt = Apt::init().unwrap(); - let mut hid = Hid::init().unwrap(); - let gfx = Gfx::init().unwrap(); + let apt = Apt::new().unwrap(); + let mut hid = Hid::new().unwrap(); + let gfx = Gfx::new().unwrap(); // Start a console on the top screen - let top_screen = Console::init(gfx.top_screen.borrow_mut()); + let top_screen = Console::new(gfx.top_screen.borrow_mut()); // Start a console on the bottom screen. // The most recently initialized console will be active by default - let bottom_screen = Console::init(gfx.bottom_screen.borrow_mut()); + let bottom_screen = Console::new(gfx.bottom_screen.borrow_mut()); // Let's print on the top screen first top_screen.select(); diff --git a/ctru-rs/examples/hello-world.rs b/ctru-rs/examples/hello-world.rs index 697ec7c..345ee2e 100644 --- a/ctru-rs/examples/hello-world.rs +++ b/ctru-rs/examples/hello-world.rs @@ -5,10 +5,10 @@ use std::io::BufWriter; fn main() { ctru::use_panic_handler(); - let gfx = Gfx::init().expect("Couldn't obtain GFX controller"); - let mut 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 gfx = Gfx::new().expect("Couldn't obtain GFX controller"); + let mut hid = Hid::new().expect("Couldn't obtain HID controller"); + let apt = Apt::new().expect("Couldn't obtain APT controller"); + let _console = Console::new(gfx.top_screen.borrow_mut()); let out = b"Hello fellow Rustaceans, I'm on the Nintendo 3DS!"; let width = 24; diff --git a/ctru-rs/examples/linear-memory.rs b/ctru-rs/examples/linear-memory.rs index b3afced..2373941 100644 --- a/ctru-rs/examples/linear-memory.rs +++ b/ctru-rs/examples/linear-memory.rs @@ -6,10 +6,10 @@ use ctru::prelude::*; fn main() { ctru::use_panic_handler(); - let gfx = Gfx::init().expect("Couldn't obtain GFX controller"); - let mut 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 gfx = Gfx::new().expect("Couldn't obtain GFX controller"); + let mut hid = Hid::new().expect("Couldn't obtain HID controller"); + let apt = Apt::new().expect("Couldn't obtain APT controller"); + let _console = Console::new(gfx.top_screen.borrow_mut()); let linear_space_before = LinearAllocator::free_space(); diff --git a/ctru-rs/examples/mii-selector.rs b/ctru-rs/examples/mii-selector.rs index ef7d7d3..9ef86f6 100644 --- a/ctru-rs/examples/mii-selector.rs +++ b/ctru-rs/examples/mii-selector.rs @@ -4,12 +4,12 @@ use ctru::prelude::*; fn main() { ctru::use_panic_handler(); - let gfx = Gfx::init().expect("Couldn't obtain GFX controller"); - let mut 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 gfx = Gfx::new().expect("Couldn't obtain GFX controller"); + let mut hid = Hid::new().expect("Couldn't obtain HID controller"); + let apt = Apt::new().expect("Couldn't obtain APT controller"); + let _console = Console::new(gfx.top_screen.borrow_mut()); - let mut mii_selector = MiiSelector::init(); + let mut mii_selector = MiiSelector::new(); mii_selector.set_initial_index(3); mii_selector.blacklist_user_mii(0.into()); mii_selector.set_title("Great Mii Selector!"); diff --git a/ctru-rs/examples/network-sockets.rs b/ctru-rs/examples/network-sockets.rs index ca2d163..bbea510 100644 --- a/ctru-rs/examples/network-sockets.rs +++ b/ctru-rs/examples/network-sockets.rs @@ -7,14 +7,14 @@ use std::time::Duration; fn main() { ctru::use_panic_handler(); - let gfx = Gfx::init().unwrap(); - let _console = Console::init(gfx.top_screen.borrow_mut()); - let mut hid = Hid::init().unwrap(); - let apt = Apt::init().unwrap(); + let gfx = Gfx::new().unwrap(); + let _console = Console::new(gfx.top_screen.borrow_mut()); + let mut hid = Hid::new().unwrap(); + let apt = Apt::new().unwrap(); println!("\nlibctru sockets demo\n"); - let soc = Soc::init().unwrap(); + let soc = Soc::new().unwrap(); let server = TcpListener::bind("0.0.0.0:80").unwrap(); server.set_nonblocking(true).unwrap(); diff --git a/ctru-rs/examples/output-3dslink.rs b/ctru-rs/examples/output-3dslink.rs index 1fe0c6a..5649e6e 100644 --- a/ctru-rs/examples/output-3dslink.rs +++ b/ctru-rs/examples/output-3dslink.rs @@ -13,11 +13,11 @@ use ctru::prelude::*; fn main() { ctru::use_panic_handler(); - let gfx = Gfx::init().expect("Couldn't obtain GFX controller"); - let mut hid = Hid::init().expect("Couldn't obtain HID controller"); - let apt = Apt::init().expect("Couldn't obtain APT controller"); + let gfx = Gfx::new().expect("Couldn't obtain GFX controller"); + let mut hid = Hid::new().expect("Couldn't obtain HID controller"); + let apt = Apt::new().expect("Couldn't obtain APT controller"); - let mut soc = Soc::init().expect("Couldn't obtain SOC controller"); + let mut soc = Soc::new().expect("Couldn't obtain SOC controller"); soc.redirect_to_3dslink(true, true) .expect("unable to redirect stdout/err to 3dslink server"); diff --git a/ctru-rs/examples/romfs.rs b/ctru-rs/examples/romfs.rs index c729c32..f92d81d 100644 --- a/ctru-rs/examples/romfs.rs +++ b/ctru-rs/examples/romfs.rs @@ -3,17 +3,17 @@ use ctru::prelude::*; fn main() { ctru::use_panic_handler(); - let gfx = Gfx::init().expect("Couldn't obtain GFX controller"); - let mut 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 gfx = Gfx::new().expect("Couldn't obtain GFX controller"); + let mut hid = Hid::new().expect("Couldn't obtain HID controller"); + let apt = Apt::new().expect("Couldn't obtain APT controller"); + let _console = Console::new(gfx.top_screen.borrow_mut()); cfg_if::cfg_if! { // Run this code if RomFS are wanted and available // This never fails as `ctru-rs` examples inherit all of the `ctru` features, // but it might if a normal user application wasn't setup correctly if #[cfg(all(feature = "romfs", romfs_exists))] { - let _romfs = ctru::services::romfs::RomFS::init().unwrap(); + let _romfs = ctru::services::romfs::RomFS::new().unwrap(); let f = std::fs::read_to_string("romfs:/test-file.txt").unwrap(); println!("Contents of test-file.txt: \n{f}\n"); diff --git a/ctru-rs/examples/software-keyboard.rs b/ctru-rs/examples/software-keyboard.rs index 954fdd0..77e877a 100644 --- a/ctru-rs/examples/software-keyboard.rs +++ b/ctru-rs/examples/software-keyboard.rs @@ -4,10 +4,10 @@ use ctru::prelude::*; fn main() { ctru::use_panic_handler(); - let apt = Apt::init().unwrap(); - let mut hid = Hid::init().unwrap(); - let gfx = Gfx::init().unwrap(); - let _console = Console::init(gfx.top_screen.borrow_mut()); + let apt = Apt::new().unwrap(); + let mut hid = Hid::new().unwrap(); + let gfx = Gfx::new().unwrap(); + let _console = Console::new(gfx.top_screen.borrow_mut()); println!("Press A to enter some text or press Start to quit"); @@ -20,7 +20,7 @@ fn main() { if hid.keys_down().contains(KeyPad::A) { // Prepares a software keyboard with two buttons: One to cancel input and one - // to accept it. You can also use `Swkbd::init()` to launch the keyboard in different + // to accept it. You can also use `Swkbd::new()` to launch the keyboard in different // configurations. let mut keyboard = Swkbd::default(); diff --git a/ctru-rs/examples/system-configuration.rs b/ctru-rs/examples/system-configuration.rs index cd81a02..cb1e00f 100644 --- a/ctru-rs/examples/system-configuration.rs +++ b/ctru-rs/examples/system-configuration.rs @@ -4,11 +4,11 @@ use ctru::services::cfgu::Cfgu; fn main() { ctru::use_panic_handler(); - let gfx = Gfx::init().expect("Couldn't obtain GFX controller"); - let mut hid = Hid::init().expect("Couldn't obtain HID controller"); - let apt = Apt::init().expect("Couldn't obtain APT controller"); - let cfgu = Cfgu::init().expect("Couldn't obtain CFGU controller"); - let _console = Console::init(gfx.top_screen.borrow_mut()); + let gfx = Gfx::new().expect("Couldn't obtain GFX controller"); + let mut hid = Hid::new().expect("Couldn't obtain HID controller"); + let apt = Apt::new().expect("Couldn't obtain APT controller"); + let cfgu = Cfgu::new().expect("Couldn't obtain CFGU controller"); + let _console = Console::new(gfx.top_screen.borrow_mut()); println!("\x1b[0;0HRegion: {:?}", cfgu.region().unwrap()); println!("\x1b[10;0HLanguage: {:?}", cfgu.language().unwrap()); diff --git a/ctru-rs/examples/thread-basic.rs b/ctru-rs/examples/thread-basic.rs index 73be659..cc494f6 100644 --- a/ctru-rs/examples/thread-basic.rs +++ b/ctru-rs/examples/thread-basic.rs @@ -8,10 +8,10 @@ use std::time::Duration; fn main() { ctru::use_panic_handler(); - let apt = Apt::init().unwrap(); - let mut hid = Hid::init().unwrap(); - let gfx = Gfx::init().unwrap(); - let _console = Console::init(gfx.top_screen.borrow_mut()); + let apt = Apt::new().unwrap(); + let mut hid = Hid::new().unwrap(); + let gfx = Gfx::new().unwrap(); + let _console = Console::new(gfx.top_screen.borrow_mut()); let prio = std::os::horizon::thread::current_priority(); println!("Main thread prio: {}\n", prio); diff --git a/ctru-rs/examples/thread-info.rs b/ctru-rs/examples/thread-info.rs index 968e858..9ab04fe 100644 --- a/ctru-rs/examples/thread-info.rs +++ b/ctru-rs/examples/thread-info.rs @@ -9,10 +9,10 @@ use std::os::horizon::thread::BuilderExt; fn main() { ctru::use_panic_handler(); - let gfx = Gfx::init().expect("Couldn't obtain GFX controller"); - let mut 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 gfx = Gfx::new().expect("Couldn't obtain GFX controller"); + let mut hid = Hid::new().expect("Couldn't obtain HID controller"); + let apt = Apt::new().expect("Couldn't obtain APT controller"); + let _console = Console::new(gfx.top_screen.borrow_mut()); // Give ourselves up to 30% of the system core's time apt.set_app_cpu_time_limit(30) diff --git a/ctru-rs/examples/thread-locals.rs b/ctru-rs/examples/thread-locals.rs index 09e2082..d2a5e3e 100644 --- a/ctru-rs/examples/thread-locals.rs +++ b/ctru-rs/examples/thread-locals.rs @@ -12,11 +12,11 @@ std::thread_local! { fn main() { ctru::use_panic_handler(); - let gfx = Gfx::init().expect("Couldn't obtain GFX controller"); + let gfx = Gfx::new().expect("Couldn't obtain GFX controller"); gfx.top_screen.borrow_mut().set_wide_mode(true); - let mut 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 hid = Hid::new().expect("Couldn't obtain HID controller"); + let apt = Apt::new().expect("Couldn't obtain APT controller"); + let _console = Console::new(gfx.top_screen.borrow_mut()); // Give ourselves up to 30% of the system core's time apt.set_app_cpu_time_limit(30) diff --git a/ctru-rs/examples/time-rtc.rs b/ctru-rs/examples/time-rtc.rs index 86db923..66c9a63 100644 --- a/ctru-rs/examples/time-rtc.rs +++ b/ctru-rs/examples/time-rtc.rs @@ -3,11 +3,11 @@ use ctru::prelude::*; fn main() { ctru::use_panic_handler(); - let gfx = Gfx::init().expect("Couldn't obtain GFX controller"); - let mut hid = Hid::init().expect("Couldn't obtain HID controller"); - let apt = Apt::init().expect("Couldn't obtain APT controller"); + let gfx = Gfx::new().expect("Couldn't obtain GFX controller"); + let mut hid = Hid::new().expect("Couldn't obtain HID controller"); + let apt = Apt::new().expect("Couldn't obtain APT controller"); - let _console = Console::init(gfx.top_screen.borrow_mut()); + let _console = Console::new(gfx.top_screen.borrow_mut()); print!("\x1b[30;16HPress Start to exit."); diff --git a/ctru-rs/examples/title-info.rs b/ctru-rs/examples/title-info.rs index a18534e..07ba9f4 100644 --- a/ctru-rs/examples/title-info.rs +++ b/ctru-rs/examples/title-info.rs @@ -5,12 +5,12 @@ use ctru::services::fs::FsMediaType; fn main() { ctru::use_panic_handler(); - let gfx = Gfx::init().expect("Couldn't obtain GFX controller"); - let mut hid = Hid::init().expect("Couldn't obtain HID controller"); - let apt = Apt::init().expect("Couldn't obtain APT controller"); - let am = Am::init().expect("Couldn't obtain AM controller"); - let top_screen = Console::init(gfx.top_screen.borrow_mut()); - let bottom_screen = Console::init(gfx.bottom_screen.borrow_mut()); + let gfx = Gfx::new().expect("Couldn't obtain GFX controller"); + let mut hid = Hid::new().expect("Couldn't obtain HID controller"); + let apt = Apt::new().expect("Couldn't obtain APT controller"); + let am = Am::new().expect("Couldn't obtain AM controller"); + let top_screen = Console::new(gfx.top_screen.borrow_mut()); + let bottom_screen = Console::new(gfx.bottom_screen.borrow_mut()); let sd_count = am .title_count(FsMediaType::Sd) diff --git a/ctru-rs/src/applets/mii_selector.rs b/ctru-rs/src/applets/mii_selector.rs index 8d289ee..69175a2 100644 --- a/ctru-rs/src/applets/mii_selector.rs +++ b/ctru-rs/src/applets/mii_selector.rs @@ -41,7 +41,7 @@ bitflags! { /// ``` /// use ctru::applets::mii_selector::MiiSelector; /// -/// let mut mii_selector = MiiSelector::init(); +/// let mut mii_selector = MiiSelector::new(); /// mii_selector.set_title("Example Mii selector"); /// /// let result = mii_selector.launch().unwrap(); @@ -68,7 +68,7 @@ pub enum MiiLaunchError { impl MiiSelector { /// Initializes a Mii Selector - pub fn init() -> Self { + pub fn new() -> Self { let mut config = Box::::default(); unsafe { ctru_sys::miiSelectorInit(config.as_mut()); diff --git a/ctru-rs/src/applets/swkbd.rs b/ctru-rs/src/applets/swkbd.rs index 0af7dee..178a86e 100644 --- a/ctru-rs/src/applets/swkbd.rs +++ b/ctru-rs/src/applets/swkbd.rs @@ -89,7 +89,7 @@ bitflags! { impl Swkbd { /// Initializes a software keyboard of the specified type and the chosen number of buttons /// (from 1-3). - pub fn init(keyboard_type: Kind, num_buttons: i32) -> Self { + pub fn new(keyboard_type: Kind, num_buttons: i32) -> Self { unsafe { let mut state = Box::::default(); swkbdInit(state.as_mut(), keyboard_type.into(), num_buttons, -1); @@ -207,7 +207,7 @@ impl Swkbd { impl Default for Swkbd { fn default() -> Self { - Swkbd::init(Kind::Normal, 2) + Swkbd::new(Kind::Normal, 2) } } diff --git a/ctru-rs/src/console.rs b/ctru-rs/src/console.rs index c0a8765..73d3952 100644 --- a/ctru-rs/src/console.rs +++ b/ctru-rs/src/console.rs @@ -16,7 +16,7 @@ impl<'screen> Console<'screen> { /// Initialize a console on the chosen screen, overwriting whatever was on the screen /// previously (including other consoles). The new console is automatically selected for /// printing. - pub fn init(screen: RefMut<'screen, dyn Screen>) -> Self { + pub fn new(screen: RefMut<'screen, dyn Screen>) -> Self { let mut context = Box::::default(); unsafe { consoleInit(screen.as_raw(), context.as_mut()) }; diff --git a/ctru-rs/src/lib.rs b/ctru-rs/src/lib.rs index 2073fe3..57b61e9 100644 --- a/ctru-rs/src/lib.rs +++ b/ctru-rs/src/lib.rs @@ -54,7 +54,7 @@ fn panic_hook_setup() { if main_thread == std::thread::current().id() && console::Console::exists() { println!("\nPress SELECT to exit the software"); - match Hid::init() { + match Hid::new() { Ok(mut hid) => loop { hid.scan_input(); let keys = hid.keys_down(); diff --git a/ctru-rs/src/services/am.rs b/ctru-rs/src/services/am.rs index ada179e..6fcee8c 100644 --- a/ctru-rs/src/services/am.rs +++ b/ctru-rs/src/services/am.rs @@ -61,7 +61,7 @@ impl<'a> Title<'a> { pub struct Am(()); impl Am { - pub fn init() -> crate::Result { + pub fn new() -> crate::Result { unsafe { ResultCode(ctru_sys::amInit())?; Ok(Am(())) diff --git a/ctru-rs/src/services/apt.rs b/ctru-rs/src/services/apt.rs index aa1dd28..f7731be 100644 --- a/ctru-rs/src/services/apt.rs +++ b/ctru-rs/src/services/apt.rs @@ -3,7 +3,7 @@ use crate::error::ResultCode; pub struct Apt(()); impl Apt { - pub fn init() -> crate::Result { + pub fn new() -> crate::Result { unsafe { ResultCode(ctru_sys::aptInit())?; Ok(Apt(())) diff --git a/ctru-rs/src/services/cam.rs b/ctru-rs/src/services/cam.rs index 52ce926..261dbd3 100644 --- a/ctru-rs/src/services/cam.rs +++ b/ctru-rs/src/services/cam.rs @@ -770,7 +770,7 @@ impl Cam { /// This function will return an error if the service was unable to be initialized. /// Since this service requires no special or elevated permissions, errors are /// rare in practice. - pub fn init() -> crate::Result { + pub fn new() -> crate::Result { unsafe { ResultCode(ctru_sys::camInit())?; Ok(Cam { diff --git a/ctru-rs/src/services/cfgu.rs b/ctru-rs/src/services/cfgu.rs index 3f268c7..90edf44 100644 --- a/ctru-rs/src/services/cfgu.rs +++ b/ctru-rs/src/services/cfgu.rs @@ -61,7 +61,7 @@ impl Cfgu { /// ctrulib services are reference counted, so this function may be called /// as many times as desired and the service will not exit until all /// instances of Cfgu drop out of scope. - pub fn init() -> crate::Result { + pub fn new() -> crate::Result { ResultCode(unsafe { ctru_sys::cfguInit() })?; Ok(Cfgu(())) } diff --git a/ctru-rs/src/services/fs.rs b/ctru-rs/src/services/fs.rs index 9364bb6..f502afc 100644 --- a/ctru-rs/src/services/fs.rs +++ b/ctru-rs/src/services/fs.rs @@ -103,7 +103,7 @@ pub struct Fs(()); /// ```no_run /// use ctru::services::fs::Fs; /// -/// let fs = Fs::init().unwrap(); +/// let fs = Fs::new().unwrap(); /// let sdmc_archive = fs.sdmc().unwrap(); /// ``` pub struct Archive { @@ -126,7 +126,7 @@ pub struct Archive { /// use std::io::prelude::*; /// use ctru::services::fs::{Fs, File}; /// -/// let fs = Fs::init()?; +/// let fs = Fs::new()?; /// let sdmc = fs.sdmc()?; /// /// let mut file = File::create(&sdmc, "/foo.txt")?; @@ -139,7 +139,7 @@ pub struct Archive { /// use std::io::prelude::*; /// use ctru::services::fs::{Fs, File}; /// -/// let fs = Fs::init()?; +/// let fs = Fs::new()?; /// let sdmc = fs.sdmc()?; /// /// let mut file = File::open(&sdmc, "/foo.txt")?; @@ -156,7 +156,7 @@ pub struct Archive { /// use std::io::prelude::*; /// use ctru::services::fs::{Fs, File}; /// -/// let fs = Fs::init()?; +/// let fs = Fs::new()?; /// let sdmc = fs.sdmc()?; /// /// let file = File::open(&sdmc, "/foo.txt")?; @@ -209,7 +209,7 @@ pub struct Metadata { /// ```no_run /// use ctru::services::fs::{Fs, OpenOptions}; /// -/// let fs = Fs::init().unwrap(); +/// let fs = Fs::new().unwrap(); /// let sdmc_archive = fs.sdmc().unwrap(); /// let file = OpenOptions::new() /// .read(true) @@ -224,7 +224,7 @@ pub struct Metadata { /// ```no_run /// use ctru::services::fs::{Fs, OpenOptions}; /// -/// let fs = Fs::init().unwrap(); +/// let fs = Fs::new().unwrap(); /// let sdmc_archive = fs.sdmc().unwrap(); /// let file = OpenOptions::new() /// .read(true) @@ -298,7 +298,7 @@ impl Fs { /// ctrulib services are reference counted, so this function may be called /// as many times as desired and the service will not exit until all /// instances of Fs drop out of scope. - pub fn init() -> crate::Result { + pub fn new() -> crate::Result { unsafe { let r = ctru_sys::fsInit(); if r < 0 { @@ -351,7 +351,7 @@ impl File { /// ```no_run /// use ctru::services::fs::{Fs, File}; /// - /// let fs = Fs::init().unwrap(); + /// let fs = Fs::new().unwrap(); /// let sdmc_archive = fs.sdmc().unwrap(); /// let mut f = File::open(&sdmc_archive, "/foo.txt").unwrap(); /// ``` @@ -380,7 +380,7 @@ impl File { /// ```no_run /// use ctru::services::fs::{Fs, File}; /// - /// let fs = Fs::init().unwrap(); + /// let fs = Fs::new().unwrap(); /// let sdmc_archive = fs.sdmc().unwrap(); /// let mut f = File::create(&sdmc_archive, "/foo.txt").unwrap(); /// ``` diff --git a/ctru-rs/src/services/gfx.rs b/ctru-rs/src/services/gfx.rs index 40d4740..87be464 100644 --- a/ctru-rs/src/services/gfx.rs +++ b/ctru-rs/src/services/gfx.rs @@ -131,7 +131,7 @@ impl Gfx { /// Initialize the Gfx module with the chosen framebuffer formats for the top and bottom /// screens /// - /// Use `Gfx::init()` instead of this function to initialize the module with default parameters + /// Use `Gfx::new()` instead of this function to initialize the module with default parameters pub fn with_formats( top_fb_fmt: FramebufferFormat, bottom_fb_fmt: FramebufferFormat, @@ -158,7 +158,7 @@ impl Gfx { /// Creates a new [Gfx] instance with default init values /// It's the same as calling: /// `Gfx::with_formats(FramebufferFormat::Bgr8, FramebufferFormat::Bgr8, false)` - pub fn init() -> Result { + pub fn new() -> Result { Gfx::with_formats(FramebufferFormat::Bgr8, FramebufferFormat::Bgr8, false) } @@ -294,6 +294,6 @@ mod tests { #[test] fn gfx_duplicate() { // We don't need to build a `Gfx` because the test runner has one already - assert!(matches!(Gfx::init(), Err(Error::ServiceAlreadyActive))); + assert!(matches!(Gfx::new(), Err(Error::ServiceAlreadyActive))); } } diff --git a/ctru-rs/src/services/hid.rs b/ctru-rs/src/services/hid.rs index 31dd4d9..9577f42 100644 --- a/ctru-rs/src/services/hid.rs +++ b/ctru-rs/src/services/hid.rs @@ -61,7 +61,7 @@ pub struct CirclePosition(ctru_sys::circlePosition); /// Since this service requires no special or elevated permissions, errors are /// rare in practice. impl Hid { - pub fn init() -> crate::Result { + pub fn new() -> crate::Result { unsafe { ResultCode(ctru_sys::hidInit())?; Ok(Hid(())) diff --git a/ctru-rs/src/services/ndsp/mod.rs b/ctru-rs/src/services/ndsp/mod.rs index fa93cf6..3fff3b8 100644 --- a/ctru-rs/src/services/ndsp/mod.rs +++ b/ctru-rs/src/services/ndsp/mod.rs @@ -80,7 +80,7 @@ impl Ndsp { /// /// This function will return an error if an instance of the `Ndsp` struct already exists /// or if there are any issues during initialization. - pub fn init() -> crate::Result { + pub fn new() -> crate::Result { let _service_handler = ServiceReference::new( &NDSP_ACTIVE, false, diff --git a/ctru-rs/src/services/romfs.rs b/ctru-rs/src/services/romfs.rs index fd022e8..49369a6 100644 --- a/ctru-rs/src/services/romfs.rs +++ b/ctru-rs/src/services/romfs.rs @@ -25,7 +25,7 @@ pub struct RomFS { static ROMFS_ACTIVE: Mutex = Mutex::new(0); impl RomFS { - pub fn init() -> crate::Result { + pub fn new() -> crate::Result { let _service_handler = ServiceReference::new( &ROMFS_ACTIVE, true, @@ -50,7 +50,7 @@ mod tests { #[test] fn romfs_counter() { - let _romfs = RomFS::init().unwrap(); + let _romfs = RomFS::new().unwrap(); let value = *ROMFS_ACTIVE.lock().unwrap(); assert_eq!(value, 1); diff --git a/ctru-rs/src/services/soc.rs b/ctru-rs/src/services/soc.rs index c5df066..5b9c696 100644 --- a/ctru-rs/src/services/soc.rs +++ b/ctru-rs/src/services/soc.rs @@ -25,7 +25,7 @@ impl Soc { /// # Errors /// /// This function will return an error if the `Soc` service is already initialized - pub fn init() -> crate::Result { + pub fn new() -> crate::Result { Self::init_with_buffer_size(0x100000) } @@ -107,8 +107,8 @@ mod tests { #[test] fn soc_duplicate() { - let _soc = Soc::init().unwrap(); + let _soc = Soc::new().unwrap(); - assert!(matches!(Soc::init(), Err(Error::ServiceAlreadyActive))) + assert!(matches!(Soc::new(), Err(Error::ServiceAlreadyActive))) } } diff --git a/ctru-rs/src/services/sslc.rs b/ctru-rs/src/services/sslc.rs index 99eb456..405fb9b 100644 --- a/ctru-rs/src/services/sslc.rs +++ b/ctru-rs/src/services/sslc.rs @@ -8,7 +8,7 @@ pub struct SslC(()); impl SslC { /// Initialize the service - pub fn init() -> crate::Result { + pub fn new() -> crate::Result { unsafe { ResultCode(ctru_sys::sslcInit(0))?; Ok(SslC(())) diff --git a/ctru-rs/src/test_runner.rs b/ctru-rs/src/test_runner.rs index 6f157e3..713e0e6 100644 --- a/ctru-rs/src/test_runner.rs +++ b/ctru-rs/src/test_runner.rs @@ -12,13 +12,13 @@ use crate::prelude::*; /// runs all tests in series, "failing" on the first one to panic (really, the /// panic is just treated the same as any normal application panic). pub(crate) fn run(tests: &[&TestDescAndFn]) { - let gfx = Gfx::init().unwrap(); - let mut hid = Hid::init().unwrap(); - let apt = Apt::init().unwrap(); + let gfx = Gfx::new().unwrap(); + let mut hid = Hid::new().unwrap(); + let apt = Apt::new().unwrap(); let mut top_screen = gfx.top_screen.borrow_mut(); top_screen.set_wide_mode(true); - let _console = Console::init(top_screen); + let _console = Console::new(top_screen); let opts = TestOpts { force_run_in_process: true,