Reads button states, awaits until there's data. Poll rate determines how often button state gets checked
(&self, poll_rate: f32)
| 92 | /// Reads button states, awaits until there's data. |
| 93 | /// Poll rate determines how often button state gets checked |
| 94 | pub async fn read_input(&self, poll_rate: f32) -> Result<StreamDeckInput, StreamDeckError> { |
| 95 | loop { |
| 96 | let device = self.device.lock().await; |
| 97 | let data = block_in_place(move || device.read_input(None))?; |
| 98 | |
| 99 | if !data.is_empty() { |
| 100 | return Ok(data); |
| 101 | } |
| 102 | |
| 103 | sleep(Duration::from_secs_f32(1.0 / poll_rate)).await; |
| 104 | } |
| 105 | } |
| 106 | |
| 107 | /// Resets the device |
| 108 | pub async fn reset(&self) -> Result<(), StreamDeckError> { |