Keyboard

The keyboard is connected directly to the GPIO pins. It is a matrix of 17 columns and 8 rows of copper wire. On crossings of a row wire with a column wire there is a key on it, which can connect the two wires. By setting voltages on one side and reading voltages on the other, it is possible to see if a key is pressed.

For some reason, the keyboard only works if the voltages are set on the columns and read out from the rows.

The row pins are 0 through 7 on port 0.

The column pins are 0 through 15, and 29, all on port 3.

There are several ways to design a keyboard driver. Iris uses the following method. All pins are set to input, which means they don't drive the pin with a voltage. The row pins have a pull-up enabled. One by one the column pins are scanned by setting them to output 0. Because of the pull-ups, any row which is not connected to this column will have a logic 1 at its input, while the ones which are connected will have a logic 0. Thus the entire keyboard is scanned, and differences with the previous scan are reported as press or release events.

Linux uses a different method, which seems inefficient and possibly broken. If you know that it isn't, please explain here what it does.

The following is a map of the keys, taken from Linux:

  • /* 0*/ {KEY_PAUSE, 0, 0, 0, 0, 0, KEY_LEFTCTRL, KEY_F5,},
  • /* 1*/ {KEY_Q, KEY_TAB, KEY_A, KEY_ESC, KEY_Z, 0, KEY_GRAVE, KEY_1,},
  • /* 2*/ {KEY_W, KEY_CAPSLOCK, KEY_S, KEY_102ND, KEY_X, 0, 0, KEY_2,},//CZJ delet the KEY_BACKSLASH
  • /* 3*/ {KEY_E, KEY_F3, KEY_D, KEY_F4, KEY_C, 0, 0, KEY_3,},
  • /* 4*/ {KEY_R, KEY_T, KEY_F, KEY_G, KEY_V, KEY_B, KEY_5, KEY_4,},
  • /* 5*/ {KEY_U, KEY_Y, KEY_J, KEY_H, KEY_M, KEY_N, KEY_6, KEY_7,},
  • /* 6*/ {KEY_I, KEY_RIGHTBRACE, KEY_K, KEY_F6, KEY_COMMA, 0, KEY_EQUAL, KEY_8,},
  • /* 7*/ {KEY_O, KEY_F7, KEY_L, 0, KEY_DOT, KEY_F19, KEY_F8, KEY_9,},
  • /* 8*/ {0, 0, 0, KEY_SPACE, KEY_NUMLOCK, 0, KEY_DELETE, 0,},
  • /* 9*/ {0, KEY_BACKSPACE, 0, 0, KEY_ENTER, 0, KEY_F9, 0,},
  • /*10*/ {0, 0, 0, KEY_LEFTALT, 0, 0, 0, KEY_SYSRQ,},
  • /*11*/ {KEY_P, KEY_LEFTBRACE, KEY_SEMICOLON, KEY_APOSTROPHE, KEY_BACKSLASH, KEY_SLASH, KEY_MINUS, KEY_0,},
  • /*12*/ {KEY_KP0, KEY_F20, KEY_KP1, KEY_KP2, KEY_KP3, KEY_KP4, KEY_KP5, KEY_F10,}, //CZJ ADD NUM PACK
  • /*13*/ {KEY_KP6, KEY_KP7, KEY_KP8, KEY_KP9, KEY_KPPLUS, KEY_KPMINUS, KEY_F2, KEY_KPSLASH,}, //CZJ ADD NUM PACK
  • /*14*/ {KEY_KPDOT, KEY_KPASTERISK, 0, 0, 0, 0, KEY_INSERT, 0,}, //CZJ ADD NUM PACK
  • /*15*/ {0, 0, KEY_UP, KEY_DOWN, KEY_LEFT, KEY_RIGHT, 0, 0,},
  • /*16*/ {0, KEY_LEFTSHIFT, KEY_RIGHTSHIFT, 0, 0, 0, KEY_F1, KEY_FN,},

The KEY_KP* keys are nonsense. These contacts have no connection, but the symbols are returned by the driver when num-lock is enabled. I have no idea why they are in this table, because those bits cannot be set by pressing a key.

-- BasWijnen - 14 Jun 2009

Topic revision: r1 - 14 Jun 2009 - 17:41:11 - BasWijnen
 
This site is powered by the TWiki collaboration platformCopyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback