Browse Source

Renamed init functions to new

pull/116/head
Andrea Ciliberti 2 years ago
parent
commit
ff08dd9545
  1. 10
      ctru-rs/examples/audio-filters.rs
  2. 8
      ctru-rs/examples/buttons.rs
  3. 10
      ctru-rs/examples/camera-image.rs
  4. 14
      ctru-rs/examples/file-explorer.rs
  5. 8
      ctru-rs/examples/futures-basic.rs
  6. 8
      ctru-rs/examples/futures-tokio.rs
  7. 8
      ctru-rs/examples/gfx-3d-mode.rs
  8. 10
      ctru-rs/examples/gfx-wide-mode.rs
  9. 8
      ctru-rs/examples/graphics-bitmap.rs
  10. 8
      ctru-rs/examples/hashmaps.rs
  11. 10
      ctru-rs/examples/hello-both-screens.rs
  12. 8
      ctru-rs/examples/hello-world.rs
  13. 8
      ctru-rs/examples/linear-memory.rs
  14. 10
      ctru-rs/examples/mii-selector.rs
  15. 10
      ctru-rs/examples/network-sockets.rs
  16. 8
      ctru-rs/examples/output-3dslink.rs
  17. 10
      ctru-rs/examples/romfs.rs
  18. 10
      ctru-rs/examples/software-keyboard.rs
  19. 10
      ctru-rs/examples/system-configuration.rs
  20. 8
      ctru-rs/examples/thread-basic.rs
  21. 8
      ctru-rs/examples/thread-info.rs
  22. 8
      ctru-rs/examples/thread-locals.rs
  23. 8
      ctru-rs/examples/time-rtc.rs
  24. 12
      ctru-rs/examples/title-info.rs
  25. 4
      ctru-rs/src/applets/mii_selector.rs
  26. 4
      ctru-rs/src/applets/swkbd.rs
  27. 2
      ctru-rs/src/console.rs
  28. 2
      ctru-rs/src/lib.rs
  29. 2
      ctru-rs/src/services/am.rs
  30. 2
      ctru-rs/src/services/apt.rs
  31. 2
      ctru-rs/src/services/cam.rs
  32. 2
      ctru-rs/src/services/cfgu.rs
  33. 34
      ctru-rs/src/services/fs.rs
  34. 6
      ctru-rs/src/services/gfx.rs
  35. 2
      ctru-rs/src/services/hid.rs
  36. 2
      ctru-rs/src/services/ndsp/mod.rs
  37. 4
      ctru-rs/src/services/romfs.rs
  38. 6
      ctru-rs/src/services/soc.rs
  39. 2
      ctru-rs/src/services/sslc.rs
  40. 8
      ctru-rs/src/test_runner.rs

10
ctru-rs/examples/audio-filters.rs

@ -37,10 +37,10 @@ fn fill_buffer(audio_data: &mut [u8], frequency: f32) { @@ -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() { @@ -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);

8
ctru-rs/examples/buttons.rs

@ -3,10 +3,10 @@ use ctru::prelude::*; @@ -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");

10
ctru-rs/examples/camera-image.rs

@ -16,22 +16,22 @@ const WAIT_TIMEOUT: Duration = Duration::from_millis(300); @@ -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;

14
ctru-rs/examples/file-explorer.rs

@ -11,14 +11,14 @@ use std::path::{Path, PathBuf}; @@ -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> { @@ -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,

8
ctru-rs/examples/futures-basic.rs

@ -15,10 +15,10 @@ use std::os::horizon::thread::BuilderExt; @@ -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)

8
ctru-rs/examples/futures-tokio.rs

@ -8,10 +8,10 @@ use std::time::Duration; @@ -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)

8
ctru-rs/examples/gfx-3d-mode.rs

@ -12,10 +12,10 @@ static ZERO: &[u8] = &[0; IMAGE.len()]; @@ -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).");

10
ctru-rs/examples/gfx-wide-mode.rs

