Browse Source

Merge branch 'improve/api' into feat/flush-swap-screen-traits

pull/118/head
Ian Chamberlain 2 years ago
parent
commit
7ac47b8838
No known key found for this signature in database
GPG Key ID: AE5484D09405AA60
  1. 2
      ctru-rs/examples/gfx-3d-mode.rs
  2. 4
      ctru-rs/src/services/gfx.rs
  3. 16
      ctru-rs/src/services/hid.rs
  4. 4
      ctru-rs/src/services/mod.rs

2
ctru-rs/examples/gfx-3d-mode.rs

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
use ctru::prelude::*;
use ctru::services::gfx::{Screen, Side, Swap, TopScreen3D};
use ctru::services::gfx::{Flush, Screen, Side, Swap, TopScreen3D};
/// See `graphics-bitmap.rs` for details on how the image is generated.
///

4
ctru-rs/src/services/gfx.rs

@ -89,6 +89,9 @@ impl SwappableScreen for TopScreen {} @@ -89,6 +89,9 @@ impl SwappableScreen for TopScreen {}
impl SwappableScreen for BottomScreen {}
impl<S: SwappableScreen> Swap for S {
/// Swaps the video buffers.
///
/// This should be used even if double buffering is disabled.
fn swap_buffers(&mut self) {
unsafe {
ctru_sys::gfxScreenSwapBuffers(self.side().into(), false);
@ -97,6 +100,7 @@ impl<S: SwappableScreen> Swap for S { @@ -97,6 +100,7 @@ impl<S: SwappableScreen> Swap for S {
}
pub trait Flush: private::Sealed {
/// Flushes the video buffer for this screen.
fn flush_buffer(&mut self);
}

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

@ -13,10 +13,10 @@ bitflags::bitflags! { @@ -13,10 +13,10 @@ bitflags::bitflags! {
const B = ctru_sys::KEY_B;
const SELECT = ctru_sys::KEY_SELECT;
const START = ctru_sys::KEY_START;
const DRIGHT = ctru_sys::KEY_DRIGHT;
const DLEFT = ctru_sys::KEY_DLEFT;
const DUP = ctru_sys::KEY_DUP;
const DDOWN = ctru_sys::KEY_DDOWN;
const DPAD_RIGHT = ctru_sys::KEY_DRIGHT;
const DPAD_LEFT = ctru_sys::KEY_DLEFT;
const DPAD_UP = ctru_sys::KEY_DUP;
const DPAD_DOWN = ctru_sys::KEY_DDOWN;
const R = ctru_sys::KEY_R;
const L = ctru_sys::KEY_L;
const X = ctru_sys::KEY_X;
@ -33,10 +33,10 @@ bitflags::bitflags! { @@ -33,10 +33,10 @@ bitflags::bitflags! {
const CPAD_UP = ctru_sys::KEY_CPAD_UP;
const CPAD_DOWN = ctru_sys::KEY_CPAD_DOWN;
// Convenience catch-all for the dpad and cpad
const UP = KeyPad::DUP.bits() | KeyPad::CPAD_UP.bits();
const DOWN = KeyPad::DDOWN.bits() | KeyPad::CPAD_DOWN.bits();
const LEFT = KeyPad::DLEFT.bits() | KeyPad::CPAD_LEFT.bits();
const RIGHT = KeyPad::DRIGHT.bits() | KeyPad::CPAD_RIGHT.bits();
const UP = KeyPad::DPAD_UP.bits() | KeyPad::CPAD_UP.bits();
const DOWN = KeyPad::DPAD_DOWN.bits() | KeyPad::CPAD_DOWN.bits();
const LEFT = KeyPad::DPAD_LEFT.bits() | KeyPad::CPAD_LEFT.bits();
const RIGHT = KeyPad::DPAD_RIGHT.bits() | KeyPad::CPAD_RIGHT.bits();
}
}

4
ctru-rs/src/services/mod.rs

@ -34,6 +34,10 @@ cfg_if::cfg_if! { @@ -34,6 +34,10 @@ cfg_if::cfg_if! {
//! [package.metadata.cargo-3ds]
//! romfs_dir = "romfs"
//! ```
// If the feature is set, but no "romfs" directory was found: send an error during compilation.
#[cfg(feature = "romfs")]
compile_error!("romfs feature is enabled but no romfs found!");
}
}
}

Loading…
Cancel
Save