Browse Source

Merge branch 'rust3ds:master' into docs/improve-docs-v3

pull/110/head
TechiePi 2 years ago committed by GitHub
parent
commit
57628db81b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      AUTHORS.md
  2. 21
      LICENSE
  3. 33
      README.md
  4. 4
      ctru-rs/Cargo.toml
  5. 4
      ctru-rs/examples/audio-filters.rs
  6. 2
      ctru-rs/examples/buttons.rs
  7. 2
      ctru-rs/examples/camera-image.rs
  8. 8
      ctru-rs/examples/file-explorer.rs
  9. 2
      ctru-rs/examples/futures-basic.rs
  10. 2
      ctru-rs/examples/futures-tokio.rs
  11. 2
      ctru-rs/examples/gfx-3d-mode.rs
  12. 2
      ctru-rs/examples/gfx-wide-mode.rs
  13. 2
      ctru-rs/examples/graphics-bitmap.rs
  14. 2
      ctru-rs/examples/hashmaps.rs
  15. 2
      ctru-rs/examples/hello-both-screens.rs
  16. 2
      ctru-rs/examples/hello-world.rs
  17. 2
      ctru-rs/examples/linear-memory.rs
  18. 2
      ctru-rs/examples/mii-selector.rs
  19. 2
      ctru-rs/examples/network-sockets.rs
  20. 2
      ctru-rs/examples/output-3dslink.rs
  21. 2
      ctru-rs/examples/romfs.rs
  22. 2
      ctru-rs/examples/software-keyboard.rs
  23. 2
      ctru-rs/examples/system-configuration.rs
  24. 2
      ctru-rs/examples/thread-basic.rs
  25. 2
      ctru-rs/examples/thread-info.rs
  26. 2
      ctru-rs/examples/thread-locals.rs
  27. 2
      ctru-rs/examples/time-rtc.rs
  28. 2
      ctru-rs/examples/title-info.rs
  29. 4
      ctru-rs/src/lib.rs
  30. 2
      ctru-rs/src/services/apt.rs
  31. 2
      ctru-rs/src/services/cam.rs
  32. 20
      ctru-rs/src/services/fs.rs
  33. 2
      ctru-rs/src/services/hid.rs
  34. 34
      ctru-rs/src/services/ndsp/mod.rs
  35. 2
      ctru-rs/src/test_runner.rs
  36. 2
      ctru-sys/Cargo.toml

4
AUTHORS.md

@ -1,4 +0,0 @@ @@ -1,4 +0,0 @@
# Authors
* [Eidolon](https://github.com/HybridEidolon)
* [FenrirWolf](https://github.com/FenrirWolf)

21
LICENSE

@ -0,0 +1,21 @@ @@ -0,0 +1,21 @@
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.
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.

33
README.md

@ -24,33 +24,10 @@ This repository is organized as follows: @@ -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).

4
ctru-rs/Cargo.toml

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
[package]
authors = ["Ronald Kinard <furyhunter600@gmail.com>"]
authors = [ "Rust3DS Org", "Ronald Kinard <furyhunter600@gmail.com>" ]
description = "A safe wrapper around smealum's ctrulib."
license = "Zlib"
name = "ctru-rs"
@ -15,7 +15,7 @@ name = "ctru" @@ -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"

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());

4
ctru-rs/src/lib.rs

