diff options
| author | Fenrir <[email protected]> | 2018-04-29 17:31:52 -0600 |
|---|---|---|
| committer | Fenrir <[email protected]> | 2018-04-29 17:31:52 -0600 |
| commit | 741ef60a24193ef18ae688eb2034347260e9d78c (patch) | |
| tree | 03a7ac9d9aed77b03c8533c3cb4b1301aa00e828 | |
| parent | Add software keyboard example (diff) | |
| download | archived-ctru-rs-741ef60a24193ef18ae688eb2034347260e9d78c.tar.xz archived-ctru-rs-741ef60a24193ef18ae688eb2034347260e9d78c.zip | |
Add nul-terminatator to input that expects it
| -rw-r--r-- | ctru-rs/src/applets/swkbd.rs | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/ctru-rs/src/applets/swkbd.rs b/ctru-rs/src/applets/swkbd.rs index ee6d99a..515dd92 100644 --- a/ctru-rs/src/applets/swkbd.rs +++ b/ctru-rs/src/applets/swkbd.rs @@ -1,3 +1,4 @@ +use std::iter::once; use std::mem; use std::str; @@ -160,7 +161,8 @@ impl Swkbd { /// when the textbox is empty) pub fn set_hint_text(&mut self, text: &str) { unsafe { - swkbdSetHintText(self.state.as_mut(), text.as_ptr()); + let nul_terminated: String = text.chars().chain(once('\0')).collect(); + swkbdSetHintText(self.state.as_mut(), nul_terminated.as_ptr()); } } @@ -172,7 +174,8 @@ impl Swkbd { /// discard it. pub fn configure_button(&mut self, button: Button, text: &str, submit: bool) { unsafe { - swkbdSetButton(self.state.as_mut(), button as u32, text.as_ptr(), submit); + let nul_terminated: String = text.chars().chain(once('\0')).collect(); + swkbdSetButton(self.state.as_mut(), button as u32, nul_terminated.as_ptr(), submit); } } |