1

I've recently been getting into DirectX and along with that, game programming. I've started fleshing out my base of the program and now I'm looking to get into handling input. The way I have right now is through calling a function in my main loop which queries the mouse and keyboard using GetDeviceState (in a nutshell) and their respective arguments; however, after doing some more in depth reading into DirectInput, I've seen many people saying how DirectInput is NOT recommended for use anymore. Microsoft seems to agree too!

What I am looking for are other ways to go about doing this, along with discussion on the pros and cons about them (not necessary, but welcome. I can research)

Tanner
  • 610
  • 1
  • 6
  • 20

4 Answers4

4

Just use GetMessage or PeekMessage, see should-i-use-directinput-or-windows-message-loop for an example.

Community
  • 1
  • 1
John Knoeller
  • 31,289
  • 4
  • 56
  • 90
  • Ah yes, I like the looks of this. Should work perfect, I'll get started on that right away, I'm having a lot of fun coding this – Tanner Feb 05 '10 at 22:58
1

You can use the win32/windows API.

People of gamedev seem to agree: http://www.gamedev.net/community/forums/topic.asp?topic_id=511020

0

For keyboard I usually use GetAsyncKeyState();. It says if key is pressed in the time of execution of this function.

But for mouse the best solution is to use DirectInput I think. Because windows monitors it's position and you don't have to.

oneat
  • 9,780
  • 15
  • 47
  • 66
0

Its recommended to use "Raw Input" these days.

Goz
  • 58,120
  • 22
  • 114
  • 192
  • Bad idea, unless you are using joystick. That way you should make tons of personal code to take care of every possible culture your user may be using (to configure their keyboard input relatively) or configuration (inverted mouse button configuration, speed of double click, etc..) etc... Its generally a better idea to leave it to the windows messages as the others said. – feal87 Feb 05 '10 at 17:24
  • As far as I know, the Raw Input is suggested for devices that are not supported by the common windows messages (touchpad, joysticks, microphones, etc..) – feal87 Feb 05 '10 at 19:54
  • Well i guess its up to the user in the end. Definitely anywhere you used to use DirectInput you should now use Raw Input. Personally I've always found treating the keyboard as a set of unknown buttons far more useful than knowing whether the user hit an 'A' key or a 'Z' key ... – Goz Feb 05 '10 at 21:37