@ -8,8 +8,8 @@ @@ -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 linker_fix_3ds;
extern crate pthread_3ds;
extern crate shim_3ds;
#[no_mangle]
#[cfg(feature = "big-stack")]
@ -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) {

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

@ -14,7 +14,7 @@ impl Apt { @@ -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(())

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

@ -354,7 +354,7 @@ pub trait Camera { @@ -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,

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

@ -310,7 +310,7 @@ impl Fs { @@ -310,7 +310,7 @@ impl Fs {
}
/// Returns a handle to the SDMC (memory card) Archive.
pub fn sdmc(&self) -> crate::Result<Archive> {
pub fn sdmc(&mut self) -> crate::Result<Archive> {
unsafe {
let mut handle = 0;
let id = ArchiveID::Sdmc;
@ -384,7 +384,7 @@ impl File { @@ -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<P: AsRef<Path>>(arch: &Archive, path: P) -> IoResult<File> {
pub fn create<P: AsRef<Path>>(arch: &mut Archive, path: P) -> IoResult<File> {
OpenOptions::new()
.write(true)
.create(true)
@ -588,11 +588,11 @@ impl OpenOptions { @@ -588,11 +588,11 @@ impl OpenOptions {
/// * Invalid combinations of open options.
///
/// [`Archive`]: struct.Archive.html
pub fn open<P: AsRef<Path>>(&self, path: P) -> IoResult<File> {
pub fn open<P: AsRef<Path>>(&mut self, path: P) -> IoResult<File> {
self._open(path.as_ref(), self.open_flags())
}
fn _open(&self, path: &Path, flags: FsOpen) -> IoResult<File> {
fn _open(&mut self, path: &Path, flags: FsOpen) -> IoResult<File> {
unsafe {
let mut file_handle = 0;
let path = to_utf16(path);
@ -706,7 +706,7 @@ impl<'a> DirEntry<'a> { @@ -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<P: AsRef<Path>>(arch: &Archive, path: P) -> IoResult<()> {
pub fn create_dir<P: AsRef<Path>>(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<P: AsRef<Path>>(arch: &Archive, path: P) -> IoResult<()> { @@ -732,7 +732,7 @@ pub fn create_dir<P: AsRef<Path>>(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<P: AsRef<Path>>(arch: &Archive, path: P) -> IoResult<()> {
pub fn create_dir_all<P: AsRef<Path>>(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<P: AsRef<Path>>(arch: &Archive, path: P) -> IoResult<Metadata> { @@ -768,7 +768,7 @@ pub fn metadata<P: AsRef<Path>>(arch: &Archive, path: P) -> IoResult<Metadata> {
///
/// * The user lacks permissions to remove the directory at the provided path.
/// * The directory isn't empty.
pub fn remove_dir<P: AsRef<Path>>(arch: &Archive, path: P) -> IoResult<()> {
pub fn remove_dir<P: AsRef<Path>>(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<P: AsRef<Path>>(arch: &Archive, path: P) -> IoResult<()> { @@ -786,7 +786,7 @@ pub fn remove_dir<P: AsRef<Path>>(arch: &Archive, path: P) -> IoResult<()> {
/// # Errors
///
/// see `file::remove_file` and `fs::remove_dir`
pub fn remove_dir_all<P: AsRef<Path>>(arch: &Archive, path: P) -> IoResult<()> {
pub fn remove_dir_all<P: AsRef<Path>>(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<P: AsRef<Path>>(arch: &Archive, path: P) -> IoResult<ReadDir> { @@ -838,7 +838,7 @@ pub fn read_dir<P: AsRef<Path>>(arch: &Archive, path: P) -> IoResult<ReadDir> {
///
/// * path points to a directory.
/// * The user lacks permissions to remove the file.
pub fn remove_file<P: AsRef<Path>>(arch: &Archive, path: P) -> IoResult<()> {
pub fn remove_file<P: AsRef<Path>>(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<P: AsRef<Path>>(arch: &Archive, path: P) -> IoResult<()> { @@ -861,7 +861,7 @@ pub fn remove_file<P: AsRef<Path>>(arch: &Archive, path: P) -> IoResult<()> {
///
/// * from does not exist.
/// * The user lacks permissions to view contents.
pub fn rename<P, Q>(arch: &Archive, from: P, to: Q) -> IoResult<()>
pub fn rename<P, Q>(arch: &mut Archive, from: P, to: Q) -> IoResult<()>
where
P: AsRef<Path>,
Q: AsRef<Path>,

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

@ -71,7 +71,7 @@ impl Hid { @@ -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() };
}

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

@ -128,7 +128,7 @@ impl Ndsp { @@ -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<'_> { @@ -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<'_> { @@ -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<'_> { @@ -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<'_> { @@ -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<'_> { @@ -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<'_> { @@ -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<'_> { @@ -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,

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();

2
ctru-sys/Cargo.toml

@ -1,7 +1,7 @@ @@ -1,7 +1,7 @@
[package]
name = "ctru-sys"
version = "21.2.0+2.1.2-1"
authors = ["Ronald Kinard <furyhunter600@gmail.com>"]
authors = [ "Rust3DS Org", "Ronald Kinard <furyhunter600@gmail.com>" ]
license = "Zlib"
links = "ctru"
edition = "2021"

Loading…
Cancel
Save