DirectInput - ScanCode to Ascii
hi!
I found a function which converts DirectInput scancode to ascii code. Now, when I want to make a input field in my game, how do I get the scancode of the key which was pressed? Do I have to iterate throw the inputbuffer array to find which key is currently pressed, or is there a more elegant way?
bye
chris
Generally, people use windows messages for text input. DirectX really is meant for button press notification.
hi,
@ Pipo:
This way is NOT more elegant, I think. You really would write a giant switch statement for nearly every key on the keyboard?
@ cannelbrae:
thanks, I totally forgot that. :-). I believed there would be an easy DirectInput solution.
bye
chris
[edited by - Zoomby on May 3, 2003 12:57:25 PM]
@ Pipo:
This way is NOT more elegant, I think. You really would write a giant switch statement for nearly every key on the keyboard?
@ cannelbrae:
thanks, I totally forgot that. :-). I believed there would be an easy DirectInput solution.
bye
chris
[edited by - Zoomby on May 3, 2003 12:57:25 PM]
Since the DIK_x values are actually indexes into a 256 character array, you could create a static array that holds all those upper, lower and system character codes and just index it by the DIK_x code you get. No if-elses, for loops needed.
As far as DInput only being used for button presses, that may be the case but it is NOT very difficult to write routines to do it for you. That way you don''t have to worry about routing WM_xxx messages and DInput messages.
As far as DInput only being used for button presses, that may be the case but it is NOT very difficult to write routines to do it for you. That way you don''t have to worry about routing WM_xxx messages and DInput messages.
It may work for YOUR keyboard, but that doesn''t mean it will work elsewhere. DI doesn''t take locale into account. For instance, if I remember correctly... in German Z and Y are swapped. In France, A and W (or was it Q?) are swapped. What about accented characters? etc.
Windows messages take care of all of this for you. Why ignore it?
Windows messages take care of all of this for you. Why ignore it?
Bah, porting your keyboard implementation is trivial to localizing other aspects of your game.
hi, thank for all the replies.
I think I''ll use windows WM_CHAR messages. That''s in fact very easy. The only problem is, that you have to mix two different techniques (DirectInput keyboard handling and windows message keyboard handling). In my case the class which needs the text input will be a singleton, so accessing it even from WinProc wouldn''t be hard, I think.
bye
chris
I think I''ll use windows WM_CHAR messages. That''s in fact very easy. The only problem is, that you have to mix two different techniques (DirectInput keyboard handling and windows message keyboard handling). In my case the class which needs the text input will be a singleton, so accessing it even from WinProc wouldn''t be hard, I think.
bye
chris
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement