From 4f776778f1958b80aeca653b9fc53aaad9d6085e Mon Sep 17 00:00:00 2001 From: Fenrir Date: Sun, 29 Apr 2018 14:49:36 -0600 Subject: [PATCH] add `set_hint_text` and `configure_button` --- ctru-rs/src/applets/swkbd.rs | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/ctru-rs/src/applets/swkbd.rs b/ctru-rs/src/applets/swkbd.rs index 7f3dcfd..ee6d99a 100644 --- a/ctru-rs/src/applets/swkbd.rs +++ b/ctru-rs/src/applets/swkbd.rs @@ -1,7 +1,8 @@ use std::mem; use std::str; -use libctru::{self, SwkbdState, swkbdInit, swkbdSetFeatures, swkbdInputText}; +use libctru::{self, SwkbdState, swkbdInit, swkbdSetFeatures, swkbdSetHintText, swkbdInputText, + swkbdSetButton}; use libc; @@ -155,6 +156,26 @@ impl Swkbd { self.state.max_digits = digits; } + /// Sets the hint text for this software keyboard (that is, the help text that is displayed + /// when the textbox is empty) + pub fn set_hint_text(&mut self, text: &str) { + unsafe { + swkbdSetHintText(self.state.as_mut(), text.as_ptr()); + } + } + + /// Configures the look and behavior of a button for this keyboard. + /// + /// `button` is the `Button` to be configured + /// `text` configures the display text for the button + /// `submit` configures whether pressing the button will accept the keyboard's input or + /// 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); + } + } + /// Configures the maximum number of UTF-16 code units that can be entered into the software /// keyboard. By default the limit is 0xFDE8 code units. ///