From 8e3017b725bfef1afa89fbd3aedc77f44bbd094f Mon Sep 17 00:00:00 2001 From: Andrea Ciliberti Date: Wed, 5 Apr 2023 21:05:45 +0200 Subject: [PATCH] Fix examples --- ctru-rs/examples/audio-filters.rs | 4 ++-- ctru-rs/examples/buttons.rs | 2 +- ctru-rs/examples/camera-image.rs | 2 +- ctru-rs/examples/file-explorer.rs | 8 ++++---- ctru-rs/examples/futures-basic.rs | 2 +- ctru-rs/examples/futures-tokio.rs | 2 +- ctru-rs/examples/gfx-3d-mode.rs | 2 +- ctru-rs/examples/gfx-wide-mode.rs | 2 +- ctru-rs/examples/graphics-bitmap.rs | 2 +- ctru-rs/examples/hashmaps.rs | 2 +- ctru-rs/examples/hello-both-screens.rs | 2 +- ctru-rs/examples/hello-world.rs | 2 +- ctru-rs/examples/linear-memory.rs | 2 +- ctru-rs/examples/mii-selector.rs | 2 +- ctru-rs/examples/network-sockets.rs | 2 +- ctru-rs/examples/output-3dslink.rs | 2 +- ctru-rs/examples/romfs.rs | 2 +- ctru-rs/examples/software-keyboard.rs | 2 +- ctru-rs/examples/system-configuration.rs | 2 +- ctru-rs/examples/thread-basic.rs | 2 +- ctru-rs/examples/thread-info.rs | 2 +- ctru-rs/examples/thread-locals.rs | 2 +- ctru-rs/examples/time-rtc.rs | 2 +- ctru-rs/examples/title-info.rs | 2 +- ctru-rs/src/lib.rs | 2 +- ctru-rs/src/services/gfx.rs | 6 +++--- ctru-rs/src/test_runner.rs | 2 +- 27 files changed, 33 insertions(+), 33 deletions(-) diff --git a/ctru-rs/examples/audio-filters.rs b/ctru-rs/examples/audio-filters.rs index 3dd0e34..327ede4 100644 --- a/ctru-rs/examples/audio-filters.rs +++ b/ctru-rs/examples/audio-filters.rs @@ -38,7 +38,7 @@ fn main() { ctru::use_panic_handler(); let gfx = Gfx::init().expect("Couldn't obtain GFX controller"); - let hid = Hid::init().expect("Couldn't obtain HID 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()); @@ -73,7 +73,7 @@ fn main() { // This line isn't needed since the default NDSP configuration already sets the output mode to `Stereo` ndsp.set_output_mode(OutputMode::Stereo); - let channel_zero = ndsp.channel(0).unwrap(); + let mut channel_zero = ndsp.channel(0).unwrap(); channel_zero.set_interpolation(InterpolationType::Linear); channel_zero.set_sample_rate(SAMPLE_RATE as f32); channel_zero.set_format(AudioFormat::PCM16Stereo); diff --git a/ctru-rs/examples/buttons.rs b/ctru-rs/examples/buttons.rs index 1cc5355..39f24d9 100644 --- a/ctru-rs/examples/buttons.rs +++ b/ctru-rs/examples/buttons.rs @@ -4,7 +4,7 @@ fn main() { ctru::use_panic_handler(); let apt = Apt::init().unwrap(); - let hid = Hid::init().unwrap(); + let mut hid = Hid::init().unwrap(); let gfx = Gfx::init().unwrap(); let console = Console::init(gfx.top_screen.borrow_mut()); diff --git a/ctru-rs/examples/camera-image.rs b/ctru-rs/examples/camera-image.rs index 4303c2c..46a96d4 100644 --- a/ctru-rs/examples/camera-image.rs +++ b/ctru-rs/examples/camera-image.rs @@ -17,7 +17,7 @@ fn main() { ctru::use_panic_handler(); let apt = Apt::init().expect("Failed to initialize Apt service."); - let hid = Hid::init().expect("Failed to initialize Hid service."); + let mut hid = Hid::init().expect("Failed to initialize Hid service."); let gfx = Gfx::init().expect("Failed to initialize GFX service."); gfx.top_screen.borrow_mut().set_double_buffering(true); diff --git a/ctru-rs/examples/file-explorer.rs b/ctru-rs/examples/file-explorer.rs index 527595c..5b256c9 100644 --- a/ctru-rs/examples/file-explorer.rs +++ b/ctru-rs/examples/file-explorer.rs @@ -12,18 +12,18 @@ fn main() { ctru::use_panic_handler(); let apt = Apt::init().unwrap(); - let hid = Hid::init().unwrap(); + let mut hid = Hid::init().unwrap(); let gfx = Gfx::init().unwrap(); #[cfg(all(feature = "romfs", romfs_exists))] let _romfs = ctru::services::romfs::RomFS::init().unwrap(); - FileExplorer::init(&apt, &hid, &gfx).run(); + FileExplorer::init(&apt, &mut hid, &gfx).run(); } struct FileExplorer<'a> { apt: &'a Apt, - hid: &'a Hid, + hid: &'a mut Hid, gfx: &'a Gfx, console: Console<'a>, path: PathBuf, @@ -32,7 +32,7 @@ struct FileExplorer<'a> { } impl<'a> FileExplorer<'a> { - fn init(apt: &'a Apt, hid: &'a Hid, gfx: &'a Gfx) -> Self { + fn init(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); diff --git a/ctru-rs/examples/futures-basic.rs b/ctru-rs/examples/futures-basic.rs index bfcf053..ee2e3be 100644 --- a/ctru-rs/examples/futures-basic.rs +++ b/ctru-rs/examples/futures-basic.rs @@ -16,7 +16,7 @@ fn main() { ctru::use_panic_handler(); let gfx = Gfx::init().expect("Couldn't obtain GFX controller"); - let hid = Hid::init().expect("Couldn't obtain HID 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()); diff --git a/ctru-rs/examples/futures-tokio.rs b/ctru-rs/examples/futures-tokio.rs index 48edc14..cbb446d 100644 --- a/ctru-rs/examples/futures-tokio.rs +++ b/ctru-rs/examples/futures-tokio.rs @@ -9,7 +9,7 @@ fn main() { ctru::use_panic_handler(); let gfx = Gfx::init().expect("Couldn't obtain GFX controller"); - let hid = Hid::init().expect("Couldn't obtain HID 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()); diff --git a/ctru-rs/examples/gfx-3d-mode.rs b/ctru-rs/examples/gfx-3d-mode.rs index ca47c09..13b4d3c 100644 --- a/ctru-rs/examples/gfx-3d-mode.rs +++ b/ctru-rs/examples/gfx-3d-mode.rs @@ -13,7 +13,7 @@ fn main() { ctru::use_panic_handler(); let gfx = Gfx::init().expect("Couldn't obtain GFX controller"); - let hid = Hid::init().expect("Couldn't obtain HID 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()); diff --git a/ctru-rs/examples/gfx-wide-mode.rs b/ctru-rs/examples/gfx-wide-mode.rs index 80f73b1..f781c89 100644 --- a/ctru-rs/examples/gfx-wide-mode.rs +++ b/ctru-rs/examples/gfx-wide-mode.rs @@ -4,7 +4,7 @@ fn main() { ctru::use_panic_handler(); let apt = Apt::init().unwrap(); - let hid = Hid::init().unwrap(); + let mut hid = Hid::init().unwrap(); let gfx = Gfx::init().unwrap(); let mut console = Console::init(gfx.top_screen.borrow_mut()); diff --git a/ctru-rs/examples/graphics-bitmap.rs b/ctru-rs/examples/graphics-bitmap.rs index 6ed90e1..ebbf53e 100644 --- a/ctru-rs/examples/graphics-bitmap.rs +++ b/ctru-rs/examples/graphics-bitmap.rs @@ -18,7 +18,7 @@ fn main() { ctru::use_panic_handler(); let gfx = Gfx::init().expect("Couldn't obtain GFX controller"); - let hid = Hid::init().expect("Couldn't obtain HID 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()); diff --git a/ctru-rs/examples/hashmaps.rs b/ctru-rs/examples/hashmaps.rs index e6b9619..87ad8be 100644 --- a/ctru-rs/examples/hashmaps.rs +++ b/ctru-rs/examples/hashmaps.rs @@ -9,7 +9,7 @@ fn main() { // This generator is only active when activating the `PS` service. // This service is automatically initialized. let apt = Apt::init().unwrap(); - let hid = Hid::init().unwrap(); + let mut hid = Hid::init().unwrap(); let gfx = Gfx::init().unwrap(); let _console = Console::init(gfx.top_screen.borrow_mut()); diff --git a/ctru-rs/examples/hello-both-screens.rs b/ctru-rs/examples/hello-both-screens.rs index 601027f..7395967 100644 --- a/ctru-rs/examples/hello-both-screens.rs +++ b/ctru-rs/examples/hello-both-screens.rs @@ -4,7 +4,7 @@ fn main() { ctru::use_panic_handler(); let apt = Apt::init().unwrap(); - let hid = Hid::init().unwrap(); + let mut hid = Hid::init().unwrap(); let gfx = Gfx::init().unwrap(); // Start a console on the top screen diff --git a/ctru-rs/examples/hello-world.rs b/ctru-rs/examples/hello-world.rs index d61a7bc..697ec7c 100644 --- a/ctru-rs/examples/hello-world.rs +++ b/ctru-rs/examples/hello-world.rs @@ -6,7 +6,7 @@ fn main() { ctru::use_panic_handler(); let gfx = Gfx::init().expect("Couldn't obtain GFX controller"); - let hid = Hid::init().expect("Couldn't obtain HID 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()); diff --git a/ctru-rs/examples/linear-memory.rs b/ctru-rs/examples/linear-memory.rs index a44a35f..b3afced 100644 --- a/ctru-rs/examples/linear-memory.rs +++ b/ctru-rs/examples/linear-memory.rs @@ -7,7 +7,7 @@ fn main() { ctru::use_panic_handler(); let gfx = Gfx::init().expect("Couldn't obtain GFX controller"); - let hid = Hid::init().expect("Couldn't obtain HID 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()); diff --git a/ctru-rs/examples/mii-selector.rs b/ctru-rs/examples/mii-selector.rs index 7488c0c..ef7d7d3 100644 --- a/ctru-rs/examples/mii-selector.rs +++ b/ctru-rs/examples/mii-selector.rs @@ -5,7 +5,7 @@ fn main() { ctru::use_panic_handler(); let gfx = Gfx::init().expect("Couldn't obtain GFX controller"); - let hid = Hid::init().expect("Couldn't obtain HID 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()); diff --git a/ctru-rs/examples/network-sockets.rs b/ctru-rs/examples/network-sockets.rs index db750bc..ca2d163 100644 --- a/ctru-rs/examples/network-sockets.rs +++ b/ctru-rs/examples/network-sockets.rs @@ -9,7 +9,7 @@ fn main() { let gfx = Gfx::init().unwrap(); let _console = Console::init(gfx.top_screen.borrow_mut()); - let hid = Hid::init().unwrap(); + let mut hid = Hid::init().unwrap(); let apt = Apt::init().unwrap(); println!("\nlibctru sockets demo\n"); diff --git a/ctru-rs/examples/output-3dslink.rs b/ctru-rs/examples/output-3dslink.rs index 61731d2..1fe0c6a 100644 --- a/ctru-rs/examples/output-3dslink.rs +++ b/ctru-rs/examples/output-3dslink.rs @@ -14,7 +14,7 @@ fn main() { ctru::use_panic_handler(); let gfx = Gfx::init().expect("Couldn't obtain GFX controller"); - let hid = Hid::init().expect("Couldn't obtain HID controller"); + let mut hid = Hid::init().expect("Couldn't obtain HID controller"); let apt = Apt::init().expect("Couldn't obtain APT controller"); let mut soc = Soc::init().expect("Couldn't obtain SOC controller"); diff --git a/ctru-rs/examples/romfs.rs b/ctru-rs/examples/romfs.rs index f52fff3..c729c32 100644 --- a/ctru-rs/examples/romfs.rs +++ b/ctru-rs/examples/romfs.rs @@ -4,7 +4,7 @@ fn main() { ctru::use_panic_handler(); let gfx = Gfx::init().expect("Couldn't obtain GFX controller"); - let hid = Hid::init().expect("Couldn't obtain HID 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()); diff --git a/ctru-rs/examples/software-keyboard.rs b/ctru-rs/examples/software-keyboard.rs index 5f65be4..954fdd0 100644 --- a/ctru-rs/examples/software-keyboard.rs +++ b/ctru-rs/examples/software-keyboard.rs @@ -5,7 +5,7 @@ fn main() { ctru::use_panic_handler(); let apt = Apt::init().unwrap(); - let hid = Hid::init().unwrap(); + let mut hid = Hid::init().unwrap(); let gfx = Gfx::init().unwrap(); let _console = Console::init(gfx.top_screen.borrow_mut()); diff --git a/ctru-rs/examples/system-configuration.rs b/ctru-rs/examples/system-configuration.rs index 49787ee..cd81a02 100644 --- a/ctru-rs/examples/system-configuration.rs +++ b/ctru-rs/examples/system-configuration.rs @@ -5,7 +5,7 @@ fn main() { ctru::use_panic_handler(); let gfx = Gfx::init().expect("Couldn't obtain GFX controller"); - let hid = Hid::init().expect("Couldn't obtain HID 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()); diff --git a/ctru-rs/examples/thread-basic.rs b/ctru-rs/examples/thread-basic.rs index a6c3a6b..73be659 100644 --- a/ctru-rs/examples/thread-basic.rs +++ b/ctru-rs/examples/thread-basic.rs @@ -9,7 +9,7 @@ fn main() { ctru::use_panic_handler(); let apt = Apt::init().unwrap(); - let hid = Hid::init().unwrap(); + let mut hid = Hid::init().unwrap(); let gfx = Gfx::init().unwrap(); let _console = Console::init(gfx.top_screen.borrow_mut()); diff --git a/ctru-rs/examples/thread-info.rs b/ctru-rs/examples/thread-info.rs index 06e2864..968e858 100644 --- a/ctru-rs/examples/thread-info.rs +++ b/ctru-rs/examples/thread-info.rs @@ -10,7 +10,7 @@ fn main() { ctru::use_panic_handler(); let gfx = Gfx::init().expect("Couldn't obtain GFX controller"); - let hid = Hid::init().expect("Couldn't obtain HID 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()); diff --git a/ctru-rs/examples/thread-locals.rs b/ctru-rs/examples/thread-locals.rs index 70f2aaa..09e2082 100644 --- a/ctru-rs/examples/thread-locals.rs +++ b/ctru-rs/examples/thread-locals.rs @@ -14,7 +14,7 @@ fn main() { let gfx = Gfx::init().expect("Couldn't obtain GFX controller"); gfx.top_screen.borrow_mut().set_wide_mode(true); - let hid = Hid::init().expect("Couldn't obtain HID 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()); diff --git a/ctru-rs/examples/time-rtc.rs b/ctru-rs/examples/time-rtc.rs index a229105..86db923 100644 --- a/ctru-rs/examples/time-rtc.rs +++ b/ctru-rs/examples/time-rtc.rs @@ -4,7 +4,7 @@ fn main() { ctru::use_panic_handler(); let gfx = Gfx::init().expect("Couldn't obtain GFX controller"); - let hid = Hid::init().expect("Couldn't obtain HID 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()); diff --git a/ctru-rs/examples/title-info.rs b/ctru-rs/examples/title-info.rs index c904e96..a18534e 100644 --- a/ctru-rs/examples/title-info.rs +++ b/ctru-rs/examples/title-info.rs @@ -6,7 +6,7 @@ fn main() { ctru::use_panic_handler(); let gfx = Gfx::init().expect("Couldn't obtain GFX controller"); - let hid = Hid::init().expect("Couldn't obtain HID 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()); diff --git a/ctru-rs/src/lib.rs b/ctru-rs/src/lib.rs index e733d5a..2073fe3 100644 --- a/ctru-rs/src/lib.rs +++ b/ctru-rs/src/lib.rs @@ -55,7 +55,7 @@ fn panic_hook_setup() { println!("\nPress SELECT to exit the software"); match Hid::init() { - Ok(hid) => loop { + Ok(mut hid) => loop { hid.scan_input(); let keys = hid.keys_down(); if keys.contains(KeyPad::SELECT) { diff --git a/ctru-rs/src/services/gfx.rs b/ctru-rs/src/services/gfx.rs index 5b71978..40d4740 100644 --- a/ctru-rs/src/services/gfx.rs +++ b/ctru-rs/src/services/gfx.rs @@ -163,21 +163,21 @@ impl Gfx { } /// Flushes the current framebuffers - pub fn flush_buffers(&mut self) { + pub fn flush_buffers(&self) { unsafe { ctru_sys::gfxFlushBuffers() }; } /// Swaps the framebuffers and sets the gsp state /// /// Use this function when working with software rendering - pub fn swap_buffers(&mut self) { + pub fn swap_buffers(&self) { unsafe { ctru_sys::gfxSwapBuffers() }; } /// Swaps the framebuffers without manipulating the gsp state /// /// Use this function when working with GPU rendering - pub fn swap_buffers_gpu(&mut self) { + pub fn swap_buffers_gpu(&self) { unsafe { ctru_sys::gfxSwapBuffersGpu() }; } diff --git a/ctru-rs/src/test_runner.rs b/ctru-rs/src/test_runner.rs index 1f0698f..6f157e3 100644 --- a/ctru-rs/src/test_runner.rs +++ b/ctru-rs/src/test_runner.rs @@ -13,7 +13,7 @@ use crate::prelude::*; /// panic is just treated the same as any normal application panic). pub(crate) fn run(tests: &[&TestDescAndFn]) { let gfx = Gfx::init().unwrap(); - let hid = Hid::init().unwrap(); + let mut hid = Hid::init().unwrap(); let apt = Apt::init().unwrap(); let mut top_screen = gfx.top_screen.borrow_mut();