|
|
@ -272,6 +272,7 @@ impl SoftwareKeyboard { |
|
|
|
pub fn launch(&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 { |
|
|
|
match self.swkbd_input_text(&mut output) { |
|
|
|
match self.swkbd_input_text(&mut output) { |
|
|
|
ctru_sys::SWKBD_BUTTON_NONE => Err(self.state.result.into()), |
|
|
|
ctru_sys::SWKBD_BUTTON_NONE => Err(self.state.result.into()), |
|
|
|
ctru_sys::SWKBD_BUTTON_LEFT => Ok((output, Button::Left)), |
|
|
|
ctru_sys::SWKBD_BUTTON_LEFT => Ok((output, Button::Left)), |
|
|
@ -280,6 +281,7 @@ impl SoftwareKeyboard { |
|
|
|
_ => unreachable!(), |
|
|
|
_ => unreachable!(), |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/// Set special features for this keyboard.
|
|
|
|
/// Set special features for this keyboard.
|
|
|
|
///
|
|
|
|
///
|
|
|
@ -583,10 +585,13 @@ impl SoftwareKeyboard { |
|
|
|
self.state.valid_input = ValidInput::FixedLen.into(); |
|
|
|
self.state.valid_input = ValidInput::FixedLen.into(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// A reimplementation of `swkbdInputText` from `libctru/source/applets/swkbd.c`. Allows us to
|
|
|
|
/// A reimplementation of `swkbdInputText` from `libctru/source/applets/swkbd.c`. Allows us to fix various
|
|
|
|
// get text from the software keyboard and put it directly into a `String` without requiring
|
|
|
|
/// API nits and get rid of awkward type conversions when interacting with the Software Keyboard.
|
|
|
|
// an intermediate fixed-size buffer
|
|
|
|
///
|
|
|
|
fn swkbd_input_text(&mut self, output: &mut String) -> SwkbdButton { |
|
|
|
/// # Safety
|
|
|
|
|
|
|
|
///
|
|
|
|
|
|
|
|
/// The [`Apt`] and [`Gfx`] services must be active when this function is called.
|
|
|
|
|
|
|
|
unsafe fn swkbd_input_text(&mut self, output: &mut String) -> SwkbdButton { |
|
|
|
use ctru_sys::{ |
|
|
|
use ctru_sys::{ |
|
|
|
MEMPERM_READ, MEMPERM_WRITE, R_FAILED, SWKBD_BUTTON_LEFT, SWKBD_BUTTON_MIDDLE, |
|
|
|
MEMPERM_READ, MEMPERM_WRITE, R_FAILED, SWKBD_BUTTON_LEFT, SWKBD_BUTTON_MIDDLE, |
|
|
|
SWKBD_BUTTON_NONE, SWKBD_BUTTON_RIGHT, SWKBD_D0_CLICK, SWKBD_D1_CLICK0, |
|
|
|
SWKBD_BUTTON_NONE, SWKBD_BUTTON_RIGHT, SWKBD_D0_CLICK, SWKBD_D1_CLICK0, |
|
|
|