![]() |
|
#1
|
|||
|
|||
Handling keyboard inputHi everyone.
For the past day I've been trying to find a good way to handle keyboard input. Naturally, I wanted to just use WM_KEYDOWN and WM_KEYUP to handle my events, but they proven to have limitations. In my game there was a keyboard delay. If you pressed and held down the right arrow key, the character would move one pixel to the right, stop, then continue moving. I wanted the character to immediately start moving and continue moving once the right arrow key was pressed and held. Another problem with using just WM_KEYDOWN is that if you are moving your character with the right arrow key and then press spacebar, your character stops moving. Apparently this WM_KEYDOWN message couldn't handle more than one key being processed at a time. I look into DirectInput and get it working finally. I notice there is none of that keyboard repeat rate delay and it could handle more than one key being held at a time. The problem was, it was messy. Basically, DirectInput was overkill. Also, handling KeyUp messages with DirectInput was hell. Now I look into GetAsyncKeyState. It looks good, but it seems a bit messy and slow. Overall, I'm looking for a way to use WM_KEYDOWN and WM_KEYUP to handle more than one key at a time (so if you're moving and press space you don't stop moving for example) and I also want it to not have a delay. For example, the instant I press the right arrow key my character starts moving and doesn't stop. The only method I found for doing this so far required a messy array of bools I didn't really want to get into. It was worse than using DirectInput or GetAsyncKeyState in my opinion. Thanks |
|||
Recent GIDBlog
Problems with the Navy (Officers) by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Keyboard Buffer Question | Peter_APIIT | C++ Forum | 9 | 06-Oct-2008 02:59 |
| Break on keyboard input | slippygod | C++ Forum | 3 | 25-May-2006 15:00 |
| Getinput error. Error 2660. 4244, and 2447 | blackstone99 | C++ Forum | 1 | 13-Feb-2005 19:11 |
| [C] Discarding input | Alhazred | C Programming Language | 8 | 04-Aug-2004 11:45 |
| IP tables | rogermark100 | C Programming Language | 6 | 18-Apr-2004 07:22 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The