[AD] Direct Input driver not intercepting Alt+Tab

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


Hello,

I'm not sure if this is a specific Vista issue or not, but in Allegro 4.2 it
doesn't seem to properly intercept the Alt+Tab key in full-screen games. As
a result, when you return to the game readkey() returns a continuous stream
of 0x4000 keypresses which can really mess with the game.

This seems to be because GetKeyboardState doesn't return VK_MENU as being
pressed, which means that the KB_ALT_FLAG doesn't get set, so then when Tab
is pressed it doesn't recognise it as being alt+tab.

I've got around it by making this rather dirty hack to wkeybd.c, which looks
if Alt then Tab are pressed in succession and ignores the keypress, but this
obviously isn't ideal and will probably cause other problems. Any ideas on
this?

static void key_dinput_handle_scancode(unsigned char scancode, int pressed)
{
   HWND allegro_wnd = win_get_window();
   static int ignore_three_finger_flag = FALSE;
+   static BOOL just_pressed_alt = FALSE;
+
+   if (scancode == DIK_LMENU)
+   {
+     just_pressed_alt = TRUE;
+   }
+   else if (scancode != DIK_TAB)
+   {
+     just_pressed_alt = FALSE;
+   }

   /* ignore special Windows keys (alt+tab, alt+space, (ctrl|alt)+esc) */
   if (((scancode == DIK_TAB) && (_key_shifts & KB_ALT_FLAG))
       || ((scancode == DIK_SPACE) && (_key_shifts & KB_ALT_FLAG))
       || ((scancode == DIK_ESCAPE) && (_key_shifts & (KB_CTRL_FLAG |
KB_ALT_FLAG)))
+       || ((scancode == DIK_TAB) && (just_pressed_alt)))
+   {
+     just_pressed_alt = FALSE;
      return;
+   }

Cheers
Chris






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