The first key press after DirectFB initialization is always discarded. The
behavior is new in 1.4-0 and I believe comes from the following changeset:

commit e0be70ec8aedde56f23d216530746a93e7746ff6
Author: Ville Syrjala <syrj...@sci.fi>
Date:   Tue May 12 04:16:57 2009 +0300

    vt/keyboard: Flush console input when not used

    To keep the kernel happy the console buffer must be kept from filling
    up. If the buffer is sufficiently full the kernel stop sleeping and
    instead wakes up every tick to do something. This problem occurs when
    the keyboard driver is not used and the linuxinput driver does not grab
    the devices. Add a new thread whose job is to keep flushing the buffer
    when the keyboard driver is not there to consume the data.

I have traced the issue to vt.c::vt_flush_thread() calling select().
keyboard.c::driver_open_device() sets dfb_vt->flush to false but
vt_flush_thread() will not exit until the first key press. As
vt_flush_thread() exits, it makes one final call to tcflush() and discards
the unread input.

Here is a brief excerpt of my console output, demonstrating that the first
input is a key release, rather than a key press.
(*) Direct/Thread: Started 'VT Flusher' (831) [DEFAULT OTHER/OTHER 0/0]
<2093056>...
(*) Direct/Thread: Started 'Keyboard Input' (832) [INPUT OTHER/OTHER 0/0]
<2093056>...
(*) DirectFB/Input: Keyboard 0.9 (directfb.org)
waiting for event
got key_id= 63043key released
waiting for event
got key_id= 63043key pressed
waiting for event
got key_id= 63043key released

The patch found at the end was generated from 1.4-9, though I believe it
applies to 1.4-15 and 1.5-3 as well.

Jon Pomrenke

--- 
DirectFB-1.4.9.org/systems/fbdev/vt.c<http://directfb-1.4.9.org/systems/fbdev/vt.c>
2010-09-17
00:42:15.000000000 -0500
+++ DirectFB-1.4.9/systems/fbdev/vt.c 2012-01-09 16:50:24.965960912 -0600
@@ -665,7 +665,7 @@
           if (ret < 0 && errno == EINTR)
                continue;

-          if (ret < 0)
+          if (ret < 0 || !dfb_vt->flush)
                break;

           tcflush( dfb_vt->fd, TCIFLUSH );
_______________________________________________
directfb-dev mailing list
directfb-dev@directfb.org
http://mail.directfb.org/cgi-bin/mailman/listinfo/directfb-dev

Reply via email to