@@ -29,11 +29,13 @@ use input::{
2929use libc:: { O_RDONLY , O_RDWR , O_WRONLY } ;
3030use input_linux:: { uinput:: UInputHandle , EventKind , Key , SynchronizeKind } ;
3131use input_linux_sys:: { uinput_setup, input_id, timeval, input_event} ;
32+ use nix:: poll:: { poll, PollFd , PollFlags } ;
3233
3334const DFR_WIDTH : i32 = 2008 ;
3435const DFR_HEIGHT : i32 = 64 ;
3536const BUTTON_COLOR_INACTIVE : f64 = 0.267 ;
3637const BUTTON_COLOR_ACTIVE : f64 = 0.567 ;
38+ const TIMEOUT_MS : i32 = 30 * 1000 ;
3739
3840struct Card ( File ) ;
3941impl AsFd for Card {
@@ -309,6 +311,7 @@ fn main() {
309311 let mut drm = open_card ( ) . unwrap ( ) ;
310312 let mut input = Libinput :: new_with_udev ( Interface ) ;
311313 input. udev_assign_seat ( "seat0" ) . unwrap ( ) ;
314+ let pollfd = PollFd :: new ( input. as_raw_fd ( ) , PollFlags :: POLLIN ) ;
312315 let mut uinput = UInputHandle :: new ( OpenOptions :: new ( ) . write ( true ) . open ( "/dev/uinput" ) . unwrap ( ) ) ;
313316 uinput. set_evbit ( EventKind :: Key ) . unwrap ( ) ;
314317 for button in & layer. buttons {
@@ -344,6 +347,7 @@ fn main() {
344347 map. as_mut ( ) [ ..data. len ( ) ] . copy_from_slice ( & data) ;
345348 drm. card . dirty_framebuffer ( drm. fb , & [ ClipRect { x1 : 0 , y1 : 0 , x2 : DFR_HEIGHT as u16 , y2 : DFR_WIDTH as u16 } ] ) . unwrap ( ) ;
346349 }
350+ poll ( & mut [ pollfd] , TIMEOUT_MS ) . unwrap ( ) ;
347351 input. dispatch ( ) . unwrap ( ) ;
348352 for event in & mut input {
349353 match event {
0 commit comments