Browse Source

Store initial_text data in SoftwareKeyboard

pull/158/head
Fenrir 10 months ago
parent
commit
22773f644a
  1. 10
      ctru-rs/src/applets/swkbd.rs

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

@ -22,6 +22,7 @@ pub struct SoftwareKeyboard {
state: Box<SwkbdState>, state: Box<SwkbdState>,
callback: Option<Box<CallbackFunction>>, callback: Option<Box<CallbackFunction>>,
error_message: Option<CString>, error_message: Option<CString>,
initial_text: Option<CString>,
} }
/// Configuration structure to setup the Parental Lock applet. /// Configuration structure to setup the Parental Lock applet.
@ -233,6 +234,7 @@ impl SoftwareKeyboard {
state, state,
callback: None, callback: None,
error_message: None, error_message: None,
initial_text: None,
} }
} }
} }
@ -503,8 +505,12 @@ impl SoftwareKeyboard {
#[doc(alias = "swkbdSetInitialText")] #[doc(alias = "swkbdSetInitialText")]
pub fn set_initial_text(&mut self, text: &str) { pub fn set_initial_text(&mut self, text: &str) {
unsafe { unsafe {
let nul_terminated: String = text.chars().chain(once('\0')).collect(); self.initial_text = Some(CString::new(text).unwrap());
ctru_sys::swkbdSetInitialText(self.state.as_mut(), nul_terminated.as_ptr());
ctru_sys::swkbdSetInitialText(
self.state.as_mut(),
self.initial_text.as_ref().unwrap().as_ptr(),
);
} }
} }

Loading…
Cancel
Save