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

9
ctru-rs/src/console.rs

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

1
ctru-sys/bindgen.sh

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