@ -3,10 +3,10 @@ use ctru::prelude::*; @@ -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() { @@ -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.");
}

8
ctru-rs/examples/graphics-bitmap.rs

@ -17,10 +17,10 @@ static IMAGE: &[u8] = include_bytes!("assets/ferris.rgb"); @@ -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.");

8
ctru-rs/examples/hashmaps.rs

@ -8,10 +8,10 @@ fn main() { @@ -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);

10
ctru-rs/examples/hello-both-screens.rs

@ -3,16 +3,16 @@ use ctru::prelude::*; @@ -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();

8
ctru-rs/examples/hello-world.rs

@ -5,10 +5,10 @@ use std::io::BufWriter; @@ -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;

8
ctru-rs/examples/linear-memory.rs

@ -6,10 +6,10 @@ use ctru::prelude::*; @@ -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();

10
ctru-rs/examples/mii-selector.rs

@ -4,12 +4,12 @@ use ctru::prelude::*; @@ -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!");

10
ctru-rs/examples/network-sockets.rs

@ -7,14 +7,14 @@ use std::time::Duration; @@ -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();

8
ctru-rs/examples/output-3dslink.rs

@ -13,11 +13,11 @@ use ctru::prelude::*; @@ -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");

10
ctru-rs/examples/romfs.rs

@ -3,17 +3,17 @@ use ctru::prelude::*; @@ -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");

10
ctru-rs/examples/software-keyboard.rs

@ -4,10 +4,10 @@ use ctru::prelude::*; @@ -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() { @@ -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();

10
ctru-rs/examples/system-configuration.rs

@ -4,11 +4,11 @@ use ctru::services::cfgu::Cfgu; @@ -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());

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

@ -8,10 +8,10 @@ use std::time::Duration; @@ -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);

8
ctru-rs/examples/thread-info.rs

@ -9,10 +9,10 @@ use std::os::horizon::thread::BuilderExt; @@ -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)

8
ctru-rs/examples/thread-locals.rs

@ -12,11 +12,11 @@ std::thread_local! { @@ -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)

8
ctru-rs/examples/time-rtc.rs

@ -3,11 +3,11 @@ use ctru::prelude::*; @@ -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.");

12
ctru-rs/examples/title-info.rs

@ -5,12 +5,12 @@ use ctru::services::fs::FsMediaType; @@ -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)

4
ctru-rs/src/applets/mii_selector.rs

