MCPcopy Create free account
hub / github.com/OpenActionAPI/rust-elgato-streamdeck / read_button_states

Function read_button_states

src/util.rs:55–77  ·  view source on GitHub ↗

Reads button states, empty vector if no data

(kind: &Kind, states: &[u8])

Source from the content-addressed store, hash-verified

53
54/// Reads button states, empty vector if no data
55pub 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
80pub fn read_lcd_input(data: &[u8]) -> Result<StreamDeckInput, StreamDeckError> {

Callers 1

read_inputMethod · 0.85

Calls 2

flip_key_indexFunction · 0.85
key_countMethod · 0.80

Tested by

no test coverage detected