Keyboard input

Started by
5 comments, last by Lemon Boy 20 years ago
hi im a newbie to this forum and im wondering if someone can help me im creating a 2D RPG egnine for my uni deissertation and i need to get input from the keyboard what i do now is in the WinProc message func. in the Key_up switch statement i use wParam which holds the Ascii code of the key pressed i then pass this to a Asicc to char function wich converts it to the right char my prolem is this only work on CAPITAL letters even if caps lock is on or off, and other keys like '' : ; ? / dont work if anyone knows of a better way to do this reply please Thanxs
-----------------------------Soo Many Things In My Mind To ProgramWhere Do I Start?
Advertisement
Well, if this is part of a 2D RPG engine, what graphics API are you using? If you happen to already be using DirectX for graphics anyway, then I''d suggest DirectInput (the input part of DirectX). If your using something other than DirectX for graphics, it may also have its own input handling (I''m fairly sure SDL does for example, although I''ve never tried it myself) you could learn and implement, but if not, I''m sure someone can help you to do it another way.

Gamedev''s DirectInput articles

- Jason Astle-Adams

For movement keys use either WM_KEYDOWN/WM_KEYUP or DirectInput, for real input (all letters, capital, small) use WM_CHAR.

Fruny: Ftagn! Ia! Ia! std::time_put_byname! Mglui naflftagn std::codecvt eY'ha-nthlei!,char,mbstate_t>

yeah im using Open GL
i think ill try the WM_CHAR windows message and see if that works.
thanx!
-----------------------------Soo Many Things In My Mind To ProgramWhere Do I Start?
Hmm... I wonder if he''s working on a similar project to me...
Incidentally, you can use GetKeyState(VK_CAPITAL) to check for capslock or use GetKeyState(VK_SHIFT) to check for shift. This would allow you to read the input and check whether it should be uppercase or lowercase.

Worship the holy trinity that is Blitz, Babes and Beers!
Worship the holy trinity that is Blitz, Babes and Beers!
Yeah, but basically why reinvent the wheel. Plus he doesn''t need to take in account different keyboard layouts. Let windows do the work.

Fruny: Ftagn! Ia! Ia! std::time_put_byname! Mglui naflftagn std::codecvt eY'ha-nthlei!,char,mbstate_t>

thankz guys i works perfectly
just using WM_CHAR in the messge loop of my WinMain func
wicked!!
gonna post another Question in the OpenGL section
maybe u guys can help me there?
-----------------------------Soo Many Things In My Mind To ProgramWhere Do I Start?

This topic is closed to new replies.

Advertisement