Browse Source

Fix examples

pull/115/head
Andrea Ciliberti 2 years ago
parent
commit
8e3017b725
  1. 4
      ctru-rs/examples/audio-filters.rs
  2. 2
      ctru-rs/examples/buttons.rs
  3. 2
      ctru-rs/examples/camera-image.rs
  4. 8
      ctru-rs/examples/file-explorer.rs
  5. 2
      ctru-rs/examples/futures-basic.rs
  6. 2
      ctru-rs/examples/futures-tokio.rs
  7. 2
      ctru-rs/examples/gfx-3d-mode.rs
  8. 2
      ctru-rs/examples/gfx-wide-mode.rs
  9. 2
      ctru-rs/examples/graphics-bitmap.rs
  10. 2
      ctru-rs/examples/hashmaps.rs
  11. 2
      ctru-rs/examples/hello-both-screens.rs
  12. 2
      ctru-rs/examples/hello-world.rs
  13. 2
      ctru-rs/examples/linear-memory.rs
  14. 2
      ctru-rs/examples/mii-selector.rs
  15. 2
      ctru-rs/examples/network-sockets.rs
  16. 2
      ctru-rs/examples/output-3dslink.rs
  17. 2
      ctru-rs/examples/romfs.rs
  18. 2
      ctru-rs/examples/software-keyboard.rs
  19. 2
      ctru-rs/examples/system-configuration.rs
  20. 2
      ctru-rs/examples/thread-basic.rs
  21. 2
      ctru-rs/examples/thread-info.rs
  22. 2
      ctru-rs/examples/thread-locals.rs
  23. 2
      ctru-rs/examples/time-rtc.rs
  24. 2
      ctru-rs/examples/title-info.rs
  25. 2
      ctru-rs/src/lib.rs
  26. 6
      ctru-rs/src/services/gfx.rs
  27. 2
      ctru-rs/src/test_runner.rs

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

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

2
ctru-rs/examples/buttons.rs

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

2
ctru-rs/examples/hashmaps.rs

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

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

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

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

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

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

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

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

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

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

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

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

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

2
ctru-rs/examples/romfs.rs

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

2
ctru-rs/src/lib.rs

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

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

@ -163,21 +163,21 @@ impl Gfx { @@ -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() };
}

2
ctru-rs/src/test_runner.rs

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

Loading…
Cancel
Save