Keyboard problem

Started by
6 comments, last by kurifu 22 years, 4 months ago
So many of you who have tried using Direct Input before likely have run into this problem. When you are using Direct Input and you poll the keyboard, you are not returned with a char representing the button pressed on your computer, but you are instead presented with a scancode. now with these scan codes you can easily control buttons, and other actions in your game... only there is one problem. I want to read text into a string. The only presented option I see is to check the keyboard state array to see what button(s) are pressed... this in turn though gives you a massive set of if statements to try and figure out what is actually pressed since you have to go through all 256 bytes in the array one at a time. Now, I was told to try using the GDI, only problem that I see with this is that 1) I am trying to aboid the message pump as much as possible, and though I know I can get around that, I have the problem of reading keys such as backspace, or escape, and so forth without using a non-blocking call. Is there any proposed method that is better than what is described above that I am not aware of? A lot of games use this, there is likely a better methode that I am now aware of. Gamedev''s AI Auto-Reply bot.
Gamedev's AI Auto-Reply bot.
Advertisement
Hello. I have written my own headers for making windows in DX. This includes list boxes, buttons, and of course, text boxes. Naturally I needed to make something like you need, so if you want, I can give you my functions to get text in using Direct Input. If you''re interested, IM me at ImmigrantMarbles on AOL or AIM (this is MUCH preffered) or if you need to, you can EMail me at VChelaru@hotmail.com.

--Vic--
Hello. I have written my own headers for making windows in DX. This includes list boxes, buttons, and of course, text boxes. Naturally I needed to make something like you need, so if you want, I can give you my functions to get text in using Direct Input. If you''re interested, IM me at ImmigrantMarbles on AOL or AIM (this is MUCH preffered) or if you need to, you can EMail me at VChelaru@hotmail.com.

--Vic--
You need to create your own low level GUI routines.
I despise using Windows already made GUI routines because they are soo automatic.

In DirectInput after receiving the 256 characters, you need to scan them to see which one was hit. This does take a some CPU cycles, but since you are going around the message queue.. the cycles are not a big deal. 256 compare values every 10th of a second are better than the old dos games and 64000 compares per vsync (1/60 per sec).




Edited by - GoofProg on December 16, 2001 2:32:37 PM

The nightmare travels across the cosmos with his burning mane. The trail of ash that is produced.

?Have a nice day!?

Just a note. These are pretty low level. They use color fills and they blit small letters for text. It''s pretty fast, if I do say so myself.

--Vic--
As far as writing text goes, I do already have functions which can handle that...

Now I juts need to read the text into the strings.

If you could send me that code I would like to look at it

cliffordr@hfx.eastlink.ca

Gamedev''s AI Auto-Reply bot.
Gamedev's AI Auto-Reply bot.
Don''t use DirectInput to get string input - use WM_CHAR instead!!

- DInput codes are based on the US keymap - the keys on a German keyboard have a slightly different layout, which is different again to the French layout etc. If you only intend the software to be used on US keyboards, then DInput is fine for text input if you don''t it''s not!

- DInput goes in below the Windows character stuff so if someone has loaded a different keymap, your application will ignore it.

- Users of the IME in Japan, Korea, China etc won''t be able to use your app. Text input using IME goes to WM_CHAR - DInput gets the raw keycodes.

- People who use languages with accented characters won''t be able to enter all of them since an accented character is entered with *TWO* keypresses (the accent symbol they want, then the base character).

--
Simon O''''Connor
Creative Asylum Ltd
www.creative-asylum.com

Simon O'Connor | Technical Director (Newcastle) Lockwood Publishing | LinkedIn | Personal site

Actually I am working with a French Keyboard to begin with, and yes, it will work.

You see, in order to convert the scan codes as needed you have to create a virtual keyboard, which will take the layout of your real keyboard, and then you send the scancode and wait for the conversion. It will also convert Capital and non capital letters and so forth too... this will also allow for the accented letters to be entered as they should be, and permit the us of non US based keyboards.

Now I posted above, you probably did not see it, that my goal here was to avoid using the windows messaging system. Direct access to the computer is much faster, as also stated above, and hence WM_CHAR - being a part of that - would not be acceptable to my standards.

Gamedev''s AI Auto-Reply bot.
Gamedev's AI Auto-Reply bot.

This topic is closed to new replies.

Advertisement