Archived

This topic is now archived and is closed to further replies.

Getting input from 0x60

This topic is 5649 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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)

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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]

Share this post


Link to post
Share on other sites

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).

Share this post


Link to post
Share on other sites