delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/03/30/08:43:34

From: hackeroc3 AT aol DOT com (HackerOC3)
Newsgroups: comp.os.msdos.djgpp
Subject: Get_Scan_Code
Date: 30 Mar 1998 01:56:30 GMT
Lines: 30
Message-ID: <1998033001563000.UAA06101@ladder01.news.aol.com>
NNTP-Posting-Host: ladder01.news.aol.com
Organization: AOL http://www.aol.com
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

does anyone have code to get a scan code?  I have this microsoft c code:

unsigned char Get_Scan_Code(void)
{
// get the scan code of a key press, since we have to look at status bits
// let's use the inline assembler


// is a key ready?

asm
    {
    mov ah,01h          ; //function 1: is a key ready?
    int 16h             ; //call the interrupt
    jz empty            ; //there was no key so exit
    mov ah,00h          ; //function 0: get the scan code please
    int 16h             ; //call the interrupt
    mov al,ah           ; //result was in ah so put into al
    xor ah,ah           ; //zero out ah
    jmp done            ; //data's in ax...let's blaze!

empty:
     xor ax,ax          ; //clear out ax i.e. 0 means no key
done:

    } // end asm

// since data is in ax it will be returned properly

} // end Get_Scan_Code

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019