Thread: Game console input

  1. #1
    Registered User glUser3f's Avatar
    Join Date
    Aug 2003

    Game console input

    First of all, the console I'm talking about isn't a DOS window, it's the command line interface that appears in FPS games when you press ~
    I've implemented a basic console for my engine, the problem I have right now is how to get input for it, I use DirectInput, which isn't based on messages like the Win32 API, I check keyboard and mouse input every frame, and respond to it, this works fine with input for moving around in the world, but it doesn't work at all for the console, because pressing a key would definitely last for more than one frame, repeating the character several times in the console, and I have to check all the keyboard keys every frame.
    The only way I could come up with is checking all the keys every frame, and storing a cool-down period for each key, which doesn't sound that efficient to me, any other suggestions?

  2. #2
    Join Date
    Feb 2003
    do something like the following:
    if(keypressed[key] !=true)
    // your code
    what this will do is as long as the key is held down, it will only be processed once. This removes the ability of spamming the same characters to in a MP game by just holding down a char .

  3. #3
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    You should also trap the mouse this way.

    A button is not pressed until it is down and up once - for menus.

    Of course this would not work for say shooting in an FPS or other things but it does help in menus for DX.

    Some major games out there have this flaw in their menus and it is so irritating. As well many games also allow you to hold down keys that I think give an unfair advantage - they should have checked which keys could be held down and what effect those would have on the game.

  4. #4
    Registered User glUser3f's Avatar
    Join Date
    Aug 2003
    thanks guys for your posts, I was tinkering around with the buffered mode of DirectInput yesterday, it works in a similar way to Windows messages, I'll use immediate input for the game, and buffered input for the GUI.
    thanks again

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Told ya so...
    By Cheeze-It in forum A Brief History of
    Replies: 58
    Last Post: 09-12-2007, 08:12 PM
  2. Console application - input handling
    By Something in forum C++ Programming
    Replies: 4
    Last Post: 06-09-2007, 02:19 PM
  3. 2D RPG Online Game Project. 30% Complete. To be released and marketed.
    By drallstars in forum Projects and Job Recruitment
    Replies: 2
    Last Post: 10-28-2006, 12:48 AM
  4. Game console programming
    By swgh in forum Game Programming
    Replies: 10
    Last Post: 05-07-2006, 12:24 PM
  5. saving a game in console mode
    By Leeman_s in forum C++ Programming
    Replies: 8
    Last Post: 05-08-2002, 06:30 PM