Re: [AD] Breakpointing an app in the MSVC 6 debugger can get a key to be stuck in Windows 2000 |
[ Thread Index |
Date Index
| More lists.liballeg.org/allegro-developers Archives
]
- To: alleg-developers@xxxxxxxxxx
- Subject: Re: [AD] Breakpointing an app in the MSVC 6 debugger can get a key to be stuck in Windows 2000
- From: Andrei Ellman <ae-a-alleg@xxxxxxxxxx>
- Date: Mon, 16 Jan 2006 11:58:20 +0100
- Organization: Wacko Software
Peter Wang wrote:
On 2005-12-31, Andrei Ellman <ae-a-alleg@xxxxxxxxxx> wrote:
Peter Wang wrote:
You can try this test. Using a windowed graphics driver, set a
SWITCH_IN and SWITCH_OUT callback with set_display_switch_callback() and
see if the callback is called before and after you enter the breakpoint.
I tried the test, but it appears that in both Windows 98 and Windows
2000, neither the SWITCH_IN or SWITCH_OUT callbacks are called when the
breakpoint is reached. However, when I bring another app to the
foreground, the SWITCH_OUT callback is called, and when I switch back to
the app, the SWITCH_IN callback is called.
Maybe try setting breakpoints on handle_key_release() or
_handle_key_release() to see if either get called after resuming from a
breakpoint in Win98?
Nothing in src/win/wkeybd.c modifies key[] directly. For that,
handle_key_press() and handle_key_release() call _handle_key_press() and
_handle_key_release() respectively, which are defined in src/keyboard.c.
If key[] is being set in Win98 it should happen via handle_key_release()
or _handle_key_release().
OK. I finally got round to trying it out. Here are the results:
Windows 98:
Firstly, the breakpoint in the main code is reached. After resuming (I'm
using the menu's restart option so I don't have to press F5 which would
cause the Allegro keyboard-handler to register that as well),
handle_key_release() and then _handle_key_release() get called. After
that, execution returns to main code, where I need to resume from the
breakpoint again. Without the breakpoint in the main code, both
handle_key_release() and _handle_key_release() get called.
Windows 2000:
The breakpoint in the main code is reached, but when resuming, neither
handle_key_release() or _handle_key_release() get called. The breakpoint
is hit again even though F2 is no longer held down. Without the
breakpoint in the main code, both handle_key_release() and
_handle_key_release() get called.
Attatched is the test-program.
AE.
/***************************************************************************
*
* breakpointkbdtest.c
* Test program to show the Allegro keyboard handler failing to release a key if it was released during a break by the debugger.
*
**************************************************************************/
/****************************************************************************
Includes
*/
#include <allegro.h>
/****************************************************************************
Types
*/
typedef int TeBool;
/****************************************************************************
Defines
*/
void
teDisplaySwitchInCallback(void)
{
TRACE("Switching IN\n");
}
void
teDisplaySwitchOutCallback(void)
{
TRACE("Switching OUT\n");
}
TeBool
teSetupGfx()
{
set_gfx_mode(GFX_AUTODETECT_WINDOWED, 640, 480, 0, 0);
set_palette(desktop_palette);
if(set_display_switch_callback(SWITCH_IN, teDisplaySwitchInCallback))
{
TRACE("Error setting up the switch-in callback.\n");
return FALSE;
}
if(set_display_switch_callback(SWITCH_OUT, teDisplaySwitchOutCallback))
{
TRACE("Error setting up the switch-out callback.\n");
return FALSE;
}
return TRUE;
}
void
teCleanupGraphics()
{
remove_display_switch_callback(teDisplaySwitchOutCallback);
remove_display_switch_callback(teDisplaySwitchInCallback);
}
void
teDoTest()
{
TRACE("Starting test...\n\n");
textout_ex(screen, font, "Hold down F2 to display some text", 0, 0, 1, 0);
while(!key[KEY_ESC] && !key[KEY_SPACE])
{
if(key[KEY_F2])
{
// Place a breakpoint on the line below to see F2 getting stuck on Windows 2000
textout_ex(screen, font, "F2 is pressed", 30, 20, 0, 1);
}
else
{
rectfill(screen,30,20,30+(13*8),20+(1*8),0);
}
}
TRACE("\nEnding test...\n");
}
TeBool
teSetup()
{
if(allegro_init())
{
TRACE("Error Initialising Allegro.\n");
return FALSE;
}
if(install_keyboard())
{
TRACE("Error Initialising Keyboard.\n");
return FALSE;
}
if(!teSetupGfx())
{
TRACE("Error setting up the graphics.\n");
return FALSE;
}
return TRUE;
}
void
teCleanUp()
{
teCleanupGraphics();
remove_keyboard();
allegro_exit();
}
int main(void)
{
if(!teSetup())
{
teCleanUp();
return -1;
}
teDoTest();
teCleanUp();
return 0;
}
END_OF_MAIN();