Notes on Representing Multi-Byte PS/2 Keyboard Scan Codes As Single-Byte ASCII-Based Characters Michael P

Notes on Representing Multi-Byte PS/2 Keyboard Scan Codes As Single-Byte ASCII-Based Characters Michael P

Notes on Representing Multi-Byte PS/2 Keyboard Scan Codes as Single-Byte ASCII-based Characters Michael P. Frank Wednesday, November 29, 2006 Version 4 of this document presents an improved scheme for the decoding of byte sequences, with a greatly simplified FSM design. Version 5 rearranges some of the ASCII coding of keys so that more of the commonly- encountered punctuation characters are used to represent associated keypresses. Introduction The standard PS/2-compatible keyboards used with most PCs in the United States generate multiple-byte sequences to represent various key-press (“make”) and key- release (“break”) events. For designing custom digital systems that can accept input from such keyboards, it is convenient if the multi-byte make/break sequences are pre-translated into a convenient single-byte format that is easy to interpret using a simple combinational circuit. In this document, we present a proposed mapping from multi-byte sequences into single-byte codes based on the standard US 7-bit ASCII character set. We also summarize the design of a simple state machine that can accomplish this translation. List of Codes In the below table I am inventing a mapping from key make and break events on a standard 104-key PS/2 US keyboard (scan code set 2) to 8-bit characters that correspond, in as many cases as possible, to ASCII characters that are related in some way to the key pressed. The break codes are the same as the make codes except with bit 7 turned on. Raw input byte sequences for most standard US PS/2 keyboards My Custom ASCII-based Encoding ASCII ASCII ASCII Make Break make make break Key code code char hex hex Notes Use uppercase for letter A 1C F0,1C A 41 C1 keys B 32 F0,32 B 42 C2 C 21 F0,21 C 43 C3 D 23 F0,23 D 44 C4 E 24 F0,24 E 45 C5 F 2B F0,2B F 46 C6 G 34 F0,34 G 47 C7 H 33 F0,33 H 48 C8 I 43 F0,43 I 49 C9 J 3B F0,3B J 4A CA K 42 F0,42 K 4B CB L 4B F0,4B L 4C CC M 3A F0,3A M 4D CD Raw input byte sequences for most standard US PS/2 keyboards My Custom ASCII-based Encoding ASCII ASCII ASCII Make Break make make break Key code code char hex hex Notes N 31 F0,31 N 4E CE O 44 F0,44 O 4F CF P 4D F0,4D P 50 D0 Q 15 F0,15 Q 51 D1 R 2D F0,2D R 52 D2 S 1B F0,1B S 53 D3 T 2C F0,2C T 54 D4 U 3C F0,3C U 55 D5 V 2A F0,2A V 56 D6 W 1D F0,1D W 57 D7 X 22 F0,22 X 58 D8 Y 35 F0,35 Y 59 D9 Z 1A F0,1A Z 5A DA ) Use punctuation to disting. ) 0 45 F0,45 29 A9 these fr. the #s on keypad ! ! 1 16 F0,16 21 A1 @ @ 2 1E F0,1E 40 C0 # # 3 26 F0,26 23 A3 $ $ 4 25 F0,25 24 A4 % % 5 2E F0,2E 25 A5 ^ ^ 6 36 F0,36 5E DE & & 7 3D F0,3D 26 A6 * * 8 3E F0,3E 2A AA ( ( 9 46 F0,46 28 A8 ~ Unshifted punctuation char ` ` 0E F0,0E 60 E0 _ To distinguish from keypad _ - 4E F0,4E 5F DF - + Unshifted punctuation char = = 55 F0,55 3D BD | Unshifted punctuation char \ \ 5D F0,5D 5C DC Backsp 66 F0,66 BS ⌫ 08 88 Standard ASCII control Space 29 F0,29 SP ␣ 20 A0 Standard ASCII control Tab 0D F0,0D HT ↦ 09 89 Standard ASCII control Raw input byte sequences for most standard US PS/2 keyboards My Custom ASCII-based Encoding ASCII ASCII ASCII Make Break make make break Key code code char hex hex Notes CapsLk 58 F0,58 DC2 ⊛ 12 92 “Special mode” control L Shft 12 F0,12 SO ⊙ 0E 8E “Outermost” shift key L Ctrl 14 F0,14 { 7B FB Left & right control: { , } L GUI E0,1F E0,F0,1F v 76 F6 Windows keys: v & w L Alt 11 F0,11 a 61 E1 Left & right alt: a & b R Shft 59 F0,59 SI ⊗ 0F 8F “Innermost” shift key R Ctrl E0,14 E0,F0,14 } 7D FD Left & right control: { , } R GUI E0,27 E0,F0,27 w 77 F7 Windows keys: v & w R Alt E0,11 E0,F0,11 b 62 E2 Left & right alt: a & b Menu E0,2F E0,F0,2F m 6D ED m is for menu Enter 5A F0,5A CR ↵ 0D 8D Line feed left implicit Standard ASCII control Esc ESC ⇑ 76 F0,76 1B 9B char F1 05 F0,05 ENQ ⍰ 05 85 Help function, like ENQ F2 06 F0,06 GS ∯ 1D 9D “two” Arbitrary control char. Was F3 ACK ☑ 04 F0,04 04 84 “f” for Find File function F4 0C F0,0C EOT ↯ 04 84 Alt-F4 terminates app Refresh: Reset, turn on, F5 DC1 ⊚ 03 F0,03 11 91 XON Arbitrary control char. Was F6 BEL ☎ 0B F0,0B 07 87 “c” for Cycle cursor around F7 83 F0,83 CAN ✖ 18 98 Cancel misspelling Arbitrary control char. Was F8 0A F0,0A DC4 ⊝ 13 93 “e” for Extend selection in Word F9 01 F0,01 US ∫ 1F 9F Update Selected fields Arbitrary control char. Was F10 09 F0,09 NAK ☒ 15 15 backtick, for menu bar in upper-left corner F11 78 F0,78 FS ∰ 1C 9C Full Screen mode toggle F12 07 F0,07 ETB ▣ 17 97 End work, Save As… PrtScr E0,12, E0,F0,7C, Escape to OS DLE ⌥ 10 90 SysRq E0,7C E0,F0,12 ScrLck 7E F0,7E SYN ⌚ 16 96 Used to pause output Pause E1,F0,14, Pause function 1 E1,14,77 DC3 ⊜ 13 93 Break F0,77 1 Note: The break code for the Pause/Break key is always sent immediately following its make code, without waiting for the key to be released. No code is sent when the key is actually released. Raw input byte sequences for most standard US PS/2 keyboards My Custom ASCII-based Encoding ASCII ASCII ASCII Make Break make make break Key code code char hex hex Notes { [ 54 F0,54 ] 5B DB Unshifted punctuation char Insert E0,70 E0,F0,70 STX ⊥ 02 82 Insert start of new text here Home E0,6C E0,F0,6C SOH ⌈ 01 81 Start of document Pg Up E0,7D E0,F0,7D VT ↧ 0B 8B VT can move backwards Delete E0,71 E0,F0,71 DEL ⌦ 7F FF Forwards delete character End E0,69 E0,F0,69 ETX ⌋ 03 83 End of document Pg Dn E0,7A E0,F0,7A FF ⇟ 0C 8C Go to start of next page U arr E0,75 E0,F0,75 u 75 F5 u is for up L arr E0,6B E0,F0,6B l 6C EC l is for left R arr E0,74 E0,F0,72 r 72 F2 r is for right D arr E0,72 E0,F0,74 d 64 E4 d is for down NumLk 77 F0,77 n 6E EE n is for num lock KP / E0,4A E0,F0,4A / 2F AF Label on keypad key KP * 7C F0,7C x 78 F8 x means multiply KP - 7B F0,7B - 2D AD Label on keypad key KP + 79 F0,79 p 70 F0 p means plus KP Ent E0,5A E0,F0,5A LF ↓ 0A 8A Let this enter do a LF KP . 71 F0,71 . 2E AE Label on keypad key KP 0 70 F0,70 0 30 B0 Label on keypad key KP 1 69 F0,69 1 31 B1 Label on keypad key KP 2 72 F0,72 2 32 B2 Label on keypad key KP 3 7A F0,7A 3 33 B3 Label on keypad key KP 4 6B F0,6B 4 34 B4 Label on keypad key KP 5 73 F0,73 5 35 B5 Label on keypad key KP 6 74 F0,74 6 36 B6 Label on keypad key KP 7 6C F0,6C 7 37 B7 Label on keypad key KP 8 75 F0,75 8 38 B8 Label on keypad key KP 9 7D F0,7D 9 39 B9 Label on keypad key } ] 5B F0,5B ] 5D DD Unshifted punctuation char : ; 4C F0,4C : 3A BA Unshifted punctuation char “ ‘ 52 F0,52 ’ 60 E0 Unshifted punctuation char < , 41 F0,41 , 2C AC Unshifted punctuation char > . 49 F0,49 > 3E BE To dist. fr. keypad “.” ? / 4A F0,4A ? 3F BF To dist. fr. keypad “/” Here’s the same table again, this time sorted by the raw make codes (column 2). ASCII ASCII ASCII Make Break make make break Key code code char hex hex F9 01 F0,01 US ∫ 1F 9F F5 03 F0,03 DC1 ⊚ 11 91 F3 04 F0,04 ACK ☑ 06 86 F1 05 F0,05 ENQ ⍰ 05 85 F2 06 F0,06 GS ∯ 1D 9D F12 07 F0,07 ETB ▣ 17 97 F10 09 F0,09 NAK ☒ 15 95 F8 0A F0,0A DC4 ⊝ 13 93 F6 0B F0,0B BEL ☎ 07 87 F4 0C F0,0C EOT ↯ 04 84 Tab 0D F0,0D HT ↦ 09 89 ~ ` ` 0E F0,0E 60 E0 L Alt 11 F0,11 a 61 E1 L Shft 12 F0,12 SO ⊙ 0E 8E L Ctrl 14 F0,14 { 7B FB Q 15 F0,15 Q 51 D1 ! ! 1 16 F0,16 21 A1 Z 1A F0,1A Z 5A DA S 1B F0,1B S 53 D3 A 1C F0,1C A 41 C1 W 1D F0,1D W 57 D7 @ @ 2 1E F0,1E 40 C0 C 21 F0,21 C 43 C3 X 22 F0,22 X 58 D8 D 23 F0,23 D 44 C4 E 24 F0,24 E 45 C5 $ $ 4 25 F0,25 24 A4 # # 3 26 F0,26 23 A3 Space 29 F0,29 SP ␣ 20 A0 V 2A F0,2A V 56 D6 F 2B F0,2B F 46 C6 T 2C F0,2C T 54 D4 R 2D F0,2D R 52 D2 % % 5 2E F0,2E 25 A5 ASCII ASCII ASCII Make Break make make break Key code code char hex hex N 31 F0,31 N 4E CE B 32 F0,32 B 42 C2 H 33 F0,33 H 48 C8 G 34 F0,34 G 47 C7 Y 35 F0,35 Y 59 D9 ^ ^ 6 36 F0,36 5E DE M 3A F0,3A M 4D CD J 3B F0,3B J 4A CA U 3C F0,3C U 55 D5 & & 7 3D F0,3D 26 A6 * * 8 3E F0,3E 2A AA < , 41 F0,41 , 2C AC K 42 F0,42 K 4B CB I 43 F0,43 I 49 C9 O 44 F0,44 O 4F CF ) ) 0 45 F0,45 29 A9 ( ( 9 46 F0,46 28 A8 > .

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    18 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us