It is currently Tue Oct 17, 2017 4:24 am

All times are UTC - 5 hours




 Page 1 of 1 [ 6 posts ] 
Author Message
 Post subject: Shader VMK 16 - Keyboard Input
PostPosted: Sat Oct 06, 2012 4:52 am 
Site Admin

Joined: Sun Feb 11, 2007 8:59 am
Posts: 1105
Location: Ontario Canada
In this video I add the code that lets us handle key presses (and releases) on the keyboard when the game window is in focus. I also add the ability to suppress repeat key presses.


Offline
 Profile  
 
 Post subject: Re: Shader VMK 16 - Keyboard Input
PostPosted: Sat Oct 06, 2012 4:23 pm 

Joined: Sat Aug 16, 2008 7:58 am
Posts: 449
I followed the video exactly and everything works as expected. If the console is in focus nothing happens and if the window is in focus and I press the keys the console does display the key down and up messages, however, when I press the ESC key it does not exit the game, it displays the key pressed and released in the console. I put a break point in the Game::keyboardInput() function at the line where PostQuitMessage(0) is called. When I run it through the debugger the execution does stop at that line so execution is going into the if statement before it, when I press F11 to step into the PostQuitMessage() function it is skipping over it and leaving the scope of the keyboardInput function. ????


Offline
 Profile  
 
 Post subject: Re: Shader VMK 16 - Keyboard Input
PostPosted: Sat Oct 06, 2012 4:30 pm 
Site Admin

Joined: Sun Feb 11, 2007 8:59 am
Posts: 1105
Location: Ontario Canada
Did you make the change that I mentioned here: viewtopic.php?p=2530#p2530


Offline
 Profile  
 
 Post subject: Re: Shader VMK 16 - Keyboard Input
PostPosted: Sat Oct 06, 2012 4:40 pm 

Joined: Sat Aug 16, 2008 7:58 am
Posts: 449
All works well, thank you. I never noticed you had posted it. It is crazy how one little variable can change the whole course of an application.


Offline
 Profile  
 
 Post subject: Re: Shader VMK 16 - Keyboard Input
PostPosted: Thu Jun 27, 2013 8:05 pm 

Joined: Tue Jun 18, 2013 7:24 pm
Posts: 8
Hello Marek, first of all great videos! I have a small problem with the keyboard code that suppresses held down key messages.

if ( 0 == (lparam & 0x4000000))
{
KeyboardInput( wparam, true );
}

This code always fires, it seems bit 30 is always 0. As mentioned on the comments here
MSDN LINK

It seems to be related to my os Win7 64bit. I can't figure out why it doesn't work, or how I can make a work around to get this working.

Do you know how/what I should do about this?


Offline
 Profile  
 
 Post subject: Re: Shader VMK 16 - Keyboard Input
PostPosted: Thu Jun 27, 2013 8:18 pm 
Site Admin

Joined: Sun Feb 11, 2007 8:59 am
Posts: 1105
Location: Ontario Canada
I'm also using Win7 64bit and the code is working for me. You should expect to receive a 0 in bit 30 when you first press a key. If you continue to hold down the same key, bit 30 should go high to 1. If you are not seeing that happen then there may be something wrong with your keyboard driver. You could always manually handle the suppression of held keys by just monitoring the previous state of each key. This will just be a little bit more work, the OS should do it for you.


Offline
 Profile  
 
Display posts from previous:  Sort by  
 Page 1 of 1 [ 6 posts ] 

All times are UTC - 5 hours


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Jump to:  

cron