|
problem with keypressed function |
William Labbett
Member #4,486
March 2004
|
Hi, I'm just trying to get a wait for keypress function working and when I run my program with this code and a call to it, the console window does print "Waiting for event." but when I press a key, the program doesn't continue. Can anyone help? 1int wait_for_keypress()
2{
3 ALLEGRO_EVENT_QUEUE *queue = NULL;
4 ALLEGRO_EVENT event;
5
6
7 queue = al_create_event_queue();
8 if(queue == NULL)
9 {
10 return 0;
11 }
12
13 al_register_event_source(queue, al_get_keyboard_event_source());
14
15 do
16 {
17 cout << "waiting for event.\n";
18 al_wait_for_event(queue, &event);
19
20 } while( event.type != ALLEGRO_EVENT_KEY_DOWN );
21
22 cout << "got key down";
23
24 al_destroy_event_queue(queue);
25
26 return 1;
27}
|
SiegeLord
Member #7,827
October 2006
|
Did you create a display beforehand? "For in much wisdom is much grief: and he that increases knowledge increases sorrow."-Ecclesiastes 1:18 |
torhu
Member #2,727
September 2002
|
Did you call al_install_keyboard? |
William Labbett
Member #4,486
March 2004
|
I do create a display but after I've installed the keyboard. Is that the wrong thing to do?
|
|