Browse Source

Finalize Mii module

pull/134/head
Andrea Ciliberti 1 year ago
parent
commit
acb1d3fbb8
  1. 6
      ctru-rs/src/applets/mii_selector.rs
  2. 4
      ctru-rs/src/linear.rs
  3. 76
      ctru-rs/src/mii.rs
  4. 82
      ctru-rs/src/services/cam.rs

6
ctru-rs/src/applets/mii_selector.rs

@ -1,9 +1,9 @@
//! Mii Selector applet. //! Mii Selector applet.
//! //!
//! This applet opens a window which lets the player/user choose a Mii from the ones present on their console. //! This applet opens a window which lets the player/user choose a Mii from the ones present on their console.
//! The selected Mii is readable as a [`MiiData`](crate::mii::MiiData). //! The selected Mii is readable as a [`Mii`](crate::mii::Mii).
use crate::mii::MiiData; use crate::mii::Mii;
use bitflags::bitflags; use bitflags::bitflags;
use std::{ffi::CString, fmt}; use std::{ffi::CString, fmt};
@ -65,7 +65,7 @@ pub struct MiiSelector {
#[derive(Clone, Debug)] #[derive(Clone, Debug)]
pub struct Selection { pub struct Selection {
/// Data of the selected Mii. /// Data of the selected Mii.
pub mii_data: MiiData, pub mii_data: Mii,
/// Type of the selected Mii. /// Type of the selected Mii.
pub mii_type: MiiType, pub mii_type: MiiType,
} }

4
ctru-rs/src/linear.rs

@ -4,7 +4,7 @@
//! As such, it is used for fast and safe memory sharing between hardware processors (such as the GPU and the DSP). //! As such, it is used for fast and safe memory sharing between hardware processors (such as the GPU and the DSP).
//! //!
//! # Additional Resources //! # Additional Resources
//! //!
//! - <https://github.com/devkitPro/libctru/blob/master/libctru/source/allocator/linear.cpp><br> //! - <https://github.com/devkitPro/libctru/blob/master/libctru/source/allocator/linear.cpp><br>
//! - <https://www.3dbrew.org/wiki/Memory_layout> //! - <https://www.3dbrew.org/wiki/Memory_layout>
@ -17,7 +17,7 @@ use std::ptr::NonNull;
// but the default fallback of the `std` will take care of that for us. // but the default fallback of the `std` will take care of that for us.
/// [`Allocator`](std::alloc::Allocator) struct for LINEAR memory. /// [`Allocator`](std::alloc::Allocator) struct for LINEAR memory.
/// ///
/// To use this struct the main crate must activate the `allocator_api` unstable feature. /// To use this struct the main crate must activate the `allocator_api` unstable feature.
#[derive(Copy, Clone, Default, Debug)] #[derive(Copy, Clone, Default, Debug)]
pub struct LinearAllocator; pub struct LinearAllocator;

76
ctru-rs/src/mii.rs

@ -1,9 +1,10 @@
//! Mii Data //! Mii data.
//! //!
//! This module contains the structs that represent all the data of a Mii. //! This module contains the structs that represent all the data of a Mii.
//! This data is given by the [``MiiSelector``](crate::applets::mii_selector::MiiSelector) //!
//! Have a look at the [`MiiSelector`](crate::applets::mii_selector::MiiSelector) applet to learn how to ask the user for a specific Mii.
/// Represents the region lock of the console. /// Region lock of the Mii.
#[derive(Copy, Clone, Debug, Eq, PartialEq)] #[derive(Copy, Clone, Debug, Eq, PartialEq)]
pub enum RegionLock { pub enum RegionLock {
/// No region-lock. /// No region-lock.
@ -16,7 +17,7 @@ pub enum RegionLock {
Europe, Europe,
} }
/// Represent the charset of the console. /// Charset of the Mii.
#[derive(Copy, Clone, Debug, Eq, PartialEq)] #[derive(Copy, Clone, Debug, Eq, PartialEq)]
pub enum Charset { pub enum Charset {
/// Japan-USA-Europe unified charset. /// Japan-USA-Europe unified charset.
@ -29,9 +30,9 @@ pub enum Charset {
Taiwan, Taiwan,
} }
/// Represents the options of the Mii. /// Generic options of the Mii.
#[derive(Copy, Clone, Debug)] #[derive(Copy, Clone, Debug)]
pub struct MiiDataOptions { pub struct Options {
/// Whether it is allowed to copy the Mii. /// Whether it is allowed to copy the Mii.
pub is_copying_allowed: bool, pub is_copying_allowed: bool,
/// Whether the profanity flag is active. /// Whether the profanity flag is active.
@ -42,7 +43,7 @@ pub struct MiiDataOptions {
pub charset: Charset, pub charset: Charset,
} }
/// Represents the position that the Mii has on the selector. /// Positional Index that the Mii has on the [`MiiSelector`](crate::applets::mii_selector::MiiSelector) window.
#[derive(Copy, Clone, Debug)] #[derive(Copy, Clone, Debug)]
pub struct SelectorPosition { pub struct SelectorPosition {
/// Index of the page where the Mii is found. /// Index of the page where the Mii is found.
@ -51,40 +52,42 @@ pub struct SelectorPosition {
pub slot_index: u8, pub slot_index: u8,
} }
/// Represents the console where the Mii originated from. /// Console model from which the Mii originated.
#[derive(Copy, Clone, Debug, Eq, PartialEq)] #[derive(Copy, Clone, Debug, Eq, PartialEq)]
pub enum OriginConsole { pub enum OriginConsole {
/// Nintendo Wii. /// Nintendo Wii.
Wii, Wii,
/// Nintendo DSi. /// Nintendo DSi.
DSi, DSi,
/// Nintendo 3DS (both New 3DS and Old 3DS). /// Nintendo 3DS.
///
/// This includes all consoles of the 3DS family (3DS, 2DS, and their respective "New" or "XL" variants).
N3DS, N3DS,
/// Nintendo WiiU/Switch. /// Nintendo Wii U/Switch.
WiiUSwitch, WiiUSwitch,
} }
/// Represents the identity of the origin console. /// Identity of the origin console.
#[derive(Copy, Clone, Debug)] #[derive(Copy, Clone, Debug)]
pub struct ConsoleIdentity { pub struct ConsoleIdentity {
/// From which console the Mii originated from. /// From which console the Mii originated from.
pub origin_console: OriginConsole, pub origin_console: OriginConsole,
} }
/// Represents the sex of the Mii. /// Sex of the Mii.
#[derive(Copy, Clone, Debug, Eq, PartialEq)] #[derive(Copy, Clone, Debug, Eq, PartialEq)]
pub enum MiiSex { pub enum Sex {
/// Male sex. /// Male sex.
Male, Male,
/// Female sex. /// Female sex.
Female, Female,
} }
/// Represents the details of the Mii. /// Generic details of the Mii.
#[derive(Copy, Clone, Debug)] #[derive(Copy, Clone, Debug)]
pub struct Details { pub struct Details {
/// Sex of the Mii. /// Sex of the Mii.
pub sex: MiiSex, pub sex: Sex,
/// Birthday month. /// Birthday month.
pub birthday_month: u8, pub birthday_month: u8,
/// Birthday day. /// Birthday day.
@ -97,7 +100,7 @@ pub struct Details {
pub is_sharing_enabled: bool, pub is_sharing_enabled: bool,
} }
/// Represents the face style of the Mii. /// Face style of the Mii.
#[derive(Copy, Clone, Debug)] #[derive(Copy, Clone, Debug)]
pub struct FaceStyle { pub struct FaceStyle {
/// Face shape. /// Face shape.
@ -106,7 +109,7 @@ pub struct FaceStyle {
pub skin_color: u8, pub skin_color: u8,
} }
/// Represents the face details of the Mii. /// Face details of the Mii.
#[derive(Copy, Clone, Debug)] #[derive(Copy, Clone, Debug)]
pub struct FaceDetails { pub struct FaceDetails {
/// Face style. /// Face style.
@ -117,7 +120,7 @@ pub struct FaceDetails {
pub makeup: u8, pub makeup: u8,
} }
/// Represents the hair details of the Mii. /// Hair details of the Mii.
#[derive(Copy, Clone, Debug)] #[derive(Copy, Clone, Debug)]
pub struct HairDetails { pub struct HairDetails {
/// Hair style. /// Hair style.
@ -128,7 +131,7 @@ pub struct HairDetails {
pub is_flipped: bool, pub is_flipped: bool,
} }
/// Represents the eye details of the Mii. /// Eye details of the Mii.
#[derive(Copy, Clone, Debug)] #[derive(Copy, Clone, Debug)]
pub struct EyeDetails { pub struct EyeDetails {
/// Eye style. /// Eye style.
@ -147,7 +150,7 @@ pub struct EyeDetails {
pub y_position: u8, pub y_position: u8,
} }
/// Represents the eyebrow details of the Mii /// Eyebrow details of the Mii.
#[derive(Copy, Clone, Debug)] #[derive(Copy, Clone, Debug)]
pub struct EyebrowDetails { pub struct EyebrowDetails {
/// Eyebrow style. /// Eyebrow style.
@ -166,7 +169,7 @@ pub struct EyebrowDetails {
pub y_position: u8, pub y_position: u8,
} }
/// Represents the details of the nose /// Nose details of the Mii.
#[derive(Copy, Clone, Debug)] #[derive(Copy, Clone, Debug)]
pub struct NoseDetails { pub struct NoseDetails {
/// Nose style. /// Nose style.
@ -177,7 +180,7 @@ pub struct NoseDetails {
pub y_position: u8, pub y_position: u8,
} }
/// Represents the details of the mouth /// Mouth details of the Mii.
#[derive(Copy, Clone, Debug)] #[derive(Copy, Clone, Debug)]
pub struct MouthDetails { pub struct MouthDetails {
/// Mouth style. /// Mouth style.
@ -192,14 +195,14 @@ pub struct MouthDetails {
pub y_position: u8, pub y_position: u8,
} }
/// Represents the details of the mustache /// Mustache details of the Mii.
#[derive(Copy, Clone, Debug)] #[derive(Copy, Clone, Debug)]
pub struct MustacheDetails { pub struct MustacheDetails {
/// Mustache style. /// Mustache style.
pub mustache_style: u8, pub mustache_style: u8,
} }
/// Represents the details of the beard /// Beard details of the Mii.
#[derive(Copy, Clone, Debug)] #[derive(Copy, Clone, Debug)]
pub struct BeardDetails { pub struct BeardDetails {
/// Beard style /// Beard style
@ -212,7 +215,7 @@ pub struct BeardDetails {
pub y_position: u8, pub y_position: u8,
} }
/// Represents the details of the glasses /// Glasses details of the Mii.
#[derive(Copy, Clone, Debug)] #[derive(Copy, Clone, Debug)]
pub struct GlassesDetails { pub struct GlassesDetails {
/// Glasses style. /// Glasses style.
@ -225,7 +228,7 @@ pub struct GlassesDetails {
pub y_position: u8, pub y_position: u8,
} }
/// Represents the details of the mole. /// Mole details of the Mii.
#[derive(Copy, Clone, Debug)] #[derive(Copy, Clone, Debug)]
pub struct MoleDetails { pub struct MoleDetails {
/// Whether the Mii has a mole. /// Whether the Mii has a mole.
@ -238,16 +241,15 @@ pub struct MoleDetails {
pub y_position: u8, pub y_position: u8,
} }
/// Represents all the data of a Mii /// Full Mii data representation.
/// ///
/// Some values are not ordered _like_ the Mii Editor UI. The mapped values can be seen here: /// Some values are not ordered *like* the Mii Editor UI. The mapped values can be seen [here](https://www.3dbrew.org/wiki/Mii#Mapped_Editor_.3C-.3E_Hex_values).
/// <https://www.3dbrew.org/wiki/Mii#Mapped_Editor_.3C-.3E_Hex_values>
/// ///
/// This struct is returned by the [`MiiSelector`](crate::applets::mii_selector::MiiSelector) /// This struct can be retrieved by [`MiiSelector::lauch()`](crate::applets::mii_selector::MiiSelector::launch).
#[derive(Clone, Debug)] #[derive(Clone, Debug)]
pub struct MiiData { pub struct Mii {
/// Mii options. /// Mii options.
pub options: MiiDataOptions, pub options: Options,
/// Position taken by the Mii on the Mii Selector screen. /// Position taken by the Mii on the Mii Selector screen.
pub selector_position: SelectorPosition, pub selector_position: SelectorPosition,
/// Console the Mii was created on. /// Console the Mii was created on.
@ -293,7 +295,7 @@ pub struct MiiData {
pub author_name: String, pub author_name: String,
} }
impl From<ctru_sys::MiiData> for MiiData { impl From<ctru_sys::MiiData> for Mii {
fn from(mii_data: ctru_sys::MiiData) -> Self { fn from(mii_data: ctru_sys::MiiData) -> Self {
let raw_mii_data = mii_data._bindgen_opaque_blob; let raw_mii_data = mii_data._bindgen_opaque_blob;
// Source for the representation and what each thing means: https://www.3dbrew.org/wiki/Mii // Source for the representation and what each thing means: https://www.3dbrew.org/wiki/Mii
@ -358,7 +360,7 @@ impl From<ctru_sys::MiiData> for MiiData {
let name = utf16_byte_pairs_to_string(raw_utf16_name); let name = utf16_byte_pairs_to_string(raw_utf16_name);
let author_name = utf16_byte_pairs_to_string(raw_utf16_author); let author_name = utf16_byte_pairs_to_string(raw_utf16_author);
let options = MiiDataOptions { let options = Options {
is_copying_allowed: raw_options[0], is_copying_allowed: raw_options[0],
is_profanity_flag_enabled: raw_options[1], is_profanity_flag_enabled: raw_options[1],
region_lock: { region_lock: {
@ -398,8 +400,8 @@ impl From<ctru_sys::MiiData> for MiiData {
let details = Details { let details = Details {
sex: { sex: {
match raw_details[0] { match raw_details[0] {
true => MiiSex::Female, true => Sex::Female,
false => MiiSex::Male, false => Sex::Male,
} }
}, },
birthday_month: partial_u8_bits_to_u8(&raw_details[1..=4]), birthday_month: partial_u8_bits_to_u8(&raw_details[1..=4]),
@ -485,7 +487,7 @@ impl From<ctru_sys::MiiData> for MiiData {
y_position: partial_u8_bits_to_u8(&raw_mole_details[10..=14]), y_position: partial_u8_bits_to_u8(&raw_mole_details[10..=14]),
}; };
MiiData { Mii {
options, options,
selector_position, selector_position,
console_identity, console_identity,

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

@ -22,7 +22,7 @@ pub struct Cam {
} }
/// Different kinds of flip modes. /// Different kinds of flip modes.
/// ///
/// See [`Camera::flip_image()`] to learn how to use this. /// See [`Camera::flip_image()`] to learn how to use this.
#[doc(alias = "CAMU_Flip")] #[doc(alias = "CAMU_Flip")]
#[derive(Copy, Clone, Debug, PartialEq, Eq)] #[derive(Copy, Clone, Debug, PartialEq, Eq)]
@ -39,7 +39,7 @@ pub enum FlipMode {
} }
/// Size of the camera view. /// Size of the camera view.
/// ///
/// See [`Camera::set_view_size()`] to learn how to use this. /// See [`Camera::set_view_size()`] to learn how to use this.
#[doc(alias = "CAMU_Size")] #[doc(alias = "CAMU_Size")]
#[derive(Copy, Clone, Debug, PartialEq, Eq)] #[derive(Copy, Clone, Debug, PartialEq, Eq)]
@ -68,7 +68,7 @@ pub enum ViewSize {
} }
/// Framerate settings. /// Framerate settings.
/// ///
/// See [`Camera::set_frame_rate()`] to learn how to use this. /// See [`Camera::set_frame_rate()`] to learn how to use this.
#[doc(alias = "CAMU_FramRate")] #[doc(alias = "CAMU_FramRate")]
#[derive(Copy, Clone, Debug, PartialEq, Eq)] #[derive(Copy, Clone, Debug, PartialEq, Eq)]
@ -103,7 +103,7 @@ pub enum FrameRate {
} }
/// White balance settings. /// White balance settings.
/// ///
/// See [`Camera::set_white_balance()`] and [`Camera::set_white_balance_without_base_up()`] to learn how to use this. /// See [`Camera::set_white_balance()`] and [`Camera::set_white_balance_without_base_up()`] to learn how to use this.
#[doc(alias = "CAMU_WhiteBalance")] #[doc(alias = "CAMU_WhiteBalance")]
#[derive(Copy, Clone, Debug, PartialEq, Eq)] #[derive(Copy, Clone, Debug, PartialEq, Eq)]
@ -124,7 +124,7 @@ pub enum WhiteBalance {
} }
/// Photo mode settings. /// Photo mode settings.
/// ///
/// See [`Camera::set_photo_mode()`] to learn how to use this. /// See [`Camera::set_photo_mode()`] to learn how to use this.
#[doc(alias = "CAMU_PhotoMode")] #[doc(alias = "CAMU_PhotoMode")]
#[derive(Copy, Clone, Debug, PartialEq, Eq)] #[derive(Copy, Clone, Debug, PartialEq, Eq)]
@ -143,7 +143,7 @@ pub enum PhotoMode {
} }
/// Special camera effects. /// Special camera effects.
/// ///
/// See [`Camera::set_effect()`] to learn how to use this. /// See [`Camera::set_effect()`] to learn how to use this.
#[doc(alias = "CAMU_Effect")] #[doc(alias = "CAMU_Effect")]
#[derive(Copy, Clone, Debug, PartialEq, Eq)] #[derive(Copy, Clone, Debug, PartialEq, Eq)]
@ -160,13 +160,13 @@ pub enum Effect {
/// Negative film effect. /// Negative film effect.
Negafilm = ctru_sys::EFFECT_NEGAFILM, Negafilm = ctru_sys::EFFECT_NEGAFILM,
/// Sepia effect. /// Sepia effect.
/// ///
/// The difference between this and [`Sepia`](Effect::Sepia) is unknown. /// The difference between this and [`Sepia`](Effect::Sepia) is unknown.
Sepia01 = ctru_sys::EFFECT_SEPIA01, Sepia01 = ctru_sys::EFFECT_SEPIA01,
} }
/// Contrast settings. /// Contrast settings.
/// ///
/// See [`Camera::set_contrast()`] to learn how to use this. /// See [`Camera::set_contrast()`] to learn how to use this.
#[doc(alias = "CAMU_Contrast")] #[doc(alias = "CAMU_Contrast")]
#[derive(Copy, Clone, Debug, PartialEq, Eq)] #[derive(Copy, Clone, Debug, PartialEq, Eq)]
@ -181,7 +181,7 @@ pub enum Contrast {
} }
/// Lens correction settings. /// Lens correction settings.
/// ///
/// See [`Camera::set_lens_correction()`] to learn how to use this. /// See [`Camera::set_lens_correction()`] to learn how to use this.
#[doc(alias = "CAMU_LensCorrection")] #[doc(alias = "CAMU_LensCorrection")]
#[derive(Copy, Clone, Debug, PartialEq, Eq)] #[derive(Copy, Clone, Debug, PartialEq, Eq)]
@ -196,7 +196,7 @@ pub enum LensCorrection {
} }
/// Image output format. /// Image output format.
/// ///
/// See [`Camera::set_output_format()`] to learn how to use this. /// See [`Camera::set_output_format()`] to learn how to use this.
#[doc(alias = "CAMU_OutputFormat")] #[doc(alias = "CAMU_OutputFormat")]
#[derive(Copy, Clone, Debug, PartialEq, Eq)] #[derive(Copy, Clone, Debug, PartialEq, Eq)]
@ -209,7 +209,7 @@ pub enum OutputFormat {
} }
/// Playable shutter sounds. /// Playable shutter sounds.
/// ///
/// See [`Cam::play_shutter_sound()`] to learn how to use this. /// See [`Cam::play_shutter_sound()`] to learn how to use this.
#[doc(alias = "CAMU_ShutterSoundType")] #[doc(alias = "CAMU_ShutterSoundType")]
#[derive(Copy, Clone, Debug, PartialEq, Eq)] #[derive(Copy, Clone, Debug, PartialEq, Eq)]
@ -224,7 +224,7 @@ pub enum ShutterSound {
} }
/// Parameters to handle image trimming. /// Parameters to handle image trimming.
/// ///
/// See [`Camera::set_trimming_params()`] to learn how to use this. /// See [`Camera::set_trimming_params()`] to learn how to use this.
#[derive(Clone, Copy, Debug, PartialEq, Eq)] #[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub struct TrimmingParams { pub struct TrimmingParams {
@ -237,7 +237,7 @@ pub struct TrimmingParams {
impl TrimmingParams { impl TrimmingParams {
/// Creates a new [`TrimmingParams`] and guarantees the start coordinates are less than or /// Creates a new [`TrimmingParams`] and guarantees the start coordinates are less than or
/// equal to the end coordinates. /// equal to the end coordinates.
/// ///
/// # Panics /// # Panics
/// ///
/// This function panics if the start coordinates are larger than the end coordinates (for each axis). /// This function panics if the start coordinates are larger than the end coordinates (for each axis).
@ -264,7 +264,7 @@ pub struct ImageQualityCalibrationData(pub ctru_sys::CAMU_ImageQualityCalibratio
pub struct StereoCameraCalibrationData(pub ctru_sys::CAMU_StereoCameraCalibrationData); pub struct StereoCameraCalibrationData(pub ctru_sys::CAMU_StereoCameraCalibrationData);
/// Inward camera representation (facing the user of the 3DS). /// Inward camera representation (facing the user of the 3DS).
/// ///
/// Usually used for selfies. /// Usually used for selfies.
#[non_exhaustive] #[non_exhaustive]
pub struct InwardCam; pub struct InwardCam;
@ -296,7 +296,7 @@ impl Camera for OutwardLeftCam {
} }
/// Both outer cameras combined. /// Both outer cameras combined.
/// ///
/// Usually used for 3D photos. /// Usually used for 3D photos.
#[non_exhaustive] #[non_exhaustive]
pub struct BothOutwardCam; pub struct BothOutwardCam;
@ -340,7 +340,7 @@ pub trait Camera {
} }
/// Returns `true` if the camera is busy (receiving data). /// Returns `true` if the camera is busy (receiving data).
/// ///
/// # Example /// # Example
/// ///
/// ```no_run /// ```no_run
@ -349,9 +349,9 @@ pub trait Camera {
/// # /// #
/// use ctru::services::cam::{Cam, Camera}; /// use ctru::services::cam::{Cam, Camera};
/// let cam = Cam::new()?; /// let cam = Cam::new()?;
/// ///
/// let inward = &cam.inner_cam; /// let inward = &cam.inner_cam;
/// ///
/// // Inward cam is not busy since it is not being used. /// // Inward cam is not busy since it is not being used.
/// assert!(!inward.is_busy()?); /// assert!(!inward.is_busy()?);
/// # /// #
@ -369,7 +369,7 @@ pub trait Camera {
/// Returns the maximum amount of transfer bytes based on the view size, trimming, and other /// Returns the maximum amount of transfer bytes based on the view size, trimming, and other
/// modifications set to the camera. /// modifications set to the camera.
/// ///
/// # Example /// # Example
/// ///
/// ```no_run /// ```no_run
@ -378,9 +378,9 @@ pub trait Camera {
/// # /// #
/// use ctru::services::cam::{Cam, Camera}; /// use ctru::services::cam::{Cam, Camera};
/// let cam = Cam::new()?; /// let cam = Cam::new()?;
/// ///
/// let inward = &cam.inner_cam; /// let inward = &cam.inner_cam;
/// ///
/// // Inward cam is not busy since it is not being used. /// // Inward cam is not busy since it is not being used.
/// let transfer_count = inward.transfer_byte_count(); /// let transfer_count = inward.transfer_byte_count();
/// # /// #
@ -400,7 +400,7 @@ pub trait Camera {
} }
/// Set whether or not the camera should trim the image. /// Set whether or not the camera should trim the image.
/// ///
/// [`TrimmingParams`] can be set via [`Camera::set_trimming_params`]. /// [`TrimmingParams`] can be set via [`Camera::set_trimming_params`].
#[doc(alias = "CAMU_SetTrimming")] #[doc(alias = "CAMU_SetTrimming")]
fn set_trimming(&mut self, enabled: bool) -> crate::Result<()> { fn set_trimming(&mut self, enabled: bool) -> crate::Result<()> {
@ -421,7 +421,7 @@ pub trait Camera {
} }
/// Set trimming bounds based on image coordinates. /// Set trimming bounds based on image coordinates.
/// ///
/// For trimming to take effect it is required to pass `true` into [`Camera::set_trimming()`]. /// For trimming to take effect it is required to pass `true` into [`Camera::set_trimming()`].
#[doc(alias = "CAMU_SetTrimmingParams")] #[doc(alias = "CAMU_SetTrimmingParams")]
fn set_trimming_params(&mut self, params: TrimmingParams) -> crate::Result<()> { fn set_trimming_params(&mut self, params: TrimmingParams) -> crate::Result<()> {
@ -463,9 +463,9 @@ pub trait Camera {
} }
/// Set the trimming bounds relatively to the center of the image. /// Set the trimming bounds relatively to the center of the image.
/// ///
/// # Notes /// # Notes
/// ///
/// The new width will be `trim_width / 2` to the left and right of the center. /// 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. /// The new height will be `trim_height / 2` above and below the center.
// TODO: This function doesn't use `TrimmingParams`. It'd be better to merge it with `set_trimming_params()` and change the `TrimmingParams` representation. // TODO: This function doesn't use `TrimmingParams`. It'd be better to merge it with `set_trimming_params()` and change the `TrimmingParams` representation.
@ -606,7 +606,7 @@ pub trait Camera {
/// coordinates of the second crop point. /// coordinates of the second crop point.
/// ///
/// # Arguments /// # Arguments
/// ///
/// * `width` - Width of the image /// * `width` - Width of the image
/// * `height` - height of the image /// * `height` - height of the image
/// * `crop_0` - The first crop point in which the image will be trimmed /// * `crop_0` - The first crop point in which the image will be trimmed
@ -672,9 +672,9 @@ pub trait Camera {
} }
/// Sets the effect of the camera. /// Sets the effect of the camera.
/// ///
/// # Notes /// # Notes
/// ///
/// This operation will override any previously set [`Effect`]s. /// This operation will override any previously set [`Effect`]s.
/// Multiple effects can be set at once by combining the bitflags of [`Effect`]. /// Multiple effects can be set at once by combining the bitflags of [`Effect`].
#[doc(alias = "CAMU_SetEffect")] #[doc(alias = "CAMU_SetEffect")]
@ -762,9 +762,9 @@ pub trait Camera {
/// * `y` - Starting y coordinate of the window /// * `y` - Starting y coordinate of the window
/// * `width` - Width of the window /// * `width` - Width of the window
/// * `height` - Height of the window /// * `height` - Height of the window
/// ///
/// # Notes /// # Notes
/// ///
/// To activate automatic white balance, you must pass [`WhiteBalance::Auto`] into [`Camera::set_white_balance()`]. /// To activate automatic white balance, you must pass [`WhiteBalance::Auto`] into [`Camera::set_white_balance()`].
#[doc(alias = "CAMU_SetAutoWhiteBalanceWindow")] #[doc(alias = "CAMU_SetAutoWhiteBalanceWindow")]
fn set_auto_white_balance_window( fn set_auto_white_balance_window(
@ -838,9 +838,9 @@ pub trait Camera {
/// * `width` - Width of the desired image /// * `width` - Width of the desired image
/// * `height` - Height of the desired image /// * `height` - Height of the desired image
/// * `timeout` - Duration to wait for the image /// * `timeout` - Duration to wait for the image
/// ///
/// # Example /// # Example
/// ///
/// ```no_run /// ```no_run
/// # use std::error::Error; /// # use std::error::Error;
/// # use std::time::Duration; /// # use std::time::Duration;
@ -848,19 +848,19 @@ pub trait Camera {
/// # /// #
/// use ctru::services::cam::{Cam, Camera, ViewSize, OutputFormat}; /// use ctru::services::cam::{Cam, Camera, ViewSize, OutputFormat};
/// let mut cam = Cam::new()?; /// let mut cam = Cam::new()?;
/// ///
/// // We borrow the inward facing `Camera`. /// // We borrow the inward facing `Camera`.
/// let inward = &mut cam.inner_cam; /// let inward = &mut cam.inner_cam;
/// ///
/// inward.set_view_size(ViewSize::TopLCD)?; /// inward.set_view_size(ViewSize::TopLCD)?;
/// inward.set_output_format(OutputFormat::Rgb565)?; /// inward.set_output_format(OutputFormat::Rgb565)?;
/// inward.set_noise_filter(true)?; /// inward.set_noise_filter(true)?;
/// inward.set_auto_exposure(true)?; /// inward.set_auto_exposure(true)?;
/// inward.set_auto_white_balance(true)?; /// inward.set_auto_white_balance(true)?;
/// ///
/// // Size of the top screen buffer at 2 bytes per pixel (RGB565). /// // Size of the top screen buffer at 2 bytes per pixel (RGB565).
/// let mut buffer = vec![0; 400*240*2]; /// let mut buffer = vec![0; 400*240*2];
/// ///
/// // Take picture with 3 seconds of timeout. /// // Take picture with 3 seconds of timeout.
/// inward.take_picture(&mut buffer, 400, 240, Duration::from_secs(3)); /// inward.take_picture(&mut buffer, 400, 240, Duration::from_secs(3));
/// # /// #
@ -948,7 +948,7 @@ impl Cam {
/// This function will return an error if the service was unable to be initialized. /// This function will return an error if the service was unable to be initialized.
/// Since this service requires no special or elevated permissions, errors are /// Since this service requires no special or elevated permissions, errors are
/// rare in practice. /// rare in practice.
/// ///
/// # Example /// # Example
/// ///
/// ```no_run /// ```no_run
@ -976,12 +976,12 @@ impl Cam {
} }
/// Plays the specified sound based on the [`ShutterSound`] argument /// Plays the specified sound based on the [`ShutterSound`] argument
/// ///
/// # Notes /// # Notes
/// ///
/// Playing the shutter sound does not require a liviving handle to the [`Ndsp`](crate::services::ndsp::Ndsp) service. /// Playing the shutter sound does not require a liviving handle to the [`Ndsp`](crate::services::ndsp::Ndsp) service.
/// Volume will always be maxed out to ensure everyone within photo range can hear the picture being taken (as by japanese law). /// Volume will always be maxed out to ensure everyone within photo range can hear the picture being taken (as by japanese law).
/// ///
/// # Example /// # Example
/// ///
/// ```no_run /// ```no_run
@ -990,7 +990,7 @@ impl Cam {
/// # /// #
/// use ctru::services::cam::{Cam, ShutterSound}; /// use ctru::services::cam::{Cam, ShutterSound};
/// let cam = Cam::new()?; /// let cam = Cam::new()?;
/// ///
/// // We play the shutter sound on the console's speakers! /// // We play the shutter sound on the console's speakers!
/// // (even though we aren't taking a photo :P) /// // (even though we aren't taking a photo :P)
/// cam.play_shutter_sound(ShutterSound::Normal); /// cam.play_shutter_sound(ShutterSound::Normal);

Loading…
Cancel
Save