[AD] Bug in pause key

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


Hi people.

I was programming a game and noted that the pause key was not working
properly. I'm using Allegro 4.2.0 (release version), in windows server
2003.

The problem is that when i press the pause key, testing
'key[KEY_PAUSE]' says that it is pressed, but when i release it,
'key[KEY_PAUSE]' still says it is pressed. The key just go to unpressed
state when i press it again and then release.
Or in other words, instead of saying if it is pressed or not it says if
it is 'on' or 'off' (like the num, caps and scroll lock leds).

I attached a small program that reproduces the problem. Couldn't use
the allegro test programs with because video is broken in Windows 2003
as i'd reported some time ago (the attached program works around the
problem).

Victor


	



	
		
_______________________________________________________ 
Yahoo! doce lar. Faça do Yahoo! sua homepage. 
http://br.yahoo.com/homepageset.html 
#include <allegro.h>

#define H 600
#define W 800

/* Isn't important in this case, just try to find a usable windowed mode. */
int find_video_mode() {
  set_color_depth(32);
  if (set_gfx_mode(GFX_AUTODETECT_WINDOWED, W, H, 0, 0) >= 0) return 1;
  set_color_depth(24);
  if (set_gfx_mode(GFX_AUTODETECT_WINDOWED, W, H, 0, 0) >= 0) return 1;
  set_color_depth(16);
  if (set_gfx_mode(GFX_AUTODETECT_WINDOWED, W, H, 0, 0) >= 0) return 1;
  set_color_depth(15);
  if (set_gfx_mode(GFX_AUTODETECT_WINDOWED, W, H, 0, 0) >= 0) return 1;
  set_color_depth(8);
  if (set_gfx_mode(GFX_AUTODETECT_WINDOWED, W, H, 0, 0) >= 0) return 1;
  return 0;
}

/* HERE WE GO! */
int main() {
  BITMAP *bmp;

  /* Initializes stuff. */
  allegro_init();
  install_keyboard();
  install_timer();
  if (!find_video_mode()) return 0;
  bmp = create_bitmap(W, H);
  clear_to_color(bmp, makecol(255, 255, 255));

  /* Loop until ESC is pressed. */
  do {
    blit(bmp, screen, 0, 0, 0, 0, W, H);
    clear_to_color(bmp, makecol(255, 255, 255));
    poll_keyboard();

    /* Here it's work as expect (with the X key or any other ordinary key).
       Initially, when that key is not pressed i see "X key not pressed".
       When i press it, i see "X key pressed". Releasing it i see
       "X key not pressed". */
    if (key[KEY_X])
      textout_ex(bmp, font, "X key pressed", 10, 20, makecol(0, 0, 0), -1);
    else
      textout_ex(bmp, font, "X key not pressed", 10, 20, makecol(0, 0, 0), -1);

    /* The pause key here is buggy. Initially, when that key is not pressed i
       see "Pause key not pressed". When i press it i see "Pause key pressed".
       If i release it, nothing changes and i still see "Pause key pressed".
       Pressing it again, nothing changes and the "Pause key pressed" is still
       on the screen. When i release it this time i can see
       "Pause key not pressed". */
    if (key[KEY_PAUSE])
      textout_ex(bmp, font, "Pause key pressed", 10, 10, makecol(0, 0, 0), -1);
    else
      textout_ex(bmp, font, "Pause key not pressed", 10, 10, makecol(0, 0, 0), -1);
    /* So, instead of saying if the pause key is pressed or not,
       key[KEY_PAUSE] is saying if it is on or off (in the same way we do with
       CAPS, NUM and SCROLL LOCK leds). */

  } while (!key[KEY_ESC]);

  allegro_exit();
  return 0;
}
END_OF_MAIN()


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/