On Wed, 2005-07-06 at 08:57 +0200, Denis Oliver Kropp wrote:
> 
> What should I do? Add a bool return value like in HasEvent()?
> But what would true mean then? Event or timeout? Or return DFBResult
> with DFB_OK or DFB_TIMEDOUT?
> 

No no.. it's perfect!
I'm studing c++ and i don't know the try statement yet (this is why i
didn't think on it.

The program now works:

#include <++dfb.h>
#include <iostream>

using namespace std;

int main()
{
    //here we declare the main interfaces
    IDirectFB              dfb;
    IDirectFBInputDevice keyboard;
    IDirectFBEventBuffer keybuffer;
    DFBInputEvent keyevent;

    //start directfb
    DirectFB::Init();
   
    dfb = DirectFB::Create();
    //set up a keyboard
    keyboard = dfb.GetInputDevice(DIDID_KEYBOARD);
    //set up a keybuffer
    keybuffer = keyboard.CreateEventBuffer();


    while(1) //we start the main cicle, an infinite one
    {
                try 
                {
                keybuffer.WaitForEventWithTimeout(2,0); //let us listen if a
key is pressed
        }
     catch (DFBException *ex) {} //if we get no event we do nothing
                       
        while(keybuffer.GetEvent(DFB_EVENT(&keyevent))) //if there is a
event...
        {   
                       
            if (keyevent.type == DIET_KEYPRESS) //and this event is a
key pressed
            {
                if(keyevent.key_id == DIKI_ESCAPE || keyevent.key_id ==
DIKI_F2) //and it's  hte ESC or F2 button
                return 1;
            }
           
        }
    }
   
   
}


Thanks again :D

-- 
Vincenzo Ampolo <[EMAIL PROTECTED]>


_______________________________________________
directfb-users mailing list
[email protected]
http://mail.directfb.org/cgi-bin/mailman/listinfo/directfb-users

Reply via email to