Difference between revisions of "PRGM GetKey"

From WikiPrizm
Jump to navigationJump to search
m (moved Useful Keyboard Routines to PRGM GetKey: Dedicating this page to PRGM_GetKey and having all useful routines on one page like the syscall page)
(Finalizing the changes)
Line 1: Line 1:
=== PRGM_GetKey ===
+
== Synopsis ==
 +
This is a routine that is non-blocking, goes through the OS, and returns one key value: the very last one pressed.
  
This is a routine that is non-blocking, goes through the OS, and returns one key value: the very last one pressed. While it's slightly outdated, it is still commonly used for simple key checking.
+
=== Definition ===
 +
  <nowiki>int PRGM_GetKey(void)
 +
{
 +
  unsigned char buffer[12];
 +
  PRGM_GetKey_OS( buffer );
 +
  return ( buffer[1] & 0x0F ) * 10 + ( ( buffer[2] & 0xF0 ) >> 4 );
 +
}</nowiki>
  
Input: none
+
=== Inputs ===
 +
None
  
Output: int (key value)
+
=== Outputs ===
 +
Packed key code
 +
 
 +
== Comments ==
 +
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.
  
int PRGM_GetKey(void){
 
unsigned char buffer[12];
 
PRGM_GetKey_OS( buffer );
 
return ( buffer[1] & 0x0F ) * 10 + ( ( buffer[2] & 0xF0 ) >> 4 );
 
}
 
  
 
[[Category: Useful Routines]]
 
[[Category: Useful Routines]]

Revision as of 19:01, 29 January 2012

Synopsis

This is a routine that is non-blocking, goes through the OS, and returns one key value: the very last one pressed.

Definition

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

Inputs

None

Outputs

Packed key code

Comments

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.