• Advertisement
Sign in to follow this  

I think I have seen a bug ... in dxut

This topic is 4893 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I was just playing a bit with framework that comes with sdk 9c, and I think I have found a bug (I'm not sure - maybe I did somethign wrong). Nothing serious but anyway ... This code should open a window and install a keyboard callback that closes app when 'q' is pressed. However if u press F2 it has same effect too even if framework is initialized not to handle default keys. A bug? #include "dxstdafx.h" #include "resource.h" void CALLBACK KeyboardProc( UINT nChar, bool bKeyDown, bool bAltDown ){ if( bKeyDown ) { switch( nChar ) { case 'q': case 'Q': PostQuitMessage( 0 ); } } } INT WINAPI WinMain(HINSTANCE,HINSTANCE, LPSTR, int){ DXUTInit(false,false,true); DXUTSetCallbackKeyboard( KeyboardProc ); DXUTCreateWindow(); DXUTCreateDevice(); DXUTMainLoop(); return DXUTGetExitCode(); } The code is stripped of anything else then a window and keyboard callback for simplicity.

Share this post


Link to post
Share on other sites
Advertisement
nChar is a virtual-key code, not an ASCII code. 'q' is probably the same as VK_F2. You probably only want 'Q'.

Share this post


Link to post
Share on other sites
That's true!

Didn't know that one; thnks

But do I use lower 'q' in that case? If I run code above with only 'Q' compiled, it doesn't matter if I use caps lock or not, it responds on both cases. Does it mean I can only use "one" case with this framework?

Share this post


Link to post
Share on other sites
Use GetKeyboardState() then ToAscii() if you want an ASCII code. You could also be slightly lazy and just check the state of the caps lock and shift keys (with GetKeyState()).

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement