From 581c62dd493350cf9ed7c33ddad57cba1f2f471f Mon Sep 17 00:00:00 2001 From: Andrea Ciliberti Date: Wed, 5 Apr 2023 13:45:59 +0200 Subject: [PATCH 1/9] Fix licensing issues --- AUTHORS.md | 4 ---- README.md | 33 +++++---------------------------- ctru-rs/Cargo.toml | 2 +- ctru-sys/Cargo.toml | 2 +- 4 files changed, 7 insertions(+), 34 deletions(-) delete mode 100644 AUTHORS.md diff --git a/AUTHORS.md b/AUTHORS.md deleted file mode 100644 index ba0e0f0..0000000 --- a/AUTHORS.md +++ /dev/null @@ -1,4 +0,0 @@ -# Authors - - * [Eidolon](https://github.com/HybridEidolon) - * [FenrirWolf](https://github.com/FenrirWolf) diff --git a/README.md b/README.md index f719b4b..abd23dd 100644 --- a/README.md +++ b/README.md @@ -24,33 +24,10 @@ This repository is organized as follows: (displayed when built with `-vv`) will be issued if the build script detects a mismatch or is unable to check the installed `libctru` version. -## License +## Original version -Copyright (C) Rust 3DS Project authors, 2015-2016 - -See AUTHORS.md. - -As with the original ctrulib, this library is licensed under zlib. This -applies to every file in the tree, unless otherwise noted. - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any - damages arising from the use of this software. - - Permission is granted to anyone to use this software for any - purpose, including commercial applications, and to alter it and - redistribute it freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you - must not claim that you wrote the original software. If you use - this software in a product, an acknowledgment in the product - documentation would be appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and - must not be misrepresented as being the original software. - 3. This notice may not be removed or altered from any source - distribution. - -Rust is primarily distributed under the terms of both the MIT license and the Apache License (Version 2.0), with portions covered by various BSD-like licenses. - -See [LICENSE-APACHE](https://github.com/rust-lang/rust/blob/master/LICENSE-APACHE), [LICENSE-MIT](https://github.com/rust-lang/rust/blob/master/LICENSE-MIT), and [COPYRIGHT](https://github.com/rust-lang/rust/blob/master/COPYRIGHT) for details. +This project is based on the efforts the original authors: + * [Eidolon](https://github.com/HybridEidolon) + * [FenrirWolf](https://github.com/FenrirWolf) +The old version is archived [here](https://github.com/rust3ds/ctru-rs-old). diff --git a/ctru-rs/Cargo.toml b/ctru-rs/Cargo.toml index d5bdff6..c06e4a5 100644 --- a/ctru-rs/Cargo.toml +++ b/ctru-rs/Cargo.toml @@ -1,5 +1,5 @@ [package] -authors = ["Ronald Kinard "] +authors = [ "Rust3DS Team", "Ronald Kinard " ] description = "A safe wrapper around smealum's ctrulib." license = "Zlib" name = "ctru-rs" diff --git a/ctru-sys/Cargo.toml b/ctru-sys/Cargo.toml index f7bf67b..6cbc641 100644 --- a/ctru-sys/Cargo.toml +++ b/ctru-sys/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "ctru-sys" version = "21.2.0+2.1.2-1" -authors = ["Ronald Kinard "] +authors = [ "Rust3DS Team", "Ronald Kinard " ] license = "Zlib" links = "ctru" edition = "2021" From a71e1318490b1421ad0c0206162ee0ebe0764eeb Mon Sep 17 00:00:00 2001 From: Andrea Ciliberti Date: Wed, 5 Apr 2023 13:47:00 +0200 Subject: [PATCH 2/9] Add license file --- LICENSE | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 LICENSE diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..c59f0a0 --- /dev/null +++ b/LICENSE @@ -0,0 +1,19 @@ +As with the original ctrulib, this library is licensed under zlib. This +applies to every file in the tree, unless otherwise noted. + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any + damages arising from the use of this software. + + Permission is granted to anyone to use this software for any + purpose, including commercial applications, and to alter it and + redistribute it freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you + must not claim that you wrote the original software. If you use + this software in a product, an acknowledgment in the product + documentation would be appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and + must not be misrepresented as being the original software. + 3. This notice may not be removed or altered from any source + distribution. \ No newline at end of file From 27d85582741d05c85b0964a635b9442dd2519560 Mon Sep 17 00:00:00 2001 From: Andrea Ciliberti Date: Wed, 5 Apr 2023 13:49:26 +0200 Subject: [PATCH 3/9] Rename org --- ctru-rs/Cargo.toml | 2 +- ctru-sys/Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ctru-rs/Cargo.toml b/ctru-rs/Cargo.toml index c06e4a5..d8b095a 100644 --- a/ctru-rs/Cargo.toml +++ b/ctru-rs/Cargo.toml @@ -1,5 +1,5 @@ [package] -authors = [ "Rust3DS Team", "Ronald Kinard " ] +authors = [ "Rust3DS Org", "Ronald Kinard " ] description = "A safe wrapper around smealum's ctrulib." license = "Zlib" name = "ctru-rs" diff --git a/ctru-sys/Cargo.toml b/ctru-sys/Cargo.toml index 6cbc641..4e062bd 100644 --- a/ctru-sys/Cargo.toml +++ b/ctru-sys/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "ctru-sys" version = "21.2.0+2.1.2-1" -authors = [ "Rust3DS Team", "Ronald Kinard " ] +authors = [ "Rust3DS Org", "Ronald Kinard " ] license = "Zlib" links = "ctru" edition = "2021" From d82ba961520215403d2d465d6cddc005eaf7a2ad Mon Sep 17 00:00:00 2001 From: Meziu <55318903+Meziu@users.noreply.github.com> Date: Wed, 5 Apr 2023 20:28:11 +0200 Subject: [PATCH 4/9] Restore copyright label --- LICENSE | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/LICENSE b/LICENSE index c59f0a0..a53f9d0 100644 --- a/LICENSE +++ b/LICENSE @@ -1,3 +1,5 @@ +Copyright (C) Rust 3DS Project authors, 2015-2016 + As with the original ctrulib, this library is licensed under zlib. This applies to every file in the tree, unless otherwise noted. @@ -16,4 +18,4 @@ applies to every file in the tree, unless otherwise noted. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source - distribution. \ No newline at end of file + distribution. From 5ad6708bb64061a07d08beddceee90e05a0e4219 Mon Sep 17 00:00:00 2001 From: Andrea Ciliberti Date: Wed, 5 Apr 2023 20:35:13 +0200 Subject: [PATCH 5/9] Update for linker-fix-3ds rename --- ctru-rs/Cargo.toml | 2 +- ctru-rs/src/lib.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ctru-rs/Cargo.toml b/ctru-rs/Cargo.toml index d8b095a..a7a160c 100644 --- a/ctru-rs/Cargo.toml +++ b/ctru-rs/Cargo.toml @@ -15,7 +15,7 @@ name = "ctru" cfg-if = "1.0" ctru-sys = { path = "../ctru-sys", version = "21.2" } const-zero = "0.1.0" -linker-fix-3ds = { git = "https://github.com/rust3ds/rust-linker-fix-3ds.git" } +shim-3ds = { git = "https://github.com/rust3ds/shim-3ds.git" } pthread-3ds = { git = "https://github.com/rust3ds/pthread-3ds.git" } libc = "0.2.121" bitflags = "1.0.0" diff --git a/ctru-rs/src/lib.rs b/ctru-rs/src/lib.rs index e733d5a..5ead8b6 100644 --- a/ctru-rs/src/lib.rs +++ b/ctru-rs/src/lib.rs @@ -8,7 +8,7 @@ #![test_runner(test_runner::run)] // Nothing is imported from these crates but their inclusion here assures correct linking of the missing implementations. -extern crate linker_fix_3ds; +extern crate shim_3ds; extern crate pthread_3ds; #[no_mangle] From ca3a2de6a6cdf491dd05264bab6ad88e98821aec Mon Sep 17 00:00:00 2001 From: Andrea Ciliberti Date: Wed, 5 Apr 2023 20:41:31 +0200 Subject: [PATCH 6/9] fmt --- ctru-rs/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ctru-rs/src/lib.rs b/ctru-rs/src/lib.rs index 5ead8b6..1370097 100644 --- a/ctru-rs/src/lib.rs +++ b/ctru-rs/src/lib.rs @@ -8,8 +8,8 @@ #![test_runner(test_runner::run)] // Nothing is imported from these crates but their inclusion here assures correct linking of the missing implementations. -extern crate shim_3ds; extern crate pthread_3ds; +extern crate shim_3ds; #[no_mangle] #[cfg(feature = "big-stack")] From 12f3d8ad40408a3436e578b482d0231656e76d3f Mon Sep 17 00:00:00 2001 From: Andrea Ciliberti Date: Wed, 5 Apr 2023 20:44:15 +0200 Subject: [PATCH 7/9] Ask for mut references in Channel --- ctru-rs/src/services/ndsp/mod.rs | 34 ++++++++++++++++---------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/ctru-rs/src/services/ndsp/mod.rs b/ctru-rs/src/services/ndsp/mod.rs index 1a1c981..fa93cf6 100644 --- a/ctru-rs/src/services/ndsp/mod.rs +++ b/ctru-rs/src/services/ndsp/mod.rs @@ -128,7 +128,7 @@ impl Ndsp { impl Channel<'_> { /// Reset the channel - pub fn reset(&self) { + pub fn reset(&mut self) { unsafe { ctru_sys::ndspChnReset(self.id.into()) }; } @@ -165,28 +165,28 @@ impl Channel<'_> { } /// Pause or un-pause the channel's playback. - pub fn set_paused(&self, state: bool) { + pub fn set_paused(&mut self, state: bool) { unsafe { ctru_sys::ndspChnSetPaused(self.id.into(), state) }; } /// Set the channel's output format. /// Change this setting based on the used sample's format. - pub fn set_format(&self, format: AudioFormat) { + pub fn set_format(&mut self, format: AudioFormat) { unsafe { ctru_sys::ndspChnSetFormat(self.id.into(), format.into()) }; } /// Set the channel's interpolation mode. - pub fn set_interpolation(&self, interp_type: InterpolationType) { + pub fn set_interpolation(&mut self, interp_type: InterpolationType) { unsafe { ctru_sys::ndspChnSetInterp(self.id.into(), interp_type.into()) }; } /// Set the channel's volume mix. - pub fn set_mix(&self, mix: &AudioMix) { + pub fn set_mix(&mut self, mix: &AudioMix) { unsafe { ctru_sys::ndspChnSetMix(self.id.into(), mix.as_raw().as_ptr().cast_mut()) } } /// Set the channel's rate of sampling. - pub fn set_sample_rate(&self, rate: f32) { + pub fn set_sample_rate(&mut self, rate: f32) { unsafe { ctru_sys::ndspChnSetRate(self.id.into(), rate) }; } @@ -195,7 +195,7 @@ impl Channel<'_> { // We suggest using other wave formats when developing homebrew applications. /// Clear the wave buffer queue and stop playback. - pub fn clear_queue(&self) { + pub fn clear_queue(&mut self) { unsafe { ctru_sys::ndspChnWaveBufClear(self.id.into()) }; } @@ -206,7 +206,7 @@ impl Channel<'_> { /// /// `libctru` expects the user to manually keep the info data (in this case [Wave]) alive during playback. /// To ensure safety, checks within [Wave] will clear the whole channel queue if any queued [Wave] is dropped prematurely. - pub fn queue_wave(&self, wave: &mut Wave) -> std::result::Result<(), NdspError> { + pub fn queue_wave(&mut self, wave: &mut Wave) -> std::result::Result<(), NdspError> { match wave.status() { WaveStatus::Playing | WaveStatus::Queued => return Err(NdspError::WaveBusy(self.id)), _ => (), @@ -225,7 +225,7 @@ impl Channel<'_> { /// Refer to [libctru](https://libctru.devkitpro.org/channel_8h.html#a1da3b363c2edfd318c92276b527daae6) for more info. impl Channel<'_> { /// Enables/disables monopole filters. - pub fn iir_mono_set_enabled(&self, enable: bool) { + pub fn iir_mono_set_enabled(&mut self, enable: bool) { unsafe { ctru_sys::ndspChnIirMonoSetEnable(self.id.into(), enable) }; } @@ -234,7 +234,7 @@ impl Channel<'_> { /// # Notes /// /// This is a lower quality filter than the Biquad alternative. - pub fn iir_mono_set_params_high_pass_filter(&self, cut_off_freq: f32) { + pub fn iir_mono_set_params_high_pass_filter(&mut self, cut_off_freq: f32) { unsafe { ctru_sys::ndspChnIirMonoSetParamsHighPassFilter(self.id.into(), cut_off_freq) }; } @@ -243,38 +243,38 @@ impl Channel<'_> { /// # Notes /// /// This is a lower quality filter than the Biquad alternative. - pub fn iir_mono_set_params_low_pass_filter(&self, cut_off_freq: f32) { + pub fn iir_mono_set_params_low_pass_filter(&mut self, cut_off_freq: f32) { unsafe { ctru_sys::ndspChnIirMonoSetParamsLowPassFilter(self.id.into(), cut_off_freq) }; } /// Enables/disables biquad filters. - pub fn iir_biquad_set_enabled(&self, enable: bool) { + pub fn iir_biquad_set_enabled(&mut self, enable: bool) { unsafe { ctru_sys::ndspChnIirBiquadSetEnable(self.id.into(), enable) }; } /// Sets the biquad to be a high pass filter. - pub fn iir_biquad_set_params_high_pass_filter(&self, cut_off_freq: f32, quality: f32) { + pub fn iir_biquad_set_params_high_pass_filter(&mut self, cut_off_freq: f32, quality: f32) { unsafe { ctru_sys::ndspChnIirBiquadSetParamsHighPassFilter(self.id.into(), cut_off_freq, quality) }; } /// Sets the biquad to be a low pass filter. - pub fn iir_biquad_set_params_low_pass_filter(&self, cut_off_freq: f32, quality: f32) { + pub fn iir_biquad_set_params_low_pass_filter(&mut self, cut_off_freq: f32, quality: f32) { unsafe { ctru_sys::ndspChnIirBiquadSetParamsLowPassFilter(self.id.into(), cut_off_freq, quality) }; } /// Sets the biquad to be a notch filter. - pub fn iir_biquad_set_params_notch_filter(&self, notch_freq: f32, quality: f32) { + pub fn iir_biquad_set_params_notch_filter(&mut self, notch_freq: f32, quality: f32) { unsafe { ctru_sys::ndspChnIirBiquadSetParamsNotchFilter(self.id.into(), notch_freq, quality) }; } /// Sets the biquad to be a band pass filter. - pub fn iir_biquad_set_params_band_pass_filter(&self, mid_freq: f32, quality: f32) { + pub fn iir_biquad_set_params_band_pass_filter(&mut self, mid_freq: f32, quality: f32) { unsafe { ctru_sys::ndspChnIirBiquadSetParamsBandPassFilter(self.id.into(), mid_freq, quality) }; @@ -282,7 +282,7 @@ impl Channel<'_> { /// Sets the biquad to be a peaking equalizer. pub fn iir_biquad_set_params_peaking_equalizer( - &self, + &mut self, central_freq: f32, quality: f32, gain: f32, From 1e4002604f37fb850cccb68b3dc3e20cea75585c Mon Sep 17 00:00:00 2001 From: Andrea Ciliberti Date: Wed, 5 Apr 2023 20:58:23 +0200 Subject: [PATCH 8/9] Fixed mutability for all modules --- ctru-rs/src/services/apt.rs | 2 +- ctru-rs/src/services/cam.rs | 2 +- ctru-rs/src/services/fs.rs | 20 ++++++++++---------- ctru-rs/src/services/gfx.rs | 6 +++--- ctru-rs/src/services/hid.rs | 2 +- 5 files changed, 16 insertions(+), 16 deletions(-) diff --git a/ctru-rs/src/services/apt.rs b/ctru-rs/src/services/apt.rs index 2096a70..aa1dd28 100644 --- a/ctru-rs/src/services/apt.rs +++ b/ctru-rs/src/services/apt.rs @@ -14,7 +14,7 @@ impl Apt { unsafe { ctru_sys::aptMainLoop() } } - pub fn set_app_cpu_time_limit(&self, percent: u32) -> crate::Result<()> { + pub fn set_app_cpu_time_limit(&mut self, percent: u32) -> crate::Result<()> { unsafe { ResultCode(ctru_sys::APT_SetAppCpuTimeLimit(percent))?; Ok(()) diff --git a/ctru-rs/src/services/cam.rs b/ctru-rs/src/services/cam.rs index 520e3e2..52ce926 100644 --- a/ctru-rs/src/services/cam.rs +++ b/ctru-rs/src/services/cam.rs @@ -354,7 +354,7 @@ pub trait Camera { /// The new width will be `trim_width / 2` to the left and right of the center. /// The new height will be `trim_height / 2` above and below the center. fn set_trimming_params_center( - &self, + &mut self, trim_width: i16, trim_height: i16, cam_width: i16, diff --git a/ctru-rs/src/services/fs.rs b/ctru-rs/src/services/fs.rs index 45f9efb..9364bb6 100644 --- a/ctru-rs/src/services/fs.rs +++ b/ctru-rs/src/services/fs.rs @@ -310,7 +310,7 @@ impl Fs { } /// Returns a handle to the SDMC (memory card) Archive. - pub fn sdmc(&self) -> crate::Result { + pub fn sdmc(&mut self) -> crate::Result { unsafe { let mut handle = 0; let id = ArchiveID::Sdmc; @@ -384,7 +384,7 @@ impl File { /// let sdmc_archive = fs.sdmc().unwrap(); /// let mut f = File::create(&sdmc_archive, "/foo.txt").unwrap(); /// ``` - pub fn create>(arch: &Archive, path: P) -> IoResult { + pub fn create>(arch: &mut Archive, path: P) -> IoResult { OpenOptions::new() .write(true) .create(true) @@ -588,11 +588,11 @@ impl OpenOptions { /// * Invalid combinations of open options. /// /// [`Archive`]: struct.Archive.html - pub fn open>(&self, path: P) -> IoResult { + pub fn open>(&mut self, path: P) -> IoResult { self._open(path.as_ref(), self.open_flags()) } - fn _open(&self, path: &Path, flags: FsOpen) -> IoResult { + fn _open(&mut self, path: &Path, flags: FsOpen) -> IoResult { unsafe { let mut file_handle = 0; let path = to_utf16(path); @@ -706,7 +706,7 @@ impl<'a> DirEntry<'a> { /// but is not limited to just these cases: /// /// * User lacks permissions to create directory at `path` -pub fn create_dir>(arch: &Archive, path: P) -> IoResult<()> { +pub fn create_dir>(arch: &mut Archive, path: P) -> IoResult<()> { unsafe { let path = to_utf16(path.as_ref()); let fs_path = ctru_sys::fsMakePath(PathType::UTF16.into(), path.as_ptr() as _); @@ -732,7 +732,7 @@ pub fn create_dir>(arch: &Archive, path: P) -> IoResult<()> { /// /// * If any directory in the path specified by `path` does not already exist /// and it could not be created otherwise. -pub fn create_dir_all>(arch: &Archive, path: P) -> IoResult<()> { +pub fn create_dir_all>(arch: &mut Archive, path: P) -> IoResult<()> { let path = path.as_ref(); let mut dir = PathBuf::new(); let mut result = Ok(()); @@ -768,7 +768,7 @@ pub fn metadata>(arch: &Archive, path: P) -> IoResult { /// /// * The user lacks permissions to remove the directory at the provided path. /// * The directory isn't empty. -pub fn remove_dir>(arch: &Archive, path: P) -> IoResult<()> { +pub fn remove_dir>(arch: &mut Archive, path: P) -> IoResult<()> { unsafe { let path = to_utf16(path.as_ref()); let fs_path = ctru_sys::fsMakePath(PathType::UTF16.into(), path.as_ptr() as _); @@ -786,7 +786,7 @@ pub fn remove_dir>(arch: &Archive, path: P) -> IoResult<()> { /// # Errors /// /// see `file::remove_file` and `fs::remove_dir` -pub fn remove_dir_all>(arch: &Archive, path: P) -> IoResult<()> { +pub fn remove_dir_all>(arch: &mut Archive, path: P) -> IoResult<()> { unsafe { let path = to_utf16(path.as_ref()); let fs_path = ctru_sys::fsMakePath(PathType::UTF16.into(), path.as_ptr() as _); @@ -838,7 +838,7 @@ pub fn read_dir>(arch: &Archive, path: P) -> IoResult { /// /// * path points to a directory. /// * The user lacks permissions to remove the file. -pub fn remove_file>(arch: &Archive, path: P) -> IoResult<()> { +pub fn remove_file>(arch: &mut Archive, path: P) -> IoResult<()> { unsafe { let path = to_utf16(path.as_ref()); let fs_path = ctru_sys::fsMakePath(PathType::UTF16.into(), path.as_ptr() as _); @@ -861,7 +861,7 @@ pub fn remove_file>(arch: &Archive, path: P) -> IoResult<()> { /// /// * from does not exist. /// * The user lacks permissions to view contents. -pub fn rename(arch: &Archive, from: P, to: Q) -> IoResult<()> +pub fn rename(arch: &mut Archive, from: P, to: Q) -> IoResult<()> where P: AsRef, Q: AsRef, diff --git a/ctru-rs/src/services/gfx.rs b/ctru-rs/src/services/gfx.rs index 40d4740..5b71978 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(&self) { + pub fn flush_buffers(&mut 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(&self) { + pub fn swap_buffers(&mut 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(&self) { + pub fn swap_buffers_gpu(&mut self) { unsafe { ctru_sys::gfxSwapBuffersGpu() }; } diff --git a/ctru-rs/src/services/hid.rs b/ctru-rs/src/services/hid.rs index 26b034f..31dd4d9 100644 --- a/ctru-rs/src/services/hid.rs +++ b/ctru-rs/src/services/hid.rs @@ -71,7 +71,7 @@ impl Hid { /// Scans the HID service for all user input occurring on the current /// frame. This function should be called on every frame when polling /// for user input. - pub fn scan_input(&self) { + pub fn scan_input(&mut self) { unsafe { ctru_sys::hidScanInput() }; } From 8e3017b725bfef1afa89fbd3aedc77f44bbd094f Mon Sep 17 00:00:00 2001 From: Andrea Ciliberti Date: Wed, 5 Apr 2023 21:05:45 +0200 Subject: [PATCH 9/9] 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();