Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 8 of 8

Thread: how to use mouse and keyboard at the same time for FPS-like movements ?

  1. #1
    Junior Member Newbie
    Join Date
    Mar 2005
    Location
    Cannes - FRANCE
    Posts
    16

    how to use mouse and keyboard at the same time for FPS-like movements ?

    Hello,
    I'd like to know how to use both mouse and keyboard at the same time to allow a quaque-like moving style ?
    For the moment, if I keep the up arrow pressed and I press the left arrow, I stop to go forward and I strafe left...
    I'd like to use the mouse for the head direction, up/down to move forward/backward, left/right to strafe left/right.
    Have you got code example ?
    Thanks.

  2. #2
    Junior Member Newbie
    Join Date
    Dec 2004
    Posts
    19

    Re: how to use mouse and keyboard at the same time for FPS-like movements ?

    The best way to do that is setting a bool flag indicating the key was pressed. Then you can press more than one key at a once. When you release it, then you set the bool to false.

    Also take a look at the topic "Problem on moving eye coordinate", since I posted interest things there. See ya!

  3. #3
    Member Regular Contributor
    Join Date
    Aug 2003
    Posts
    368

    Re: how to use mouse and keyboard at the same time for FPS-like movements ?

    You'd probably need to get into a serious API so you can have a good responce time. SDL and DirectX should be considered in my opinion.

  4. #4
    Senior Member OpenGL Pro
    Join Date
    Jul 2001
    Location
    France
    Posts
    1,749

    Re: how to use mouse and keyboard at the same time for FPS-like movements ?

    moucard: why directx ? why sdl ?

    glut can do that.

  5. #5
    Member Regular Contributor
    Join Date
    Aug 2003
    Posts
    368

    Re: how to use mouse and keyboard at the same time for FPS-like movements ?

    Yes, but maybe he'd need more functionality. I don't think glut can keep track of 2 keys pressed simultaneously. It's just for learning OpenGL (ok, and I bit more than that). But when was the last time that you saw a big game (like unreal, neverwinter, especially on linux) use glut?
    The user didn't state if this was for a serious full on production or just some learning purposes. That's all. It's just my opinion.
    (By the way, I still think glut rocks, but just for learning things or creating a quick prototype)

  6. #6
    Junior Member Regular Contributor
    Join Date
    Jun 2004
    Location
    mexico
    Posts
    127

    Re: how to use mouse and keyboard at the same time for FPS-like movements ?

    glut is only for learning. if you make a somewhat big app using glut youll get a bottleneck, there was some info on www.gametutorials.com on how cto control pressed keys

  7. #7
    Senior Member OpenGL Pro
    Join Date
    Jul 2001
    Location
    France
    Posts
    1,749

    Re: how to use mouse and keyboard at the same time for FPS-like movements ?

    Like you said glut is for learning, and it seems it's the beginner forum. So maybe it's suffisant for him. Making our own code to manage multiple keys up or down can be best than an API that does it alone for you (and I don't think SDL can do that). I don't know about directx but I think it's not a good idea to merge directx and opengl.

  8. #8
    Advanced Member Frequent Contributor
    Join Date
    Aug 2004
    Location
    munich, germany
    Posts
    658

    Re: how to use mouse and keyboard at the same time for FPS-like movements ?

    since vince put a post in a linux forum, i assume directX is no option.

    for linux i recommend the use of XQueryKeymap, which allows you to get the state of all keys at any time without having to wait for events to be processed.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •