|
|
|
@ -2,11 +2,11 @@
@@ -2,11 +2,11 @@
|
|
|
|
|
//!
|
|
|
|
|
//! This module contains basic methods to retrieve and change configuration from the console.
|
|
|
|
|
|
|
|
|
|
#[derive(Debug)] |
|
|
|
|
#[derive(Clone, Debug)] |
|
|
|
|
#[repr(u32)] |
|
|
|
|
pub enum Region { |
|
|
|
|
Japan = ctru_sys::CFG_REGION_JPN, |
|
|
|
|
Usa = ctru_sys::CFG_REGION_USA, |
|
|
|
|
USA = ctru_sys::CFG_REGION_USA, |
|
|
|
|
Europe = ctru_sys::CFG_REGION_EUR, |
|
|
|
|
Australia = ctru_sys::CFG_REGION_AUS, |
|
|
|
|
China = ctru_sys::CFG_REGION_CHN, |
|
|
|
@ -14,7 +14,7 @@ pub enum Region {
@@ -14,7 +14,7 @@ pub enum Region {
|
|
|
|
|
Taiwan = ctru_sys::CFG_REGION_TWN, |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
#[derive(Debug)] |
|
|
|
|
#[derive(Clone, Debug)] |
|
|
|
|
#[repr(u32)] |
|
|
|
|
pub enum Language { |
|
|
|
|
Japan = ctru_sys::CFG_LANGUAGE_JP, |
|
|
|
@ -23,15 +23,15 @@ pub enum Language {
@@ -23,15 +23,15 @@ pub enum Language {
|
|
|
|
|
German = ctru_sys::CFG_LANGUAGE_DE, |
|
|
|
|
Italian = ctru_sys::CFG_LANGUAGE_IT, |
|
|
|
|
Spanish = ctru_sys::CFG_LANGUAGE_ES, |
|
|
|
|
SimpChinese = ctru_sys::CFG_LANGUAGE_ZH, |
|
|
|
|
SimplifiedChinese = ctru_sys::CFG_LANGUAGE_ZH, |
|
|
|
|
Korean = ctru_sys::CFG_LANGUAGE_KO, |
|
|
|
|
Dutch = ctru_sys::CFG_LANGUAGE_NL, |
|
|
|
|
Portuguese = ctru_sys::CFG_LANGUAGE_PT, |
|
|
|
|
Russian = ctru_sys::CFG_LANGUAGE_RU, |
|
|
|
|
TradChinese = ctru_sys::CFG_LANGUAGE_TW, |
|
|
|
|
TraditionalChinese = ctru_sys::CFG_LANGUAGE_TW, |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
#[derive(Debug)] |
|
|
|
|
#[derive(Clone, Debug)] |
|
|
|
|
#[repr(u32)] |
|
|
|
|
pub enum SystemModel { |
|
|
|
|
Model3DS = ctru_sys::CFG_MODEL_3DS, |
|
|
|
@ -73,10 +73,8 @@ impl Cfgu {
@@ -73,10 +73,8 @@ impl Cfgu {
|
|
|
|
|
/// Gets system region from secure info
|
|
|
|
|
pub fn get_region(&self) -> crate::Result<Region> { |
|
|
|
|
let mut region: u8 = 0; |
|
|
|
|
let region_pointer: *mut u8 = &mut region; |
|
|
|
|
|
|
|
|
|
unsafe { |
|
|
|
|
let r = ctru_sys::CFGU_SecureInfoGetRegion(region_pointer); |
|
|
|
|
let r = unsafe { ctru_sys::CFGU_SecureInfoGetRegion(&mut region) }; |
|
|
|
|
if r < 0 { |
|
|
|
|
Err(r.into()) |
|
|
|
|
} else { |
|
|
|
@ -84,15 +82,12 @@ impl Cfgu {
@@ -84,15 +82,12 @@ impl Cfgu {
|
|
|
|
|
Ok(Region::try_from(region).unwrap()) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/// Gets system's model
|
|
|
|
|
pub fn get_model(&self) -> crate::Result<SystemModel> { |
|
|
|
|
let mut model: u8 = 0; |
|
|
|
|
let model_pointer: *mut u8 = &mut model; |
|
|
|
|
|
|
|
|
|
unsafe { |
|
|
|
|
let r = ctru_sys::CFGU_GetSystemModel(model_pointer); |
|
|
|
|
let r = unsafe { ctru_sys::CFGU_GetSystemModel(&mut model) }; |
|
|
|
|
if r < 0 { |
|
|
|
|
Err(r.into()) |
|
|
|
|
} else { |
|
|
|
@ -100,15 +95,12 @@ impl Cfgu {
@@ -100,15 +95,12 @@ impl Cfgu {
|
|
|
|
|
Ok(SystemModel::try_from(model).unwrap()) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/// Gets system's language
|
|
|
|
|
pub fn get_language(&self) -> crate::Result<Language> { |
|
|
|
|
let mut language: u8 = 0; |
|
|
|
|
let language_pointer: *mut u8 = &mut language; |
|
|
|
|
|
|
|
|
|
unsafe { |
|
|
|
|
let r = ctru_sys::CFGU_GetSystemLanguage(language_pointer); |
|
|
|
|
let r = unsafe { ctru_sys::CFGU_GetSystemLanguage(&mut language) }; |
|
|
|
|
if r < 0 { |
|
|
|
|
Err(r.into()) |
|
|
|
|
} else { |
|
|
|
@ -116,35 +108,28 @@ impl Cfgu {
@@ -116,35 +108,28 @@ impl Cfgu {
|
|
|
|
|
Ok(Language::try_from(language).unwrap()) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/// Checks if NFC is supported by the console
|
|
|
|
|
pub fn is_nfc_supported(&self) -> crate::Result<bool> { |
|
|
|
|
let mut supported: bool = false; |
|
|
|
|
let supported_pointer: *mut bool = &mut supported; |
|
|
|
|
|
|
|
|
|
unsafe { |
|
|
|
|
let r = ctru_sys::CFGU_IsNFCSupported(supported_pointer); |
|
|
|
|
let r = unsafe { ctru_sys::CFGU_IsNFCSupported(&mut supported) }; |
|
|
|
|
if r < 0 { |
|
|
|
|
Err(r.into()) |
|
|
|
|
} else { |
|
|
|
|
Ok(supported) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/// Check if the console is from the 2DS family (2DS, New2DS, New2DSXL)
|
|
|
|
|
pub fn is_2ds_family(&self) -> crate::Result<bool> { |
|
|
|
|
let mut is_2ds_family: u8 = 0; |
|
|
|
|
let is_2ds_family_pointer: *mut u8 = &mut is_2ds_family; |
|
|
|
|
|
|
|
|
|
unsafe { |
|
|
|
|
let r = ctru_sys::CFGU_GetModelNintendo2DS(is_2ds_family_pointer); |
|
|
|
|
let r = unsafe { ctru_sys::CFGU_GetModelNintendo2DS(&mut is_2ds_family) }; |
|
|
|
|
if r < 0 { |
|
|
|
|
Err(r.into()) |
|
|
|
|
} else { |
|
|
|
|
Ok(is_2ds_family < 1) |
|
|
|
|
} |
|
|
|
|
Ok(is_2ds_family == 0) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -177,7 +162,7 @@ impl TryFrom<u8> for Region {
@@ -177,7 +162,7 @@ impl TryFrom<u8> for Region {
|
|
|
|
|
fn try_from(value: u8) -> Result<Self, Self::Error> { |
|
|
|
|
match value as u32 { |
|
|
|
|
ctru_sys::CFG_REGION_JPN => Ok(Region::Japan), |
|
|
|
|
ctru_sys::CFG_REGION_USA => Ok(Region::Usa), |
|
|
|
|
ctru_sys::CFG_REGION_USA => Ok(Region::USA), |
|
|
|
|
ctru_sys::CFG_REGION_EUR => Ok(Region::Europe), |
|
|
|
|
ctru_sys::CFG_REGION_AUS => Ok(Region::Australia), |
|
|
|
|
ctru_sys::CFG_REGION_CHN => Ok(Region::China), |
|
|
|
@ -199,12 +184,12 @@ impl TryFrom<u8> for Language {
@@ -199,12 +184,12 @@ impl TryFrom<u8> for Language {
|
|
|
|
|
ctru_sys::CFG_LANGUAGE_DE => Ok(Language::German), |
|
|
|
|
ctru_sys::CFG_LANGUAGE_IT => Ok(Language::Italian), |
|
|
|
|
ctru_sys::CFG_LANGUAGE_ES => Ok(Language::Spanish), |
|
|
|
|
ctru_sys::CFG_LANGUAGE_ZH => Ok(Language::SimpChinese), |
|
|
|
|
ctru_sys::CFG_LANGUAGE_ZH => Ok(Language::SimplifiedChinese), |
|
|
|
|
ctru_sys::CFG_LANGUAGE_KO => Ok(Language::Korean), |
|
|
|
|
ctru_sys::CFG_LANGUAGE_NL => Ok(Language::Dutch), |
|
|
|
|
ctru_sys::CFG_LANGUAGE_PT => Ok(Language::Portuguese), |
|
|
|
|
ctru_sys::CFG_LANGUAGE_RU => Ok(Language::Russian), |
|
|
|
|
ctru_sys::CFG_LANGUAGE_TW => Ok(Language::TradChinese), |
|
|
|
|
ctru_sys::CFG_LANGUAGE_TW => Ok(Language::TraditionalChinese), |
|
|
|
|
_ => Err(()) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|