![]() |
| | #1 |
| Registered User Join Date: Sep 2001
Posts: 13
| "How does C++ detect the keyboard input at a precise moment, without waitng for a key to be pressed - ie. returning a value of 0 (or likewise) if no key is being pressed at that instant??" The getch function is absolotely hopeless as it waits for a keypress (not much good for games)!! Can anyone help? Thanx, Ad... |
| adamdalziel is offline | |
| | #2 |
| Registered User Join Date: Aug 2001
Posts: 411
| I use WndProc and windows messages for my user interface stuff, What graphics API are you useing?
__________________ www.EberKain.com |
| Eber Kain is offline | |
| | #3 |
| Registered User Join Date: Sep 2001
Posts: 13
| You'll have to forgive me, am a bit new to C++, although am v familiar with programming - think I'm using OWL API. What does API stand for - does it allow me to utilise the keyboard in the way I want? I'm confused!!! |
| adamdalziel is offline | |
| | #4 |
| Skunkmeister Join Date: Aug 2001
Posts: 2,572
| If you are writing for windows then check out this api function at msdn or in your helpfiles.... GetAsyncKeyState()
__________________ Free the weed!! Class B to class C is not good enough!! And the FAQ is here :- http://faq.cprogramming.com/cgi-bin/smartfaq.cgi |
| Stoned_Coder is offline | |
| | #5 |
| Registered User Join Date: Sep 2001
Posts: 13
| Thanx, think that's exactly what I'm looking for. Am using Borland 5.02 and it's in the Windows API. How do you actually use the function, is it just a case of: #include <relevantHeader.h> if (GetAsyncKeyState()==codeForRequiredKey) statementBlock or am I naive to think it could be quite that straight-forward?!! Cheers, Ad. PS: keep smoking!! |
| adamdalziel is offline | |
| | #6 |
| Has a Masters in B.S. Join Date: Aug 2001
Posts: 2,267
| more like this if(GetAsyncKeyState("W")) //do whatever also use VK_*? keys for things such as Shift and ctrl thre might be something othere than VK_* in borland so your gonna have to look it up in the docs...
__________________ ADVISORY: This users posts are rated CP-MA, for Mature Audiences only. |
| no-one is offline | |
| | #7 |
| Registered User Join Date: Sep 2001
Posts: 13
| Excellent, that seems to be working a treat now (finally realised that you've gotta include windows.h - duh!!) So, have now got thrust & rotation working, so that the position and velocity vectors alter accordingly as you move through 3-Space. Hehe. One curious thing happens, though. On compilation, the keys work fine, but if you click in the programme window, they cease to work - anyone know what this could be? Cheers for the help. Ad. |
| adamdalziel is offline | |
![]() |
| Thread Tools | |
| Display Modes | |
|
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| can someone help me with these errors please code included | geekrockergal | C Programming | 7 | 02-10-2009 02:20 PM |
| About aes | gumit | C Programming | 13 | 10-24-2006 03:42 PM |
| Trouble with a lab | michael- | C Programming | 18 | 12-06-2005 11:28 PM |
| Linux: Send keyboard input to background process | xErath | Tech Board | 2 | 12-09-2004 07:02 PM |
| Need help with keyboard input | wiramu | C++ Programming | 2 | 11-28-2003 02:44 PM |