Browse Source

Fix Console and Swkbd to not move after initialization

pull/10/head
AzureMarker 3 years ago
parent
commit
42e68139cb
No known key found for this signature in database
GPG Key ID: 47A133F3BF9D03D3
  1. 9
      ctru-rs/src/applets/swkbd.rs
  2. 9
      ctru-rs/src/console.rs
  3. 1
      ctru-sys/bindgen.sh
  4. 1169
      ctru-sys/src/bindings.rs

9
ctru-rs/src/applets/swkbd.rs

@ -1,6 +1,5 @@ @@ -1,6 +1,5 @@
use std::convert::TryInto;
use std::iter::once;
use std::mem::MaybeUninit;
use std::str;
use libctru::{
@ -92,11 +91,9 @@ impl Swkbd { @@ -92,11 +91,9 @@ impl Swkbd {
/// (from 1-3).
pub fn init(keyboard_type: Kind, num_buttons: i32) -> Self {
unsafe {
let mut state = MaybeUninit::<SwkbdState>::uninit();
swkbdInit(state.as_mut_ptr(), keyboard_type as u32, num_buttons, -1);
Swkbd {
state: Box::new(state.assume_init()),
}
let mut state = Box::new(SwkbdState::default());
swkbdInit(state.as_mut(), keyboard_type as u32, num_buttons, -1);
Swkbd { state }
}
}

9
ctru-rs/src/console.rs

@ -1,5 +1,4 @@ @@ -1,5 +1,4 @@
use std::default::Default;
use std::mem::MaybeUninit;
use libctru::{consoleClear, consoleInit, consoleSelect, consoleSetWindow, PrintConsole};
@ -15,12 +14,10 @@ impl Console { @@ -15,12 +14,10 @@ impl Console {
/// printing.
pub fn init(screen: Screen) -> Self {
unsafe {
let mut context = MaybeUninit::<PrintConsole>::uninit();
consoleInit(screen.into(), context.as_mut_ptr());
let mut context = Box::new(PrintConsole::default());
consoleInit(screen.into(), context.as_mut());
Console {
context: Box::new(context.assume_init()),
}
Console { context }
}
}

1
ctru-sys/bindgen.sh

@ -15,6 +15,7 @@ bindgen "$DEVKITPRO/libctru/include/3ds.h" \ @@ -15,6 +15,7 @@ bindgen "$DEVKITPRO/libctru/include/3ds.h" \
--blacklist-type "__builtin_va_list" \
--blacklist-type "__va_list" \
--opaque-type "MiiData" \
--with-derive-default \
-- \
--target=arm-none-eabi \
--sysroot=$DEVKITARM/arm-none-eabi \

1169
ctru-sys/src/bindings.rs

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save