Subversion Repositories HelenOS

Rev

Rev 3924 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1. /*
  2.  * Copyright (c) 2009 Jiri Svoboda
  3.  * All rights reserved.
  4.  *
  5.  * Redistribution and use in source and binary forms, with or without
  6.  * modification, are permitted provided that the following conditions
  7.  * are met:
  8.  *
  9.  * - Redistributions of source code must retain the above copyright
  10.  *   notice, this list of conditions and the following disclaimer.
  11.  * - Redistributions in binary form must reproduce the above copyright
  12.  *   notice, this list of conditions and the following disclaimer in the
  13.  *   documentation and/or other materials provided with the distribution.
  14.  * - The name of the author may not be used to endorse or promote products
  15.  *   derived from this software without specific prior written permission.
  16.  *
  17.  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
  18.  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  19.  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  20.  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
  21.  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  22.  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  23.  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  24.  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  25.  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  26.  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  27.  */
  28.  
  29. /** @addtogroup kbd
  30.  * @brief   PC keyboard controller driver.
  31.  * @{
  32.  */
  33.  
  34. #include <kbd.h>
  35. #include <kbd/kbd.h>
  36. #include <kbd/keycode.h>
  37. #include <kbd_ctl.h>
  38.  
  39. int scanmap_simple[];
  40.  
  41. void kbd_ctl_parse_scancode(int scancode)
  42. {
  43.     kbd_ev_type_t type;
  44.     unsigned int key;
  45.  
  46.     if (scancode < 0 || scancode >= 0x100) return;
  47.  
  48.     if (scancode & 0x80) {
  49.         scancode &= ~0x80;
  50.         type = KE_RELEASE;
  51.     } else {
  52.         type = KE_PRESS;
  53.     }
  54.  
  55.     key = scanmap_simple[scancode];
  56.     if (key != 0)
  57.         kbd_push_ev(type, key, 0);
  58. }
  59.  
  60. int scanmap_simple[128] = {
  61.  
  62.     [0x29] = KC_BACKTICK,
  63.  
  64.     [0x02] = KC_1,
  65.     [0x03] = KC_2,
  66.     [0x04] = KC_3,
  67.     [0x05] = KC_4,
  68.     [0x06] = KC_5,
  69.     [0x07] = KC_6,
  70.     [0x08] = KC_7,
  71.     [0x09] = KC_8,
  72.     [0x0a] = KC_9,
  73.     [0x0b] = KC_0,
  74.  
  75.     [0x0c] = KC_MINUS,
  76.     [0x0d] = KC_EQUALS,
  77.     [0x0e] = KC_BACKSPACE,
  78.  
  79.     [0x0f] = KC_TAB,
  80.  
  81.     [0x10] = KC_Q,
  82.     [0x11] = KC_W,
  83.     [0x12] = KC_E,
  84.     [0x13] = KC_R,
  85.     [0x14] = KC_T,
  86.     [0x15] = KC_Y,
  87.     [0x16] = KC_U,
  88.     [0x17] = KC_I,
  89.     [0x18] = KC_O,
  90.     [0x19] = KC_P,
  91.  
  92.     [0x1a] = KC_LBRACKET,
  93.     [0x1b] = KC_RBRACKET,
  94.  
  95.     [0x3a] = KC_CAPS_LOCK,
  96.  
  97.     [0x1e] = KC_A,
  98.     [0x1f] = KC_S,
  99.     [0x20] = KC_D,
  100.     [0x21] = KC_F,
  101.     [0x22] = KC_G,
  102.     [0x23] = KC_H,
  103.     [0x24] = KC_J,
  104.     [0x25] = KC_K,
  105.     [0x26] = KC_L,
  106.  
  107.     [0x27] = KC_SEMICOLON,
  108.     [0x28] = KC_QUOTE,
  109.     [0x2b] = KC_BACKSLASH,
  110.  
  111.     [0x2a] = KC_LSHIFT,
  112.  
  113.     [0x2c] = KC_Z,
  114.     [0x2d] = KC_X,
  115.     [0x2e] = KC_C,
  116.     [0x2f] = KC_V,
  117.     [0x30] = KC_B,
  118.     [0x31] = KC_N,
  119.     [0x32] = KC_M,
  120.  
  121.     [0x33] = KC_COMMA,
  122.     [0x34] = KC_PERIOD,
  123.     [0x35] = KC_SLASH,
  124.  
  125.     [0x36] = KC_RSHIFT,
  126.  
  127.     [0x1d] = KC_LCTRL,
  128.     [0x38] = KC_LALT,
  129.     [0x39] = KC_SPACE,
  130.  
  131.     [0x01] = KC_ESCAPE,
  132.  
  133.     [0x3b] = KC_F1,
  134.     [0x3c] = KC_F2,
  135.     [0x3d] = KC_F3,
  136.     [0x3e] = KC_F4,
  137.     [0x3f] = KC_F5,
  138.     [0x40] = KC_F6,
  139.     [0x41] = KC_F7,
  140.  
  141.     [0x42] = KC_F8,
  142.     [0x43] = KC_F9,
  143.     [0x44] = KC_F10,
  144.  
  145.     [0x57] = KC_F11,
  146.     [0x58] = KC_F12,
  147.  
  148.     [0x1c] = KC_ENTER
  149.  
  150. /*
  151.     [0x1] = KC_PRNSCR,
  152.     [0x1] = KC_SCROLL_LOCK,
  153.     [0x1] = KC_PAUSE,
  154. */
  155. };
  156.  
  157. /**
  158.  * @}
  159.  */
  160.