(target_up: u16, skip: u8)
| 26 | |
| 27 | impl TouchScreen for HidapiTouchScreen { |
| 28 | fn open_device(target_up: u16, skip: u8) -> Option<HidapiTouchScreen> { |
| 29 | debug!( |
| 30 | "Looking for touchscreen HID device {:X} {}", |
| 31 | target_up, skip |
| 32 | ); |
| 33 | let mut skip = skip; |
| 34 | match HidApi::new() { |
| 35 | Ok(api) => { |
| 36 | for dev_info in api.device_list() { |
| 37 | let vid = dev_info.vendor_id(); |
| 38 | let pid = dev_info.product_id(); |
| 39 | let usage_page = dev_info.usage_page(); |
| 40 | if vid != ILI_VID { |
| 41 | trace!(" Skipping VID:PID. Expected {:04X}:*", ILI_VID); |
| 42 | continue; |
| 43 | } |
| 44 | debug!( |
| 45 | " Found {:04X}:{:04X} (Usage Page {:04X})", |
| 46 | vid, pid, usage_page |
| 47 | ); |
| 48 | if usage_page != target_up { |
| 49 | debug!(" Skipping usage page. Expected {:04X}", 0xFF00); |
| 50 | continue; |
| 51 | } |
| 52 | if pid != ILI_PID { |
| 53 | debug!(" Warning: PID is {:04X}, expected {:04X}", pid, ILI_PID); |
| 54 | } |
| 55 | |
| 56 | debug!(" Found matching touchscreen HID device"); |
| 57 | debug!(" Path: {:?}", dev_info.path()); |
| 58 | debug!(" IC Type: {:04X}", pid); |
| 59 | if skip > 0 { |
| 60 | skip -= 1; |
| 61 | continue; |
| 62 | } |
| 63 | |
| 64 | // Unwrapping because if we can enumerate it, we should be able to open it |
| 65 | let device = dev_info.open_device(&api).unwrap(); |
| 66 | debug!(" Opened device."); |
| 67 | |
| 68 | return Some(HidapiTouchScreen { device }); |
| 69 | } |
| 70 | } |
| 71 | Err(e) => { |
| 72 | error!("Failed to open hidapi. Error: {e}"); |
| 73 | } |
| 74 | }; |
| 75 | |
| 76 | None |
| 77 | } |
| 78 | |
| 79 | fn send_message(&self, message_id: u8, read_len: usize, data: Vec<u8>) -> Option<Vec<u8>> { |
| 80 | let report_id = 0x03; |
no outgoing calls
no test coverage detected