@ -41,7 +41,7 @@ bitflags! { @@ -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 { @@ -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::<ctru_sys::MiiSelectorConf>::default();
unsafe {
ctru_sys::miiSelectorInit(config.as_mut());

4
ctru-rs/src/applets/swkbd.rs

@ -89,7 +89,7 @@ bitflags! { @@ -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::<SwkbdState>::default();
swkbdInit(state.as_mut(), keyboard_type.into(), num_buttons, -1);
@ -207,7 +207,7 @@ impl Swkbd { @@ -207,7 +207,7 @@ impl Swkbd {
impl Default for Swkbd {
fn default() -> Self {
Swkbd::init(Kind::Normal, 2)
Swkbd::new(Kind::Normal, 2)
}
}

2
ctru-rs/src/console.rs

@ -16,7 +16,7 @@ impl<'screen> Console<'screen> { @@ -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::<PrintConsole>::default();
unsafe { consoleInit(screen.as_raw(), context.as_mut()) };

2
ctru-rs/src/lib.rs

@ -54,7 +54,7 @@ fn panic_hook_setup() { @@ -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();

2
ctru-rs/src/services/am.rs

@ -61,7 +61,7 @@ impl<'a> Title<'a> { @@ -61,7 +61,7 @@ impl<'a> Title<'a> {
pub struct Am(());
impl Am {
pub fn init() -> crate::Result<Am> {
pub fn new() -> crate::Result<Am> {
unsafe {
ResultCode(ctru_sys::amInit())?;
Ok(Am(()))

2
ctru-rs/src/services/apt.rs

@ -3,7 +3,7 @@ use crate::error::ResultCode; @@ -3,7 +3,7 @@ use crate::error::ResultCode;
pub struct Apt(());
impl Apt {
pub fn init() -> crate::Result<Apt> {
pub fn new() -> crate::Result<Apt> {
unsafe {
ResultCode(ctru_sys::aptInit())?;
Ok(Apt(()))

2
ctru-rs/src/services/cam.rs

@ -770,7 +770,7 @@ impl Cam { @@ -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<Cam> {
pub fn new() -> crate::Result<Cam> {
unsafe {
ResultCode(ctru_sys::camInit())?;
Ok(Cam {

2
ctru-rs/src/services/cfgu.rs

@ -61,7 +61,7 @@ impl Cfgu { @@ -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<Cfgu> {
pub fn new() -> crate::Result<Cfgu> {
ResultCode(unsafe { ctru_sys::cfguInit() })?;
Ok(Cfgu(()))
}

34
ctru-rs/src/services/fs.rs

@ -103,7 +103,7 @@ pub struct Fs(()); @@ -103,7 +103,7 @@ pub struct Fs(());
/// ```no_run
/// use ctru::services::fs::Fs;
///
/// let mut fs = Fs::init().unwrap();
/// let fs = Fs::new().unwrap();
/// let sdmc_archive = fs.sdmc().unwrap();
/// ```
pub struct Archive {
@ -129,8 +129,8 @@ pub struct Archive { @@ -129,8 +129,8 @@ pub struct Archive {
/// use std::io::prelude::*;
/// use ctru::services::fs::{Fs, File};
///
/// let mut fs = Fs::init()?;
/// let mut sdmc = fs.sdmc()?;
/// let fs = Fs::new()?;
/// let sdmc = fs.sdmc()?;
///
/// let mut file = File::create(&mut sdmc, "/foo.txt")?;
/// file.write_all(b"Hello, world!")?;
@ -148,8 +148,8 @@ pub struct Archive { @@ -148,8 +148,8 @@ pub struct Archive {
/// use std::io::prelude::*;
/// use ctru::services::fs::{Fs, File};
///
/// let mut fs = Fs::init()?;
/// let mut sdmc = fs.sdmc()?;
/// let fs = Fs::new()?;
/// let sdmc = fs.sdmc()?;
///
/// let mut file = File::open(&sdmc, "/foo.txt")?;
/// let mut contents = String::new();
@ -171,8 +171,8 @@ pub struct Archive { @@ -171,8 +171,8 @@ pub struct Archive {
/// use std::io::prelude::*;
/// use ctru::services::fs::{Fs, File};
///
/// let mut fs = Fs::init()?;
/// let mut sdmc = fs.sdmc()?;
/// let fs = Fs::new()?;
/// let sdmc = fs.sdmc()?;
///
/// let file = File::open(&sdmc, "/foo.txt")?;
/// let mut buf_reader = BufReader::new(file);
@ -227,8 +227,8 @@ pub struct Metadata { @@ -227,8 +227,8 @@ pub struct Metadata {
/// ```no_run
/// use ctru::services::fs::{Fs, OpenOptions};
///
/// let mut fs = Fs::init().unwrap();
/// let mut sdmc_archive = fs.sdmc().unwrap();
/// let fs = Fs::new().unwrap();
/// let sdmc_archive = fs.sdmc().unwrap();
/// let file = OpenOptions::new()
/// .read(true)
/// .archive(&sdmc_archive)
@ -242,8 +242,8 @@ pub struct Metadata { @@ -242,8 +242,8 @@ pub struct Metadata {
/// ```no_run
/// use ctru::services::fs::{Fs, OpenOptions};
///
/// let mut fs = Fs::init().unwrap();
/// let mut sdmc_archive = fs.sdmc().unwrap();
/// let fs = Fs::new().unwrap();
/// let sdmc_archive = fs.sdmc().unwrap();
/// let file = OpenOptions::new()
/// .read(true)
/// .write(true)
@ -316,7 +316,7 @@ impl Fs { @@ -316,7 +316,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<Fs> {
pub fn new() -> crate::Result<Fs> {
unsafe {
let r = ctru_sys::fsInit();
if r < 0 {
@ -369,8 +369,8 @@ impl File { @@ -369,8 +369,8 @@ impl File {
/// ```no_run
/// use ctru::services::fs::{Fs, File};
///
/// let mut fs = Fs::init().unwrap();
/// let mut sdmc_archive = fs.sdmc().unwrap();
/// let fs = Fs::new().unwrap();
/// let sdmc_archive = fs.sdmc().unwrap();
/// let mut f = File::open(&sdmc_archive, "/foo.txt").unwrap();
/// ```
pub fn open<P: AsRef<Path>>(arch: &Archive, path: P) -> IoResult<File> {
@ -398,9 +398,9 @@ impl File { @@ -398,9 +398,9 @@ impl File {
/// ```no_run
/// use ctru::services::fs::{Fs, File};
///
/// let mut fs = Fs::init().unwrap();
/// let mut sdmc_archive = fs.sdmc().unwrap();
/// let mut f = File::create(&mut sdmc_archive, "/foo.txt").unwrap();
/// let fs = Fs::new().unwrap();
/// let sdmc_archive = fs.sdmc().unwrap();
/// let mut f = File::create(&sdmc_archive, "/foo.txt").unwrap();
/// ```
pub fn create<P: AsRef<Path>>(arch: &mut Archive, path: P) -> IoResult<File> {
OpenOptions::new()

6
ctru-rs/src/services/gfx.rs

@ -131,7 +131,7 @@ impl Gfx { @@ -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 { @@ -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<Self> {
pub fn new() -> Result<Self> {
Gfx::with_formats(FramebufferFormat::Bgr8, FramebufferFormat::Bgr8, false)
}
@ -294,6 +294,6 @@ mod tests { @@ -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)));
}
}

2
ctru-rs/src/services/hid.rs

@ -61,7 +61,7 @@ pub struct CirclePosition(ctru_sys::circlePosition); @@ -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<Hid> {
pub fn new() -> crate::Result<Hid> {
unsafe {
ResultCode(ctru_sys::hidInit())?;
Ok(Hid(()))

2
ctru-rs/src/services/ndsp/mod.rs

@ -80,7 +80,7 @@ impl Ndsp { @@ -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<Self> {
pub fn new() -> crate::Result<Self> {
let _service_handler = ServiceReference::new(
&NDSP_ACTIVE,
false,

4
ctru-rs/src/services/romfs.rs

@ -25,7 +25,7 @@ pub struct RomFS { @@ -25,7 +25,7 @@ pub struct RomFS {
static ROMFS_ACTIVE: Mutex<usize> = Mutex::new(0);
impl RomFS {
pub fn init() -> crate::Result<Self> {
pub fn new() -> crate::Result<Self> {
let _service_handler = ServiceReference::new(
&ROMFS_ACTIVE,
true,
@ -50,7 +50,7 @@ mod tests { @@ -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);

6
ctru-rs/src/services/soc.rs

@ -25,7 +25,7 @@ impl Soc { @@ -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<Self> {
pub fn new() -> crate::Result<Self> {
Self::init_with_buffer_size(0x100000)
}
@ -107,8 +107,8 @@ mod tests { @@ -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)))
}
}

2
ctru-rs/src/services/sslc.rs

@ -8,7 +8,7 @@ pub struct SslC(()); @@ -8,7 +8,7 @@ pub struct SslC(());
impl SslC {
/// Initialize the service
pub fn init() -> crate::Result<Self> {
pub fn new() -> crate::Result<Self> {
unsafe {
ResultCode(ctru_sys::sslcInit(0))?;
Ok(SslC(()))

8
ctru-rs/src/test_runner.rs

@ -12,13 +12,13 @@ use crate::prelude::*; @@ -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,

Loading…
Cancel
Save