|
|
@ -633,6 +633,7 @@ impl SoftwareKeyboard { |
|
|
|
// an intermediate fixed-size buffer
|
|
|
|
// an intermediate fixed-size buffer
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// SAFETY: `swkbd` must be initialized by `swkbdInit` before calling this function.
|
|
|
|
// SAFETY: `swkbd` must be initialized by `swkbdInit` before calling this function.
|
|
|
|
|
|
|
|
#[deny(unsafe_op_in_unsafe_fn)] |
|
|
|
unsafe fn swkbd_input_text(swkbd: &mut SwkbdState, output: &mut String) -> SwkbdButton { |
|
|
|
unsafe fn swkbd_input_text(swkbd: &mut SwkbdState, 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, |
|
|
@ -842,15 +843,15 @@ impl SoftwareKeyboard { |
|
|
|
// A reimplementation of `swkbdMessageCallback` from `libctru/source/applets/swkbd.c`.
|
|
|
|
// A reimplementation of `swkbdMessageCallback` from `libctru/source/applets/swkbd.c`.
|
|
|
|
// This is only needed because the original function is private to libctru, so we can't
|
|
|
|
// This is only needed because the original function is private to libctru, so we can't
|
|
|
|
// simply reuse their version
|
|
|
|
// simply reuse their version
|
|
|
|
#[allow(non_snake_case)] |
|
|
|
#[deny(unsafe_op_in_unsafe_fn)] |
|
|
|
unsafe extern "C" fn swkbd_message_callback( |
|
|
|
unsafe extern "C" fn swkbd_message_callback( |
|
|
|
user: *mut libc::c_void, |
|
|
|
user: *mut libc::c_void, |
|
|
|
sender: NS_APPID, |
|
|
|
sender: NS_APPID, |
|
|
|
msg: *mut libc::c_void, |
|
|
|
msg: *mut libc::c_void, |
|
|
|
msg_size: libc::size_t, |
|
|
|
msg_size: libc::size_t, |
|
|
|
) { |
|
|
|
) { |
|
|
|
let extra = &mut *user.cast::<SwkbdExtra>(); |
|
|
|
let extra = unsafe { &mut *user.cast::<SwkbdExtra>() }; |
|
|
|
let swkbd = &mut *msg.cast::<SwkbdState>(); |
|
|
|
let swkbd = unsafe { &mut *msg.cast::<SwkbdState>() }; |
|
|
|
|
|
|
|
|
|
|
|
if sender != ctru_sys::APPID_SOFTWARE_KEYBOARD |
|
|
|
if sender != ctru_sys::APPID_SOFTWARE_KEYBOARD |
|
|
|
|| msg_size != std::mem::size_of::<SwkbdState>() |
|
|
|
|| msg_size != std::mem::size_of::<SwkbdState>() |
|
|
@ -870,12 +871,14 @@ impl SoftwareKeyboard { |
|
|
|
let mut retmsg = std::ptr::null(); |
|
|
|
let mut retmsg = std::ptr::null(); |
|
|
|
|
|
|
|
|
|
|
|
if let Some(cb) = extra.callback { |
|
|
|
if let Some(cb) = extra.callback { |
|
|
|
swkbd.callback_result = cb( |
|
|
|
swkbd.callback_result = unsafe { |
|
|
|
extra.callback_user, |
|
|
|
cb( |
|
|
|
&mut retmsg, |
|
|
|
extra.callback_user, |
|
|
|
text8.as_ptr(), |
|
|
|
&mut retmsg, |
|
|
|
text8.len(), |
|
|
|
text8.as_ptr(), |
|
|
|
) as _ |
|
|
|
text8.len(), |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
} as _ |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
let retmsg = if !retmsg.is_null() { |
|
|
|
let retmsg = if !retmsg.is_null() { |
|
|
@ -897,14 +900,16 @@ impl SoftwareKeyboard { |
|
|
|
callback_msg[idx] = code_point; |
|
|
|
callback_msg[idx] = code_point; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
let _ = APT_SendParameter( |
|
|
|
let _ = unsafe { |
|
|
|
envGetAptAppId(), |
|
|
|
APT_SendParameter( |
|
|
|
sender, |
|
|
|
envGetAptAppId(), |
|
|
|
APTCMD_MESSAGE, |
|
|
|
sender, |
|
|
|
swkbd as *mut _ as *mut _, |
|
|
|
APTCMD_MESSAGE, |
|
|
|
std::mem::size_of::<SwkbdState>() as _, |
|
|
|
swkbd as *mut _ as *mut _, |
|
|
|
0, |
|
|
|
std::mem::size_of::<SwkbdState>() as _, |
|
|
|
); |
|
|
|
0, |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
}; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|