Browse Source

Remove CamContext implementation

pull/65/head
Steve Cook 2 years ago
parent
commit
63949f5a0e
  1. 6
      ctru-rs/examples/camera-image.rs
  2. 51
      ctru-rs/src/services/cam.rs

6
ctru-rs/examples/camera-image.rs

@ -1,6 +1,6 @@
use ctru::console::Console; use ctru::console::Console;
use ctru::gfx::{Screen, Side}; 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::hid::KeyPad;
use ctru::services::{Apt, Hid}; use ctru::services::{Apt, Hid};
use ctru::Gfx; use ctru::Gfx;
@ -32,11 +32,11 @@ fn main() {
let mut camera = cam.outer_right_cam.borrow_mut(); let mut camera = cam.outer_right_cam.borrow_mut();
camera camera
.set_size(CamSize::CTR_TOP_LCD, CamContext::A) .set_size(CamSize::CTR_TOP_LCD)
.expect("Failed to set camera size"); .expect("Failed to set camera size");
camera camera
.set_output_format(CamOutputFormat::RGB_565, CamContext::A) .set_output_format(CamOutputFormat::RGB_565)
.expect("Failed to set camera output format"); .expect("Failed to set camera output format");
camera camera

51
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! { bitflags! {
#[derive(Default)] #[derive(Default)]
pub struct CamFlip: u32 { 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<()> { fn set_exposure(&mut self, exposure: i8) -> crate::Result<()> {
unsafe { unsafe {
let r = ctru_sys::CAMU_SetExposure(self.camera_as_raw(), exposure); 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 { 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 { if r < 0 {
Err(r.into()) Err(r.into())
} else { } else {
@ -657,7 +637,6 @@ pub trait Camera {
height: i16, height: i16,
crop_0: (i16, i16), crop_0: (i16, i16),
crop_1: (i16, i16), crop_1: (i16, i16),
context: CamContext,
) -> crate::Result<()> { ) -> crate::Result<()> {
unsafe { unsafe {
let r = ctru_sys::CAMU_SetDetailSize( let r = ctru_sys::CAMU_SetDetailSize(
@ -668,7 +647,7 @@ pub trait Camera {
crop_0.1, crop_0.1,
crop_1.0, crop_1.0,
crop_1.1, crop_1.1,
context.bits(), ctru_sys::CONTEXT_A,
); );
if r < 0 { if r < 0 {
Err(r.into()) 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 { 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 { if r < 0 {
Err(r.into()) Err(r.into())
} else { } 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 { 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 { if r < 0 {
Err(r.into()) Err(r.into())
} else { } else {
@ -744,14 +724,13 @@ pub trait Camera {
} }
} }
fn set_output_format( fn set_output_format(&mut self, format: CamOutputFormat) -> crate::Result<()> {
&mut self,
format: CamOutputFormat,
context: CamContext,
) -> crate::Result<()> {
unsafe { unsafe {
let r = let r = ctru_sys::CAMU_SetOutputFormat(
ctru_sys::CAMU_SetOutputFormat(self.camera_as_raw(), format.bits(), context.bits()); self.camera_as_raw(),
format.bits(),
ctru_sys::CONTEXT_A,
);
if r < 0 { if r < 0 {
Err(r.into()) Err(r.into())
} else { } else {

Loading…
Cancel
Save