Keyboard Controls

This is a discussion on Keyboard Controls within the C++ Programming forums, part of the General Programming Boards category; I wonder if you can help me with the following problem. I want to write a function to accept keyboard ...

  1. #1
    Registered User
    Join Date
    Oct 2002
    Posts
    1

    Keyboard Controls

    I wonder if you can help me with the following problem.

    I want to write a function to accept keyboard controls and it needs to be able to accept multiple keys at the same time.

    For example: If I have a key that when pressed rotates the screen upward and another key that rotates it sideway, but if pressed together they will move the screen at a 45 degree angle.

    I dont have much experience with this and havent been able to find a function which allows you to do this. Any help would be much appreciated.

    Thanks.

  2. #2
    S Sang-drax's Avatar
    Join Date
    May 2002
    Location
    Göteborg, Sweden
    Posts
    2,072
    There is no function that allows you to do this , sorry.

    I'd use DirectInput, or Allegro if you need more portability.
    Last edited by Sang-drax : Tomorrow at 02:21 AM. Reason: Time travelling

  3. #3
    Emotionally Unstable DarkViper's Avatar
    Join Date
    Oct 2002
    Posts
    343
    lol!

    uhh, try DirectX controls, get the SDK from microsoft.com, its the only microsoft product i like, its 126megs, and FREE!
    ~DJ DarkViper signing out
    ----------------------------------------
    My Site:
    Black Jaguar Studios

    Languages:
    Fluent English, Starter German, HTML, Javascript, Actionscript, Intermediate PHP

    Verteran Despiser of: ASP, Java, BASIC, Pascal, Cobalt

  4. #4
    Rebooted Inquirer's Avatar
    Join Date
    Apr 2002
    Posts
    281
    You could use the numpad, and make the 7,9,3, and 1 keys move in the varius directions. THis is a viable option, and can be done relatively easily.

    ~Inquirer
    Compilers:
    GCC on Red Hat 8.1 (Primary)
    GCC on Mac OS X 10.2.4 (Secondary)

    Others:
    MinGW on XP

  5. #5
    Emotionally Unstable DarkViper's Avatar
    Join Date
    Oct 2002
    Posts
    343
    hey good idea!
    ~DJ DarkViper signing out
    ----------------------------------------
    My Site:
    Black Jaguar Studios

    Languages:
    Fluent English, Starter German, HTML, Javascript, Actionscript, Intermediate PHP

    Verteran Despiser of: ASP, Java, BASIC, Pascal, Cobalt

  6. #6
    Registered User SPiRiToFCaT's Avatar
    Join Date
    May 2002
    Posts
    35
    I'm pretty sure you can watch for keyboard input with windows.h
    Of course that only works IN windows, but there is a way of intercepting windows messages and checking if they are keypresses. I don't have the code on me at the moment, but I'll be back in a couple of hours and I can tell you then.
    - Well that's my 4c Australian.

  7. #7
    S Sang-drax's Avatar
    Join Date
    May 2002
    Location
    Göteborg, Sweden
    Posts
    2,072
    Originally posted by SPiRiToFCaT
    I'm pretty sure you can watch for keyboard input with windows.h
    Yes, that is easier.

    Code:
     
    bool IsKeydown(int key)
    {
       return GetAsyncKeyState(key) bitand 0x80;
    }
    
    //Test for up-arrow:
    if (IsKeyDown(VK_UP)) ...
    
    //Test for P
    if (IsKeyDown('P')) ...
    Last edited by Sang-drax : Tomorrow at 02:21 AM. Reason: Time travelling

  8. #8
    Emotionally Unstable DarkViper's Avatar
    Join Date
    Oct 2002
    Posts
    343
    i know this windows game called Kieg. is a cheapy 5meg game where your in some sort of small cramped area and you get bombarded with enemies left right and center. and the controls are
    w -> move forward
    a -> turn left
    d -> turn right
    s -> move backwards
    Tab -> fire weapon
    ~DJ DarkViper signing out
    ----------------------------------------
    My Site:
    Black Jaguar Studios

    Languages:
    Fluent English, Starter German, HTML, Javascript, Actionscript, Intermediate PHP

    Verteran Despiser of: ASP, Java, BASIC, Pascal, Cobalt

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Detecting keyboard and mouse in linux
    By sameer.nalwade in forum C Programming
    Replies: 3
    Last Post: 11-22-2008, 03:24 AM
  2. Keyboard port using other that a keyboard
    By antoinelac in forum C++ Programming
    Replies: 4
    Last Post: 06-12-2008, 02:46 PM
  3. Virtual keys
    By Arkanos in forum Windows Programming
    Replies: 4
    Last Post: 12-12-2005, 09:00 AM
  4. I need help disabling Keyboard and Mouse input on Edit controls
    By Templario in forum Windows Programming
    Replies: 4
    Last Post: 01-06-2003, 11:59 PM
  5. Game Design Topic #2 - Keyboard or Mouse?
    By TechWins in forum Game Programming
    Replies: 4
    Last Post: 10-08-2002, 03:34 PM

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