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

Function read_encoder_input

src/util.rs:100–110  ·  view source on GitHub ↗

Reads encoder input

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

Source from the content-addressed store, hash-verified

98
99/// Reads encoder input
100pub fn read_encoder_input(kind: &Kind, data: &[u8]) -> Result<StreamDeckInput, StreamDeckError> {
101 match &data[4] {
102 0x0 => Ok(StreamDeckInput::EncoderStateChange(data[5..5 + kind.encoder_count() as usize].iter().map(|s| *s != 0).collect())),
103
104 0x1 => Ok(StreamDeckInput::EncoderTwist(
105 data[5..5 + kind.encoder_count() as usize].iter().map(|s| i8::from_le_bytes([*s])).collect(),
106 )),
107
108 _ => Err(StreamDeckError::BadData),
109 }
110}

Callers 1

read_inputMethod · 0.85

Calls 1

encoder_countMethod · 0.80

Tested by

no test coverage detected