Thread: Going Crazy

  1. #1
    Registered User
    Join Date
    Oct 2001
    Posts
    2

    Exclamation Going Crazy

    Ok, I'm going nuckin' futs. I've been trying to (semi-actively) figure out how to keep an array of ints that keeps track of keys being held down in MSVC++6 for the past couple years... using plain ol' C... The use of this is probably obvious: to be able to check if more than one key is being held down at any given time... I've hunted around, found one thing that worked... only not in MSVC, but borland... this was the usage of assembly and the _bios_keybrd() functions, etc... some of the headers/libraries used don't exist with MSVC... Arg, anyone know how my goal is accomplished, or perhaps knows of a really nice place for me to learn how to make use of the keyboard by making my own procedures and whatnot? Thanks in advance.

  2. #2
    Registered User
    Join Date
    Oct 2001
    Posts
    375
    You have to go under what a Windows console will provide you. That means either Win32 API, DirectInput, Allegro, or, if you go for DOS, assembly. Sorry, but the way this is done is not part of the standard.. though it probably ought to be.

    Allegro will give you DirectX support in a powerful, easy to learn and use (and debug) library that is supported and loved world wide. So that's my answer to everything. It also works quite well with MSVC. (Or.. in the future if you should go with porting to several OS's... Allegro is also your ticket without changing a single line of code.)
    Allegro precompiled Installer for Dev-C++, MSVC, and Borland: http://galileo.spaceports.com/~springs/

  3. #3
    Registered User
    Join Date
    Aug 2001
    Posts
    101
    You can use GetAsyncKeyState, or map the keys on your own with an array of bools, setting each bool to true when the key is pressed and to false when it's released.
    - lmov

  4. #4
    Registered User
    Join Date
    Oct 2001
    Posts
    375
    Of course, as Imov states, sometimes using Win32 API is the quick fix. ;p
    Allegro precompiled Installer for Dev-C++, MSVC, and Borland: http://galileo.spaceports.com/~springs/

  5. #5
    Registered User
    Join Date
    Aug 2001
    Posts
    411
    I use WM_KEYDOWN and WM_KEYUP in my winproc messages to do this.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Is AOL music crazy?
    By joeprogrammer in forum A Brief History of Cprogramming.com
    Replies: 9
    Last Post: 03-24-2006, 07:24 PM
  2. restart drives me crazy
    By Jumper in forum A Brief History of Cprogramming.com
    Replies: 20
    Last Post: 03-17-2004, 12:52 PM
  3. crazy
    By DavidP in forum A Brief History of Cprogramming.com
    Replies: 23
    Last Post: 08-31-2002, 08:54 PM
  4. crazy output
    By asirep in forum C Programming
    Replies: 22
    Last Post: 04-09-2002, 11:41 AM
  5. Replies: 1
    Last Post: 02-24-2002, 06:24 PM