PRGM GetKey OS

From WikiPrizm
Jump to: navigation, search


Synopsis

Header: fxcg/keyboard.h
Syscall index: 0x0D39
Function signature: void PRGM_GetKey_OS(unsigned char* p)

Reads the keyboard input without blocking.

Parameters

  • p - pointer to 12 bytes unsigned char array that will receive the keyboard status.

Returns

0 if AC/on is pressed, 1 otherwise.

Comments

This syscall calls GetKeyWait_OS with KEYWAIT_HALTOFF_TIMEROFF as parameter, hence why it doesn't block.

p receives the keyboard status as a BCD-coded value. If no key is pressed, the BCD value is 0. If the AC/on key is pressed, the BCD value will have exponent 0xF00 and first nibble of the mantissa 1. Otherwise, it the BCD value will contain the key matrix-code, with the row number decremented by 1 to prevent the occurrence of an invalid BCD digit.

To yield the same function result as legacy syscall PRGM_GetKey, one can use this (taken from Simon Lothar's documentation):

int PRGM_GetKey(){
    unsigned char buffer[12];
    KBD_PRGM_GetKey( buffer );
    return ( buffer[1] & 0x0F ) * 10 + ( ( buffer[2]  & 0xF0 )  >> 4 );
}