Jump to content

  • Log In with Google      Sign In   
  • Create Account


#ActualKhatharr

Posted 19 November 2012 - 09:07 PM

Abstract the winproc input from your input handler. Have something that contains information about key states. The winproc modifies it (with keyup and keydown) and the program reads from it when needed.

Actually, glancing at your post tags I see you're using DirectX. Why not use DirectInput?

If not then you can just write a simple class that holds keystate bools in a private array. Friend the winproc (don't taze me, bros) and then have a 'bool operator[](DWORD vkey) const;' function on the class. (Possibly you could make the class members static so you won't even need to initialize the class.) Then you can just have the winproc manage the array contents and check like so:

[source lang="cpp"]if(inputObj[VK_LEFT] && inputObj[VK_UP]) { //do stuff}[/source]

I'd really recommend DirectInput though.

#2Khatharr

Posted 19 November 2012 - 08:45 PM

Abstract the winproc input from your input handler. Have something that contains information about key states. The winproc modifies it (with keyup and keydown) and the program reads from it when needed.

Actually, glancing at your post tags I see you're using DirectX. Why not use DirectInput?

If not then you can just write a simple class that holds keystate bools in a private array. Friend the winproc (don't taze me, bros) and then have a query(VK_*) function on the class. Then you can just have the winproc manage the array contents and check like so:

[source lang="cpp"]if(inputObj.query(VK_LEFT) && inputObj.query(VK_UP)) { //do stuff}[/source]
I'd really recommend DirectInput though.

#1Khatharr

Posted 19 November 2012 - 08:39 PM

Abstract the winproc input from your input handler. Have something that contains information about key states. The winproc modifies it (with keyup and keydown) and the program reads from it when needed.

PARTNERS