Reads button states, empty vector if no data
(kind: &Kind, states: &[u8])
| 53 | |
| 54 | /// Reads button states, empty vector if no data |
| 55 | pub fn read_button_states(kind: &Kind, states: &[u8]) -> Vec<bool> { |
| 56 | if states[0] == 0 { |
| 57 | return vec![]; |
| 58 | } |
| 59 | |
| 60 | match kind { |
| 61 | Kind::Original => { |
| 62 | let mut bools = vec![]; |
| 63 | |
| 64 | for i in 0..kind.key_count() { |
| 65 | let flipped_i = flip_key_index(kind, i) as usize; |
| 66 | |
| 67 | bools.push(states[flipped_i + 1] != 0); |
| 68 | } |
| 69 | |
| 70 | bools |
| 71 | } |
| 72 | |
| 73 | Kind::Mini | Kind::MiniMk2 | Kind::MiniDiscord | Kind::MiniMk2Module => states[1..].iter().map(|s| *s != 0).collect(), |
| 74 | |
| 75 | _ => states[4..].iter().map(|s| *s != 0).collect(), |
| 76 | } |
| 77 | } |
| 78 | |
| 79 | /// Reads lcd screen input |
| 80 | pub fn read_lcd_input(data: &[u8]) -> Result<StreamDeckInput, StreamDeckError> { |
no test coverage detected