Reads lcd screen input
(data: &[u8])
| 78 | |
| 79 | /// Reads lcd screen input |
| 80 | pub fn read_lcd_input(data: &[u8]) -> Result<StreamDeckInput, StreamDeckError> { |
| 81 | let start_x = u16::from_le_bytes([data[6], data[7]]); |
| 82 | let start_y = u16::from_le_bytes([data[8], data[9]]); |
| 83 | |
| 84 | match &data[4] { |
| 85 | 0x1 => Ok(StreamDeckInput::TouchScreenPress(start_x, start_y)), |
| 86 | 0x2 => Ok(StreamDeckInput::TouchScreenLongPress(start_x, start_y)), |
| 87 | |
| 88 | 0x3 => { |
| 89 | let end_x = u16::from_le_bytes([data[10], data[11]]); |
| 90 | let end_y = u16::from_le_bytes([data[12], data[13]]); |
| 91 | |
| 92 | Ok(StreamDeckInput::TouchScreenSwipe((start_x, start_y), (end_x, end_y))) |
| 93 | } |
| 94 | |
| 95 | _ => Err(StreamDeckError::BadData), |
| 96 | } |
| 97 | } |
| 98 | |
| 99 | /// Reads encoder input |
| 100 | pub fn read_encoder_input(kind: &Kind, data: &[u8]) -> Result<StreamDeckInput, StreamDeckError> { |