|
|
@ -1,11 +1,10 @@ |
|
|
|
//! CAM service
|
|
|
|
//! Camera service
|
|
|
|
//!
|
|
|
|
//!
|
|
|
|
//! The CAM service provides access to the cameras. Cameras can return 2D images
|
|
|
|
//! The CAM service provides access to the cameras. Cameras can return images
|
|
|
|
//! in the form of byte vectors which can be used for display or other usages.
|
|
|
|
//! in the form of byte vectors which can be displayed or used in other ways.
|
|
|
|
|
|
|
|
|
|
|
|
use crate::error::{Error, ResultCode}; |
|
|
|
use crate::error::{Error, ResultCode}; |
|
|
|
use crate::services::gspgpu::FramebufferFormat; |
|
|
|
use crate::services::gspgpu::FramebufferFormat; |
|
|
|
use bitflags::bitflags; |
|
|
|
|
|
|
|
use ctru_sys::Handle; |
|
|
|
use ctru_sys::Handle; |
|
|
|
use std::time::Duration; |
|
|
|
use std::time::Duration; |
|
|
|
|
|
|
|
|
|
|
@ -21,191 +20,168 @@ pub struct Cam { |
|
|
|
pub both_outer_cams: BothOutwardCam, |
|
|
|
pub both_outer_cams: BothOutwardCam, |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
bitflags! { |
|
|
|
/// Flag to pass to [Camera::flip_image]
|
|
|
|
/// A set of flags to be passed to [Camera::flip_image]
|
|
|
|
#[derive(Copy, Clone, Debug)] |
|
|
|
#[derive(Default)] |
|
|
|
#[repr(u32)] |
|
|
|
pub struct CamFlip: u32 { |
|
|
|
pub enum FlipMode { |
|
|
|
const NONE = ctru_sys::FLIP_NONE; |
|
|
|
None = ctru_sys::FLIP_NONE, |
|
|
|
const HORIZONTAL = ctru_sys::FLIP_HORIZONTAL; |
|
|
|
Horizontal = ctru_sys::FLIP_HORIZONTAL, |
|
|
|
const VERTICAL = ctru_sys::FLIP_VERTICAL; |
|
|
|
Vertical = ctru_sys::FLIP_VERTICAL, |
|
|
|
const REVERSE = ctru_sys::FLIP_REVERSE; |
|
|
|
Reverse = ctru_sys::FLIP_REVERSE, |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/// Flag to pass to [Camera::set_view_size]
|
|
|
|
bitflags! { |
|
|
|
#[derive(Copy, Clone, Debug)] |
|
|
|
/// A set of flags to be passed to [Camera::set_view_size]
|
|
|
|
#[repr(u32)] |
|
|
|
#[derive(Default)] |
|
|
|
pub enum ViewSize { |
|
|
|
pub struct CamSize: u32 { |
|
|
|
TopLCD = ctru_sys::SIZE_CTR_TOP_LCD, |
|
|
|
const VGA = ctru_sys::SIZE_VGA; |
|
|
|
/// Equivalent to QVga
|
|
|
|
const QVGA = ctru_sys::SIZE_QVGA; |
|
|
|
BottomLCD = ctru_sys::SIZE_CTR_BOTTOM_LCD, |
|
|
|
const QQVGA = ctru_sys::SIZE_QQVGA; |
|
|
|
Vga = ctru_sys::SIZE_VGA, |
|
|
|
const CIF = ctru_sys::SIZE_CIF; |
|
|
|
QQVga = ctru_sys::SIZE_QQVGA, |
|
|
|
const QCIF = ctru_sys::SIZE_QCIF; |
|
|
|
Cif = ctru_sys::SIZE_CIF, |
|
|
|
const DS_LCD = ctru_sys::SIZE_DS_LCD; |
|
|
|
QCif = ctru_sys::SIZE_QCIF, |
|
|
|
const DS_LCD_X4 = ctru_sys::SIZE_DS_LCDx4; |
|
|
|
/// Nintendo DS Screen
|
|
|
|
const CTR_TOP_LCD = ctru_sys::SIZE_CTR_TOP_LCD; |
|
|
|
DS = ctru_sys::SIZE_DS_LCD, |
|
|
|
const CTR_BOTTOM_LCD = ctru_sys::SIZE_CTR_BOTTOM_LCD; |
|
|
|
/// Nintendo DS Screen x4
|
|
|
|
} |
|
|
|
DSX4 = ctru_sys::SIZE_DS_LCDx4, |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
bitflags! { |
|
|
|
/// Flag to pass to [Camera::set_frame_rate]
|
|
|
|
/// A set of flags to be passed to [Camera::set_frame_rate]
|
|
|
|
#[derive(Copy, Clone, Debug)] |
|
|
|
#[derive(Default)] |
|
|
|
#[repr(u32)] |
|
|
|
pub struct CamFrameRate: u32 { |
|
|
|
pub enum FrameRate { |
|
|
|
const RATE_15 = ctru_sys::FRAME_RATE_15; |
|
|
|
Fps15 = ctru_sys::FRAME_RATE_15, |
|
|
|
const RATE_15_TO_5 = ctru_sys::FRAME_RATE_15_TO_5; |
|
|
|
Fps15To5 = ctru_sys::FRAME_RATE_15_TO_5, |
|
|
|
const RATE_15_TO_2 = ctru_sys::FRAME_RATE_15_TO_2; |
|
|
|
Fps15To2 = ctru_sys::FRAME_RATE_15_TO_2, |
|
|
|
const RATE_10 = ctru_sys::FRAME_RATE_10; |
|
|
|
Fps10 = ctru_sys::FRAME_RATE_10, |
|
|
|
const RATE_8_5 = ctru_sys::FRAME_RATE_8_5; |
|
|
|
Fps8_5 = ctru_sys::FRAME_RATE_8_5, |
|
|
|
const RATE_5 = ctru_sys::FRAME_RATE_5; |
|
|
|
Fps5 = ctru_sys::FRAME_RATE_5, |
|
|
|
const RATE_20 = ctru_sys::FRAME_RATE_20; |
|
|
|
Fps20 = ctru_sys::FRAME_RATE_20, |
|
|
|
const RATE_20_TO_5 = ctru_sys::FRAME_RATE_20_TO_5; |
|
|
|
Fps20To5 = ctru_sys::FRAME_RATE_20_TO_5, |
|
|
|
const RATE_30 = ctru_sys::FRAME_RATE_30; |
|
|
|
Fps30 = ctru_sys::FRAME_RATE_30, |
|
|
|
const RATE_30_TO_5 = ctru_sys::FRAME_RATE_30_TO_5; |
|
|
|
Fps30To5 = ctru_sys::FRAME_RATE_30_TO_5, |
|
|
|
const RATE_15_TO_10 = ctru_sys::FRAME_RATE_15_TO_10; |
|
|
|
Fps15To10 = ctru_sys::FRAME_RATE_15_TO_10, |
|
|
|
const RATE_20_TO_10 = ctru_sys::FRAME_RATE_20_TO_10; |
|
|
|
Fps20To10 = ctru_sys::FRAME_RATE_20_TO_10, |
|
|
|
const RATE_30_TO_10 = ctru_sys::FRAME_RATE_30_TO_10; |
|
|
|
Fps30To10 = ctru_sys::FRAME_RATE_30_TO_10, |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/// Flag to pass to [Camera::set_white_balance] or
|
|
|
|
bitflags! { |
|
|
|
|
|
|
|
/// A set of flags to be passed to [Camera::set_white_balance] or
|
|
|
|
|
|
|
|
/// [Camera::set_white_balance_without_base_up]
|
|
|
|
/// [Camera::set_white_balance_without_base_up]
|
|
|
|
#[derive(Default)] |
|
|
|
#[derive(Copy, Clone, Debug)] |
|
|
|
pub struct CamWhiteBalance: u32 { |
|
|
|
#[repr(u32)] |
|
|
|
const AUTO = ctru_sys::WHITE_BALANCE_AUTO; |
|
|
|
pub enum WhiteBalance { |
|
|
|
const BALANCE_3200K = ctru_sys::WHITE_BALANCE_3200K; |
|
|
|
/// Normal
|
|
|
|
const BALANCE_4150K = ctru_sys::WHITE_BALANCE_4150K; |
|
|
|
Auto = ctru_sys::WHITE_BALANCE_AUTO, |
|
|
|
const BALANCE_5200K = ctru_sys::WHITE_BALANCE_5200K; |
|
|
|
/// Tungsten
|
|
|
|
const BALANCE_6000K = ctru_sys::WHITE_BALANCE_6000K; |
|
|
|
Temp3200K = ctru_sys::WHITE_BALANCE_3200K, |
|
|
|
const BALANCE_7000K = ctru_sys::WHITE_BALANCE_7000K; |
|
|
|
/// Fluorescent Light
|
|
|
|
|
|
|
|
Temp4150K = ctru_sys::WHITE_BALANCE_4150K, |
|
|
|
const NORMAL = ctru_sys::WHITE_BALANCE_NORMAL; |
|
|
|
/// Daylight
|
|
|
|
const TUNGSTEN = ctru_sys::WHITE_BALANCE_TUNGSTEN; |
|
|
|
Temp5200K = ctru_sys::WHITE_BALANCE_5200K, |
|
|
|
const WHITE_FLUORESCENT_LIGHT = ctru_sys::WHITE_BALANCE_WHITE_FLUORESCENT_LIGHT; |
|
|
|
/// Cloudy/Horizon
|
|
|
|
const DAYLIGHT = ctru_sys::WHITE_BALANCE_DAYLIGHT; |
|
|
|
Temp6000K = ctru_sys::WHITE_BALANCE_6000K, |
|
|
|
const CLOUDY = ctru_sys::WHITE_BALANCE_CLOUDY; |
|
|
|
///Shade
|
|
|
|
const HORIZON = ctru_sys::WHITE_BALANCE_HORIZON; |
|
|
|
Temp7000K = ctru_sys::WHITE_BALANCE_7000K, |
|
|
|
const SHADE = ctru_sys::WHITE_BALANCE_SHADE; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
/// Flag to pass to [Camera::set_photo_mode]
|
|
|
|
|
|
|
|
#[derive(Copy, Clone, Debug)] |
|
|
|
bitflags! { |
|
|
|
#[repr(u32)] |
|
|
|
/// A set of flags to be passed to [Camera::set_photo_mode]
|
|
|
|
pub enum PhotoMode { |
|
|
|
#[derive(Default)] |
|
|
|
Normal = ctru_sys::PHOTO_MODE_NORMAL, |
|
|
|
pub struct CamPhotoMode: u32 { |
|
|
|
Portrait = ctru_sys::PHOTO_MODE_PORTRAIT, |
|
|
|
const NORMAL = ctru_sys::PHOTO_MODE_NORMAL; |
|
|
|
Landscape = ctru_sys::PHOTO_MODE_LANDSCAPE, |
|
|
|
const PORTRAIT = ctru_sys::PHOTO_MODE_PORTRAIT; |
|
|
|
NightView = ctru_sys::PHOTO_MODE_NIGHTVIEW, |
|
|
|
const LANDSCAPE = ctru_sys::PHOTO_MODE_LANDSCAPE; |
|
|
|
Letter = ctru_sys::PHOTO_MODE_LETTER, |
|
|
|
const NIGHTVIEW = ctru_sys::PHOTO_MODE_NIGHTVIEW; |
|
|
|
} |
|
|
|
const LETTER = ctru_sys::PHOTO_MODE_LETTER; |
|
|
|
|
|
|
|
} |
|
|
|
/// Flag to pass to [Camera::set_effect]
|
|
|
|
} |
|
|
|
#[derive(Copy, Clone, Debug)] |
|
|
|
|
|
|
|
#[repr(u32)] |
|
|
|
bitflags! { |
|
|
|
pub enum Effect { |
|
|
|
/// A set of flags to be passed to [Camera::set_effect]
|
|
|
|
None = ctru_sys::EFFECT_NONE, |
|
|
|
#[derive(Default)] |
|
|
|
Mono = ctru_sys::EFFECT_MONO, |
|
|
|
pub struct CamEffect: u32 { |
|
|
|
Sepia = ctru_sys::EFFECT_SEPIA, |
|
|
|
const NONE = ctru_sys::EFFECT_NONE; |
|
|
|
Negative = ctru_sys::EFFECT_NEGATIVE, |
|
|
|
const MONO = ctru_sys::EFFECT_MONO; |
|
|
|
Negafilm = ctru_sys::EFFECT_NEGAFILM, |
|
|
|
const SEPIA = ctru_sys::EFFECT_SEPIA; |
|
|
|
Sepia01 = ctru_sys::EFFECT_SEPIA01, |
|
|
|
const NEGATIVE = ctru_sys::EFFECT_NEGATIVE; |
|
|
|
} |
|
|
|
const NEGAFILM = ctru_sys::EFFECT_NEGAFILM; |
|
|
|
|
|
|
|
const SEPIA01 = ctru_sys::EFFECT_SEPIA01; |
|
|
|
/// Flag to pass to [Camera::set_contrast]
|
|
|
|
} |
|
|
|
#[derive(Copy, Clone, Debug)] |
|
|
|
} |
|
|
|
#[repr(u32)] |
|
|
|
|
|
|
|
pub enum Contrast { |
|
|
|
bitflags! { |
|
|
|
/// OFF
|
|
|
|
/// A set of flags to be passed to [Camera::set_contrast]
|
|
|
|
Low = ctru_sys::CONTRAST_LOW, |
|
|
|
#[derive(Default)] |
|
|
|
/// Brightness ratio: 70
|
|
|
|
pub struct CamContrast: u32 { |
|
|
|
Normal = ctru_sys::CONTRAST_NORMAL, |
|
|
|
const PATTERN_01 = ctru_sys::CONTRAST_PATTERN_01; |
|
|
|
/// Brightness ratio: 90
|
|
|
|
const PATTERN_02 = ctru_sys::CONTRAST_PATTERN_02; |
|
|
|
High = ctru_sys::CONTRAST_HIGH, |
|
|
|
const PATTERN_03 = ctru_sys::CONTRAST_PATTERN_03; |
|
|
|
} |
|
|
|
const PATTERN_04 = ctru_sys::CONTRAST_PATTERN_04; |
|
|
|
|
|
|
|
const PATTERN_05 = ctru_sys::CONTRAST_PATTERN_05; |
|
|
|
/// Flag to pass to [Camera::set_lens_correction]
|
|
|
|
const PATTERN_06 = ctru_sys::CONTRAST_PATTERN_06; |
|
|
|
#[derive(Copy, Clone, Debug)] |
|
|
|
const PATTERN_07 = ctru_sys::CONTRAST_PATTERN_07; |
|
|
|
#[repr(u32)] |
|
|
|
const PATTERN_08 = ctru_sys::CONTRAST_PATTERN_08; |
|
|
|
pub enum LensCorrection { |
|
|
|
const PATTERN_09 = ctru_sys::CONTRAST_PATTERN_09; |
|
|
|
Off = ctru_sys::LENS_CORRECTION_DARK, |
|
|
|
const PATTERN_10 = ctru_sys::CONTRAST_PATTERN_10; |
|
|
|
Normal = ctru_sys::LENS_CORRECTION_NORMAL, |
|
|
|
const PATTERN_11 = ctru_sys::CONTRAST_PATTERN_11; |
|
|
|
Bright = ctru_sys::LENS_CORRECTION_BRIGHT, |
|
|
|
|
|
|
|
} |
|
|
|
const LOW = ctru_sys::CONTRAST_LOW; |
|
|
|
|
|
|
|
const NORMAL = ctru_sys::CONTRAST_NORMAL; |
|
|
|
/// Flag to pass to [Camera::set_output_format]
|
|
|
|
const HIGH = ctru_sys::CONTRAST_HIGH; |
|
|
|
#[derive(Copy, Clone, Debug)] |
|
|
|
} |
|
|
|
#[repr(u32)] |
|
|
|
} |
|
|
|
pub enum OutputFormat { |
|
|
|
|
|
|
|
Yuv422 = ctru_sys::OUTPUT_YUV_422, |
|
|
|
bitflags! { |
|
|
|
Rgb565 = ctru_sys::OUTPUT_RGB_565, |
|
|
|
/// A set of flags to be passed to [Camera::set_lens_correction]
|
|
|
|
} |
|
|
|
#[derive(Default)] |
|
|
|
|
|
|
|
pub struct CamLensCorrection: u32 { |
|
|
|
/// Flag to pass to [Cam::play_shutter_sound]
|
|
|
|
const OFF = ctru_sys::LENS_CORRECTION_OFF; |
|
|
|
#[derive(Copy, Clone, Debug)] |
|
|
|
const ON_70 = ctru_sys::LENS_CORRECTION_ON_70; |
|
|
|
#[repr(u32)] |
|
|
|
const ON_90 = ctru_sys::LENS_CORRECTION_ON_90; |
|
|
|
pub enum ShutterSound { |
|
|
|
|
|
|
|
Normal = ctru_sys::SHUTTER_SOUND_TYPE_NORMAL, |
|
|
|
const DARK = ctru_sys::LENS_CORRECTION_DARK; |
|
|
|
Movie = ctru_sys::SHUTTER_SOUND_TYPE_MOVIE, |
|
|
|
const NORMAL = ctru_sys::LENS_CORRECTION_NORMAL; |
|
|
|
MovieEnd = ctru_sys::SHUTTER_SOUND_TYPE_MOVIE_END, |
|
|
|
const BRIGHT = ctru_sys::LENS_CORRECTION_BRIGHT; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
impl TryFrom<FramebufferFormat> for OutputFormat { |
|
|
|
|
|
|
|
|
|
|
|
bitflags! { |
|
|
|
|
|
|
|
/// A set of flags to be passed to [Camera::set_output_format]
|
|
|
|
|
|
|
|
#[derive(Default)] |
|
|
|
|
|
|
|
pub struct CamOutputFormat: u32 { |
|
|
|
|
|
|
|
const YUV_422 = ctru_sys::OUTPUT_YUV_422; |
|
|
|
|
|
|
|
const RGB_565 = ctru_sys::OUTPUT_RGB_565; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
impl TryFrom<FramebufferFormat> for CamOutputFormat { |
|
|
|
|
|
|
|
type Error = (); |
|
|
|
type Error = (); |
|
|
|
|
|
|
|
|
|
|
|
fn try_from(value: FramebufferFormat) -> Result<Self, Self::Error> { |
|
|
|
fn try_from(value: FramebufferFormat) -> Result<Self, Self::Error> { |
|
|
|
match value { |
|
|
|
match value { |
|
|
|
FramebufferFormat::Rgb565 => Ok(CamOutputFormat::RGB_565), |
|
|
|
FramebufferFormat::Rgb565 => Ok(OutputFormat::Rgb565), |
|
|
|
_ => Err(()), |
|
|
|
_ => Err(()), |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
impl TryFrom<CamOutputFormat> for FramebufferFormat { |
|
|
|
impl TryFrom<OutputFormat> for FramebufferFormat { |
|
|
|
type Error = (); |
|
|
|
type Error = (); |
|
|
|
|
|
|
|
|
|
|
|
fn try_from(value: CamOutputFormat) -> Result<Self, Self::Error> { |
|
|
|
fn try_from(value: OutputFormat) -> Result<Self, Self::Error> { |
|
|
|
match value { |
|
|
|
match value { |
|
|
|
CamOutputFormat::RGB_565 => Ok(FramebufferFormat::Rgb565), |
|
|
|
OutputFormat::Rgb565 => Ok(FramebufferFormat::Rgb565), |
|
|
|
_ => Err(()), |
|
|
|
_ => Err(()), |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
bitflags! { |
|
|
|
|
|
|
|
/// A set of flags to be passed to [Cam::play_shutter_sound]
|
|
|
|
|
|
|
|
#[derive(Default)] |
|
|
|
|
|
|
|
pub struct CamShutterSoundType: u32 { |
|
|
|
|
|
|
|
const NORMAL = ctru_sys::SHUTTER_SOUND_TYPE_NORMAL; |
|
|
|
|
|
|
|
const MOVIE = ctru_sys::SHUTTER_SOUND_TYPE_MOVIE; |
|
|
|
|
|
|
|
const MOVIE_END = ctru_sys::SHUTTER_SOUND_TYPE_MOVIE_END; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// Struct containing coordinates passed to [Camera::set_trimming_params].
|
|
|
|
/// Struct containing coordinates passed to [Camera::set_trimming_params].
|
|
|
|
pub struct CamTrimmingParams { |
|
|
|
pub struct TrimmingParams { |
|
|
|
x_start: i16, |
|
|
|
x_start: i16, |
|
|
|
y_start: i16, |
|
|
|
y_start: i16, |
|
|
|
x_end: i16, |
|
|
|
x_end: i16, |
|
|
|
y_end: i16, |
|
|
|
y_end: i16, |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
impl CamTrimmingParams { |
|
|
|
impl TrimmingParams { |
|
|
|
/// Creates a new [CamTrimmingParams] and guarantees the start coordinates are less than or
|
|
|
|
/// Creates a new [CamTrimmingParams] and guarantees the start coordinates are less than or
|
|
|
|
/// equal to the end coordinates.
|
|
|
|
/// equal to the end coordinates.
|
|
|
|
///
|
|
|
|
///
|
|
|
|
/// `x_start <= x_end && y_start <= y_end`
|
|
|
|
/// `x_start <= x_end && y_start <= y_end`
|
|
|
|
pub fn new(x_start: i16, y_start: i16, x_end: i16, y_end: i16) -> CamTrimmingParams { |
|
|
|
pub fn new(x_start: i16, y_start: i16, x_end: i16, y_end: i16) -> TrimmingParams { |
|
|
|
assert!(x_start <= x_end && y_start <= y_end); |
|
|
|
assert!(x_start <= x_end && y_start <= y_end); |
|
|
|
Self { |
|
|
|
Self { |
|
|
|
x_start, |
|
|
|
x_start, |
|
|
@ -307,7 +283,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
|
|
|
|
fn get_transfer_bytes(&self) -> crate::Result<u32> { |
|
|
|
fn transfer_byte_count(&self) -> crate::Result<u32> { |
|
|
|
unsafe { |
|
|
|
unsafe { |
|
|
|
let mut transfer_bytes = 0; |
|
|
|
let mut transfer_bytes = 0; |
|
|
|
ResultCode(ctru_sys::CAMU_GetTransferBytes( |
|
|
|
ResultCode(ctru_sys::CAMU_GetTransferBytes( |
|
|
@ -336,8 +312,8 @@ pub trait Camera { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/// Sets trimming parameters based on coordinates specified inside a [CamTrimmingParams]
|
|
|
|
/// Sets trimming parameters based on coordinates specified inside a [TrimmingParams]
|
|
|
|
fn set_trimming_params(&mut self, params: CamTrimmingParams) -> crate::Result<()> { |
|
|
|
fn set_trimming_params(&mut self, params: TrimmingParams) -> crate::Result<()> { |
|
|
|
unsafe { |
|
|
|
unsafe { |
|
|
|
ResultCode(ctru_sys::CAMU_SetTrimmingParams( |
|
|
|
ResultCode(ctru_sys::CAMU_SetTrimmingParams( |
|
|
|
self.port_as_raw(), |
|
|
|
self.port_as_raw(), |
|
|
@ -350,8 +326,8 @@ pub trait Camera { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/// Returns the set [CamTrimmingParams] from the camera
|
|
|
|
/// Returns the [TrimmingParams] set
|
|
|
|
fn get_trimming_params(&self) -> crate::Result<CamTrimmingParams> { |
|
|
|
fn trimming_params(&self) -> crate::Result<TrimmingParams> { |
|
|
|
unsafe { |
|
|
|
unsafe { |
|
|
|
let mut x_start = 0; |
|
|
|
let mut x_start = 0; |
|
|
|
let mut y_start = 0; |
|
|
|
let mut y_start = 0; |
|
|
@ -365,7 +341,7 @@ pub trait Camera { |
|
|
|
self.port_as_raw(), |
|
|
|
self.port_as_raw(), |
|
|
|
))?; |
|
|
|
))?; |
|
|
|
|
|
|
|
|
|
|
|
Ok(CamTrimmingParams { |
|
|
|
Ok(TrimmingParams { |
|
|
|
x_start, |
|
|
|
x_start, |
|
|
|
y_start, |
|
|
|
y_start, |
|
|
|
x_end, |
|
|
|
x_end, |
|
|
@ -404,27 +380,27 @@ pub trait Camera { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/// Sets the white balance mod of the camera based on the passed [CamWhiteBalance] argument
|
|
|
|
/// Sets the white balance mod of the camera based on the passed [WhiteBalance] argument
|
|
|
|
fn set_white_balance(&mut self, white_balance: CamWhiteBalance) -> crate::Result<()> { |
|
|
|
fn set_white_balance(&mut self, white_balance: WhiteBalance) -> crate::Result<()> { |
|
|
|
unsafe { |
|
|
|
unsafe { |
|
|
|
ResultCode(ctru_sys::CAMU_SetWhiteBalance( |
|
|
|
ResultCode(ctru_sys::CAMU_SetWhiteBalance( |
|
|
|
self.camera_as_raw(), |
|
|
|
self.camera_as_raw(), |
|
|
|
white_balance.bits(), |
|
|
|
white_balance.into(), |
|
|
|
))?; |
|
|
|
))?; |
|
|
|
Ok(()) |
|
|
|
Ok(()) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/// Sets the white balance mode of the camera based on the passed [CamWhiteBalance] argument
|
|
|
|
/// Sets the white balance mode of the camera based on the passed [WhiteBalance] argument
|
|
|
|
// TODO: Explain base up
|
|
|
|
// TODO: Explain base up
|
|
|
|
fn set_white_balance_without_base_up( |
|
|
|
fn set_white_balance_without_base_up( |
|
|
|
&mut self, |
|
|
|
&mut self, |
|
|
|
white_balance: CamWhiteBalance, |
|
|
|
white_balance: WhiteBalance, |
|
|
|
) -> crate::Result<()> { |
|
|
|
) -> crate::Result<()> { |
|
|
|
unsafe { |
|
|
|
unsafe { |
|
|
|
ResultCode(ctru_sys::CAMU_SetWhiteBalanceWithoutBaseUp( |
|
|
|
ResultCode(ctru_sys::CAMU_SetWhiteBalanceWithoutBaseUp( |
|
|
|
self.camera_as_raw(), |
|
|
|
self.camera_as_raw(), |
|
|
|
white_balance.bits(), |
|
|
|
white_balance.into(), |
|
|
|
))?; |
|
|
|
))?; |
|
|
|
Ok(()) |
|
|
|
Ok(()) |
|
|
|
} |
|
|
|
} |
|
|
@ -484,12 +460,12 @@ pub trait Camera { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/// Sets the flip direction of the camera's image based on the passed [CamFlip] argument
|
|
|
|
/// Sets the flip direction of the camera's image based on the passed [FlipMode] argument
|
|
|
|
fn flip_image(&mut self, flip: CamFlip) -> crate::Result<()> { |
|
|
|
fn flip_image(&mut self, flip: FlipMode) -> crate::Result<()> { |
|
|
|
unsafe { |
|
|
|
unsafe { |
|
|
|
ResultCode(ctru_sys::CAMU_FlipImage( |
|
|
|
ResultCode(ctru_sys::CAMU_FlipImage( |
|
|
|
self.camera_as_raw(), |
|
|
|
self.camera_as_raw(), |
|
|
|
flip.bits(), |
|
|
|
flip.into(), |
|
|
|
ctru_sys::CONTEXT_A, |
|
|
|
ctru_sys::CONTEXT_A, |
|
|
|
))?; |
|
|
|
))?; |
|
|
|
Ok(()) |
|
|
|
Ok(()) |
|
|
@ -530,82 +506,82 @@ pub trait Camera { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/// Sets the view size of the camera based on the passed [CamSize] argument.
|
|
|
|
/// Sets the view size of the camera based on the passed [ViewSize] argument.
|
|
|
|
fn set_view_size(&mut self, size: CamSize) -> crate::Result<()> { |
|
|
|
fn set_view_size(&mut self, size: ViewSize) -> crate::Result<()> { |
|
|
|
unsafe { |
|
|
|
unsafe { |
|
|
|
ResultCode(ctru_sys::CAMU_SetSize( |
|
|
|
ResultCode(ctru_sys::CAMU_SetSize( |
|
|
|
self.camera_as_raw(), |
|
|
|
self.camera_as_raw(), |
|
|
|
size.bits(), |
|
|
|
size.into(), |
|
|
|
ctru_sys::CONTEXT_A, |
|
|
|
ctru_sys::CONTEXT_A, |
|
|
|
))?; |
|
|
|
))?; |
|
|
|
Ok(()) |
|
|
|
Ok(()) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/// Sets the frame rate of the camera based on the passed [CamFrameRate] argument.
|
|
|
|
/// Sets the frame rate of the camera based on the passed [FrameRate] argument.
|
|
|
|
fn set_frame_rate(&mut self, frame_rate: CamFrameRate) -> crate::Result<()> { |
|
|
|
fn set_frame_rate(&mut self, frame_rate: FrameRate) -> crate::Result<()> { |
|
|
|
unsafe { |
|
|
|
unsafe { |
|
|
|
ResultCode(ctru_sys::CAMU_SetFrameRate( |
|
|
|
ResultCode(ctru_sys::CAMU_SetFrameRate( |
|
|
|
self.camera_as_raw(), |
|
|
|
self.camera_as_raw(), |
|
|
|
frame_rate.bits(), |
|
|
|
frame_rate.into(), |
|
|
|
))?; |
|
|
|
))?; |
|
|
|
Ok(()) |
|
|
|
Ok(()) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/// Sets the photo mode of the camera based on the passed [CamPhotoMode] argument.
|
|
|
|
/// Sets the photo mode of the camera based on the passed [PhotoMode] argument.
|
|
|
|
fn set_photo_mode(&mut self, photo_mode: CamPhotoMode) -> crate::Result<()> { |
|
|
|
fn set_photo_mode(&mut self, photo_mode: PhotoMode) -> crate::Result<()> { |
|
|
|
unsafe { |
|
|
|
unsafe { |
|
|
|
ResultCode(ctru_sys::CAMU_SetPhotoMode( |
|
|
|
ResultCode(ctru_sys::CAMU_SetPhotoMode( |
|
|
|
self.camera_as_raw(), |
|
|
|
self.camera_as_raw(), |
|
|
|
photo_mode.bits(), |
|
|
|
photo_mode.into(), |
|
|
|
))?; |
|
|
|
))?; |
|
|
|
Ok(()) |
|
|
|
Ok(()) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/// Sets the effect of the camera based on the passed [CamEffect] argument.
|
|
|
|
/// Sets the effect of the camera based on the passed [Effect] argument.
|
|
|
|
///
|
|
|
|
///
|
|
|
|
/// Multiple effects can be set at once by combining the bitflags of [CamEffect]
|
|
|
|
/// Multiple effects can be set at once by combining the bitflags of [CamEffect]
|
|
|
|
fn set_effect(&mut self, effect: CamEffect) -> crate::Result<()> { |
|
|
|
fn set_effect(&mut self, effect: Effect) -> crate::Result<()> { |
|
|
|
unsafe { |
|
|
|
unsafe { |
|
|
|
ResultCode(ctru_sys::CAMU_SetEffect( |
|
|
|
ResultCode(ctru_sys::CAMU_SetEffect( |
|
|
|
self.camera_as_raw(), |
|
|
|
self.camera_as_raw(), |
|
|
|
effect.bits(), |
|
|
|
effect.into(), |
|
|
|
ctru_sys::CONTEXT_A, |
|
|
|
ctru_sys::CONTEXT_A, |
|
|
|
))?; |
|
|
|
))?; |
|
|
|
Ok(()) |
|
|
|
Ok(()) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/// Sets the contrast of the camera based on the passed [CamContrast] argument.
|
|
|
|
/// Sets the contrast of the camera based on the passed [Contrast] argument.
|
|
|
|
fn set_contrast(&mut self, contrast: CamContrast) -> crate::Result<()> { |
|
|
|
fn set_contrast(&mut self, contrast: Contrast) -> crate::Result<()> { |
|
|
|
unsafe { |
|
|
|
unsafe { |
|
|
|
ResultCode(ctru_sys::CAMU_SetContrast( |
|
|
|
ResultCode(ctru_sys::CAMU_SetContrast( |
|
|
|
self.camera_as_raw(), |
|
|
|
self.camera_as_raw(), |
|
|
|
contrast.bits(), |
|
|
|
contrast.into(), |
|
|
|
))?; |
|
|
|
))?; |
|
|
|
Ok(()) |
|
|
|
Ok(()) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/// Sets the lens correction of the camera based on the passed [CamLensCorrection] argument.
|
|
|
|
/// Sets the lens correction of the camera based on the passed [LensCorrection] argument.
|
|
|
|
fn set_lens_correction(&mut self, lens_correction: CamLensCorrection) -> crate::Result<()> { |
|
|
|
fn set_lens_correction(&mut self, lens_correction: LensCorrection) -> crate::Result<()> { |
|
|
|
unsafe { |
|
|
|
unsafe { |
|
|
|
ResultCode(ctru_sys::CAMU_SetLensCorrection( |
|
|
|
ResultCode(ctru_sys::CAMU_SetLensCorrection( |
|
|
|
self.camera_as_raw(), |
|
|
|
self.camera_as_raw(), |
|
|
|
lens_correction.bits(), |
|
|
|
lens_correction.into(), |
|
|
|
))?; |
|
|
|
))?; |
|
|
|
Ok(()) |
|
|
|
Ok(()) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/// Sets the output format of the camera based on the passed [CamOutputFormat] argument.
|
|
|
|
/// Sets the output format of the camera based on the passed [OutputFormat] argument.
|
|
|
|
fn set_output_format(&mut self, format: CamOutputFormat) -> crate::Result<()> { |
|
|
|
fn set_output_format(&mut self, format: OutputFormat) -> crate::Result<()> { |
|
|
|
unsafe { |
|
|
|
unsafe { |
|
|
|
ResultCode(ctru_sys::CAMU_SetOutputFormat( |
|
|
|
ResultCode(ctru_sys::CAMU_SetOutputFormat( |
|
|
|
self.camera_as_raw(), |
|
|
|
self.camera_as_raw(), |
|
|
|
format.bits(), |
|
|
|
format.into(), |
|
|
|
ctru_sys::CONTEXT_A, |
|
|
|
ctru_sys::CONTEXT_A, |
|
|
|
))?; |
|
|
|
))?; |
|
|
|
Ok(()) |
|
|
|
Ok(()) |
|
|
@ -687,7 +663,7 @@ pub trait Camera { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/// Returns the current [ImageQualityCalibrationData] for the camera
|
|
|
|
/// Returns the current [ImageQualityCalibrationData] for the camera
|
|
|
|
fn get_image_quality_calibration_data(&self) -> crate::Result<ImageQualityCalibrationData> { |
|
|
|
fn image_quality_calibration_data(&self) -> crate::Result<ImageQualityCalibrationData> { |
|
|
|
unsafe { |
|
|
|
unsafe { |
|
|
|
let mut data = ImageQualityCalibrationData::default(); |
|
|
|
let mut data = ImageQualityCalibrationData::default(); |
|
|
|
ResultCode(ctru_sys::CAMU_GetImageQualityCalibrationData(&mut data.0))?; |
|
|
|
ResultCode(ctru_sys::CAMU_GetImageQualityCalibrationData(&mut data.0))?; |
|
|
@ -806,10 +782,10 @@ impl Cam { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/// Plays the specified sound based on the [CamShutterSoundType] argument
|
|
|
|
/// Plays the specified sound based on the [ShutterSound] argument
|
|
|
|
pub fn play_shutter_sound(&self, sound: CamShutterSoundType) -> crate::Result<()> { |
|
|
|
pub fn play_shutter_sound(&self, sound: ShutterSound) -> crate::Result<()> { |
|
|
|
unsafe { |
|
|
|
unsafe { |
|
|
|
ResultCode(ctru_sys::CAMU_PlayShutterSound(sound.bits()))?; |
|
|
|
ResultCode(ctru_sys::CAMU_PlayShutterSound(sound.into()))?; |
|
|
|
Ok(()) |
|
|
|
Ok(()) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -820,3 +796,14 @@ impl Drop for Cam { |
|
|
|
unsafe { ctru_sys::camExit() }; |
|
|
|
unsafe { ctru_sys::camExit() }; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
from_impl!(FlipMode, ctru_sys::CAMU_Flip); |
|
|
|
|
|
|
|
from_impl!(ViewSize, ctru_sys::CAMU_Size); |
|
|
|
|
|
|
|
from_impl!(FrameRate, ctru_sys::CAMU_FrameRate); |
|
|
|
|
|
|
|
from_impl!(WhiteBalance, ctru_sys::CAMU_WhiteBalance); |
|
|
|
|
|
|
|
from_impl!(PhotoMode, ctru_sys::CAMU_PhotoMode); |
|
|
|
|
|
|
|
from_impl!(Effect, ctru_sys::CAMU_Effect); |
|
|
|
|
|
|
|
from_impl!(Contrast, ctru_sys::CAMU_Contrast); |
|
|
|
|
|
|
|
from_impl!(LensCorrection, ctru_sys::CAMU_LensCorrection); |
|
|
|
|
|
|
|
from_impl!(OutputFormat, ctru_sys::CAMU_OutputFormat); |
|
|
|
|
|
|
|
from_impl!(ShutterSound, ctru_sys::CAMU_ShutterSoundType); |
|
|
|