Hi! I'm trying to understand the use of `CreateInputEventBuffer`, and I
have the following test:

    #include <stdlib.h>
    #include <stdio.h>
    #include <unistd.h>

    #include <directfb.h>

    #include <iostream>

    using namespace std;

    static IDirectFB *dfb = NULL;
    static IDirectFBSurface *primary = NULL;
    static IDirectFBSurface *foot = NULL;
    static IDirectFBInputDevice *keyboard = NULL;
    static int screen_width = 0;
    static int screen_height = 0;
    #define DFBCHECK(x...) \
    { \
    DFBResult err = x; \
    \
    if (err != DFB_OK) \
    { \
    fprintf( stderr, "%s <%d>:\n\t", __FILE__, __LINE__ ); \
    DirectFBErrorFatal( #x, err ); \
    } \
    }
    static IDirectFBEventBuffer *buffer = NULL;
    int main (int argc, char **argv)
    {

    DFBSurfaceDescription dsc;
    IDirectFBImageProvider *provider;
    int quit = 0;
    DFBCHECK (DirectFBInit (&argc, &argv));
    DFBCHECK (DirectFBCreate (&dfb));
    DFBCHECK (dfb->SetCooperativeLevel (dfb, DFSCL_FULLSCREEN));
    dsc.flags = DSDESC_CAPS;
    dsc.caps = DSCAPS_PRIMARY;
    DFBCHECK (dfb->CreateSurface( dfb, &dsc, &primary ));
    DFBCHECK (primary->GetSize (primary, &screen_width, &screen_height));
    DFBCHECK (primary->FillRectangle (primary, 0, 0, screen_width,
screen_height));
    DFBCHECK (dfb->CreateImageProvider (dfb, DATADIR"/foot.jpg",
&provider));
    DFBCHECK (provider->GetSurfaceDescription (provider, &dsc));
    DFBCHECK (dfb->CreateSurface (dfb, &dsc, &foot));
    DFBCHECK (provider->RenderTo (provider, foot, NULL));
    provider->Release (provider);
    DFBCHECK (primary->SetBlittingFlags (primary,
DSBLIT_BLEND_ALPHACHANNEL));

    IDirectFBEventBuffer* eventBuffer = NULL;

    while (!quit) {
    DFBCHECK(dfb->CreateInputEventBuffer(
    dfb,
    DICAPS_ALL,
    DFB_TRUE,
    &eventBuffer));

            if (eventBuffer != NULL) {
                eventBuffer->WaitForEvent(eventBuffer);
            }

    cout << "DFBEventBuffer::getNextEvent ...";
            if (eventBuffer != NULL &&
                    (eventBuffer->HasEvent(eventBuffer) == DFB_OK)) {

                DFBInputEvent* evt = new DFBInputEvent;
                if (eventBuffer->GetEvent(eventBuffer, DFB_EVENT(evt)) ==
DFB_OK) {
    cout << " evt=" << evt->type << endl;
    if (evt->key_id == DIKI_ESCAPE)
    quit = 1;
                } else {
                    delete evt;
                    evt = NULL;
                }
            }
    cout << " NULL !!!" << endl;
    }
    dfb->Release (dfb);
    return 0;
    }

For some reason, after press the key about 10 times, it stats to give me 2
"release" events for a single keypress. And sometimes 2 "press" events
also. Any idea why is this happening? (using DirectFB 1.4.11)

Obs. I know I could use `GetInputDevice`, but I really would like to use
`CreateInputEventBuffer`, and understand what's happening on this example.
*
*
*
*
*Wellington B. de Carvalho*
_______________________________________________
directfb-users mailing list
directfb-users@directfb.org
http://mail.directfb.org/cgi-bin/mailman/listinfo/directfb-users

Reply via email to