Is there a way to get the asynchronous state of a key using GLUT?

This is a discussion on Is there a way to get the asynchronous state of a key using GLUT? within the Game Programming forums, part of the General Programming Boards category; I'd like to get the asynchronous state of a key using GLUT, because, well, I want my code to be ...

  1. #1
    User
    Join Date
    Jan 2006
    Location
    Canada
    Posts
    498

    Post Is there a way to get the asynchronous state of a key using GLUT?

    I'd like to get the asynchronous state of a key using GLUT, because, well, I want my code to be platform-independent. Up until now, I have been using callbacks like this:

    Code:
    glutKeyboardFunc(keyboard);
    But that creates impracticalities in a lot of cases; and I would like to check the state of a key, anytime. The other problem with this code is that my program cannot process 2 keys at the same time. I probably would use the Windows functions that everybody knows, except that I'm using a Mac . So anybody know of a way?

    Thanks

  2. #2
    vae victus! skorman00's Avatar
    Join Date
    Nov 2003
    Posts
    594
    I never even knew glut had i/o support! What will happen if you hold the A key, then press S? Will the callback be called twice?

  3. #3
    GA ichijoji's Avatar
    Join Date
    Nov 2002
    Posts
    179
    You could keep a list of key states in some input manager and update the values with keyboardFunc and keyboardUpFunc. I've found this to be especially useful when dealing with the mouse in glut.
    Illusion and reality become impartiality and confidence.

  4. #4
    User
    Join Date
    Jan 2006
    Location
    Canada
    Posts
    498
    Yeah, I guess that would work. But if I hold down one key, and then I press another, will GLUT call keyboardUpFunc after I press the second key, or will it be as if I were getting the asynchrounos state of a key?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 16
    Last Post: 11-23-2007, 01:48 PM
  2. Virtual keys
    By Arkanos in forum Windows Programming
    Replies: 4
    Last Post: 12-12-2005, 10:00 AM
  3. Directional Keys - Useing in Console
    By RoD in forum C++ Programming
    Replies: 38
    Last Post: 10-06-2002, 05:42 PM
  4. FAQ: Directional Keys - Useing in Console
    By RoD in forum FAQ Board
    Replies: 38
    Last Post: 10-06-2002, 05:42 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21