diff --git a/ctru-rs/src/applets/swkbd.rs b/ctru-rs/src/applets/swkbd.rs index 667a459..69b6f98 100644 --- a/ctru-rs/src/applets/swkbd.rs +++ b/ctru-rs/src/applets/swkbd.rs @@ -211,6 +211,7 @@ bitflags! { } // Internal book-keeping struct used to send data to `aptSetMessageCallback` when calling the software keyboard. +#[derive(Copy, Clone)] struct MessageCallbackData { filter_callback: *const Box, swkbd_shared_mem_ptr: *mut libc::c_void, @@ -802,15 +803,15 @@ impl SoftwareKeyboard { msg: *mut libc::c_void, msg_size: libc::size_t, ) { - let data = unsafe { &mut *user.cast::() }; - let swkbd = unsafe { &mut *msg.cast::() }; - if sender != ctru_sys::APPID_SOFTWARE_KEYBOARD || msg_size != std::mem::size_of::() { return; } + let swkbd = unsafe { &mut *msg.cast::() }; + let data = unsafe { *user.cast::() }; + let text16 = unsafe { widestring::Utf16Str::from_slice_unchecked(std::slice::from_raw_parts( data.swkbd_shared_mem_ptr.add(swkbd.text_offset as _).cast(),