Browse Source

SoftwareKeyboard::get_string -> SoftwareKeyboard::launch

pull/157/head
Fenrir 11 months ago
parent
commit
cb67d92512
  1. 2
      ctru-rs/examples/file-explorer.rs
  2. 4
      ctru-rs/examples/software-keyboard.rs
  3. 8
      ctru-rs/src/applets/swkbd.rs

2
ctru-rs/examples/file-explorer.rs

@ -165,7 +165,7 @@ impl<'a> FileExplorer<'a> {
fn get_input_and_run(&mut self, action: impl FnOnce(&mut Self, String)) { fn get_input_and_run(&mut self, action: impl FnOnce(&mut Self, String)) {
let mut keyboard = SoftwareKeyboard::default(); let mut keyboard = SoftwareKeyboard::default();
match keyboard.get_string(self.apt, self.gfx) { match keyboard.launch(self.apt, self.gfx) {
Ok((path, Button::Right)) => { Ok((path, Button::Right)) => {
// Clicked "OK". // Clicked "OK".
action(self, path); action(self, path);

4
ctru-rs/examples/software-keyboard.rs

@ -44,9 +44,9 @@ fn main() {
// Check if the user request to write some input. // Check if the user request to write some input.
if hid.keys_down().contains(KeyPad::A) { if hid.keys_down().contains(KeyPad::A) {
// Raise the software keyboard. You can perform different actions depending on which // Launch the software keyboard. You can perform different actions depending on which
// software button the user pressed. // software button the user pressed.
match keyboard.get_string(&apt, &gfx) { match keyboard.launch(&apt, &gfx) {
Ok((text, Button::Right)) => println!("You entered: {text}"), Ok((text, Button::Right)) => println!("You entered: {text}"),
Ok((_, Button::Left)) => println!("Cancelled"), Ok((_, Button::Left)) => println!("Cancelled"),
Ok((_, Button::Middle)) => println!("How did you even press this?"), Ok((_, Button::Middle)) => println!("How did you even press this?"),

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

@ -114,7 +114,7 @@ pub enum ButtonConfig {
LeftMiddleRight = 3, LeftMiddleRight = 3,
} }
/// Error returned by an unsuccessful [`SoftwareKeyboard::get_string()`]. /// Error returned by an unsuccessful [`SoftwareKeyboard::launch()`].
#[doc(alias = "SwkbdResult")] #[doc(alias = "SwkbdResult")]
#[derive(Copy, Clone, Debug, PartialEq, Eq)] #[derive(Copy, Clone, Debug, PartialEq, Eq)]
#[repr(i32)] #[repr(i32)]
@ -266,13 +266,13 @@ impl SoftwareKeyboard {
/// use ctru::applets::swkbd::SoftwareKeyboard; /// use ctru::applets::swkbd::SoftwareKeyboard;
/// let mut keyboard = SoftwareKeyboard::default(); /// let mut keyboard = SoftwareKeyboard::default();
/// ///
/// let (text, button) = keyboard.get_string(&apt, &gfx)?; /// let (text, button) = keyboard.launch(&apt, &gfx)?;
/// # /// #
/// # Ok(()) /// # Ok(())
/// # } /// # }
/// ``` /// ```
#[doc(alias = "swkbdInputText")] #[doc(alias = "swkbdInputText")]
pub fn get_string(&mut self, _apt: &Apt, _gfx: &Gfx) -> Result<(String, Button), Error> { pub fn launch(&mut self, _apt: &Apt, _gfx: &Gfx) -> Result<(String, Button), Error> {
let mut output = String::new(); let mut output = String::new();
unsafe { unsafe {
@ -608,7 +608,7 @@ impl SoftwareKeyboard {
/// ///
/// Keyboard input is converted from UTF-16 to UTF-8 before being handed to Rust, /// Keyboard input is converted from UTF-16 to UTF-8 before being handed to Rust,
/// so this code point limit does not necessarily equal the max number of UTF-8 code points /// so this code point limit does not necessarily equal the max number of UTF-8 code points
/// receivable by [`SoftwareKeyboard::get_string()`]. /// receivable by [`SoftwareKeyboard::launch()`].
/// ///
/// # Example /// # Example
/// ///

Loading…
Cancel
Save