Browse Source

Easy fixes to review suggestions

pull/134/head
Andrea Ciliberti 1 year ago
parent
commit
414b760bd7
  1. 3
      ctru-rs/Cargo.toml
  2. 11
      ctru-rs/examples/gfx-3d-mode.rs
  3. 2
      ctru-rs/src/applets/swkbd.rs
  4. 16
      ctru-rs/src/console.rs
  5. 6
      ctru-rs/src/error.rs
  6. 10
      ctru-rs/src/services/hid.rs
  7. 5
      ctru-rs/src/services/romfs.rs
  8. 3
      ctru-sys/Cargo.toml

3
ctru-rs/Cargo.toml

@ -5,7 +5,7 @@ authors = ["Rust3DS Org", "Ronald Kinard <furyhunter600@gmail.com>"]
description = "A safe wrapper around libctru" description = "A safe wrapper around libctru"
repository = "https://github.com/rust3ds/ctru-rs" repository = "https://github.com/rust3ds/ctru-rs"
keywords = ["3ds", "libctru"] keywords = ["3ds", "libctru"]
categories = ["os", "api-bindings"] categories = ["os", "api-bindings", "hardware-support"]
exclude = ["examples"] exclude = ["examples"]
license = "Zlib" license = "Zlib"
edition = "2021" edition = "2021"
@ -51,6 +51,7 @@ romfs_dir = "examples/romfs"
[package.metadata.docs.rs] [package.metadata.docs.rs]
default-target = "armv6k-nintendo-3ds" default-target = "armv6k-nintendo-3ds"
targets = []
cargo-args = ["-Z", "build-std"] cargo-args = ["-Z", "build-std"]
[[example]] [[example]]

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

@ -2,14 +2,17 @@
//! //!
//! This example showcases 3D mode rendering (using the CPU). //! This example showcases 3D mode rendering (using the CPU).
//! In a normal application, all rendering should be handled via the GPU. //! 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::prelude::*;
use ctru::services::gfx::{Flush, Screen, Side, Swap, TopScreen3D}; 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"); const IMAGE: &[u8] = include_bytes!("assets/ferris.rgb");
static ZERO: &[u8] = &[0; IMAGE.len()]; static ZERO: &[u8] = &[0; IMAGE.len()];

2
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 /// 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 /// # Notes
/// ///

16
ctru-rs/src/console.rs

@ -16,18 +16,20 @@ static mut EMPTY_CONSOLE: PrintConsole = unsafe { const_zero::const_zero!(PrintC
/// Virtual text console. /// Virtual text console.
/// ///
/// [`Console`] lets the application redirect `stdout` to a simple text displayer on the 3DS screen. /// [`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` (e.g. using `println!` or `dbg!`) will become visible in the area taken by the console. /// 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 /// # 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`] 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 /// The [`Console`]'s window size will be:
/// 100x30 on the top screen when wide mode is enabled. /// - 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 /// # 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`). /// 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). /// More info in the [`cargo-3ds` docs](https://github.com/rust3ds/cargo-3ds#running-executables).
#[doc(alias = "PrintConsole")] #[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 /// # 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 /// # Example
/// ///

6
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. /// 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<T> = ::std::result::Result<T, Error>; pub type Result<T> = ::std::result::Result<T, Error>;
/// 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`]. /// This struct supports the "try" syntax (`?`) to convert to an [`Error::Os`].
/// ///
@ -80,7 +80,7 @@ impl<T> FromResidual<Error> for Result<T> {
pub enum Error { pub enum Error {
/// Raw [`ctru_sys::Result`] codes. /// Raw [`ctru_sys::Result`] codes.
Os(ctru_sys::Result), Os(ctru_sys::Result),
/// Generic `libc` error codes. /// Generic [`libc`] errors.
Libc(String), Libc(String),
/// Requested service is already active and cannot be activated again. /// Requested service is already active and cannot be activated again.
ServiceAlreadyActive, ServiceAlreadyActive,

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

@ -58,15 +58,15 @@ bitflags! {
/// CirclePad Down. /// CirclePad Down.
const CPAD_DOWN = ctru_sys::KEY_CPAD_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(); 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(); 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(); 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(); const RIGHT = KeyPad::DPAD_RIGHT.bits() | KeyPad::CPAD_RIGHT.bits();
} }
} }

5
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)] #[cfg(test)]
mod tests { mod tests {
use super::*; use super::*;

3
ctru-sys/Cargo.toml

@ -5,7 +5,7 @@ authors = [ "Rust3DS Org", "Ronald Kinard <furyhunter600@gmail.com>" ]
description = "Raw bindings to libctru" description = "Raw bindings to libctru"
repository = "https://github.com/rust3ds/ctru-rs" repository = "https://github.com/rust3ds/ctru-rs"
keywords = ["3ds", "libctru"] keywords = ["3ds", "libctru"]
categories = ["os", "external-ffi-bindings", "no-std"] categories = ["os", "external-ffi-bindings", "no-std", "hardware-support"]
exclude = ["bindgen.sh", "src/.gitattributes"] exclude = ["bindgen.sh", "src/.gitattributes"]
license = "Zlib" license = "Zlib"
links = "ctru" links = "ctru"
@ -19,4 +19,5 @@ which = "4.4.0"
[package.metadata.docs.rs] [package.metadata.docs.rs]
default-target = "armv6k-nintendo-3ds" default-target = "armv6k-nintendo-3ds"
targets = []
cargo-args = ["-Z", "build-std"] cargo-args = ["-Z", "build-std"]

Loading…
Cancel
Save