//! This applet opens a virtual keyboard on the console's bottom screen which lets the user write UTF-16 valid text.
//! This applet opens a virtual keyboard on the console's bottom screen which lets the user write UTF-16 valid text.
// TODO: Implement remaining functionality (password mode, filter callbacks, etc.). Also improve "max text length" API. Improve `number of buttons` API when creating a new SoftwareKeyboard.
// TODO: Implement remaining functionality (password mode, filter callbacks, etc.). Also improve "max text length" API.
#![doc(alias = "keyboard")]
#![doc(alias = "keyboard")]
usecrate::services::{apt::Apt,gfx::Gfx};
usecrate::services::{apt::Apt,gfx::Gfx};
@ -66,6 +66,18 @@ pub enum Button {
Right=ctru_sys::SWKBD_BUTTON_RIGHT,
Right=ctru_sys::SWKBD_BUTTON_RIGHT,
}
}
/// Configuration to setup the on-screen buttons to exit the [`SoftwareKeyboard`] prompt.
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
#[repr(i32)]
pubenumButtonConfig{
/// 1 Button: considered the right button.
Right=1,
/// 2 Buttons: left and right buttons.
LeftRight=2,
/// 3 Buttons: left, middle and right buttons.
LeftMiddleRight=3,
}
/// Error returned by an unsuccessful [`SoftwareKeyboard::get_string()`].
/// Error returned by an unsuccessful [`SoftwareKeyboard::get_string()`].
#[doc(alias = "SwkbdResult")]
#[doc(alias = "SwkbdResult")]
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
@ -176,20 +188,20 @@ impl SoftwareKeyboard {
/// # let _runner = test_runner::GdbRunner::default();
/// # let _runner = test_runner::GdbRunner::default();
/// # fn main() {
/// # fn main() {
/// #
/// #
/// use ctru::applets::swkbd::{SoftwareKeyboard, Kind};
/// use ctru::applets::swkbd::{SoftwareKeyboard, ButtonConfig, Kind};
///
///
/// // Standard keyboard.
/// // Standard keyboard. Equivalent to `SoftwareKeyboard::default()`.
/// let keyboard = SoftwareKeyboard::new(Kind::Normal, 2);
/// let keyboard = SoftwareKeyboard::new(Kind::Normal, ButtonConfig::LeftRight);
///
///
/// // Numpad (with only the "confirm" button).
/// // Numpad (with only the "confirm" button).
/// let keyboard = SoftwareKeyboard::new(Kind::Numpad, 1);
/// let keyboard = SoftwareKeyboard::new(Kind::Numpad, ButtonConfig::Right);