en:ibm:prcp:kbd:charin

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
en:ibm:prcp:kbd:charin [2014/05/13 13:42] – created valeriusen:ibm:prcp:kbd:charin [2016/09/15 02:17] (current) valerius
Line 1: Line 1:
 ==== KbdCharIn ==== ==== KbdCharIn ====
  
-**Bindings**: +**Bindings**: [[charin#C bindings|C]][[charin#MASM bindings|MASM]]
- +
-C: +
-<code c> +
-typedef struct _KBDKEYINFO {   /* kbci */ +
-  UCHAR    chChar;             /* ASCII character code */ +
-  UCHAR    chScan;             /* Scan Code */ +
-  UCHAR    fbStatus;           /* State of the character */ +
-  UCHAR    bNlsShift;          /* Reserved (set to zero) */ +
-  USHORT   fsState;            /* State of the shift keys */ +
-  ULONG    time;               /* Time stamp of keystroke (ms since ipl) */ +
-}KBDKEYINFO; +
- +
-#define INCL_KBD +
- +
-USHORT  rc = KbdCharIn(CharDataIOWait, KbdHandle); +
- +
-PKBDKEYINFO      CharData;      /* Buffer for data */ +
-USHORT           IOWait;        /* Indicate if wait */ +
-HKBD             KbdHandle;     /* Keyboard handle */ +
- +
-USHORT           rc;            /* return code */ +
-</code> +
- +
-Asm: +
-<code asm> +
-KBDKEYINFO struc +
-  kbci_chChar    db  ? ;ASCII character code +
-  kbci_chScan    db  ? ;Scan Code +
-  kbci_fbStatus  db  ? ;State of the character +
-  kbci_bNlsShift db  ? ;Reserved (set to zero) +
-  kbci_fsState   dw  ? ;state of the shift keys +
-  kbci_time      dd  ? ;time stamp of keystroke (ms since ipl) +
-KBDKEYINFO ends +
- +
-EXTRN  KbdCharIn:FAR +
-INCL_KBD            EQU 1 +
- +
-PUSH@  OTHER   CharData      ;Buffer for data +
-PUSH   WORD    IOWait        ;Indicate if wait +
-PUSH   WORD    KbdHandle     ;Keyboard handle +
-CALL   KbdCharIn +
- +
-Returns WORD +
-</code>+
  
 This call returns a character data record from the keyboard.  This call returns a character data record from the keyboard. 
Line 51: Line 7:
 KbdCharIn (CharData, IOWait, KbdHandle)  KbdCharIn (CharData, IOWait, KbdHandle) 
  
-CharData (PKBDKEYINFO) - output +//CharData// (**PKBDKEYINFO**) - output 
 Address of the character data structure:  Address of the character data structure: 
  
-asciicharcode (UCHAR) +//asciicharcode// (**UCHAR**
 ASCII character code. The scan code received from the keyboard is translated to the ASCII character code.  ASCII character code. The scan code received from the keyboard is translated to the ASCII character code. 
  
-scancode (UCHAR) +//scancode// (**UCHAR**
 Code received from the keyboard. The scan code received from the keyboard is translated to the ASCII character code.  Code received from the keyboard. The scan code received from the keyboard is translated to the ASCII character code. 
  
-status (UCHAR) +//status// (**UCHAR**
 State of the keystroke event:  State of the keystroke event: 
  
Line 74: Line 30:
 |0 1 |= Shift status returned without character. | |0 1 |= Shift status returned without character. |
  
-reserved (UCHAR) +//reserved// (**UCHAR**
 NLS shift status. Reserved, set to zero.  NLS shift status. Reserved, set to zero. 
  
-shiftkeystat (USHORT) +//shiftkeystat// (**USHORT**
 Shift key status.  Shift key status. 
  
Line 98: Line 54:
 |0 |Right Shift key down | |0 |Right Shift key down |
  
-time (ULONG) +//time// (**ULONG**
 Time stamp indicating when a key was pressed. It is specified in milliseconds from the time the system was started.  Time stamp indicating when a key was pressed. It is specified in milliseconds from the time the system was started. 
  
-IOWait (USHORT) - input +//IOWait// (**USHORT**) - input 
 Wait if a character is not available.  Wait if a character is not available. 
  
Line 108: Line 64:
 |1 |Requestor gets an immediate return if no character is available. | |1 |Requestor gets an immediate return if no character is available. |
  
-KbdHandle (HKBD) - input +//KbdHandle// (**HKBD**) - input 
 Default keyboard or the logical keyboard.  Default keyboard or the logical keyboard. 
  
-rc (USHORT) - return +//rc// (**USHORT**) - return 
 Return code descriptions are:  Return code descriptions are: 
  
Line 126: Line 82:
   * On an enhanced keyboard, the secondary enter key returns the normal character 0DH and a scan code of E0H.    * On an enhanced keyboard, the secondary enter key returns the normal character 0DH and a scan code of E0H. 
   * Double-byte character codes (DBCS) require two function calls to obtain the entire code.    * Double-byte character codes (DBCS) require two function calls to obtain the entire code. 
-  * If shift report is set with KbdSetStatus, the CharData record returned reflects changed shift information only. +  * If shift report is set with [[en:ibm:prcp:kbd:setstatus|KbdSetStatus]], the CharData record returned reflects changed shift information only. 
   * Extended ASCII codes are identified with the status byte, bit 1 on and the ASCII character code being either 00H or E0H. Both conditions must be satisfied for the character to be an extended keystroke. For extended ASCII codes, the scan code byte returned is the second code (extended code). Usually the extended ASCII code is the scan code of the primary key that was pressed.    * Extended ASCII codes are identified with the status byte, bit 1 on and the ASCII character code being either 00H or E0H. Both conditions must be satisfied for the character to be an extended keystroke. For extended ASCII codes, the scan code byte returned is the second code (extended code). Usually the extended ASCII code is the scan code of the primary key that was pressed. 
   * A thread in the foreground session that repeatedly polls the keyboard with KbdCharIn (with no wait), can prevent all regular priority class threads from executing. If polling must be used and a minimal amount of other processing is being performed, the thread should periodically yield to the CPU by issuing a DosSleep call for an interval of at least 5 milliseconds.    * A thread in the foreground session that repeatedly polls the keyboard with KbdCharIn (with no wait), can prevent all regular priority class threads from executing. If polling must be used and a minimal amount of other processing is being performed, the thread should periodically yield to the CPU by issuing a DosSleep call for an interval of at least 5 milliseconds. 
Line 138: Line 94:
   * Status can be 0 or 40H    * Status can be 0 or 40H 
   * KbdHandle is ignored.    * KbdHandle is ignored. 
 +
 +=== C bindings ===
 +
 +<code c>
 +typedef struct _KBDKEYINFO {   /* kbci */
 +  UCHAR    chChar;             /* ASCII character code */
 +  UCHAR    chScan;             /* Scan Code */
 +  UCHAR    fbStatus;           /* State of the character */
 +  UCHAR    bNlsShift;          /* Reserved (set to zero) */
 +  USHORT   fsState;            /* State of the shift keys */
 +  ULONG    time;               /* Time stamp of keystroke (ms since ipl) */
 +}KBDKEYINFO;
 +
 +#define INCL_KBD
 +
 +USHORT  rc = KbdCharIn(CharData, IOWait, KbdHandle);
 +
 +PKBDKEYINFO      CharData;      /* Buffer for data */
 +USHORT           IOWait;        /* Indicate if wait */
 +HKBD             KbdHandle;     /* Keyboard handle */
 +
 +USHORT           rc;            /* return code */
 +</code>
 +
 +=== MASM bindings ===
 +
 +<code asm>
 +KBDKEYINFO struc
 +  kbci_chChar    db  ? ;ASCII character code
 +  kbci_chScan    db  ? ;Scan Code
 +  kbci_fbStatus  db  ? ;State of the character
 +  kbci_bNlsShift db  ? ;Reserved (set to zero)
 +  kbci_fsState   dw  ? ;state of the shift keys
 +  kbci_time      dd  ? ;time stamp of keystroke (ms since ipl)
 +KBDKEYINFO ends
 +
 +EXTRN  KbdCharIn:FAR
 +INCL_KBD            EQU 1
 +
 +PUSH@  OTHER   CharData      ;Buffer for data
 +PUSH   WORD    IOWait        ;Indicate if wait
 +PUSH   WORD    KbdHandle     ;Keyboard handle
 +CALL   KbdCharIn
 +
 +Returns WORD
 +</code>
 +