Browse Source

Enum variants documentation + ide files ignored

pull/134/head
Andrea Ciliberti 1 year ago
parent
commit
61e20fa2dc
  1. 1
      .gitignore
  2. 16
      ctru-rs/src/applets/mii_selector.rs
  3. 49
      ctru-rs/src/applets/swkbd.rs
  4. 133
      ctru-rs/src/mii.rs
  5. 12
      ctru-rs/src/services/am.rs
  6. 63
      ctru-rs/src/services/cam.rs
  7. 30
      ctru-rs/src/services/cfgu.rs
  8. 35
      ctru-rs/src/services/fs.rs
  9. 10
      ctru-rs/src/services/gspgpu.rs
  10. 31
      ctru-rs/src/services/hid.rs
  11. 14
      ctru-rs/src/services/ndsp/mod.rs
  12. 4
      ctru-rs/src/services/ndsp/wave.rs
  13. 18
      ctru-rs/src/services/ps.rs
  14. 1
      ctru-rs/src/services/sslc.rs

1
.gitignore vendored

@ -4,3 +4,4 @@ Cargo.lock
# IDE files # IDE files
.idea .idea
.vscode

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

@ -6,18 +6,26 @@ use crate::mii::MiiData;
use bitflags::bitflags; use bitflags::bitflags;
use std::ffi::CString; use std::ffi::CString;
/// Index of a Mii used to configure some parameters of the Mii Selector /// Index of a Mii used to configure some parameters of the Mii Selector.
/// Can be either a single index, or _all_ Miis
#[derive(Debug, Clone, Copy, Eq, PartialEq)] #[derive(Debug, Clone, Copy, Eq, PartialEq)]
pub enum Index { pub enum Index {
/// Specific Mii index.
Index(u32), Index(u32),
/// All Miis.
All, All,
} }
/// The type of a Mii with their respective data /// The type of a Mii with their respective data
#[derive(Debug, Clone, Eq, PartialEq)] #[derive(Debug, Clone, Eq, PartialEq)]
pub enum MiiType { 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, User,
} }
@ -56,7 +64,9 @@ pub struct MiiSelector {
#[non_exhaustive] #[non_exhaustive]
#[derive(Clone, Debug)] #[derive(Clone, Debug)]
pub struct SelectionResult { pub struct SelectionResult {
/// Data regarding the selected Mii.
pub mii_data: MiiData, pub mii_data: MiiData,
/// Type of the selected Mii.
pub mii_type: MiiType, pub mii_type: MiiType,
} }

49
ctru-rs/src/applets/swkbd.rs

@ -14,19 +14,19 @@ pub struct Swkbd {
} }
/// The kind of keyboard to be initialized. /// 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")] #[doc(alias = "SwkbdType")]
#[derive(Copy, Clone, Debug, PartialEq, Eq)] #[derive(Copy, Clone, Debug, PartialEq, Eq)]
#[repr(u32)] #[repr(u32)]
pub enum Kind { pub enum Kind {
/// Normal keyboard composed of several pages (QWERTY, accents, symbols, mobile).
Normal = ctru_sys::SWKBD_TYPE_NORMAL, Normal = ctru_sys::SWKBD_TYPE_NORMAL,
/// Only QWERTY keyboard.
Qwerty = ctru_sys::SWKBD_TYPE_QWERTY, Qwerty = ctru_sys::SWKBD_TYPE_QWERTY,
/// Only number pad.
Numpad = ctru_sys::SWKBD_TYPE_NUMPAD, 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, Western = ctru_sys::SWKBD_TYPE_WESTERN,
} }
@ -35,8 +35,11 @@ pub enum Kind {
#[derive(Copy, Clone, Debug, PartialEq, Eq)] #[derive(Copy, Clone, Debug, PartialEq, Eq)]
#[repr(u32)] #[repr(u32)]
pub enum Button { pub enum Button {
/// Left button. Usually corresponds to "Cancel".
Left = ctru_sys::SWKBD_BUTTON_LEFT, Left = ctru_sys::SWKBD_BUTTON_LEFT,
/// Middle button. Usually corresponds to "I Forgot".
Middle = ctru_sys::SWKBD_BUTTON_MIDDLE, Middle = ctru_sys::SWKBD_BUTTON_MIDDLE,
/// Right button. Usually corresponds to "OK".
Right = ctru_sys::SWKBD_BUTTON_RIGHT, Right = ctru_sys::SWKBD_BUTTON_RIGHT,
} }
@ -45,49 +48,77 @@ pub enum Button {
#[derive(Copy, Clone, Debug, PartialEq, Eq)] #[derive(Copy, Clone, Debug, PartialEq, Eq)]
#[repr(i32)] #[repr(i32)]
pub enum Error { pub enum Error {
/// Invalid parameters inputted in the Software Keyboard.
InvalidInput = ctru_sys::SWKBD_INVALID_INPUT, InvalidInput = ctru_sys::SWKBD_INVALID_INPUT,
/// Out of memory.
OutOfMem = ctru_sys::SWKBD_OUTOFMEM, OutOfMem = ctru_sys::SWKBD_OUTOFMEM,
/// Home button was pressed during execution.
HomePressed = ctru_sys::SWKBD_HOMEPRESSED, HomePressed = ctru_sys::SWKBD_HOMEPRESSED,
/// Reset button was pressed during execution.
ResetPressed = ctru_sys::SWKBD_RESETPRESSED, ResetPressed = ctru_sys::SWKBD_RESETPRESSED,
/// Power button was pressed during execution.
PowerPressed = ctru_sys::SWKBD_POWERPRESSED, PowerPressed = ctru_sys::SWKBD_POWERPRESSED,
/// The parental PIN was correct.
ParentalOk = ctru_sys::SWKBD_PARENTAL_OK, ParentalOk = ctru_sys::SWKBD_PARENTAL_OK,
/// The parental PIN was incorrect.
ParentalFail = ctru_sys::SWKBD_PARENTAL_FAIL, ParentalFail = ctru_sys::SWKBD_PARENTAL_FAIL,
/// Input triggered the filter.
BannedInput = ctru_sys::SWKBD_BANNED_INPUT, BannedInput = ctru_sys::SWKBD_BANNED_INPUT,
} }
/// Restrictions on keyboard input /// Restrictions on keyboard input.
#[doc(alias = "SwkbdValidInput")] #[doc(alias = "SwkbdValidInput")]
#[derive(Copy, Clone, Debug, PartialEq, Eq)] #[derive(Copy, Clone, Debug, PartialEq, Eq)]
#[repr(u32)] #[repr(u32)]
pub enum ValidInput { pub enum ValidInput {
/// All inputs are accepted.
Anything = ctru_sys::SWKBD_ANYTHING, Anything = ctru_sys::SWKBD_ANYTHING,
/// Empty inputs are not accepted.
NotEmpty = ctru_sys::SWKBD_NOTEMPTY, 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, 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, FixedLen = ctru_sys::SWKBD_FIXEDLEN,
} }
bitflags! { bitflags! {
/// Keyboard feature flags /// Keyboard feature flags.
pub struct Features: u32 { pub struct Features: u32 {
/// Parental PIN mode.
const PARENTAL_PIN = ctru_sys::SWKBD_PARENTAL; 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; 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; const PREDICTIVE_INPUT = ctru_sys::SWKBD_PREDICTIVE_INPUT;
/// Enable multiline input.
const MULTILINE = ctru_sys::SWKBD_MULTILINE; const MULTILINE = ctru_sys::SWKBD_MULTILINE;
/// Enable fixed-width mode.
const FIXED_WIDTH = ctru_sys::SWKBD_FIXED_WIDTH; 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; 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; 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; 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; const DEFAULT_QWERTY = ctru_sys::SWKBD_DEFAULT_QWERTY;
} }
/// Keyboard input filtering flags /// Keyboard input filtering flags
pub struct Filters: u32 { pub struct Filters: u32 {
/// Disallows the usage of numerical digits.
const DIGITS = ctru_sys::SWKBD_FILTER_DIGITS; const DIGITS = ctru_sys::SWKBD_FILTER_DIGITS;
/// Disallows the usage of the "at" (@) sign.
const AT = ctru_sys::SWKBD_FILTER_AT; const AT = ctru_sys::SWKBD_FILTER_AT;
/// Disallows the usage of the "percent" (%) sign.
const PERCENT = ctru_sys::SWKBD_FILTER_PERCENT; const PERCENT = ctru_sys::SWKBD_FILTER_PERCENT;
/// Disallows the usage of the "backslash" (\) sign.
const BACKSLASH = ctru_sys::SWKBD_FILTER_BACKSLASH; const BACKSLASH = ctru_sys::SWKBD_FILTER_BACKSLASH;
/// Disallows the use of profanity via Nintendo's profanity filter.
const PROFANITY = ctru_sys::SWKBD_FILTER_PROFANITY; const PROFANITY = ctru_sys::SWKBD_FILTER_PROFANITY;
/// Use a custom callback in order to filter the input.
const CALLBACK = ctru_sys::SWKBD_FILTER_CALLBACK; const CALLBACK = ctru_sys::SWKBD_FILTER_CALLBACK;
} }
} }

133
ctru-rs/src/mii.rs

@ -3,171 +3,238 @@
//! 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) //! 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)] #[derive(Copy, Clone, Debug, Eq, PartialEq)]
pub enum RegionLock { pub enum RegionLock {
/// No region-lock.
None, None,
/// Japan region-lock.
Japan, Japan,
/// USA region-lock.
USA, USA,
/// Europe region-lock.
Europe, Europe,
} }
/// Represent the charset of the console /// Represent the charset of the console.
#[derive(Copy, Clone, Debug, Eq, PartialEq)] #[derive(Copy, Clone, Debug, Eq, PartialEq)]
pub enum Charset { pub enum Charset {
/// Japan-USA-Europe unified charset.
JapanUSAEurope, JapanUSAEurope,
/// China charset.
China, China,
/// Korea charset.
Korea, Korea,
/// Taiwan charset.
Taiwan, Taiwan,
} }
/// Represents the options of the Mii /// Represents the options of the Mii.
#[derive(Copy, Clone, Debug)] #[derive(Copy, Clone, Debug)]
pub struct MiiDataOptions { pub struct MiiDataOptions {
/// Whether it is allowed to copy the Mii.
pub is_copying_allowed: bool, pub is_copying_allowed: bool,
/// Whether the profanity flag is active.
pub is_profanity_flag_enabled: bool, pub is_profanity_flag_enabled: bool,
/// The Mii's active region-lock.
pub region_lock: RegionLock, pub region_lock: RegionLock,
/// The Mii's used charset.
pub charset: 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)] #[derive(Copy, Clone, Debug)]
pub struct SelectorPosition { pub struct SelectorPosition {
/// Index of the page where the Mii is found.
pub page_index: u8, pub page_index: u8,
/// Index of the slot (relative to the page) where the Mii is found.
pub slot_index: u8, pub slot_index: u8,
} }
/// Represents the kind of origin console /// Represents the console where the Mii originated from.
#[derive(Copy, Clone, Debug, Eq, PartialEq)] #[derive(Copy, Clone, Debug, Eq, PartialEq)]
pub enum OriginConsole { pub enum OriginConsole {
/// Nintendo Wii.
Wii, Wii,
/// Nintendo DSi.
DSi, DSi,
/// Both New 3DS and Old 3DS /// Nintendo 3DS (both New 3DS and Old 3DS).
N3DS, N3DS,
/// Nintendo WiiU/Switch.
WiiUSwitch, WiiUSwitch,
} }
/// Represents the identity of the origin console /// Represents the 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.
pub origin_console: OriginConsole, pub origin_console: OriginConsole,
} }
/// Represents the sex of the Mii /// Represents the sex of the Mii.
#[derive(Copy, Clone, Debug, Eq, PartialEq)] #[derive(Copy, Clone, Debug, Eq, PartialEq)]
pub enum MiiSex { pub enum MiiSex {
/// Male sex.
Male, Male,
/// Female sex.
Female, Female,
} }
/// Represents the details of the Mii /// Represents the details of the Mii.
#[derive(Copy, Clone, Debug)] #[derive(Copy, Clone, Debug)]
pub struct Details { pub struct Details {
/// Sex of the Mii.
pub sex: MiiSex, pub sex: MiiSex,
/// Birthday month.
pub birthday_month: u8, pub birthday_month: u8,
/// Birthday day.
pub birthday_day: u8, pub birthday_day: u8,
/// Color of the Mii's shirt.
pub shirt_color: u8, pub shirt_color: u8,
/// Whether the Mii is a favorite.
pub is_favorite: bool, 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)] #[derive(Copy, Clone, Debug)]
pub struct FaceStyle { pub struct FaceStyle {
pub is_sharing_enabled: bool, /// Face shape.
pub shape: u8, pub shape: u8,
/// Skin color.
pub skin_color: u8, pub skin_color: u8,
} }
/// Represents the face details of the Mii /// Represents the face details of the Mii.
#[derive(Copy, Clone, Debug)] #[derive(Copy, Clone, Debug)]
pub struct FaceDetails { pub struct FaceDetails {
/// Face style.
pub style: FaceStyle, pub style: FaceStyle,
/// Wrinkles.
pub wrinkles: u8, pub wrinkles: u8,
/// Makeup.
pub makeup: u8, pub makeup: u8,
} }
/// Represents the hair details of the Mii /// Represents the hair details of the Mii.
#[derive(Copy, Clone, Debug)] #[derive(Copy, Clone, Debug)]
pub struct HairDetails { pub struct HairDetails {
/// Hair style.
pub style: u8, pub style: u8,
/// Hair color.
pub color: u8, pub color: u8,
/// Whether the Mii's hair is flipped.
pub is_flipped: bool, pub is_flipped: bool,
} }
/// Represents the eye details of the Mii /// Represents the eye details of the Mii.
#[derive(Copy, Clone, Debug)] #[derive(Copy, Clone, Debug)]
pub struct EyeDetails { pub struct EyeDetails {
/// Eye style.
pub style: u8, pub style: u8,
/// Eye color.
pub color: u8, pub color: u8,
/// Eye scale.
pub scale: u8, pub scale: u8,
/// Eye scale (y-axis).
pub y_scale: u8, pub y_scale: u8,
/// Eye rotation.
pub rotation: u8, pub rotation: u8,
/// Spacing between the eyes /// Spacing between the eyes.
pub x_spacing: u8, pub x_spacing: u8,
/// Eye height.
pub y_position: u8, pub y_position: u8,
} }
/// Represents the eyebrow details of the Mii /// Represents the eyebrow details of the Mii
#[derive(Copy, Clone, Debug)] #[derive(Copy, Clone, Debug)]
pub struct EyebrowDetails { pub struct EyebrowDetails {
/// Eyebrow style.
pub style: u8, pub style: u8,
/// Eyebrow color.
pub color: u8, pub color: u8,
/// Eyebrow scale.
pub scale: u8, pub scale: u8,
/// Eyebrow scale (y-axis).
pub y_scale: u8, pub y_scale: u8,
/// Eyebrow rotation.
pub rotation: u8, pub rotation: u8,
/// Spacing between the eyebrows /// Spacing between the eyebrows
pub x_spacing: u8, pub x_spacing: u8,
/// Eyebrow height.
pub y_position: u8, pub y_position: u8,
} }
/// Represents the details of the nose /// Represents the details of the nose
#[derive(Copy, Clone, Debug)] #[derive(Copy, Clone, Debug)]
pub struct NoseDetails { pub struct NoseDetails {
/// Nose style.
pub style: u8, pub style: u8,
/// Nose scale.
pub scale: u8, pub scale: u8,
/// Nose height.
pub y_position: u8, pub y_position: u8,
} }
/// Represents the details of the mouth /// Represents the details of the mouth
#[derive(Copy, Clone, Debug)] #[derive(Copy, Clone, Debug)]
pub struct MouthDetails { pub struct MouthDetails {
/// Mouth style.
pub style: u8, pub style: u8,
/// Mouth color.
pub color: u8, pub color: u8,
/// Mouth scale.
pub scale: u8, pub scale: u8,
/// Mouth scale (y-axis).
pub y_scale: u8, pub y_scale: u8,
/// Mouth height.
pub y_position: u8,
} }
/// Represents the details of the mustache /// Represents the details of the mustache
#[derive(Copy, Clone, Debug)] #[derive(Copy, Clone, Debug)]
pub struct MustacheDetails { pub struct MustacheDetails {
pub mouth_y_position: u8, /// Mustache style.
pub mustache_style: u8, pub mustache_style: u8,
} }
/// Represents the details of the beard /// Represents the details of the beard
#[derive(Copy, Clone, Debug)] #[derive(Copy, Clone, Debug)]
pub struct BeardDetails { pub struct BeardDetails {
/// Beard style
pub style: u8, pub style: u8,
/// Beard color.
pub color: u8, pub color: u8,
/// Beard scale.
pub scale: u8, pub scale: u8,
/// Beard height.
pub y_position: u8, pub y_position: u8,
} }
/// Represents the details of the glass /// Represents the details of the glasses
#[derive(Copy, Clone, Debug)] #[derive(Copy, Clone, Debug)]
pub struct GlassDetails { pub struct GlassesDetails {
/// Glasses style.
pub style: u8, pub style: u8,
/// Glasses color.
pub color: u8, pub color: u8,
/// Glasses scale.
pub scale: u8, pub scale: u8,
/// Glasses height.
pub y_position: u8, pub y_position: u8,
} }
/// Represents the details of the mole /// Represents the details of the mole.
#[derive(Copy, Clone, Debug)] #[derive(Copy, Clone, Debug)]
pub struct MoleDetails { pub struct MoleDetails {
/// Whether the Mii has a mole.
pub is_enabled: bool, pub is_enabled: bool,
/// Mole scale.
pub scale: u8, pub scale: u8,
/// Mole position (x-axis).
pub x_position: u8, pub x_position: u8,
/// Mole position (y-axis).
pub y_position: u8, pub y_position: u8,
} }
@ -177,34 +244,52 @@ pub struct MoleDetails {
/// <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 is returned by the [`MiiSelector`](crate::applets::mii_selector::MiiSelector)
#[doc(alias = "MiiData")]
#[derive(Clone, Debug)] #[derive(Clone, Debug)]
pub struct MiiData { pub struct MiiData {
/// Mii options.
pub options: MiiDataOptions, pub options: MiiDataOptions,
/// Position taken by the Mii on the Mii Selector screen.
pub selector_position: SelectorPosition, pub selector_position: SelectorPosition,
/// Console the Mii was created on.
pub console_identity: ConsoleIdentity, pub console_identity: ConsoleIdentity,
/// Unique system ID, not dependant on the MAC address /// Unique system ID, not dependant on the MAC address
pub system_id: [u8; 8], pub system_id: [u8; 8],
/// Console's MAC address.
pub mac_address: [u8; 6], pub mac_address: [u8; 6],
/// General information about the Mii.
pub details: Details, pub details: Details,
/// Mii name.
pub name: String, pub name: String,
/// Mii height.
pub height: u8, pub height: u8,
/// Mii width.
pub width: u8, pub width: u8,
/// Face details.
pub face_details: FaceDetails, pub face_details: FaceDetails,
/// Hair details.
pub hair_details: HairDetails, pub hair_details: HairDetails,
/// Eyes details.
pub eye_details: EyeDetails, pub eye_details: EyeDetails,
/// Eyebrow details.
pub eyebrow_details: EyebrowDetails, pub eyebrow_details: EyebrowDetails,
/// Nose details.
pub nose_details: NoseDetails, pub nose_details: NoseDetails,
/// Mouth details.
pub mouth_details: MouthDetails, pub mouth_details: MouthDetails,
/// Mustache details.
pub mustache_details: MustacheDetails, pub mustache_details: MustacheDetails,
/// Beard details.
pub beard_details: BeardDetails, pub beard_details: BeardDetails,
pub glass_details: GlassDetails, /// Glasses details.
pub glass_details: GlassesDetails,
/// Mole details.
pub mole_details: MoleDetails, pub mole_details: MoleDetails,
/// Name of the Mii's original author.
pub author_name: String, pub author_name: String,
} }
@ -321,11 +406,11 @@ impl From<ctru_sys::MiiData> for MiiData {
birthday_day: partial_u8_bits_to_u8(&raw_details[5..=9]), birthday_day: partial_u8_bits_to_u8(&raw_details[5..=9]),
shirt_color: partial_u8_bits_to_u8(&raw_details[10..=13]), shirt_color: partial_u8_bits_to_u8(&raw_details[10..=13]),
is_favorite: raw_details[14], is_favorite: raw_details[14],
is_sharing_enabled: !raw_face_style[0],
}; };
let face_details = FaceDetails { let face_details = FaceDetails {
style: FaceStyle { style: FaceStyle {
is_sharing_enabled: !raw_face_style[0],
shape: partial_u8_bits_to_u8(&raw_face_style[1..=4]), shape: partial_u8_bits_to_u8(&raw_face_style[1..=4]),
skin_color: partial_u8_bits_to_u8(&raw_face_style[5..=7]), skin_color: partial_u8_bits_to_u8(&raw_face_style[5..=7]),
}, },
@ -372,10 +457,10 @@ impl From<ctru_sys::MiiData> for MiiData {
color: partial_u8_bits_to_u8(&raw_mouth_details[6..=8]), color: partial_u8_bits_to_u8(&raw_mouth_details[6..=8]),
scale: partial_u8_bits_to_u8(&raw_mouth_details[9..=12]), scale: partial_u8_bits_to_u8(&raw_mouth_details[9..=12]),
y_scale: partial_u8_bits_to_u8(&raw_mouth_details[13..=15]), 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 { 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]), mustache_style: partial_u8_bits_to_u8(&raw_mustache_details[5..=7]),
}; };
@ -386,7 +471,7 @@ impl From<ctru_sys::MiiData> for MiiData {
y_position: partial_u8_bits_to_u8(&raw_beard_details[10..=14]), 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]), style: partial_u8_bits_to_u8(&raw_glass_details[0..=3]),
color: partial_u8_bits_to_u8(&raw_glass_details[4..=6]), color: partial_u8_bits_to_u8(&raw_glass_details[4..=6]),
scale: partial_u8_bits_to_u8(&raw_glass_details[7..=10]), scale: partial_u8_bits_to_u8(&raw_glass_details[7..=10]),

