From 61e20fa2dce4ac8eae95f741683025aa6aecae1d Mon Sep 17 00:00:00 2001 From: Andrea Ciliberti Date: Sat, 8 Jul 2023 19:19:53 +0200 Subject: [PATCH] Enum variants documentation + ide files ignored --- .gitignore | 1 + ctru-rs/src/applets/mii_selector.rs | 16 +++- ctru-rs/src/applets/swkbd.rs | 49 ++++++++-- ctru-rs/src/mii.rs | 133 +++++++++++++++++++++++----- ctru-rs/src/services/am.rs | 12 +-- ctru-rs/src/services/cam.rs | 63 +++++++++++-- ctru-rs/src/services/cfgu.rs | 30 ++++++- ctru-rs/src/services/fs.rs | 35 ++++++++ ctru-rs/src/services/gspgpu.rs | 10 ++- ctru-rs/src/services/hid.rs | 31 ++++++- ctru-rs/src/services/ndsp/mod.rs | 14 +++ ctru-rs/src/services/ndsp/wave.rs | 4 + ctru-rs/src/services/ps.rs | 18 ++++ ctru-rs/src/services/sslc.rs | 1 + 14 files changed, 365 insertions(+), 52 deletions(-) diff --git a/.gitignore b/.gitignore index 54f1838..f4d733b 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ Cargo.lock # IDE files .idea +.vscode diff --git a/ctru-rs/src/applets/mii_selector.rs b/ctru-rs/src/applets/mii_selector.rs index eada7e3..577d0df 100644 --- a/ctru-rs/src/applets/mii_selector.rs +++ b/ctru-rs/src/applets/mii_selector.rs @@ -6,18 +6,26 @@ use crate::mii::MiiData; use bitflags::bitflags; use std::ffi::CString; -/// Index of a Mii used to configure some parameters of the Mii Selector -/// Can be either a single index, or _all_ Miis +/// Index of a Mii used to configure some parameters of the Mii Selector. #[derive(Debug, Clone, Copy, Eq, PartialEq)] pub enum Index { + /// Specific Mii index. Index(u32), + /// All Miis. All, } /// The type of a Mii with their respective data #[derive(Debug, Clone, Eq, PartialEq)] pub enum MiiType { - Guest { index: u32, name: String }, + /// Guest Mii. + Guest { + /// Guest Mii index. + index: u32, + /// Guest Mii name. + name: String, + }, + /// User-made Mii. User, } @@ -56,7 +64,9 @@ pub struct MiiSelector { #[non_exhaustive] #[derive(Clone, Debug)] pub struct SelectionResult { + /// Data regarding the selected Mii. pub mii_data: MiiData, + /// Type of the selected Mii. pub mii_type: MiiType, } diff --git a/ctru-rs/src/applets/swkbd.rs b/ctru-rs/src/applets/swkbd.rs index 49a4103..e5e9c28 100644 --- a/ctru-rs/src/applets/swkbd.rs +++ b/ctru-rs/src/applets/swkbd.rs @@ -14,19 +14,19 @@ pub struct Swkbd { } /// The kind of keyboard to be initialized. -/// -/// Normal is the full keyboard with several pages (QWERTY/accents/symbol/mobile) -/// Qwerty is a QWERTY-only keyboard. -/// Numpad is a number pad. -/// Western is a text keyboard without japanese symbols (only applies to JPN systems). For other -/// systems it's the same as a Normal keyboard. #[doc(alias = "SwkbdType")] #[derive(Copy, Clone, Debug, PartialEq, Eq)] #[repr(u32)] pub enum Kind { + /// Normal keyboard composed of several pages (QWERTY, accents, symbols, mobile). Normal = ctru_sys::SWKBD_TYPE_NORMAL, + /// Only QWERTY keyboard. Qwerty = ctru_sys::SWKBD_TYPE_QWERTY, + /// Only number pad. Numpad = ctru_sys::SWKBD_TYPE_NUMPAD, + /// On JPN systems: a keyboard without japanese input capablities. + /// + /// On any other region: same as [`Normal`](Kind::Normal). Western = ctru_sys::SWKBD_TYPE_WESTERN, } @@ -35,8 +35,11 @@ pub enum Kind { #[derive(Copy, Clone, Debug, PartialEq, Eq)] #[repr(u32)] pub enum Button { + /// Left button. Usually corresponds to "Cancel". Left = ctru_sys::SWKBD_BUTTON_LEFT, + /// Middle button. Usually corresponds to "I Forgot". Middle = ctru_sys::SWKBD_BUTTON_MIDDLE, + /// Right button. Usually corresponds to "OK". Right = ctru_sys::SWKBD_BUTTON_RIGHT, } @@ -45,49 +48,77 @@ pub enum Button { #[derive(Copy, Clone, Debug, PartialEq, Eq)] #[repr(i32)] pub enum Error { + /// Invalid parameters inputted in the Software Keyboard. InvalidInput = ctru_sys::SWKBD_INVALID_INPUT, + /// Out of memory. OutOfMem = ctru_sys::SWKBD_OUTOFMEM, + /// Home button was pressed during execution. HomePressed = ctru_sys::SWKBD_HOMEPRESSED, + /// Reset button was pressed during execution. ResetPressed = ctru_sys::SWKBD_RESETPRESSED, + /// Power button was pressed during execution. PowerPressed = ctru_sys::SWKBD_POWERPRESSED, + /// The parental PIN was correct. ParentalOk = ctru_sys::SWKBD_PARENTAL_OK, + /// The parental PIN was incorrect. ParentalFail = ctru_sys::SWKBD_PARENTAL_FAIL, + /// Input triggered the filter. BannedInput = ctru_sys::SWKBD_BANNED_INPUT, } -/// Restrictions on keyboard input +/// Restrictions on keyboard input. #[doc(alias = "SwkbdValidInput")] #[derive(Copy, Clone, Debug, PartialEq, Eq)] #[repr(u32)] pub enum ValidInput { + /// All inputs are accepted. Anything = ctru_sys::SWKBD_ANYTHING, + /// Empty inputs are not accepted. NotEmpty = ctru_sys::SWKBD_NOTEMPTY, - NotEmptyNotBlank = ctru_sys::SWKBD_NOTEMPTY_NOTBLANK, + /// Blank (consisting only of whitespaces) inputs are not accepted. NotBlank = ctru_sys::SWKBD_NOTBLANK, + /// Neither empty inputs nor blank inputs are accepted. + NotEmptyNotBlank = ctru_sys::SWKBD_NOTEMPTY_NOTBLANK, + /// Input must have a fixed length. Maximum length can be specified with [`Swkbd::set_max_text_len`]; FixedLen = ctru_sys::SWKBD_FIXEDLEN, } bitflags! { - /// Keyboard feature flags + /// Keyboard feature flags. pub struct Features: u32 { + /// Parental PIN mode. const PARENTAL_PIN = ctru_sys::SWKBD_PARENTAL; + /// Darken top screen while the Software Keyboard is active. const DARKEN_TOP_SCREEN = ctru_sys::SWKBD_DARKEN_TOP_SCREEN; + /// Enable predictive input (necessary for Kanji on JPN consoles). const PREDICTIVE_INPUT = ctru_sys::SWKBD_PREDICTIVE_INPUT; + /// Enable multiline input. const MULTILINE = ctru_sys::SWKBD_MULTILINE; + /// Enable fixed-width mode. const FIXED_WIDTH = ctru_sys::SWKBD_FIXED_WIDTH; + /// Allow the usage of the Home Button while the Software Keyboard is active. const ALLOW_HOME = ctru_sys::SWKBD_ALLOW_HOME; + /// Allow the usage of the Reset Button while the Software Keyboard is active. const ALLOW_RESET = ctru_sys::SWKBD_ALLOW_RESET; + /// Allow the usage of the Power Button while the Software Keyboard is active. const ALLOW_POWER = ctru_sys::SWKBD_ALLOW_POWER; + /// Default to the QWERTY page when the Software Keyboard is shown. const DEFAULT_QWERTY = ctru_sys::SWKBD_DEFAULT_QWERTY; } /// Keyboard input filtering flags pub struct Filters: u32 { + /// Disallows the usage of numerical digits. const DIGITS = ctru_sys::SWKBD_FILTER_DIGITS; + /// Disallows the usage of the "at" (@) sign. const AT = ctru_sys::SWKBD_FILTER_AT; + /// Disallows the usage of the "percent" (%) sign. const PERCENT = ctru_sys::SWKBD_FILTER_PERCENT; + /// Disallows the usage of the "backslash" (\) sign. const BACKSLASH = ctru_sys::SWKBD_FILTER_BACKSLASH; + /// Disallows the use of profanity via Nintendo's profanity filter. const PROFANITY = ctru_sys::SWKBD_FILTER_PROFANITY; + /// Use a custom callback in order to filter the input. const CALLBACK = ctru_sys::SWKBD_FILTER_CALLBACK; } } diff --git a/ctru-rs/src/mii.rs b/ctru-rs/src/mii.rs index 120eee1..b5a2f03 100644 --- a/ctru-rs/src/mii.rs +++ b/ctru-rs/src/mii.rs @@ -3,171 +3,238 @@ //! 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) -/// Represents the region lock of the console +/// Represents the region lock of the console. #[derive(Copy, Clone, Debug, Eq, PartialEq)] pub enum RegionLock { + /// No region-lock. None, + /// Japan region-lock. Japan, + /// USA region-lock. USA, + /// Europe region-lock. Europe, } -/// Represent the charset of the console +/// Represent the charset of the console. #[derive(Copy, Clone, Debug, Eq, PartialEq)] pub enum Charset { + /// Japan-USA-Europe unified charset. JapanUSAEurope, + /// China charset. China, + /// Korea charset. Korea, + /// Taiwan charset. Taiwan, } -/// Represents the options of the Mii +/// Represents the options of the Mii. #[derive(Copy, Clone, Debug)] pub struct MiiDataOptions { + /// Whether it is allowed to copy the Mii. pub is_copying_allowed: bool, + /// Whether the profanity flag is active. pub is_profanity_flag_enabled: bool, + /// The Mii's active region-lock. pub region_lock: RegionLock, + /// The Mii's used charset. pub charset: Charset, } -/// Represents the position that the Mii has on the selector +/// Represents the position that the Mii has on the selector. #[derive(Copy, Clone, Debug)] pub struct SelectorPosition { + /// Index of the page where the Mii is found. pub page_index: u8, + /// Index of the slot (relative to the page) where the Mii is found. pub slot_index: u8, } -/// Represents the kind of origin console +/// Represents the console where the Mii originated from. #[derive(Copy, Clone, Debug, Eq, PartialEq)] pub enum OriginConsole { + /// Nintendo Wii. Wii, + /// Nintendo DSi. DSi, - /// Both New 3DS and Old 3DS + /// Nintendo 3DS (both New 3DS and Old 3DS). N3DS, + /// Nintendo WiiU/Switch. WiiUSwitch, } -/// Represents the identity of the origin console +/// Represents the identity of the origin console. #[derive(Copy, Clone, Debug)] pub struct ConsoleIdentity { + /// From which console the Mii originated from. pub origin_console: OriginConsole, } -/// Represents the sex of the Mii +/// Represents the sex of the Mii. #[derive(Copy, Clone, Debug, Eq, PartialEq)] pub enum MiiSex { + /// Male sex. Male, + /// Female sex. Female, } -/// Represents the details of the Mii +/// Represents the details of the Mii. #[derive(Copy, Clone, Debug)] pub struct Details { + /// Sex of the Mii. pub sex: MiiSex, + /// Birthday month. pub birthday_month: u8, + /// Birthday day. pub birthday_day: u8, + /// Color of the Mii's shirt. pub shirt_color: u8, + /// Whether the Mii is a favorite. pub is_favorite: bool, + /// Whether the Mii can be shared. + pub is_sharing_enabled: bool, } -/// Represents the face style of the Mii +/// Represents the face style of the Mii. #[derive(Copy, Clone, Debug)] pub struct FaceStyle { - pub is_sharing_enabled: bool, + /// Face shape. pub shape: u8, + /// Skin color. pub skin_color: u8, } -/// Represents the face details of the Mii +/// Represents the face details of the Mii. #[derive(Copy, Clone, Debug)] pub struct FaceDetails { + /// Face style. pub style: FaceStyle, + /// Wrinkles. pub wrinkles: u8, + /// Makeup. pub makeup: u8, } -/// Represents the hair details of the Mii +/// Represents the hair details of the Mii. #[derive(Copy, Clone, Debug)] pub struct HairDetails { + /// Hair style. pub style: u8, + /// Hair color. pub color: u8, + /// Whether the Mii's hair is flipped. pub is_flipped: bool, } -/// Represents the eye details of the Mii +/// Represents the eye details of the Mii. #[derive(Copy, Clone, Debug)] pub struct EyeDetails { + /// Eye style. pub style: u8, + /// Eye color. pub color: u8, + /// Eye scale. pub scale: u8, + /// Eye scale (y-axis). pub y_scale: u8, + /// Eye rotation. pub rotation: u8, - /// Spacing between the eyes + /// Spacing between the eyes. pub x_spacing: u8, + /// Eye height. pub y_position: u8, } /// Represents the eyebrow details of the Mii #[derive(Copy, Clone, Debug)] pub struct EyebrowDetails { + /// Eyebrow style. pub style: u8, + /// Eyebrow color. pub color: u8, + /// Eyebrow scale. pub scale: u8, + /// Eyebrow scale (y-axis). pub y_scale: u8, + /// Eyebrow rotation. pub rotation: u8, /// Spacing between the eyebrows pub x_spacing: u8, + /// Eyebrow height. pub y_position: u8, } /// Represents the details of the nose #[derive(Copy, Clone, Debug)] pub struct NoseDetails { + /// Nose style. pub style: u8, + /// Nose scale. pub scale: u8, + /// Nose height. pub y_position: u8, } /// Represents the details of the mouth #[derive(Copy, Clone, Debug)] pub struct MouthDetails { + /// Mouth style. pub style: u8, + /// Mouth color. pub color: u8, + /// Mouth scale. pub scale: u8, + /// Mouth scale (y-axis). pub y_scale: u8, + /// Mouth height. + pub y_position: u8, } /// Represents the details of the mustache #[derive(Copy, Clone, Debug)] pub struct MustacheDetails { - pub mouth_y_position: u8, + /// Mustache style. pub mustache_style: u8, } /// Represents the details of the beard #[derive(Copy, Clone, Debug)] pub struct BeardDetails { + /// Beard style pub style: u8, + /// Beard color. pub color: u8, + /// Beard scale. pub scale: u8, + /// Beard height. pub y_position: u8, } -/// Represents the details of the glass +/// Represents the details of the glasses #[derive(Copy, Clone, Debug)] -pub struct GlassDetails { +pub struct GlassesDetails { + /// Glasses style. pub style: u8, + /// Glasses color. pub color: u8, + /// Glasses scale. pub scale: u8, + /// Glasses height. pub y_position: u8, } -/// Represents the details of the mole +/// Represents the details of the mole. #[derive(Copy, Clone, Debug)] pub struct MoleDetails { + /// Whether the Mii has a mole. pub is_enabled: bool, + /// Mole scale. pub scale: u8, + /// Mole position (x-axis). pub x_position: u8, + /// Mole position (y-axis). pub y_position: u8, } @@ -177,34 +244,52 @@ pub struct MoleDetails { /// /// /// This struct is returned by the [`MiiSelector`](crate::applets::mii_selector::MiiSelector) -#[doc(alias = "MiiData")] #[derive(Clone, Debug)] pub struct MiiData { + /// Mii options. pub options: MiiDataOptions, + /// Position taken by the Mii on the Mii Selector screen. pub selector_position: SelectorPosition, + /// Console the Mii was created on. pub console_identity: ConsoleIdentity, /// Unique system ID, not dependant on the MAC address pub system_id: [u8; 8], + /// Console's MAC address. pub mac_address: [u8; 6], + /// General information about the Mii. pub details: Details, + /// Mii name. pub name: String, + /// Mii height. pub height: u8, + /// Mii width. pub width: u8, + /// Face details. pub face_details: FaceDetails, + /// Hair details. pub hair_details: HairDetails, + /// Eyes details. pub eye_details: EyeDetails, + /// Eyebrow details. pub eyebrow_details: EyebrowDetails, + /// Nose details. pub nose_details: NoseDetails, + /// Mouth details. pub mouth_details: MouthDetails, + /// Mustache details. pub mustache_details: MustacheDetails, + /// Beard details. pub beard_details: BeardDetails, - pub glass_details: GlassDetails, + /// Glasses details. + pub glass_details: GlassesDetails, + /// Mole details. pub mole_details: MoleDetails, + /// Name of the Mii's original author. pub author_name: String, } @@ -321,11 +406,11 @@ impl From for MiiData { birthday_day: partial_u8_bits_to_u8(&raw_details[5..=9]), shirt_color: partial_u8_bits_to_u8(&raw_details[10..=13]), is_favorite: raw_details[14], + is_sharing_enabled: !raw_face_style[0], }; let face_details = FaceDetails { style: FaceStyle { - is_sharing_enabled: !raw_face_style[0], shape: partial_u8_bits_to_u8(&raw_face_style[1..=4]), skin_color: partial_u8_bits_to_u8(&raw_face_style[5..=7]), }, @@ -372,10 +457,10 @@ impl From for MiiData { color: partial_u8_bits_to_u8(&raw_mouth_details[6..=8]), scale: partial_u8_bits_to_u8(&raw_mouth_details[9..=12]), y_scale: partial_u8_bits_to_u8(&raw_mouth_details[13..=15]), + y_position: partial_u8_bits_to_u8(&raw_mustache_details[0..=4]), }; let mustache_details = MustacheDetails { - mouth_y_position: partial_u8_bits_to_u8(&raw_mustache_details[0..=4]), mustache_style: partial_u8_bits_to_u8(&raw_mustache_details[5..=7]), }; @@ -386,7 +471,7 @@ impl From for MiiData { y_position: partial_u8_bits_to_u8(&raw_beard_details[10..=14]), }; - let glass_details = GlassDetails { + let glass_details = GlassesDetails { style: partial_u8_bits_to_u8(&raw_glass_details[0..=3]), color: partial_u8_bits_to_u8(&raw_glass_details[4..=6]), scale: partial_u8_bits_to_u8(&raw_glass_details[7..=10]), diff --git a/ctru-rs/src/services/am.rs b/ctru-rs/src/services/am.rs index 2af1152..9892bd7 100644 --- a/ctru-rs/src/services/am.rs +++ b/ctru-rs/src/services/am.rs @@ -62,9 +62,9 @@ impl<'a> Title<'a> { /// Returns the size of this title in bytes. pub fn size(&self) -> crate::Result { // Get the internal entry, or fill it if empty. - let entry = self.entry.get_or_try_init(|| -> crate::Result { - self.title_info() - })?; + let entry = self + .entry + .get_or_try_init(|| -> crate::Result { self.title_info() })?; Ok(entry.size) } @@ -72,9 +72,9 @@ impl<'a> Title<'a> { /// Returns the installed version of this title. pub fn version(&self) -> crate::Result { // Get the internal entry, or fill it if empty. - let entry = self.entry.get_or_try_init(|| -> crate::Result { - self.title_info() - })?; + let entry = self + .entry + .get_or_try_init(|| -> crate::Result { self.title_info() })?; Ok(entry.version) } diff --git a/ctru-rs/src/services/cam.rs b/ctru-rs/src/services/cam.rs index 0d18d89..de9ecb5 100644 --- a/ctru-rs/src/services/cam.rs +++ b/ctru-rs/src/services/cam.rs @@ -14,9 +14,13 @@ use std::time::Duration; /// This service requires no special permissions to use. #[non_exhaustive] pub struct Cam { + /// Inside-facing camera. pub inner_cam: InwardCam, + /// Outside-facing right camera. pub outer_right_cam: OutwardRightCam, + /// Outside-facing left camera. pub outer_left_cam: OutwardLeftCam, + /// Both outside-facing cameras (mainly used for 3D photos). pub both_outer_cams: BothOutwardCam, } @@ -25,9 +29,13 @@ pub struct Cam { #[derive(Copy, Clone, Debug, PartialEq, Eq)] #[repr(u32)] pub enum FlipMode { + /// No flip applied. None = ctru_sys::FLIP_NONE, + /// Horizontal flip applied. Horizontal = ctru_sys::FLIP_HORIZONTAL, + /// Vertical flip applied. Vertical = ctru_sys::FLIP_VERTICAL, + /// Both vertical and horizontal flip applied. Reverse = ctru_sys::FLIP_REVERSE, } @@ -36,16 +44,25 @@ pub enum FlipMode { #[derive(Copy, Clone, Debug, PartialEq, Eq)] #[repr(u32)] pub enum ViewSize { + /// Size of the 3DS' top screen. (400 × 240) + /// + /// Useful if the image is meant to be displayed immediately. TopLCD = ctru_sys::SIZE_CTR_TOP_LCD, - /// Equivalent to QVga + /// Size of the 3DS' bottom screen. (320 × 240) + /// + /// Equivalent to QVga. BottomLCD = ctru_sys::SIZE_CTR_BOTTOM_LCD, + /// VGA display size. (640 × 480) Vga = ctru_sys::SIZE_VGA, + /// QQVGA display size. (160 × 120) QQVga = ctru_sys::SIZE_QQVGA, + /// CIF display size. (352 × 288) Cif = ctru_sys::SIZE_CIF, + /// QCIF display size. (176 × 144) QCif = ctru_sys::SIZE_QCIF, - /// Nintendo DS Screen + /// Nintendo DS Screen size. (256 × 192) DS = ctru_sys::SIZE_DS_LCD, - /// Nintendo DS Screen x4 + /// Nintendo DS Screen size x4. (512 × 384) DSX4 = ctru_sys::SIZE_DS_LCDx4, } @@ -54,18 +71,31 @@ pub enum ViewSize { #[derive(Copy, Clone, Debug, PartialEq, Eq)] #[repr(u32)] pub enum FrameRate { + /// 15 FPS. Fps15 = ctru_sys::FRAME_RATE_15, + /// 15 to 5 FPS. Fps15To5 = ctru_sys::FRAME_RATE_15_TO_5, + /// 15 to 2 FPS. Fps15To2 = ctru_sys::FRAME_RATE_15_TO_2, + /// 10 FPS. Fps10 = ctru_sys::FRAME_RATE_10, + /// 8.5 FPS. Fps8_5 = ctru_sys::FRAME_RATE_8_5, + /// 5 FPS. Fps5 = ctru_sys::FRAME_RATE_5, + /// 20 FPS. Fps20 = ctru_sys::FRAME_RATE_20, + /// 20 to 5 FPS. Fps20To5 = ctru_sys::FRAME_RATE_20_TO_5, + /// 30 FPS. Fps30 = ctru_sys::FRAME_RATE_30, + /// 30 to 5 FPS. Fps30To5 = ctru_sys::FRAME_RATE_30_TO_5, + /// 15 to 10 FPS. Fps15To10 = ctru_sys::FRAME_RATE_15_TO_10, + /// 20 to 10 FPS. Fps20To10 = ctru_sys::FRAME_RATE_20_TO_10, + /// 30 to 10 FPS. Fps30To10 = ctru_sys::FRAME_RATE_30_TO_10, } @@ -85,7 +115,7 @@ pub enum WhiteBalance { Temp5200K = ctru_sys::WHITE_BALANCE_5200K, /// Cloudy/Horizon Temp6000K = ctru_sys::WHITE_BALANCE_6000K, - ///Shade + /// Shade Temp7000K = ctru_sys::WHITE_BALANCE_7000K, } @@ -94,10 +124,15 @@ pub enum WhiteBalance { #[derive(Copy, Clone, Debug, PartialEq, Eq)] #[repr(u32)] pub enum PhotoMode { + /// Normal mode. Normal = ctru_sys::PHOTO_MODE_NORMAL, + /// Portrait mode. Portrait = ctru_sys::PHOTO_MODE_PORTRAIT, + /// Landscape mode. Landscape = ctru_sys::PHOTO_MODE_LANDSCAPE, + /// NightView mode. NightView = ctru_sys::PHOTO_MODE_NIGHTVIEW, + /// Letter mode. Letter = ctru_sys::PHOTO_MODE_LETTER, } @@ -106,11 +141,17 @@ pub enum PhotoMode { #[derive(Copy, Clone, Debug, PartialEq, Eq)] #[repr(u32)] pub enum Effect { + /// No effects. None = ctru_sys::EFFECT_NONE, + /// Mono effect. Mono = ctru_sys::EFFECT_MONO, + /// Sepia effect. Sepia = ctru_sys::EFFECT_SEPIA, + /// Negative effect. Negative = ctru_sys::EFFECT_NEGATIVE, + /// Negative film effect. Negafilm = ctru_sys::EFFECT_NEGAFILM, + /// Sepia effect. (unknown difference) Sepia01 = ctru_sys::EFFECT_SEPIA01, } @@ -119,11 +160,11 @@ pub enum Effect { #[derive(Copy, Clone, Debug, PartialEq, Eq)] #[repr(u32)] pub enum Contrast { - /// OFF + /// Low contrast. Low = ctru_sys::CONTRAST_LOW, - /// Brightness ratio: 70 + /// Brightness ratio: 70. Normal = ctru_sys::CONTRAST_NORMAL, - /// Brightness ratio: 90 + /// Brightness ratio: 90. High = ctru_sys::CONTRAST_HIGH, } @@ -132,8 +173,11 @@ pub enum Contrast { #[derive(Copy, Clone, Debug, PartialEq, Eq)] #[repr(u32)] pub enum LensCorrection { + /// No lens correction. Off = ctru_sys::LENS_CORRECTION_DARK, + /// Normal lens correction. Normal = ctru_sys::LENS_CORRECTION_NORMAL, + /// Bright lens correction. Bright = ctru_sys::LENS_CORRECTION_BRIGHT, } @@ -142,7 +186,9 @@ pub enum LensCorrection { #[derive(Copy, Clone, Debug, PartialEq, Eq)] #[repr(u32)] pub enum OutputFormat { + /// YUV422 output format. 16 bits per pixel. Yuv422 = ctru_sys::OUTPUT_YUV_422, + /// RGB565 output format. 16 bits per pixel. Rgb565 = ctru_sys::OUTPUT_RGB_565, } @@ -151,8 +197,11 @@ pub enum OutputFormat { #[derive(Copy, Clone, Debug, PartialEq, Eq)] #[repr(u32)] pub enum ShutterSound { + /// Normal shutter sound. Normal = ctru_sys::SHUTTER_SOUND_TYPE_NORMAL, + /// Shutter sound to begin a movie recording. Movie = ctru_sys::SHUTTER_SOUND_TYPE_MOVIE, + /// Shutter sound to finish a movie recording. MovieEnd = ctru_sys::SHUTTER_SOUND_TYPE_MOVIE_END, } diff --git a/ctru-rs/src/services/cfgu.rs b/ctru-rs/src/services/cfgu.rs index 661fdf9..99ef505 100644 --- a/ctru-rs/src/services/cfgu.rs +++ b/ctru-rs/src/services/cfgu.rs @@ -4,46 +4,74 @@ use crate::error::ResultCode; +/// Console's region. #[doc(alias = "CFG_Region")] #[derive(Copy, Clone, Debug, PartialEq, Eq)] #[repr(u32)] pub enum Region { + /// Japan. Japan = ctru_sys::CFG_REGION_JPN, + /// USA. USA = ctru_sys::CFG_REGION_USA, + /// Europe. Europe = ctru_sys::CFG_REGION_EUR, + /// Australia. Australia = ctru_sys::CFG_REGION_AUS, + /// China. China = ctru_sys::CFG_REGION_CHN, + /// Korea. Korea = ctru_sys::CFG_REGION_KOR, + /// Taiwan. Taiwan = ctru_sys::CFG_REGION_TWN, } +/// Language set for the console's OS. #[doc(alias = "CFG_Language")] #[derive(Copy, Clone, Debug, PartialEq, Eq)] #[repr(u32)] pub enum Language { + /// Japanese. Japanese = ctru_sys::CFG_LANGUAGE_JP, + /// English. English = ctru_sys::CFG_LANGUAGE_EN, + /// French. French = ctru_sys::CFG_LANGUAGE_FR, + /// German. German = ctru_sys::CFG_LANGUAGE_DE, + /// Italian. Italian = ctru_sys::CFG_LANGUAGE_IT, + /// Spanish. Spanish = ctru_sys::CFG_LANGUAGE_ES, - SimplifiedChinese = ctru_sys::CFG_LANGUAGE_ZH, + /// Korean. Korean = ctru_sys::CFG_LANGUAGE_KO, + /// Dutch. Dutch = ctru_sys::CFG_LANGUAGE_NL, + /// Portuguese. Portuguese = ctru_sys::CFG_LANGUAGE_PT, + /// Russian. Russian = ctru_sys::CFG_LANGUAGE_RU, + /// Simplified Chinese. + SimplifiedChinese = ctru_sys::CFG_LANGUAGE_ZH, + /// Traditional Chinese. TraditionalChinese = ctru_sys::CFG_LANGUAGE_TW, } +/// 3DS model. #[doc(alias = "CFG_SystemModel")] #[derive(Copy, Clone, Debug, PartialEq, Eq)] #[repr(u32)] pub enum SystemModel { + /// Old Nintendo 3DS. Old3DS = ctru_sys::CFG_MODEL_3DS, + /// Old Nintendo 3DS XL. Old3DSXL = ctru_sys::CFG_MODEL_3DSXL, + /// New Nintendo 3DS. New3DS = ctru_sys::CFG_MODEL_N3DS, + /// Old Nintendo 2DS. Old2DS = ctru_sys::CFG_MODEL_2DS, + /// New Nintendo 3DS XL. New3DSXL = ctru_sys::CFG_MODEL_N3DSXL, + /// New Nintendo 2DS XL. New2DSXL = ctru_sys::CFG_MODEL_N2DSXL, } diff --git a/ctru-rs/src/services/fs.rs b/ctru-rs/src/services/fs.rs index b498ee9..9b56ddd 100644 --- a/ctru-rs/src/services/fs.rs +++ b/ctru-rs/src/services/fs.rs @@ -39,51 +39,86 @@ bitflags! { } } +/// Media type used for storage. #[doc(alias = "FS_MediaType")] #[derive(Copy, Clone, Debug, PartialEq, Eq)] #[repr(u32)] pub enum FsMediaType { + /// Internal NAND memory. Nand = ctru_sys::MEDIATYPE_NAND, + /// External SD card. Sd = ctru_sys::MEDIATYPE_SD, + /// Game Cartridge. GameCard = ctru_sys::MEDIATYPE_GAME_CARD, } +/// Kind of file path. #[doc(alias = "FS_PathType")] #[derive(Copy, Clone, Debug, PartialEq, Eq)] #[repr(u32)] pub enum PathType { + /// Invalid path. Invalid = ctru_sys::PATH_INVALID, + /// Empty path. Empty = ctru_sys::PATH_EMPTY, + /// Binary path. + /// + /// Its meaning differs depending on the Archive it is used on. Binary = ctru_sys::PATH_BINARY, + /// ASCII path. ASCII = ctru_sys::PATH_ASCII, + /// UTF-16 path. UTF16 = ctru_sys::PATH_UTF16, } +/// Index of the various usable data archives. #[doc(alias = "FS_ArchiveID")] #[derive(Copy, Clone, Debug, PartialEq, Eq)] #[repr(u32)] pub enum ArchiveID { + /// Read-Only Memory File System. RomFS = ctru_sys::ARCHIVE_ROMFS, + /// Game save data. Savedata = ctru_sys::ARCHIVE_SAVEDATA, + /// Game ext data. Extdata = ctru_sys::ARCHIVE_EXTDATA, + /// Shared ext data. SharedExtdata = ctru_sys::ARCHIVE_SHARED_EXTDATA, + /// System save data. SystemSavedata = ctru_sys::ARCHIVE_SYSTEM_SAVEDATA, + /// SD card. Sdmc = ctru_sys::ARCHIVE_SDMC, + /// SD card (write-only). SdmcWriteOnly = ctru_sys::ARCHIVE_SDMC_WRITE_ONLY, + /// BOSS ext data. BossExtdata = ctru_sys::ARCHIVE_BOSS_EXTDATA, + /// Card SPI File System. CardSpiFS = ctru_sys::ARCHIVE_CARD_SPIFS, + /// Game ext data and BOSS data. ExtDataAndBossExtdata = ctru_sys::ARCHIVE_EXTDATA_AND_BOSS_EXTDATA, + /// System save data. SystemSaveData2 = ctru_sys::ARCHIVE_SYSTEM_SAVEDATA2, + /// Internal NAND (read-write). NandRW = ctru_sys::ARCHIVE_NAND_RW, + /// Internal NAND (read-only). NandRO = ctru_sys::ARCHIVE_NAND_RO, + /// Internal NAND (read-only write access). NandROWriteAccess = ctru_sys::ARCHIVE_NAND_RO_WRITE_ACCESS, + /// User save data and ExeFS/RomFS. SaveDataAndContent = ctru_sys::ARCHIVE_SAVEDATA_AND_CONTENT, + /// User save data and ExeFS/RomFS (only ExeFS for fs:LDR). SaveDataAndContent2 = ctru_sys::ARCHIVE_SAVEDATA_AND_CONTENT2, + /// NAND CTR File System. NandCtrFS = ctru_sys::ARCHIVE_NAND_CTR_FS, + /// TWL photo. TwlPhoto = ctru_sys::ARCHIVE_TWL_PHOTO, + /// NAND TWL File System. NandTwlFS = ctru_sys::ARCHIVE_NAND_TWL_FS, + /// Game card save data. GameCardSavedata = ctru_sys::ARCHIVE_GAMECARD_SAVEDATA, + /// User save data. UserSavedata = ctru_sys::ARCHIVE_USER_SAVEDATA, + /// Demo save data. DemoSavedata = ctru_sys::ARCHIVE_DEMO_SAVEDATA, } diff --git a/ctru-rs/src/services/gspgpu.rs b/ctru-rs/src/services/gspgpu.rs index 1510b29..cb3e67c 100644 --- a/ctru-rs/src/services/gspgpu.rs +++ b/ctru-rs/src/services/gspgpu.rs @@ -1,20 +1,28 @@ //! GSPGPU service +/// GSPGPU events that can be awaited. #[doc(alias = "GSPGPU_Event")] #[derive(Copy, Clone, Debug, PartialEq, Eq)] #[repr(u32)] pub enum Event { + /// Memory fill completed. Psc0 = ctru_sys::GSPGPU_EVENT_PSC0, + /// TODO: Unknown. Psc1 = ctru_sys::GSPGPU_EVENT_PSC1, + /// TODO: Unknown. VBlank0 = ctru_sys::GSPGPU_EVENT_VBlank0, + /// TODO: Unknown. VBlank1 = ctru_sys::GSPGPU_EVENT_VBlank1, + /// Display transfer finished. PPF = ctru_sys::GSPGPU_EVENT_PPF, + /// Command list processing finished. P3D = ctru_sys::GSPGPU_EVENT_P3D, + /// TODO: Unknown. DMA = ctru_sys::GSPGPU_EVENT_DMA, } #[doc(alias = "GSPGPU_FramebufferFormat")] -/// Framebuffer formats supported by the 3DS +/// Framebuffer formats supported by the 3DS. #[derive(Copy, Clone, Debug, PartialEq, Eq)] #[repr(u32)] pub enum FramebufferFormat { diff --git a/ctru-rs/src/services/hid.rs b/ctru-rs/src/services/hid.rs index 8de66a1..51bf63a 100644 --- a/ctru-rs/src/services/hid.rs +++ b/ctru-rs/src/services/hid.rs @@ -9,33 +9,62 @@ bitflags::bitflags! { /// A set of flags corresponding to the button and directional pad /// inputs on the 3DS pub struct KeyPad: u32 { + /// A button. const A = ctru_sys::KEY_A; + /// B button. const B = ctru_sys::KEY_B; + /// Select button. const SELECT = ctru_sys::KEY_SELECT; + /// Start button. const START = ctru_sys::KEY_START; + /// D-Pad Right. const DPAD_RIGHT = ctru_sys::KEY_DRIGHT; + /// D-Pad Left. const DPAD_LEFT = ctru_sys::KEY_DLEFT; + /// D-Pad Up. const DPAD_UP = ctru_sys::KEY_DUP; + /// D-Pad Down. const DPAD_DOWN = ctru_sys::KEY_DDOWN; + /// R button. const R = ctru_sys::KEY_R; + /// L button. const L = ctru_sys::KEY_L; + /// X button. const X = ctru_sys::KEY_X; + /// Y button. const Y = ctru_sys::KEY_Y; + /// ZL button. const ZL = ctru_sys::KEY_ZL; + /// ZR button. const ZR = ctru_sys::KEY_ZR; + /// Touchscreen. const TOUCH = ctru_sys::KEY_TOUCH; + /// C-Stick Right. const CSTICK_RIGHT = ctru_sys::KEY_CSTICK_RIGHT; + /// C-Stick Left. const CSTICK_LEFT = ctru_sys::KEY_CSTICK_LEFT; + /// C-Stick Up. const CSTICK_UP = ctru_sys::KEY_CSTICK_UP; + /// C-Stick Down. const CSTICK_DOWN = ctru_sys::KEY_CSTICK_DOWN; + /// CirclePad Right. const CPAD_RIGHT = ctru_sys::KEY_CPAD_RIGHT; + /// CirclePad Left. const CPAD_LEFT = ctru_sys::KEY_CPAD_LEFT; + /// CirclePad Up. const CPAD_UP = ctru_sys::KEY_CPAD_UP; + /// CirclePad Down. const CPAD_DOWN = ctru_sys::KEY_CPAD_DOWN; - // Convenience catch-all for the dpad and cpad + + // Convenience catch-all for the D-Pad and the C-Pad + + /// Direction Up (either D-Pad or C-Pad). const UP = KeyPad::DPAD_UP.bits() | KeyPad::CPAD_UP.bits(); + /// Direction Down (either D-Pad or C-Pad). const DOWN = KeyPad::DPAD_DOWN.bits() | KeyPad::CPAD_DOWN.bits(); + /// Direction Left (either D-Pad or C-Pad). const LEFT = KeyPad::DPAD_LEFT.bits() | KeyPad::CPAD_LEFT.bits(); + /// Direction Right (either D-Pad or C-Pad).. const RIGHT = KeyPad::DPAD_RIGHT.bits() | KeyPad::CPAD_RIGHT.bits(); } } diff --git a/ctru-rs/src/services/ndsp/mod.rs b/ctru-rs/src/services/ndsp/mod.rs index 7867048..2ff9d7b 100644 --- a/ctru-rs/src/services/ndsp/mod.rs +++ b/ctru-rs/src/services/ndsp/mod.rs @@ -14,21 +14,30 @@ use std::sync::Mutex; const NUMBER_OF_CHANNELS: u8 = 24; +/// Audio output mode. #[doc(alias = "ndspOutputMode")] #[derive(Copy, Clone, Debug, PartialEq, Eq)] #[repr(u32)] pub enum OutputMode { + /// Single-Channel. Mono = ctru_sys::NDSP_OUTPUT_MONO, + /// Dual-Channel. Stereo = ctru_sys::NDSP_OUTPUT_STEREO, + /// Surround. Surround = ctru_sys::NDSP_OUTPUT_SURROUND, } +/// Audio PCM format. #[derive(Copy, Clone, Debug, PartialEq, Eq)] #[repr(u32)] pub enum AudioFormat { + /// PCM 8bit single-channel. PCM8Mono = ctru_sys::NDSP_FORMAT_MONO_PCM8, + /// PCM 16bit single-channel. PCM16Mono = ctru_sys::NDSP_FORMAT_MONO_PCM16, + /// PCM 8bit dual-channel. PCM8Stereo = ctru_sys::NDSP_FORMAT_STEREO_PCM8, + /// PCM 16bit dual-channel. PCM16Stereo = ctru_sys::NDSP_FORMAT_STEREO_PCM16, } @@ -38,15 +47,20 @@ pub struct AudioMix { raw: [f32; 12], } +/// Interpolation used between audio frames. #[doc(alias = "ndspInterpType")] #[derive(Copy, Clone, Debug, PartialEq, Eq)] #[repr(u32)] pub enum InterpolationType { + /// Polyphase interpolation. Polyphase = ctru_sys::NDSP_INTERP_POLYPHASE, + /// Linear interpolation. Linear = ctru_sys::NDSP_INTERP_LINEAR, + /// No interpolation. None = ctru_sys::NDSP_INTERP_NONE, } +/// Error enum returned by NDSP methods. #[derive(Copy, Clone, Debug, PartialEq, Eq)] pub enum NdspError { /// Channel ID diff --git a/ctru-rs/src/services/ndsp/wave.rs b/ctru-rs/src/services/ndsp/wave.rs index 6cc5847..9194685 100644 --- a/ctru-rs/src/services/ndsp/wave.rs +++ b/ctru-rs/src/services/ndsp/wave.rs @@ -15,9 +15,13 @@ pub struct Wave { #[repr(u8)] /// Enum representing the playback status of a [`Wave`]. pub enum WaveStatus { + /// Wave has never been used. Free = ctru_sys::NDSP_WBUF_FREE as u8, + /// Wave is currently queued for usage. Queued = ctru_sys::NDSP_WBUF_QUEUED as u8, + /// Wave is currently playing. Playing = ctru_sys::NDSP_WBUF_PLAYING as u8, + /// Wave has finished playing. Done = ctru_sys::NDSP_WBUF_DONE as u8, } diff --git a/ctru-rs/src/services/ps.rs b/ctru-rs/src/services/ps.rs index ee96216..0673ce8 100644 --- a/ctru-rs/src/services/ps.rs +++ b/ctru-rs/src/services/ps.rs @@ -6,31 +6,49 @@ use crate::error::ResultCode; use crate::Result; +/// Kind of AES algorithm to use. #[doc(alias = "PS_AESAlgorithm")] #[derive(Debug, Clone, Copy, PartialEq, Eq)] #[repr(u32)] pub enum AESAlgorithm { + /// CBC encryption. CbcEnc = ctru_sys::PS_ALGORITHM_CBC_ENC, + /// CBC decryption. CbcDec = ctru_sys::PS_ALGORITHM_CBC_DEC, + /// CTR encryption. CtrEnc = ctru_sys::PS_ALGORITHM_CTR_ENC, + /// CTR decryption. CtrDec = ctru_sys::PS_ALGORITHM_CTR_DEC, + /// CCM encryption. CcmEnc = ctru_sys::PS_ALGORITHM_CCM_ENC, + /// CCM decryption. CcmDec = ctru_sys::PS_ALGORITHM_CCM_DEC, } +/// PS Key slot to use. #[doc(alias = "PS_AESKeyType")] #[derive(Debug, Clone, Copy, PartialEq, Eq)] #[repr(u32)] pub enum AESKeyType { + /// Keyslot 0x0D. Keyslot0D = ctru_sys::PS_KEYSLOT_0D, + /// Keyslot 0x2D. Keyslot2D = ctru_sys::PS_KEYSLOT_2D, + /// Keyslot 0x2E. Keyslot2E = ctru_sys::PS_KEYSLOT_2E, + /// Keyslot 0x31. Keyslot31 = ctru_sys::PS_KEYSLOT_31, + /// Keyslot 0x32. Keyslot32 = ctru_sys::PS_KEYSLOT_32, + /// Keyslot 0x36. Keyslot36 = ctru_sys::PS_KEYSLOT_36, + /// Keyslot 0x38. Keyslot38 = ctru_sys::PS_KEYSLOT_38, + /// Keyslot 0x39 (DLP). Keyslot39Dlp = ctru_sys::PS_KEYSLOT_39_DLP, + /// Keyslot 0x39 (NFC). Keyslot39Nfc = ctru_sys::PS_KEYSLOT_39_NFC, + /// Invalid keyslot. KeyslotInvalid = ctru_sys::PS_KEYSLOT_INVALID, } diff --git a/ctru-rs/src/services/sslc.rs b/ctru-rs/src/services/sslc.rs index d248f0e..9b311e3 100644 --- a/ctru-rs/src/services/sslc.rs +++ b/ctru-rs/src/services/sslc.rs @@ -4,6 +4,7 @@ use crate::error::ResultCode; +/// Handle to the SSLC service. pub struct SslC(()); impl SslC {