From 63949f5a0ea4e518dac55b073ae9f003bb7a7f5d Mon Sep 17 00:00:00 2001 From: Steve Cook Date: Fri, 19 Aug 2022 13:41:22 -0400 Subject: [PATCH] Remove CamContext implementation --- ctru-rs/examples/camera-image.rs | 6 ++-- ctru-rs/src/services/cam.rs | 51 ++++++++++---------------------- 2 files changed, 18 insertions(+), 39 deletions(-) diff --git a/ctru-rs/examples/camera-image.rs b/ctru-rs/examples/camera-image.rs index 9ae315e..91d8bcd 100644 --- a/ctru-rs/examples/camera-image.rs +++ b/ctru-rs/examples/camera-image.rs @@ -1,6 +1,6 @@ use ctru::console::Console; use ctru::gfx::{Screen, Side}; -use ctru::services::cam::{Cam, CamContext, CamOutputFormat, CamShutterSoundType, CamSize, Camera}; +use ctru::services::cam::{Cam, CamOutputFormat, CamShutterSoundType, CamSize, Camera}; use ctru::services::hid::KeyPad; use ctru::services::{Apt, Hid}; use ctru::Gfx; @@ -32,11 +32,11 @@ fn main() { let mut camera = cam.outer_right_cam.borrow_mut(); camera - .set_size(CamSize::CTR_TOP_LCD, CamContext::A) + .set_size(CamSize::CTR_TOP_LCD) .expect("Failed to set camera size"); camera - .set_output_format(CamOutputFormat::RGB_565, CamContext::A) + .set_output_format(CamOutputFormat::RGB_565) .expect("Failed to set camera output format"); camera diff --git a/ctru-rs/src/services/cam.rs b/ctru-rs/src/services/cam.rs index 1d20052..2ed40fb 100644 --- a/ctru-rs/src/services/cam.rs +++ b/ctru-rs/src/services/cam.rs @@ -32,16 +32,6 @@ bitflags! { } } -bitflags! { - #[derive(Default)] - pub struct CamContext: u32 { - const NONE = ctru_sys::CONTEXT_NONE; - const A = ctru_sys::CONTEXT_A; - const B = ctru_sys::CONTEXT_B; - const BOTH = ctru_sys::CONTEXT_BOTH; - } -} - bitflags! { #[derive(Default)] pub struct CamFlip: u32 { @@ -532,17 +522,6 @@ pub trait Camera { } } - fn switch_context(&mut self, context: CamContext) -> crate::Result<()> { - unsafe { - let r = ctru_sys::CAMU_SwitchContext(self.camera_as_raw(), context.bits()); - if r < 0 { - Err(r.into()) - } else { - Ok(()) - } - } - } - fn set_exposure(&mut self, exposure: i8) -> crate::Result<()> { unsafe { let r = ctru_sys::CAMU_SetExposure(self.camera_as_raw(), exposure); @@ -640,9 +619,10 @@ pub trait Camera { } } - fn flip_image(&mut self, flip: CamFlip, context: CamContext) -> crate::Result<()> { + fn flip_image(&mut self, flip: CamFlip) -> crate::Result<()> { unsafe { - let r = ctru_sys::CAMU_FlipImage(self.camera_as_raw(), flip.bits(), context.bits()); + let r = + ctru_sys::CAMU_FlipImage(self.camera_as_raw(), flip.bits(), ctru_sys::CONTEXT_A); if r < 0 { Err(r.into()) } else { @@ -657,7 +637,6 @@ pub trait Camera { height: i16, crop_0: (i16, i16), crop_1: (i16, i16), - context: CamContext, ) -> crate::Result<()> { unsafe { let r = ctru_sys::CAMU_SetDetailSize( @@ -668,7 +647,7 @@ pub trait Camera { crop_0.1, crop_1.0, crop_1.1, - context.bits(), + ctru_sys::CONTEXT_A, ); if r < 0 { Err(r.into()) @@ -678,9 +657,9 @@ pub trait Camera { } } - fn set_size(&mut self, size: CamSize, context: CamContext) -> crate::Result<()> { + fn set_size(&mut self, size: CamSize) -> crate::Result<()> { unsafe { - let r = ctru_sys::CAMU_SetSize(self.camera_as_raw(), size.bits(), context.bits()); + let r = ctru_sys::CAMU_SetSize(self.camera_as_raw(), size.bits(), ctru_sys::CONTEXT_A); if r < 0 { Err(r.into()) } else { @@ -711,9 +690,10 @@ pub trait Camera { } } - fn set_effect(&mut self, effect: CamEffect, context: CamContext) -> crate::Result<()> { + fn set_effect(&mut self, effect: CamEffect) -> crate::Result<()> { unsafe { - let r = ctru_sys::CAMU_SetEffect(self.camera_as_raw(), effect.bits(), context.bits()); + let r = + ctru_sys::CAMU_SetEffect(self.camera_as_raw(), effect.bits(), ctru_sys::CONTEXT_A); if r < 0 { Err(r.into()) } else { @@ -744,14 +724,13 @@ pub trait Camera { } } - fn set_output_format( - &mut self, - format: CamOutputFormat, - context: CamContext, - ) -> crate::Result<()> { + fn set_output_format(&mut self, format: CamOutputFormat) -> crate::Result<()> { unsafe { - let r = - ctru_sys::CAMU_SetOutputFormat(self.camera_as_raw(), format.bits(), context.bits()); + let r = ctru_sys::CAMU_SetOutputFormat( + self.camera_as_raw(), + format.bits(), + ctru_sys::CONTEXT_A, + ); if r < 0 { Err(r.into()) } else {