Jump to content
  • Advertisement

Archived

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

Ikuyubon

Using keyboard under C

This topic is 6917 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

I want to know how to use keyboard entries under C without using "bios.h". Maybe something like using the 0x16 interrupt... I dont know Help me please Thanx

Share this post


Link to post
Share on other sites
Advertisement
In C, it''s recommended that you use library functions to access the keyboard input. The library functions will perform the necessary system calls.

If you are intent on using the bios keyboard functions on the x86 platform they are:

INT 16H, AH = 00H -- read character
On return:
AH = scan code
AL = ASCII character

INT 16H, AH = 01H -- read status
On return:
flags - zero flag set if no character available
AH = scan code if zero flag not set
AL = ASCII character if zero flag not set

INT 16H, AH = 02H -- read flags
On return:
AH = reserved
AL = Shift Status Byte
Character is not removed from keyboard buffer.

INT 16H, AH = 12H -- read flags
On return:
AH = Extended Shift Status Byte
AL = Shift Status Byte
Character is not removed from keyboard buffer.

Shift Status Byte:
bit 7: insert state locked active
bit 6: caps lock key active
bit 5: num lock key active
bit 4: scroll lock key active
bit 3: alt key held down
bit 2: ctrl key held down
bit 1: left shift key held down
bit 0: right shift key held down

Extended Shift Status Byte:
bit 7: SysRq key held down
bit 6: Caps Lock key held down
bit 5: Num Lock key held down
bit 4: Scroll Lock key held down
bit 3: Right Alt key held down
bit 2: Right Ctrl key held down
bit 1: Left Alt key held down
bit 0: Left Ctrl key held down

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!