Sign in to follow this  
smiley_horse

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

Recommended Posts

smiley_horse    132
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
smiley_horse    132
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
uavfun    744
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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this