|
Keyboard & mouse not working on ubuntu 11.10 |
Losiowaty
Member #13,930
January 2012
|
Hi everybody, 1
2#include <allegro.h>
3#include <vector>
4#include <time.h>
5#include <sstream>
6
7int main(){
8
9//all the variables are defined here
10 allegro_init();
11 install_mouse();
12 install_timer();
13 install_keyboard();
14 set_color_depth(32);
15 gfxStatus = set_gfx_mode( GFX_AUTODETECT_WINDOWED,800,600,0,0);
16 if (gfxStatus == 0) {
17 clear_to_color(screen, WHITE);
18 gui_fg_color = D_GREY;
19 gui_bg_color = L_GREY;
20
21 srand(time(NULL));
22
23 for (int i = 0; i < 11; i++) historia[i] = create_bitmap(SCREEN_W, SCREEN_H - 50);
24
25 show_mouse(screen);
26 while (!exit){ //petla glowna
27 if (key[KEY_ESC]) { //wyjscie
28 //a lot of other key options here, basically doing the same -> changing current tool
29 if ((mouse_b & (1 | 2)) && (mouse_y > 50)) {
30 //mouse action here
31 } else if ((mouse_b & (1 | 2)) && (mouse_y < 50)) { //user dziala na
32 //special mouse action here
33} //koniec if od myszki
34 } //koniec petli glownej
35 } else { //koniec if gfxStatus
36 std::cerr << "Allegro error!\n" << allegro_error << "\n";
37 }
38
39
40 return 0;
41}
42END_OF_MAIN(); ///Makro z allegro
While writing this post I had an idea -> could it be that time.h is messing up with allegros timer? Anyway, I'd be gratefull for any help. |
Edgar Reynaldo
Major Reynaldo
May 2007
|
It may have something to do with resource locks of some sort - do you ever use acquire_screen / release_screen at all? If you acquire and don't release, it may block input. Do you ever call read_key? That function blocks until there is a keypress in the queue. We probably need to see more code - and if you post more, try to fix the formatting first (your indentation is not consistent). My Website! | EAGLE GUI Library Demos | My Deviant Art Gallery | Spiraloid Preview | A4 FontMaker | Skyline! (Missile Defense) Eagle and Allegro 5 binaries | Older Allegro 4 and 5 binaries | Allegro 5 compile guide |
Losiowaty
Member #13,930
January 2012
|
I solved the issue ;] The problem was non-allegro. I simply called sleep(200); thinkning that it took miliseconds, when it takes seconds, so it stopped my program for about 3 minutes! My bad here ;] Anyway - thanks for the replay and ideas! |
|