Thread: GetAsyncKeyState for Mac?

  1. #1
    Registered User
    Join Date
    Aug 2010
    Posts
    1

    GetAsyncKeyState for Mac?

    I've been stuck with my imac and I need GetAsyncKeyState();

    I can't seem to find an alternative on google, any help?

  2. #2
    Just a pushpin. bernt's Avatar
    Join Date
    May 2009
    Posts
    426
    I guess I don't know the magic words to narrow my search to Mac programming on google, and I'm not entirely familiar with the mac API anyways, but I'm sure there's event handling. So you could implement your own, something like this:
    Code:
    bool keys[256]
    ...
    bool key_pressed(int keycode)
    {
        return keys[keycode];
    }
    and in the event loop:
    Code:
    if (event.type == keyboard_pressed) {
        keys[event.keycode] = 1;
    }
    if (event.type == keyboard_released) {
        keys[event.keycode] = 0;
    }
    This is the general idea anyway; hopefully my imaginary api doesn't get in the way too much.

    On the other hand, if you're working with a console application, you could use ncurses to switch the terminal to non-blocking i/o.
    Or if you're working with opengl anyway you could throw in GLUT or GLFW(far better than glut) or the like to handle your input.
    Consider this post signed

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. GetAsyncKeyState() "key pressed"
    By vrkiller in forum C++ Programming
    Replies: 2
    Last Post: 03-06-2009, 05:22 PM
  2. GetAsyncKeyState.
    By kevinawad in forum Windows Programming
    Replies: 9
    Last Post: 11-09-2008, 05:02 PM
  3. GetAsyncKeyState Problem
    By kevinawad in forum C++ Programming
    Replies: 1
    Last Post: 11-07-2008, 06:00 PM
  4. Problems with cin and GetAsyncKeyState
    By KgNe in forum C++ Programming
    Replies: 32
    Last Post: 08-21-2008, 10:00 AM
  5. Problems with GetAsyncKeyState
    By blurrymadness in forum C++ Programming
    Replies: 13
    Last Post: 04-21-2007, 06:13 PM

Tags for this Thread