12
ctru-rs/src/services/am.rs

@ -62,9 +62,9 @@ impl<'a> Title<'a> {
/// Returns the size of this title in bytes. /// Returns the size of this title in bytes.
pub fn size(&self) -> crate::Result<u64> { pub fn size(&self) -> crate::Result<u64> {
// Get the internal entry, or fill it if empty. // Get the internal entry, or fill it if empty.
let entry = self.entry.get_or_try_init(|| -> crate::Result<ctru_sys::AM_TitleEntry> { let entry = self
self.title_info() .entry
})?; .get_or_try_init(|| -> crate::Result<ctru_sys::AM_TitleEntry> { self.title_info() })?;
Ok(entry.size) Ok(entry.size)
} }
@ -72,9 +72,9 @@ impl<'a> Title<'a> {
/// Returns the installed version of this title. /// Returns the installed version of this title.
pub fn version(&self) -> crate::Result<u16> { pub fn version(&self) -> crate::Result<u16> {
// Get the internal entry, or fill it if empty. // Get the internal entry, or fill it if empty.
let entry = self.entry.get_or_try_init(|| -> crate::Result<ctru_sys::AM_TitleEntry> { let entry = self
self.title_info() .entry
})?; .get_or_try_init(|| -> crate::Result<ctru_sys::AM_TitleEntry> { self.title_info() })?;
Ok(entry.version) Ok(entry.version)
} }

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

@ -14,9 +14,13 @@ use std::time::Duration;
/// This service requires no special permissions to use. /// This service requires no special permissions to use.
#[non_exhaustive] #[non_exhaustive]
pub struct Cam { pub struct Cam {
/// Inside-facing camera.
pub inner_cam: InwardCam, pub inner_cam: InwardCam,
/// Outside-facing right camera.
pub outer_right_cam: OutwardRightCam, pub outer_right_cam: OutwardRightCam,
/// Outside-facing left camera.
pub outer_left_cam: OutwardLeftCam, pub outer_left_cam: OutwardLeftCam,
/// Both outside-facing cameras (mainly used for 3D photos).
pub both_outer_cams: BothOutwardCam, pub both_outer_cams: BothOutwardCam,
} }
@ -25,9 +29,13 @@ pub struct Cam {
#[derive(Copy, Clone, Debug, PartialEq, Eq)] #[derive(Copy, Clone, Debug, PartialEq, Eq)]
#[repr(u32)] #[repr(u32)]
pub enum FlipMode { pub enum FlipMode {
/// No flip applied.
None = ctru_sys::FLIP_NONE, None = ctru_sys::FLIP_NONE,
/// Horizontal flip applied.
Horizontal = ctru_sys::FLIP_HORIZONTAL, Horizontal = ctru_sys::FLIP_HORIZONTAL,
/// Vertical flip applied.
Vertical = ctru_sys::FLIP_VERTICAL, Vertical = ctru_sys::FLIP_VERTICAL,
/// Both vertical and horizontal flip applied.
Reverse = ctru_sys::FLIP_REVERSE, Reverse = ctru_sys::FLIP_REVERSE,
} }
@ -36,16 +44,25 @@ pub enum FlipMode {
#[derive(Copy, Clone, Debug, PartialEq, Eq)] #[derive(Copy, Clone, Debug, PartialEq, Eq)]
#[repr(u32)] #[repr(u32)]
pub enum ViewSize { 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, 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, BottomLCD = ctru_sys::SIZE_CTR_BOTTOM_LCD,
/// VGA display size. (640×480)
Vga = ctru_sys::SIZE_VGA, Vga = ctru_sys::SIZE_VGA,
/// QQVGA display size. (160×120)
QQVga = ctru_sys::SIZE_QQVGA, QQVga = ctru_sys::SIZE_QQVGA,
/// CIF display size. (352 × 288)
Cif = ctru_sys::SIZE_CIF, Cif = ctru_sys::SIZE_CIF,
/// QCIF display size. (176 × 144)
QCif = ctru_sys::SIZE_QCIF, QCif = ctru_sys::SIZE_QCIF,
/// Nintendo DS Screen /// Nintendo DS Screen size. (256 × 192)
DS = ctru_sys::SIZE_DS_LCD, DS = ctru_sys::SIZE_DS_LCD,
/// Nintendo DS Screen x4 /// Nintendo DS Screen size x4. (512 × 384)
DSX4 = ctru_sys::SIZE_DS_LCDx4, DSX4 = ctru_sys::SIZE_DS_LCDx4,
} }
@ -54,18 +71,31 @@ pub enum ViewSize {
#[derive(Copy, Clone, Debug, PartialEq, Eq)] #[derive(Copy, Clone, Debug, PartialEq, Eq)]
#[repr(u32)] #[repr(u32)]
pub enum FrameRate { pub enum FrameRate {
/// 15 FPS.
Fps15 = ctru_sys::FRAME_RATE_15, Fps15 = ctru_sys::FRAME_RATE_15,
/// 15 to 5 FPS.
Fps15To5 = ctru_sys::FRAME_RATE_15_TO_5, Fps15To5 = ctru_sys::FRAME_RATE_15_TO_5,
/// 15 to 2 FPS.
Fps15To2 = ctru_sys::FRAME_RATE_15_TO_2, Fps15To2 = ctru_sys::FRAME_RATE_15_TO_2,
/// 10 FPS.
Fps10 = ctru_sys::FRAME_RATE_10, Fps10 = ctru_sys::FRAME_RATE_10,
/// 8.5 FPS.
Fps8_5 = ctru_sys::FRAME_RATE_8_5, Fps8_5 = ctru_sys::FRAME_RATE_8_5,
/// 5 FPS.
Fps5 = ctru_sys::FRAME_RATE_5, Fps5 = ctru_sys::FRAME_RATE_5,
/// 20 FPS.
Fps20 = ctru_sys::FRAME_RATE_20, Fps20 = ctru_sys::FRAME_RATE_20,
/// 20 to 5 FPS.
Fps20To5 = ctru_sys::FRAME_RATE_20_TO_5, Fps20To5 = ctru_sys::FRAME_RATE_20_TO_5,
/// 30 FPS.
Fps30 = ctru_sys::FRAME_RATE_30, Fps30 = ctru_sys::FRAME_RATE_30,
/// 30 to 5 FPS.
Fps30To5 = ctru_sys::FRAME_RATE_30_TO_5, Fps30To5 = ctru_sys::FRAME_RATE_30_TO_5,
/// 15 to 10 FPS.
Fps15To10 = ctru_sys::FRAME_RATE_15_TO_10, Fps15To10 = ctru_sys::FRAME_RATE_15_TO_10,
/// 20 to 10 FPS.
Fps20To10 = ctru_sys::FRAME_RATE_20_TO_10, Fps20To10 = ctru_sys::FRAME_RATE_20_TO_10,
/// 30 to 10 FPS.
Fps30To10 = ctru_sys::FRAME_RATE_30_TO_10, Fps30To10 = ctru_sys::FRAME_RATE_30_TO_10,
} }
@ -85,7 +115,7 @@ pub enum WhiteBalance {
Temp5200K = ctru_sys::WHITE_BALANCE_5200K, Temp5200K = ctru_sys::WHITE_BALANCE_5200K,
/// Cloudy/Horizon /// Cloudy/Horizon
Temp6000K = ctru_sys::WHITE_BALANCE_6000K, Temp6000K = ctru_sys::WHITE_BALANCE_6000K,
///Shade /// Shade
Temp7000K = ctru_sys::WHITE_BALANCE_7000K, Temp7000K = ctru_sys::WHITE_BALANCE_7000K,
} }
@ -94,10 +124,15 @@ pub enum WhiteBalance {
#[derive(Copy, Clone, Debug, PartialEq, Eq)] #[derive(Copy, Clone, Debug, PartialEq, Eq)]
#[repr(u32)] #[repr(u32)]
pub enum PhotoMode { pub enum PhotoMode {
/// Normal mode.
Normal = ctru_sys::PHOTO_MODE_NORMAL, Normal = ctru_sys::PHOTO_MODE_NORMAL,
/// Portrait mode.
Portrait = ctru_sys::PHOTO_MODE_PORTRAIT, Portrait = ctru_sys::PHOTO_MODE_PORTRAIT,
/// Landscape mode.
Landscape = ctru_sys::PHOTO_MODE_LANDSCAPE, Landscape = ctru_sys::PHOTO_MODE_LANDSCAPE,
/// NightView mode.
NightView = ctru_sys::PHOTO_MODE_NIGHTVIEW, NightView = ctru_sys::PHOTO_MODE_NIGHTVIEW,
/// Letter mode.
Letter = ctru_sys::PHOTO_MODE_LETTER, Letter = ctru_sys::PHOTO_MODE_LETTER,
} }
@ -106,11 +141,17 @@ pub enum PhotoMode {
#[derive(Copy, Clone, Debug, PartialEq, Eq)] #[derive(Copy, Clone, Debug, PartialEq, Eq)]
#[repr(u32)] #[repr(u32)]
pub enum Effect { pub enum Effect {
/// No effects.
None = ctru_sys::EFFECT_NONE, None = ctru_sys::EFFECT_NONE,
/// Mono effect.
Mono = ctru_sys::EFFECT_MONO, Mono = ctru_sys::EFFECT_MONO,
/// Sepia effect.
Sepia = ctru_sys::EFFECT_SEPIA, Sepia = ctru_sys::EFFECT_SEPIA,
/// Negative effect.
Negative = ctru_sys::EFFECT_NEGATIVE, Negative = ctru_sys::EFFECT_NEGATIVE,
/// Negative film effect.
Negafilm = ctru_sys::EFFECT_NEGAFILM, Negafilm = ctru_sys::EFFECT_NEGAFILM,
/// Sepia effect. (unknown difference)
Sepia01 = ctru_sys::EFFECT_SEPIA01, Sepia01 = ctru_sys::EFFECT_SEPIA01,
} }
@ -119,11 +160,11 @@ pub enum Effect {
#[derive(Copy, Clone, Debug, PartialEq, Eq)] #[derive(Copy, Clone, Debug, PartialEq, Eq)]
#[repr(u32)] #[repr(u32)]
pub enum Contrast { pub enum Contrast {
/// OFF /// Low contrast.
Low = ctru_sys::CONTRAST_LOW, Low = ctru_sys::CONTRAST_LOW,
/// Brightness ratio: 70 /// Brightness ratio: 70.
Normal = ctru_sys::CONTRAST_NORMAL, Normal = ctru_sys::CONTRAST_NORMAL,
/// Brightness ratio: 90 /// Brightness ratio: 90.
High = ctru_sys::CONTRAST_HIGH, High = ctru_sys::CONTRAST_HIGH,
} }
@ -132,8 +173,11 @@ pub enum Contrast {
#[derive(Copy, Clone, Debug, PartialEq, Eq)] #[derive(Copy, Clone, Debug, PartialEq, Eq)]
#[repr(u32)] #[repr(u32)]
pub enum LensCorrection { pub enum LensCorrection {
/// No lens correction.
Off = ctru_sys::LENS_CORRECTION_DARK, Off = ctru_sys::LENS_CORRECTION_DARK,
/// Normal lens correction.
Normal = ctru_sys::LENS_CORRECTION_NORMAL, Normal = ctru_sys::LENS_CORRECTION_NORMAL,
/// Bright lens correction.
Bright = ctru_sys::LENS_CORRECTION_BRIGHT, Bright = ctru_sys::LENS_CORRECTION_BRIGHT,
} }
@ -142,7 +186,9 @@ pub enum LensCorrection {
#[derive(Copy, Clone, Debug, PartialEq, Eq)] #[derive(Copy, Clone, Debug, PartialEq, Eq)]
#[repr(u32)] #[repr(u32)]
pub enum OutputFormat { pub enum OutputFormat {
/// YUV422 output format. 16 bits per pixel.
Yuv422 = ctru_sys::OUTPUT_YUV_422, Yuv422 = ctru_sys::OUTPUT_YUV_422,
/// RGB565 output format. 16 bits per pixel.
Rgb565 = ctru_sys::OUTPUT_RGB_565, Rgb565 = ctru_sys::OUTPUT_RGB_565,
} }
@ -151,8 +197,11 @@ pub enum OutputFormat {
#[derive(Copy, Clone, Debug, PartialEq, Eq)] #[derive(Copy, Clone, Debug, PartialEq, Eq)]
#[repr(u32)] #[repr(u32)]
pub enum ShutterSound { pub enum ShutterSound {
/// Normal shutter sound.
Normal = ctru_sys::SHUTTER_SOUND_TYPE_NORMAL, Normal = ctru_sys::SHUTTER_SOUND_TYPE_NORMAL,
/// Shutter sound to begin a movie recording.
Movie = ctru_sys::SHUTTER_SOUND_TYPE_MOVIE, Movie = ctru_sys::SHUTTER_SOUND_TYPE_MOVIE,
/// Shutter sound to finish a movie recording.
MovieEnd = ctru_sys::SHUTTER_SOUND_TYPE_MOVIE_END, MovieEnd = ctru_sys::SHUTTER_SOUND_TYPE_MOVIE_END,
} }

30
ctru-rs/src/services/cfgu.rs

@ -4,46 +4,74 @@
use crate::error::ResultCode; use crate::error::ResultCode;
/// Console's region.
#[doc(alias = "CFG_Region")] #[doc(alias = "CFG_Region")]
#[derive(Copy, Clone, Debug, PartialEq, Eq)] #[derive(Copy, Clone, Debug, PartialEq, Eq)]
#[repr(u32)] #[repr(u32)]
pub enum Region { pub enum Region {
/// Japan.
Japan = ctru_sys::CFG_REGION_JPN, Japan = ctru_sys::CFG_REGION_JPN,
/// USA.
USA = ctru_sys::CFG_REGION_USA, USA = ctru_sys::CFG_REGION_USA,
/// Europe.
Europe = ctru_sys::CFG_REGION_EUR, Europe = ctru_sys::CFG_REGION_EUR,
/// Australia.
Australia = ctru_sys::CFG_REGION_AUS, Australia = ctru_sys::CFG_REGION_AUS,
/// China.
China = ctru_sys::CFG_REGION_CHN, China = ctru_sys::CFG_REGION_CHN,
/// Korea.
Korea = ctru_sys::CFG_REGION_KOR, Korea = ctru_sys::CFG_REGION_KOR,
/// Taiwan.
Taiwan = ctru_sys::CFG_REGION_TWN, Taiwan = ctru_sys::CFG_REGION_TWN,
} }
/// Language set for the console's OS.
#[doc(alias = "CFG_Language")] #[doc(alias = "CFG_Language")]
#[derive(Copy, Clone, Debug, PartialEq, Eq)] #[derive(Copy, Clone, Debug, PartialEq, Eq)]
#[repr(u32)] #[repr(u32)]
pub enum Language { pub enum Language {
/// Japanese.
Japanese = ctru_sys::CFG_LANGUAGE_JP, Japanese = ctru_sys::CFG_LANGUAGE_JP,
/// English.
English = ctru_sys::CFG_LANGUAGE_EN, English = ctru_sys::CFG_LANGUAGE_EN,
/// French.
French = ctru_sys::CFG_LANGUAGE_FR, French = ctru_sys::CFG_LANGUAGE_FR,
/// German.
German = ctru_sys::CFG_LANGUAGE_DE, German = ctru_sys::CFG_LANGUAGE_DE,
/// Italian.
Italian = ctru_sys::CFG_LANGUAGE_IT, Italian = ctru_sys::CFG_LANGUAGE_IT,
/// Spanish.
Spanish = ctru_sys::CFG_LANGUAGE_ES, Spanish = ctru_sys::CFG_LANGUAGE_ES,
SimplifiedChinese = ctru_sys::CFG_LANGUAGE_ZH, /// Korean.
Korean = ctru_sys::CFG_LANGUAGE_KO, Korean = ctru_sys::CFG_LANGUAGE_KO,
/// Dutch.
Dutch = ctru_sys::CFG_LANGUAGE_NL, Dutch = ctru_sys::CFG_LANGUAGE_NL,
/// Portuguese.
Portuguese = ctru_sys::CFG_LANGUAGE_PT, Portuguese = ctru_sys::CFG_LANGUAGE_PT,
/// Russian.
Russian = ctru_sys::CFG_LANGUAGE_RU, Russian = ctru_sys::CFG_LANGUAGE_RU,
/// Simplified Chinese.
SimplifiedChinese = ctru_sys::CFG_LANGUAGE_ZH,
/// Traditional Chinese.
TraditionalChinese = ctru_sys::CFG_LANGUAGE_TW, TraditionalChinese = ctru_sys::CFG_LANGUAGE_TW,
} }
/// 3DS model.
#[doc(alias = "CFG_SystemModel")] #[doc(alias = "CFG_SystemModel")]
#[derive(Copy, Clone, Debug, PartialEq, Eq)] #[derive(Copy, Clone, Debug, PartialEq, Eq)]
#[repr(u32)] #[repr(u32)]
pub enum SystemModel { pub enum SystemModel {
/// Old Nintendo 3DS.
Old3DS = ctru_sys::CFG_MODEL_3DS, Old3DS = ctru_sys::CFG_MODEL_3DS,
/// Old Nintendo 3DS XL.
Old3DSXL = ctru_sys::CFG_MODEL_3DSXL, Old3DSXL = ctru_sys::CFG_MODEL_3DSXL,
/// New Nintendo 3DS.
New3DS = ctru_sys::CFG_MODEL_N3DS, New3DS = ctru_sys::CFG_MODEL_N3DS,
/// Old Nintendo 2DS.
Old2DS = ctru_sys::CFG_MODEL_2DS, Old2DS = ctru_sys::CFG_MODEL_2DS,
/// New Nintendo 3DS XL.
New3DSXL = ctru_sys::CFG_MODEL_N3DSXL, New3DSXL = ctru_sys::CFG_MODEL_N3DSXL,
/// New Nintendo 2DS XL.
New2DSXL = ctru_sys::CFG_MODEL_N2DSXL, New2DSXL = ctru_sys::CFG_MODEL_N2DSXL,
} }

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

@ -39,51 +39,86 @@ bitflags! {
} }
} }
/// Media type used for storage.
#[doc(alias = "FS_MediaType")] #[doc(alias = "FS_MediaType")]
#[derive(Copy, Clone, Debug, PartialEq, Eq)] #[derive(Copy, Clone, Debug, PartialEq, Eq)]
#[repr(u32)] #[repr(u32)]
pub enum FsMediaType { pub enum FsMediaType {
/// Internal NAND memory.
Nand = ctru_sys::MEDIATYPE_NAND, Nand = ctru_sys::MEDIATYPE_NAND,
/// External SD card.
Sd = ctru_sys::MEDIATYPE_SD, Sd = ctru_sys::MEDIATYPE_SD,
/// Game Cartridge.
GameCard = ctru_sys::MEDIATYPE_GAME_CARD, GameCard = ctru_sys::MEDIATYPE_GAME_CARD,
} }
/// Kind of file path.
#[doc(alias = "FS_PathType")] #[doc(alias = "FS_PathType")]
#[derive(Copy, Clone, Debug, PartialEq, Eq)] #[derive(Copy, Clone, Debug, PartialEq, Eq)]
#[repr(u32)] #[repr(u32)]
pub enum PathType { pub enum PathType {
/// Invalid path.
Invalid = ctru_sys::PATH_INVALID, Invalid = ctru_sys::PATH_INVALID,
/// Empty path.
Empty = ctru_sys::PATH_EMPTY, Empty = ctru_sys::PATH_EMPTY,
/// Binary path.
///
/// Its meaning differs depending on the Archive it is used on.
Binary = ctru_sys::PATH_BINARY, Binary = ctru_sys::PATH_BINARY,
/// ASCII path.
ASCII = ctru_sys::PATH_ASCII, ASCII = ctru_sys::PATH_ASCII,
/// UTF-16 path.
UTF16 = ctru_sys::PATH_UTF16, UTF16 = ctru_sys::PATH_UTF16,
} }
/// Index of the various usable data archives.
#[doc(alias = "FS_ArchiveID")] #[doc(alias = "FS_ArchiveID")]
#[derive(Copy, Clone, Debug, PartialEq, Eq)] #[derive(Copy, Clone, Debug, PartialEq, Eq)]
#[repr(u32)] #[repr(u32)]
pub enum ArchiveID { pub enum ArchiveID {
/// Read-Only Memory File System.
RomFS = ctru_sys::ARCHIVE_ROMFS, RomFS = ctru_sys::ARCHIVE_ROMFS,
/// Game save data.
Savedata = ctru_sys::ARCHIVE_SAVEDATA, Savedata = ctru_sys::ARCHIVE_SAVEDATA,
/// Game ext data.
Extdata = ctru_sys::ARCHIVE_EXTDATA, Extdata = ctru_sys::ARCHIVE_EXTDATA,
/// Shared ext data.
SharedExtdata = ctru_sys::ARCHIVE_SHARED_EXTDATA, SharedExtdata = ctru_sys::ARCHIVE_SHARED_EXTDATA,
/// System save data.
SystemSavedata = ctru_sys::ARCHIVE_SYSTEM_SAVEDATA, SystemSavedata = ctru_sys::ARCHIVE_SYSTEM_SAVEDATA,
/// SD card.
Sdmc = ctru_sys::ARCHIVE_SDMC, Sdmc = ctru_sys::ARCHIVE_SDMC,
/// SD card (write-only).
SdmcWriteOnly = ctru_sys::ARCHIVE_SDMC_WRITE_ONLY, SdmcWriteOnly = ctru_sys::ARCHIVE_SDMC_WRITE_ONLY,
/// BOSS ext data.
BossExtdata = ctru_sys::ARCHIVE_BOSS_EXTDATA, BossExtdata = ctru_sys::ARCHIVE_BOSS_EXTDATA,
/// Card SPI File System.
CardSpiFS = ctru_sys::ARCHIVE_CARD_SPIFS, CardSpiFS = ctru_sys::ARCHIVE_CARD_SPIFS,
/// Game ext data and BOSS data.
ExtDataAndBossExtdata = ctru_sys::ARCHIVE_EXTDATA_AND_BOSS_EXTDATA, ExtDataAndBossExtdata = ctru_sys::ARCHIVE_EXTDATA_AND_BOSS_EXTDATA,
/// System save data.
SystemSaveData2 = ctru_sys::ARCHIVE_SYSTEM_SAVEDATA2, SystemSaveData2 = ctru_sys::ARCHIVE_SYSTEM_SAVEDATA2,
/// Internal NAND (read-write).
NandRW = ctru_sys::ARCHIVE_NAND_RW, NandRW = ctru_sys::ARCHIVE_NAND_RW,
/// Internal NAND (read-only).
NandRO = ctru_sys::ARCHIVE_NAND_RO, NandRO = ctru_sys::ARCHIVE_NAND_RO,
/// Internal NAND (read-only write access).
NandROWriteAccess = ctru_sys::ARCHIVE_NAND_RO_WRITE_ACCESS, NandROWriteAccess = ctru_sys::ARCHIVE_NAND_RO_WRITE_ACCESS,
/// User save data and ExeFS/RomFS.
SaveDataAndContent = ctru_sys::ARCHIVE_SAVEDATA_AND_CONTENT, 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, SaveDataAndContent2 = ctru_sys::ARCHIVE_SAVEDATA_AND_CONTENT2,
/// NAND CTR File System.
NandCtrFS = ctru_sys::ARCHIVE_NAND_CTR_FS, NandCtrFS = ctru_sys::ARCHIVE_NAND_CTR_FS,
/// TWL photo.
TwlPhoto = ctru_sys::ARCHIVE_TWL_PHOTO, TwlPhoto = ctru_sys::ARCHIVE_TWL_PHOTO,
/// NAND TWL File System.
NandTwlFS = ctru_sys::ARCHIVE_NAND_TWL_FS, NandTwlFS = ctru_sys::ARCHIVE_NAND_TWL_FS,
/// Game card save data.
GameCardSavedata = ctru_sys::ARCHIVE_GAMECARD_SAVEDATA, GameCardSavedata = ctru_sys::ARCHIVE_GAMECARD_SAVEDATA,
/// User save data.
UserSavedata = ctru_sys::ARCHIVE_USER_SAVEDATA, UserSavedata = ctru_sys::ARCHIVE_USER_SAVEDATA,
/// Demo save data.
DemoSavedata = ctru_sys::ARCHIVE_DEMO_SAVEDATA, DemoSavedata = ctru_sys::ARCHIVE_DEMO_SAVEDATA,
} }

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

@ -1,20 +1,28 @@
//! GSPGPU service //! GSPGPU service
/// GSPGPU events that can be awaited.
#[doc(alias = "GSPGPU_Event")] #[doc(alias = "GSPGPU_Event")]
#[derive(Copy, Clone, Debug, PartialEq, Eq)] #[derive(Copy, Clone, Debug, PartialEq, Eq)]
#[repr(u32)] #[repr(u32)]
pub enum Event { pub enum Event {
/// Memory fill completed.
Psc0 = ctru_sys::GSPGPU_EVENT_PSC0, Psc0 = ctru_sys::GSPGPU_EVENT_PSC0,
/// TODO: Unknown.
Psc1 = ctru_sys::GSPGPU_EVENT_PSC1, Psc1 = ctru_sys::GSPGPU_EVENT_PSC1,
/// TODO: Unknown.
VBlank0 = ctru_sys::GSPGPU_EVENT_VBlank0, VBlank0 = ctru_sys::GSPGPU_EVENT_VBlank0,
/// TODO: Unknown.
VBlank1 = ctru_sys::GSPGPU_EVENT_VBlank1, VBlank1 = ctru_sys::GSPGPU_EVENT_VBlank1,
/// Display transfer finished.
PPF = ctru_sys::GSPGPU_EVENT_PPF, PPF = ctru_sys::GSPGPU_EVENT_PPF,
/// Command list processing finished.
P3D = ctru_sys::GSPGPU_EVENT_P3D, P3D = ctru_sys::GSPGPU_EVENT_P3D,
/// TODO: Unknown.
DMA = ctru_sys::GSPGPU_EVENT_DMA, DMA = ctru_sys::GSPGPU_EVENT_DMA,
} }
#[doc(alias = "GSPGPU_FramebufferFormat")] #[doc(alias = "GSPGPU_FramebufferFormat")]
/// Framebuffer formats supported by the 3DS /// Framebuffer formats supported by the 3DS.
#[derive(Copy, Clone, Debug, PartialEq, Eq)] #[derive(Copy, Clone, Debug, PartialEq, Eq)]
#[repr(u32)] #[repr(u32)]
pub enum FramebufferFormat { pub enum FramebufferFormat {

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

@ -9,33 +9,62 @@ bitflags::bitflags! {
/// A set of flags corresponding to the button and directional pad /// A set of flags corresponding to the button and directional pad
/// inputs on the 3DS /// inputs on the 3DS
pub struct KeyPad: u32 { pub struct KeyPad: u32 {
/// A button.
const A = ctru_sys::KEY_A; const A = ctru_sys::KEY_A;
/// B button.
const B = ctru_sys::KEY_B; const B = ctru_sys::KEY_B;
/// Select button.
const SELECT = ctru_sys::KEY_SELECT; const SELECT = ctru_sys::KEY_SELECT;
/// Start button.
const START = ctru_sys::KEY_START; const START = ctru_sys::KEY_START;
/// D-Pad Right.
const DPAD_RIGHT = ctru_sys::KEY_DRIGHT; const DPAD_RIGHT = ctru_sys::KEY_DRIGHT;
/// D-Pad Left.
const DPAD_LEFT = ctru_sys::KEY_DLEFT; const DPAD_LEFT = ctru_sys::KEY_DLEFT;
/// D-Pad Up.
const DPAD_UP = ctru_sys::KEY_DUP; const DPAD_UP = ctru_sys::KEY_DUP;
/// D-Pad Down.
const DPAD_DOWN = ctru_sys::KEY_DDOWN; const DPAD_DOWN = ctru_sys::KEY_DDOWN;
/// R button.
const R = ctru_sys::KEY_R; const R = ctru_sys::KEY_R;
/// L button.
const L = ctru_sys::KEY_L; const L = ctru_sys::KEY_L;
/// X button.
const X = ctru_sys::KEY_X; const X = ctru_sys::KEY_X;
/// Y button.
const Y = ctru_sys::KEY_Y; const Y = ctru_sys::KEY_Y;
/// ZL button.
const ZL = ctru_sys::KEY_ZL; const ZL = ctru_sys::KEY_ZL;
/// ZR button.
const ZR = ctru_sys::KEY_ZR; const ZR = ctru_sys::KEY_ZR;
/// Touchscreen.
const TOUCH = ctru_sys::KEY_TOUCH; const TOUCH = ctru_sys::KEY_TOUCH;
/// C-Stick Right.
const CSTICK_RIGHT = ctru_sys::KEY_CSTICK_RIGHT; const CSTICK_RIGHT = ctru_sys::KEY_CSTICK_RIGHT;
/// C-Stick Left.
const CSTICK_LEFT = ctru_sys::KEY_CSTICK_LEFT; const CSTICK_LEFT = ctru_sys::KEY_CSTICK_LEFT;
/// C-Stick Up.
const CSTICK_UP = ctru_sys::KEY_CSTICK_UP; const CSTICK_UP = ctru_sys::KEY_CSTICK_UP;
/// C-Stick Down.
const CSTICK_DOWN = ctru_sys::KEY_CSTICK_DOWN; const CSTICK_DOWN = ctru_sys::KEY_CSTICK_DOWN;
/// CirclePad Right.
const CPAD_RIGHT = ctru_sys::KEY_CPAD_RIGHT; const CPAD_RIGHT = ctru_sys::KEY_CPAD_RIGHT;
/// CirclePad Left.
const CPAD_LEFT = ctru_sys::KEY_CPAD_LEFT; const CPAD_LEFT = ctru_sys::KEY_CPAD_LEFT;
/// CirclePad Up.
const CPAD_UP = ctru_sys::KEY_CPAD_UP; const CPAD_UP = ctru_sys::KEY_CPAD_UP;
/// CirclePad Down.
const CPAD_DOWN = ctru_sys::KEY_CPAD_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(); 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(); 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(); 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(); const RIGHT = KeyPad::DPAD_RIGHT.bits() | KeyPad::CPAD_RIGHT.bits();
} }
} }

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

@ -14,21 +14,30 @@ use std::sync::Mutex;
const NUMBER_OF_CHANNELS: u8 = 24; const NUMBER_OF_CHANNELS: u8 = 24;
/// Audio output mode.
#[doc(alias = "ndspOutputMode")] #[doc(alias = "ndspOutputMode")]
#[derive(Copy, Clone, Debug, PartialEq, Eq)] #[derive(Copy, Clone, Debug, PartialEq, Eq)]
#[repr(u32)] #[repr(u32)]
pub enum OutputMode { pub enum OutputMode {
/// Single-Channel.
Mono = ctru_sys::NDSP_OUTPUT_MONO, Mono = ctru_sys::NDSP_OUTPUT_MONO,
/// Dual-Channel.
Stereo = ctru_sys::NDSP_OUTPUT_STEREO, Stereo = ctru_sys::NDSP_OUTPUT_STEREO,
/// Surround.
Surround = ctru_sys::NDSP_OUTPUT_SURROUND, Surround = ctru_sys::NDSP_OUTPUT_SURROUND,
} }
/// Audio PCM format.
#[derive(Copy, Clone, Debug, PartialEq, Eq)] #[derive(Copy, Clone, Debug, PartialEq, Eq)]
#[repr(u32)] #[repr(u32)]
pub enum AudioFormat { pub enum AudioFormat {
/// PCM 8bit single-channel.
PCM8Mono = ctru_sys::NDSP_FORMAT_MONO_PCM8, PCM8Mono = ctru_sys::NDSP_FORMAT_MONO_PCM8,
/// PCM 16bit single-channel.
PCM16Mono = ctru_sys::NDSP_FORMAT_MONO_PCM16, PCM16Mono = ctru_sys::NDSP_FORMAT_MONO_PCM16,
/// PCM 8bit dual-channel.
PCM8Stereo = ctru_sys::NDSP_FORMAT_STEREO_PCM8, PCM8Stereo = ctru_sys::NDSP_FORMAT_STEREO_PCM8,
/// PCM 16bit dual-channel.
PCM16Stereo = ctru_sys::NDSP_FORMAT_STEREO_PCM16, PCM16Stereo = ctru_sys::NDSP_FORMAT_STEREO_PCM16,
} }
@ -38,15 +47,20 @@ pub struct AudioMix {
raw: [f32; 12], raw: [f32; 12],
} }
/// Interpolation used between audio frames.
#[doc(alias = "ndspInterpType")] #[doc(alias = "ndspInterpType")]
#[derive(Copy, Clone, Debug, PartialEq, Eq)] #[derive(Copy, Clone, Debug, PartialEq, Eq)]
#[repr(u32)] #[repr(u32)]
pub enum InterpolationType { pub enum InterpolationType {
/// Polyphase interpolation.
Polyphase = ctru_sys::NDSP_INTERP_POLYPHASE, Polyphase = ctru_sys::NDSP_INTERP_POLYPHASE,
/// Linear interpolation.
Linear = ctru_sys::NDSP_INTERP_LINEAR, Linear = ctru_sys::NDSP_INTERP_LINEAR,
/// No interpolation.
None = ctru_sys::NDSP_INTERP_NONE, None = ctru_sys::NDSP_INTERP_NONE,
} }
/// Error enum returned by NDSP methods.
#[derive(Copy, Clone, Debug, PartialEq, Eq)] #[derive(Copy, Clone, Debug, PartialEq, Eq)]
pub enum NdspError { pub enum NdspError {
/// Channel ID /// Channel ID

4
ctru-rs/src/services/ndsp/wave.rs

@ -15,9 +15,13 @@ pub struct Wave {
#[repr(u8)] #[repr(u8)]
/// Enum representing the playback status of a [`Wave`]. /// Enum representing the playback status of a [`Wave`].
pub enum WaveStatus { pub enum WaveStatus {
/// Wave has never been used.
Free = ctru_sys::NDSP_WBUF_FREE as u8, Free = ctru_sys::NDSP_WBUF_FREE as u8,
/// Wave is currently queued for usage.
Queued = ctru_sys::NDSP_WBUF_QUEUED as u8, Queued = ctru_sys::NDSP_WBUF_QUEUED as u8,
/// Wave is currently playing.
Playing = ctru_sys::NDSP_WBUF_PLAYING as u8, Playing = ctru_sys::NDSP_WBUF_PLAYING as u8,
/// Wave has finished playing.
Done = ctru_sys::NDSP_WBUF_DONE as u8, Done = ctru_sys::NDSP_WBUF_DONE as u8,
} }

18
ctru-rs/src/services/ps.rs

@ -6,31 +6,49 @@
use crate::error::ResultCode; use crate::error::ResultCode;
use crate::Result; use crate::Result;
/// Kind of AES algorithm to use.
#[doc(alias = "PS_AESAlgorithm")] #[doc(alias = "PS_AESAlgorithm")]
#[derive(Debug, Clone, Copy, PartialEq, Eq)] #[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[repr(u32)] #[repr(u32)]
pub enum AESAlgorithm { pub enum AESAlgorithm {
/// CBC encryption.
CbcEnc = ctru_sys::PS_ALGORITHM_CBC_ENC, CbcEnc = ctru_sys::PS_ALGORITHM_CBC_ENC,
/// CBC decryption.
CbcDec = ctru_sys::PS_ALGORITHM_CBC_DEC, CbcDec = ctru_sys::PS_ALGORITHM_CBC_DEC,
/// CTR encryption.
CtrEnc = ctru_sys::PS_ALGORITHM_CTR_ENC, CtrEnc = ctru_sys::PS_ALGORITHM_CTR_ENC,
/// CTR decryption.
CtrDec = ctru_sys::PS_ALGORITHM_CTR_DEC, CtrDec = ctru_sys::PS_ALGORITHM_CTR_DEC,
/// CCM encryption.
CcmEnc = ctru_sys::PS_ALGORITHM_CCM_ENC, CcmEnc = ctru_sys::PS_ALGORITHM_CCM_ENC,
/// CCM decryption.
CcmDec = ctru_sys::PS_ALGORITHM_CCM_DEC, CcmDec = ctru_sys::PS_ALGORITHM_CCM_DEC,
} }
/// PS Key slot to use.
#[doc(alias = "PS_AESKeyType")] #[doc(alias = "PS_AESKeyType")]
#[derive(Debug, Clone, Copy, PartialEq, Eq)] #[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[repr(u32)] #[repr(u32)]
pub enum AESKeyType { pub enum AESKeyType {
/// Keyslot 0x0D.
Keyslot0D = ctru_sys::PS_KEYSLOT_0D, Keyslot0D = ctru_sys::PS_KEYSLOT_0D,
/// Keyslot 0x2D.
Keyslot2D = ctru_sys::PS_KEYSLOT_2D, Keyslot2D = ctru_sys::PS_KEYSLOT_2D,
/// Keyslot 0x2E.
Keyslot2E = ctru_sys::PS_KEYSLOT_2E, Keyslot2E = ctru_sys::PS_KEYSLOT_2E,
/// Keyslot 0x31.
Keyslot31 = ctru_sys::PS_KEYSLOT_31, Keyslot31 = ctru_sys::PS_KEYSLOT_31,
/// Keyslot 0x32.
Keyslot32 = ctru_sys::PS_KEYSLOT_32, Keyslot32 = ctru_sys::PS_KEYSLOT_32,
/// Keyslot 0x36.
Keyslot36 = ctru_sys::PS_KEYSLOT_36, Keyslot36 = ctru_sys::PS_KEYSLOT_36,
/// Keyslot 0x38.
Keyslot38 = ctru_sys::PS_KEYSLOT_38, Keyslot38 = ctru_sys::PS_KEYSLOT_38,
/// Keyslot 0x39 (DLP).
Keyslot39Dlp = ctru_sys::PS_KEYSLOT_39_DLP, Keyslot39Dlp = ctru_sys::PS_KEYSLOT_39_DLP,
/// Keyslot 0x39 (NFC).
Keyslot39Nfc = ctru_sys::PS_KEYSLOT_39_NFC, Keyslot39Nfc = ctru_sys::PS_KEYSLOT_39_NFC,
/// Invalid keyslot.
KeyslotInvalid = ctru_sys::PS_KEYSLOT_INVALID, KeyslotInvalid = ctru_sys::PS_KEYSLOT_INVALID,
} }

1
ctru-rs/src/services/sslc.rs

@ -4,6 +4,7 @@
use crate::error::ResultCode; use crate::error::ResultCode;
/// Handle to the SSLC service.
pub struct SslC(()); pub struct SslC(());
impl SslC { impl SslC {

Loading…
Cancel
Save