From 414b760bd7181adb820acff108882746c56a2c52 Mon Sep 17 00:00:00 2001 From: Andrea Ciliberti Date: Sat, 5 Aug 2023 18:52:06 +0200 Subject: [PATCH] Easy fixes to review suggestions --- ctru-rs/Cargo.toml | 3 ++- ctru-rs/examples/gfx-3d-mode.rs | 11 +++++++---- ctru-rs/src/applets/swkbd.rs | 2 +- ctru-rs/src/console.rs | 16 +++++++++------- ctru-rs/src/error.rs | 6 +++--- ctru-rs/src/services/hid.rs | 10 +++++----- ctru-rs/src/services/romfs.rs | 5 ----- ctru-sys/Cargo.toml | 3 ++- 8 files changed, 29 insertions(+), 27 deletions(-) diff --git a/ctru-rs/Cargo.toml b/ctru-rs/Cargo.toml index 027a3cb..0523b27 100644 --- a/ctru-rs/Cargo.toml +++ b/ctru-rs/Cargo.toml @@ -5,7 +5,7 @@ authors = ["Rust3DS Org", "Ronald Kinard "] description = "A safe wrapper around libctru" repository = "https://github.com/rust3ds/ctru-rs" keywords = ["3ds", "libctru"] -categories = ["os", "api-bindings"] +categories = ["os", "api-bindings", "hardware-support"] exclude = ["examples"] license = "Zlib" edition = "2021" @@ -51,6 +51,7 @@ romfs_dir = "examples/romfs" [package.metadata.docs.rs] default-target = "armv6k-nintendo-3ds" +targets = [] cargo-args = ["-Z", "build-std"] [[example]] diff --git a/ctru-rs/examples/gfx-3d-mode.rs b/ctru-rs/examples/gfx-3d-mode.rs index 6ad75e5..7176085 100644 --- a/ctru-rs/examples/gfx-3d-mode.rs +++ b/ctru-rs/examples/gfx-3d-mode.rs @@ -2,14 +2,17 @@ //! //! This example showcases 3D mode rendering (using the CPU). //! In a normal application, all rendering should be handled via the GPU. +//! +//! See `gfx-bitmap.rs` for details on how the image is generated. +//! +//! # Warning +//! +//! This example uses 3D mode in a rather unnatural way, and should +//! probably not be viewed for too long or at all if you are photosensitive. use ctru::prelude::*; use ctru::services::gfx::{Flush, Screen, Side, Swap, TopScreen3D}; -// See `graphics-bitmap.rs` for details on how the image is generated. -// -// WARNING: this example uses 3D mode in a rather unnatural way, and should -// probably not be viewed for too long or at all if you are photosensitive. const IMAGE: &[u8] = include_bytes!("assets/ferris.rgb"); static ZERO: &[u8] = &[0; IMAGE.len()]; diff --git a/ctru-rs/src/applets/swkbd.rs b/ctru-rs/src/applets/swkbd.rs index f20819b..36413c6 100644 --- a/ctru-rs/src/applets/swkbd.rs +++ b/ctru-rs/src/applets/swkbd.rs @@ -391,7 +391,7 @@ impl SoftwareKeyboard { } /// Configure the maximum number of UTF-16 code units that can be entered into the software - /// keyboard. By default the limit is `0xFDE8` code units. + /// keyboard. By default the limit is `65000` code units. /// /// # Notes /// diff --git a/ctru-rs/src/console.rs b/ctru-rs/src/console.rs index ecbde9f..6768d47 100644 --- a/ctru-rs/src/console.rs +++ b/ctru-rs/src/console.rs @@ -16,18 +16,20 @@ static mut EMPTY_CONSOLE: PrintConsole = unsafe { const_zero::const_zero!(PrintC /// Virtual text console. /// -/// [`Console`] lets the application redirect `stdout` to a simple text displayer on the 3DS screen. -/// This means that any text written to `stdout` (e.g. using `println!` or `dbg!`) will become visible in the area taken by the console. +/// [`Console`] lets the application redirect `stdout` and `stderr` to a simple text displayer on the 3DS screen. +/// This means that any text written to `stdout` and `stderr` (e.g. using `println!`, `eprintln!` or `dbg!`) will become visible in the area taken by the console. /// /// # Notes /// /// The [`Console`] will take full possession of the screen handed to it as long as it stays alive. It also supports some ANSI codes, such as text color and cursor positioning. -/// The [`Console`]'s window will have a size of 40x30 on the bottom screen, 50x30 on the normal top screen and -/// 100x30 on the top screen when wide mode is enabled. +/// The [`Console`]'s window size will be: +/// - 40x30 on the [`BottomScreen`](crate::services::gfx::BottomScreen). +/// - 50x30 on the normal [`TopScreen`](crate::services::gfx::TopScreen). +/// - 100x30 on the [`TopScreen`](crate::services::gfx::TopScreen) when wide mode is enabled. /// /// # Alternatives /// -/// If you'd like to see live `stdout` output while running the application but cannot or do not want to show the text on the 3DS itself, +/// If you'd like to see live standard output while running the application but cannot or do not want to show the text on the 3DS itself, /// you can try using [`Soc::redirect_to_3dslink`](crate::services::soc::Soc::redirect_to_3dslink) while activating the `--server` flag for `3dslink` (also supported by `cargo-3ds`). /// More info in the [`cargo-3ds` docs](https://github.com/rust3ds/cargo-3ds#running-executables). #[doc(alias = "PrintConsole")] @@ -121,11 +123,11 @@ impl<'screen> Console<'screen> { } } - /// Select this console as the current target for `stdout`. + /// Select this console as the current target for standard output. /// /// # Notes /// - /// Any previously selected console will be unhooked and will not show the `stdout` output. + /// Any previously selected console will be unhooked and will not show the `stdout` and `stderr` output. /// /// # Example /// diff --git a/ctru-rs/src/error.rs b/ctru-rs/src/error.rs index becfaef..41b09f8 100644 --- a/ctru-rs/src/error.rs +++ b/ctru-rs/src/error.rs @@ -12,10 +12,10 @@ use ctru_sys::result::{R_DESCRIPTION, R_LEVEL, R_MODULE, R_SUMMARY}; /// Custom type alias for generic [`ctru-rs`](crate) operations. /// -/// This type is compatible with `ctru-sys::Result` codes. +/// This type is compatible with [`ctru_sys::Result`] codes. pub type Result = ::std::result::Result; -/// Validity checker of raw `ctru_sys::Result` codes. +/// Validity checker of raw [`ctru_sys::Result`] codes. /// /// This struct supports the "try" syntax (`?`) to convert to an [`Error::Os`]. /// @@ -80,7 +80,7 @@ impl FromResidual for Result { pub enum Error { /// Raw [`ctru_sys::Result`] codes. Os(ctru_sys::Result), - /// Generic `libc` error codes. + /// Generic [`libc`] errors. Libc(String), /// Requested service is already active and cannot be activated again. ServiceAlreadyActive, diff --git a/ctru-rs/src/services/hid.rs b/ctru-rs/src/services/hid.rs index d972e00..a136a94 100644 --- a/ctru-rs/src/services/hid.rs +++ b/ctru-rs/src/services/hid.rs @@ -58,15 +58,15 @@ bitflags! { /// CirclePad Down. const CPAD_DOWN = ctru_sys::KEY_CPAD_DOWN; - // Convenience catch-all for the D-Pad and the C-Pad + // Convenience catch-all for the D-Pad and the CirclePad - /// Direction Up (either D-Pad or C-Pad). + /// Direction Up (either D-Pad or CirclePad). const UP = KeyPad::DPAD_UP.bits() | KeyPad::CPAD_UP.bits(); - /// Direction Down (either D-Pad or C-Pad). + /// Direction Down (either D-Pad or CirclePad). const DOWN = KeyPad::DPAD_DOWN.bits() | KeyPad::CPAD_DOWN.bits(); - /// Direction Left (either D-Pad or C-Pad). + /// Direction Left (either D-Pad or CirclePad). const LEFT = KeyPad::DPAD_LEFT.bits() | KeyPad::CPAD_LEFT.bits(); - /// Direction Right (either D-Pad or C-Pad). + /// Direction Right (either D-Pad or CirclePad). const RIGHT = KeyPad::DPAD_RIGHT.bits() | KeyPad::CPAD_RIGHT.bits(); } } diff --git a/ctru-rs/src/services/romfs.rs b/ctru-rs/src/services/romfs.rs index ad5429f..7b686fa 100644 --- a/ctru-rs/src/services/romfs.rs +++ b/ctru-rs/src/services/romfs.rs @@ -71,11 +71,6 @@ impl RomFS { } } -impl Drop for RomFS { - #[doc(alias = "romfsUnmount")] - fn drop(&mut self) {} -} - #[cfg(test)] mod tests { use super::*; diff --git a/ctru-sys/Cargo.toml b/ctru-sys/Cargo.toml index c6bb12f..0041d0c 100644 --- a/ctru-sys/Cargo.toml +++ b/ctru-sys/Cargo.toml @@ -5,7 +5,7 @@ authors = [ "Rust3DS Org", "Ronald Kinard " ] description = "Raw bindings to libctru" repository = "https://github.com/rust3ds/ctru-rs" keywords = ["3ds", "libctru"] -categories = ["os", "external-ffi-bindings", "no-std"] +categories = ["os", "external-ffi-bindings", "no-std", "hardware-support"] exclude = ["bindgen.sh", "src/.gitattributes"] license = "Zlib" links = "ctru" @@ -19,4 +19,5 @@ which = "4.4.0" [package.metadata.docs.rs] default-target = "armv6k-nintendo-3ds" +targets = [] cargo-args = ["-Z", "build-std"]