Getting input from 0x60

Started by
4 comments, last by Homer Simpson 21 years, 9 months ago
How does I get input from 0x60 , i am trying to get multiple keys, i use MSVC++ 6.0 thnx and sorry about my english hehehe i am brazilian
__________________::Homer Simpson::
Advertisement
If I''m right, you want to access directly the "keyboard" port (It''s been long so maybe I''m wrong). This is both possible and impossible. It''s possible when you want to write a driver (but I won''t suggest that and as I''ve never written any, maybe it''s a wrong solution). And it''s impossible under standard windows environment. Use DirectInput instead (a part of DirectX)
Well if you really want to and can read the port, you need a scancode lookup table. You basically use the scancode as an offset into this array of ASCII codes although it is a little more complicated than that. Check out http://www.nondot.org/sabre/os/articles/. It might be .com instead so check both.
You can use GetAsyncKeyState to check for multiple keys being pressed. Check the MSB of the return-value, if it is set, the key is pressed. Example:


    #define IsKeyDown(key) (0x8000 & GetAsyncKeyState(key)) #define IsKeyUp(key) (!IsKeyDown(key)) //Use the macros as follows:if (IsKeyDown(VK_SPACE)){   // Space is currently pressed} if (IsKeyUp(VK_F1)){   // F1 is not pressed}    

As someone mentioned above, you can also use DirectInput, though it's a bit more involved.

For further information about GetAsyncKeyState and the VK_-codes it accepts as argument check the MSDN.

[edited by - Dactylos on June 24, 2002 10:06:55 AM]

Take care with Async though, as it won''t matter if your window has the focus or not, your program will still respond to the keypress (unless you idle the frame loop when you window isn''t the focus window).

Thanx a lot guys , before i learn DirectX i'll try Dactylos axample thanx to everyone thx thx thx


[edit]

Getkeystate is in windows.h ???

[/edit]

[edited by - Homer Simpson on June 24, 2002 11:01:04 AM]
__________________::Homer Simpson::

This topic is closed to new replies.

Advertisement