Browse Source

Fmt and clippy

pull/118/head
Andrea Ciliberti 2 years ago
parent
commit
ef074a66ad
  1. 9
      ctru-rs/examples/camera-image.rs
  2. 2
      ctru-rs/examples/gfx-wide-mode.rs
  3. 2
      ctru-rs/examples/thread-info.rs
  4. 6
      ctru-rs/src/applets/mii_selector.rs
  5. 4
      ctru-rs/src/console.rs
  6. 2
      ctru-rs/src/services/fs.rs
  7. 11
      ctru-rs/src/services/gfx.rs

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

@ -23,7 +23,7 @@ fn main() { @@ -23,7 +23,7 @@ fn main() {
let mut top_screen = gfx.top_screen.borrow_mut();
top_screen.set_double_buffering(true);
top_screen.set_framebuffer_format(FramebufferFormat::Rgb565);
let _console = Console::new(gfx.bottom_screen.borrow_mut());
let mut keys_down;
@ -85,12 +85,7 @@ fn main() { @@ -85,12 +85,7 @@ fn main() {
cam.play_shutter_sound(ShutterSound::Normal)
.expect("Failed to play shutter sound");
rotate_image_to_screen(
&buf,
top_screen.raw_framebuffer().ptr,
WIDTH,
HEIGHT,
);
rotate_image_to_screen(&buf, top_screen.raw_framebuffer().ptr, WIDTH, HEIGHT);
// We will only flush the "camera" screen, since the other screen is handled by `Console`
top_screen.flush_buffer();

2
ctru-rs/examples/gfx-wide-mode.rs

@ -26,7 +26,7 @@ fn main() { @@ -26,7 +26,7 @@ fn main() {
console = Console::new(gfx.top_screen.borrow_mut());
println!("Press A to enable/disable wide screen mode.");
}
gfx.wait_for_vblank();
}
}

2
ctru-rs/examples/thread-info.rs

@ -44,7 +44,7 @@ fn main() { @@ -44,7 +44,7 @@ fn main() {
if hid.keys_down().contains(KeyPad::KEY_START) {
break;
}
gfx.wait_for_vblank();
}
}

6
ctru-rs/src/applets/mii_selector.rs

@ -155,6 +155,12 @@ impl MiiSelector { @@ -155,6 +155,12 @@ impl MiiSelector {
}
}
impl Default for MiiSelector {
fn default() -> Self {
Self::new()
}
}
impl From<ctru_sys::MiiSelectorReturn> for SelectionResult {
fn from(ret: ctru_sys::MiiSelectorReturn) -> Self {
let raw_mii_data = ret.mii;

4
ctru-rs/src/console.rs

@ -16,9 +16,9 @@ impl<'screen> Console<'screen> { @@ -16,9 +16,9 @@ impl<'screen> Console<'screen> {
/// Initialize a console on the chosen screen, overwriting whatever was on the screen
/// previously (including other consoles). The new console is automatically selected for
/// printing.
///
///
/// # Notes
///
///
/// [Console] automatically takes care of flushing and swapping buffers for its screen when printing.
pub fn new(screen: RefMut<'screen, dyn Screen>) -> Self {
let mut context = Box::<PrintConsole>::default();

2
ctru-rs/src/services/fs.rs

@ -29,7 +29,7 @@ bitflags! { @@ -29,7 +29,7 @@ bitflags! {
const FS_WRITE_FLUSH = 1;
const FS_WRITE_UPDATE_TIME = 256;
}
#[derive(Default)]
struct FsAttribute: u32 {
const FS_ATTRIBUTE_DIRECTORY = 1;

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

@ -56,17 +56,22 @@ pub trait Screen: private::Sealed { @@ -56,17 +56,22 @@ pub trait Screen: private::Sealed {
}
/// Swaps the video buffers.
///
///
/// This should be used even if double buffering is disabled.
fn flush_buffer(&mut self) {
let framebuffer = self.raw_framebuffer();
// Flush the data array. `self.raw_framebuffer` should get the correct parameters for all kinds of screens
unsafe { ctru_sys::GSPGPU_FlushDataCache(framebuffer.ptr.cast(), (framebuffer.height * framebuffer.width) as u32) };
unsafe {
ctru_sys::GSPGPU_FlushDataCache(
framebuffer.ptr.cast(),
(framebuffer.height * framebuffer.width) as u32,
)
};
}
/// 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(), true) };

Loading…
Cancel
Save