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

Method read_input

src/lib.rs:195–228  ·  view source on GitHub ↗

Reads all possible input from Stream Deck device

(&self, timeout: Option<Duration>)

Source from the content-addressed store, hash-verified

193
194 /// Reads all possible input from Stream Deck device
195 pub fn read_input(&self, timeout: Option<Duration>) -> Result<StreamDeckInput, StreamDeckError> {
196 match &self.kind {
197 Kind::Plus | Kind::PlusXl => {
198 let data = read_data(&self.device, (6 + self.kind.key_count()).max(5 + self.kind.encoder_count()) as usize, timeout)?;
199
200 if data[0] == 0 {
201 return Ok(StreamDeckInput::NoData);
202 }
203
204 match &data[1] {
205 0x0 => Ok(StreamDeckInput::ButtonStateChange(read_button_states(&self.kind, &data))),
206
207 0x2 => Ok(read_lcd_input(&data)?),
208
209 0x3 => Ok(read_encoder_input(&self.kind, &data)?),
210
211 _ => Err(StreamDeckError::BadData),
212 }
213 }
214
215 _ => {
216 let data = match self.kind {
217 Kind::Original | Kind::Mini | Kind::MiniMk2 | Kind::MiniDiscord | Kind::MiniMk2Module => read_data(&self.device, 1 + self.kind.key_count() as usize, timeout),
218 _ => read_data(&self.device, 4 + self.kind.key_count() as usize + self.kind.touchpoint_count() as usize, timeout),
219 }?;
220
221 if data[0] == 0 {
222 return Ok(StreamDeckInput::NoData);
223 }
224
225 Ok(StreamDeckInput::ButtonStateChange(read_button_states(&self.kind, &data)))
226 }
227 }
228 }
229
230 /// Resets the device
231 pub fn reset(&self) -> Result<(), StreamDeckError> {

Callers 1

readMethod · 0.45

Calls 7

read_dataFunction · 0.85
read_button_statesFunction · 0.85
read_lcd_inputFunction · 0.85
read_encoder_inputFunction · 0.85
key_countMethod · 0.80
encoder_countMethod · 0.80
touchpoint_countMethod · 0.80

Tested by

no test coverage detected