Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

The big Question?

Why is DInput so wierd?

This topic is 6927 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 making a highscore-box for my game, where the user should type in his/her name. But I couldn´t use Direct-Input, because the keys are fucked up, here an example:
#define DIK_1               0x02
#define DIK_2               0x03
.............
#define DIK_9               0x0A
#define DIK_0               0x0B
#define DIK_MINUS           0x0C
#define DIK_EQUALS          0x0D
#define DIK_BACK            0x0E
#define DIK_TAB             0x0F
#define DIK_Q               0x10
#define DIK_W               0x11
#define DIK_E               0x12
.............
#define DIK_O               0x18
#define DIK_P               0x19
[/CODE]

How in the hell are you going to detect these keys?
With a big switch, which takes care of everyone!?

This is the must stupid-code, I have ever seen MS write!
This forced me to use the WM_CHAR message instead, and avoid DInput.

Is their an easier way to use DInput, or has MS just done it again???

GOOD_PROGRAMMING != MICROSOFT    

Share this post


Link to post
Share on other sites
Advertisement
You could also use WM_CHAR or WM_KEYDOWN. You don''t really need high performance input when getting a high score name.

Share this post


Link to post
Share on other sites
quote:
Original post by Buster
You could also use WM_CHAR or WM_KEYDOWN. You don't really need high performance input when getting a high score name.


Well I know
But I´m using DInput in the game for mouse and keyboard input. And now I was using DInput, I wanted it to take care of the menu too.

But this got too complicated, because of MSs strange code, so I had to use the WM_CHAR message instead.

My code also got very ugly, because the WndProc-function (the main window) had to gain acces to my game-class.
I had to declare it as "friend".

Also to have two input systems in a game is bad, it is easier and cleaner with just one!

Edited by - The big Question? on 5/5/00 7:07:45 PM

Share this post


Link to post
Share on other sites
Why not just build an array of the DirectInput codes and what character they represent, where the code itself is the index? Once you know a code is a printable character, just use that code as the index into the array to get the character.

aig

Share this post


Link to post
Share on other sites
quote:
Original post by An Irritable Gent
Why not just build an array of the DirectInput codes and what character they represent, where the code itself is the index? Once you know a code is a printable character, just use that code as the index into the array to get the character.



Thanks this was a good idea. Why didn´t I think of it?
But still it would have been much easier if MSs had written
the code so you could do something like this:


if ((key >= DIK_0) && (key <= DIK_Z))
{
// Key is print-able.
buf[NexChar] = ''0'' +(key -DIK_0);
NextChar++;
}


Share this post


Link to post
Share on other sites
microsoft didn''t choose those numbers; those numbers represent the scan codes returned by the hardware.


adamm@san.rr.com

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!