VK_Huh?

Started by
4 comments, last by asaari 22 years, 8 months ago
Ok, I know this is going to sound like a very stupid question from a very stupid person... Im currently in the process of writing a 3D engine in OpenGL, and ive been using windows message,/VK_LEFT, VK_UP, etc. for movement just until I get the basic graphics engine in place, anyhow I decided to start using WASD, insted, so I switched the couple lines of code, and I get a compile time error saying VK_W, etc., is an undeclared identifier! Am I missing something? =(
Advertisement
For standard keys, use the standard characer

''W''
''A''
''S''
''D''

The problem arises when you want to use things like tilde (~), cos there ain''t a VK for it! I''ll give you a hint though, it''s (numerical value) 192 on my keyboard... not sure about anyone else''s =)
Exactly right, you can''t pass messages with VK_? constants because they don''t exist for normal keystrokes. This obviously becomes a REAL CHORE when trying to write internationalized code. If I had to, I would probably write or acquire a lib for Unicode 3.0, and use these as my key constants...

---------
-WarMage
...wheeeeeee! I have to pee now.
you could just use the WM_CHAR message and compate the WPARAM to the character (i.e. wParam == 'a').

Or you could use the hexidecimal values and define your own VK_ constants as follows:

VK_W = 0x57h
VK_A = 0x41h
VK_S = 0x53h
VK_D = 0x44h

As the one guy said earlier, the hex values corrispond to the letter's ascii value. in the WM_KEYDOWN message wParam == 'W' will work.

Edited by - mike on August 1, 2001 1:51:14 PM
thanks for the help all,

I just replaced VK_LEFT, etc. with ''A'', etc.
Then again, you could just use DirectInput =)

This topic is closed to new replies.

Advertisement