suppress hosted mode warnings in usb dev crate

This commit is contained in:
bunnie 2022-05-24 17:08:27 +08:00
parent 3fccc6c314
commit 3b6bc6aeeb
2 changed files with 8 additions and 0 deletions

View file

@ -43,6 +43,7 @@ use num_enum::FromPrimitive as EnumFromPrimitive;
use embedded_time::Clock;
use std::convert::TryInto;
#[cfg(any(target_os = "none", target_os = "xous"))]
use keyboard::KeyMap;
use xous_ipc::Buffer;
@ -77,7 +78,9 @@ fn xmain() -> ! {
log::trace!("registered with NS -- {:?}", usbdev_sid);
let llio = llio::Llio::new(&xns);
let tt = ticktimer_server::Ticktimer::new().unwrap();
#[cfg(any(target_os = "none", target_os = "xous"))]
let native_kbd = keyboard::Keyboard::new(&xns).unwrap();
#[cfg(any(target_os = "none", target_os = "xous"))]
let native_map = native_kbd.get_keymap().unwrap();
#[cfg(any(target_os = "none", target_os = "xous"))]
@ -275,7 +278,10 @@ fn xmain() -> ! {
}
Some(Opcode::SendString) => {
let mut buffer = unsafe { Buffer::from_memory_message_mut(msg.body.memory_message_mut().unwrap()) };
#[cfg(any(target_os = "none", target_os = "xous"))]
let mut usb_send = buffer.to_original::<api::UsbString, _>().unwrap();
#[cfg(not(any(target_os = "none", target_os = "xous")))]
let usb_send = buffer.to_original::<api::UsbString, _>().unwrap(); // suppress mut warning on hosted mode
#[cfg(any(target_os = "none", target_os = "xous"))]
{
let mut sent = 0;

View file

@ -1,5 +1,6 @@
pub use usbd_human_interface_device::page::Keyboard as UsbKeyCode;
#[cfg(any(target_os = "none", target_os = "xous"))]
pub fn char_to_hid_code_us101(key: char) -> Vec<UsbKeyCode> {
let mut code = vec![];
match key {
@ -117,6 +118,7 @@ pub fn char_to_hid_code_us101(key: char) -> Vec<UsbKeyCode> {
}
/// auto-generated using tools/kbd_layout.py + `usb kbdtest` on device for dvorak layout on US101
#[cfg(any(target_os = "none", target_os = "xous"))]
pub fn char_to_hid_code_dvorak(key: char) -> Vec<UsbKeyCode> {
let mut code = vec![];
match key {