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