Included keys are Num Lock, Backspace, Enter, Space, English letters and numerals.

Dependents:   eee212projectWithSD

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers PS2ASCII.h Source File

PS2ASCII.h

00001 #ifndef MBED_PS2ASCII_H
00002 #define MBED_PS2ASCII_H
00003 
00004 #include "PS2Kbd.h"
00005 #include "mbed.h"
00006 
00007 class PS2ASCII {
00008 
00009 public:
00010 
00011     PS2ASCII(PinName data, PinName clk);
00012     unsigned char getChar();
00013     unsigned char getASCII(unsigned char keypress);
00014     bool caps();
00015     bool shift();
00016     bool E0flag();
00017     bool numlock();
00018         
00019 private:
00020 
00021     PS2Kbd kbd;
00022     bool _caps;                        
00023     bool _shift; 
00024     bool _E0flag; 
00025     bool _numlock;
00026 };
00027 
00028     static const unsigned char shift_on[] = {
00029 //   0     1     2     3     4     5     6     7     8     9     A     B     C     D     E     F
00030     ' ',  ' ',  ' ',  ' ',  ' ',  ' ',  ' ',  ' ',  ' ',  ' ',  ' ',  ' ',  ' ',  ' ',  '`',  ' ', // 00-0F
00031     ' ',  ' ',  ' ',  ' ',  ' ',  ' ',  ' ',  ' ',  ' ',  ' ',  ' ',  ' ',  ' ',  ' ',  ' ',  ' ', // 10-1F
00032     ' ', 0x21, 0x22,  '~', 0x24, 0x25, 0x26,  '@', 0x28, 0x29, 0x30, 0x31,  '<',  '_',  '>',  '?', // 20-2F
00033     ')',  '!', '\"', 0x9C,  '$',  '%',  '^',  '&',  '*',  '(',  ' ',  ':',  ' ',  '+',  ' ',  ' ', // 30-3F
00034     0xAA, 'a',  'b',  'c',  'd',  'e',  'f',  'g',  'h',  'i',  'j',  'k',  'l',  'm',  'n',  'o', // 40-6F
00035     'p',  'q',  'r',  's',  't',  'u',  'v',  'w',  'x',  'y',  'z',  '{',  '|',  '}',  ' ',  ' ', // 50-7F
00036     ' ',  'A',  'B',  'C',  'D',  'E',  'F',  'G',  'H',  'I',  'J',  'K',  'L',  'M',  'N',  'O', // 60-4F
00037     'P',  'Q',  'R',  'S',  'T',  'U',  'V',  'W',  'X',  'Y',  'Z', 0x7B, 0x7C, 0x7D, 0x7E, 0x7F, // 70-5F
00038     ' ',  ' ',  ' ',  ' ',  ' ',  ' ',  ' ',  ' ',  ' ',  ' ',  ' ',  ' ',  ' ',  ' ',  ' ',  ' ', // 80-8F
00039     ' ',  ' ',  ' ',  ' ',  ' ',  ' ',  ' ',  ' ',  ' ',  ' ',  ' ',  ' ',  ' ',  ' ',  ' ',  ' ', // 90-9F
00040     ' ',  ' ',  ' ',  ' ',  ' ',  ' ',  ' ',  ' ',  ' ',  ' ',  ' ',  ' ',  ' ',  ' ',  ' ',  ' ', // A0-AF
00041     ' ',  ' ',  ' ',  ' ',  ' ',  ' ',  ' ',  ' ',  ' ',  ' ',  ' ',  ' ',  ' ',  ' ',  ' ',  ' ', // B0-BF
00042     ' ',  ' ',  ' ',  ' ',  ' ',  ' ',  ' ',  ' ',  ' ',  ' ',  ' ',  ' ',  ' ',  ' ',  ' ',  ' ', // C0-CF
00043     ' ',  ' ',  ' ',  ' ',  ' ',  ' ',  ' ',  ' ',  ' ',  ' ',  ' ',  ' ',  ' ',  ' ',  ' ',  ' ', // D0-DF
00044     ' ',  ' ',  ' ',  ' ',  ' ',  ' ',  ' ',  ' ',  ' ',  ' ',  ' ',  ' ',  ' ',  ' ',  ' ',  ' ', // E0-EF
00045     NULL, ' ',  ' ',  ' ',  ' ',  ' ',  ' ',  ' ',  ' ',  ' ',  ' ',  ' ',  ' ',  ' ',  ' ',  ' ', // F0-FF
00046 };
00047 
00048 #endif