From WikiPrizm
Revision as of 01:00, 13 August 2012 by Ahelper (talk | contribs) (Timing typo)
Jump to navigationJump to search


This is a routine that is non-blocking* See Comments, goes through the OS, and returns one key value: the very last one pressed or still held.


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




Packed key code


This function will retrieve the last pressed key and continue returning it if it is still held. While it's slightly outdated, it is still commonly used for simple key checking.

The return is a packed 2 digit number, with the first digit being the row - 1 and the second digit being the column. For example, GetKeyWait_OS, when F1 is pressed, will give 7,10 as the col,row. This function returns 79 as the (col)(row-1). AC/ON returns 1,1 for GetKeyWait_OS and therefore returns 10 from PRGM_GetKey.

* This function actually does block for a very small amount of time, which can hurt performance of FPS-hungry add-ins. The PRGM_GetKey_OS syscall will stall for a very small amount of time (about 0.15s) if no keys are pressed, and unnoticeable delay when a key is pressed. If you are making a time-sensative add-in, it is best to not use syscalls and directly poll the keyboard hardware.