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) 2006 Jakub Jermar
  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_ctl
  30.  * @ingroup kbd
  31.  * @{
  32.  */
  33. /**
  34.  * @file
  35.  * @brief   Sun keyboard controller driver.
  36.  */
  37.  
  38. #include <kbd.h>
  39. #include <kbd/kbd.h>
  40. #include <kbd/keycode.h>
  41. #include <kbd_ctl.h>
  42.  
  43. #define KBD_KEY_RELEASE     0x80
  44. #define KBD_ALL_KEYS_UP     0x7f
  45.  
  46. static int scanmap_simple[];
  47.  
  48. void kbd_ctl_parse_scancode(int scancode)
  49. {
  50.     kbd_ev_type_t type;
  51.     unsigned int key;
  52.  
  53.     if (scancode < 0 || scancode >= 0x100)
  54.         return;
  55.  
  56.     if (scancode == KBD_ALL_KEYS_UP)
  57.         return;
  58.  
  59.     if (scancode & KBD_KEY_RELEASE) {
  60.         scancode &= ~KBD_KEY_RELEASE;
  61.         type = KE_RELEASE;
  62.     } else {
  63.         type = KE_PRESS;
  64.     }
  65.  
  66.     key = scanmap_simple[scancode];
  67.     if (key != 0)
  68.         kbd_push_ev(type, key);
  69. }
  70.  
  71. /** Primary meaning of scancodes. */
  72. static int scanmap_simple[] = {
  73.     [0x00] = 0,
  74.     [0x01] = 0,
  75.     [0x02] = 0,
  76.     [0x03] = 0,
  77.     [0x04] = 0,
  78.     [0x05] = KC_F1,
  79.     [0x06] = KC_F2,
  80.     [0x07] = KC_F10,
  81.     [0x08] = KC_F3,
  82.     [0x09] = KC_F11,
  83.     [0x0a] = KC_F4,
  84.     [0x0b] = KC_F12,
  85.     [0x0c] = KC_F5,
  86.     [0x0d] = KC_RALT,
  87.     [0x0e] = KC_F6,
  88.     [0x0f] = 0,
  89.     [0x10] = KC_F7,
  90.     [0x11] = KC_F8,
  91.     [0x12] = KC_F9,
  92.     [0x13] = KC_LALT,
  93.     [0x14] = KC_UP,
  94.     [0x15] = KC_PAUSE,
  95.     [0x16] = 0,
  96.     [0x17] = KC_SCROLL_LOCK,
  97.     [0x18] = KC_LEFT,
  98.     [0x19] = 0,
  99.     [0x1a] = 0,
  100.     [0x1b] = KC_DOWN,
  101.     [0x1c] = KC_RIGHT,
  102.     [0x1d] = KC_ESCAPE,
  103.     [0x1e] = KC_1,
  104.     [0x1f] = KC_2,
  105.     [0x20] = KC_3,
  106.     [0x21] = KC_4,
  107.     [0x22] = KC_5,
  108.     [0x23] = KC_6,
  109.     [0x24] = KC_7,
  110.     [0x25] = KC_8,
  111.     [0x26] = KC_9,
  112.     [0x27] = KC_0,
  113.     [0x28] = KC_MINUS,
  114.     [0x29] = KC_EQUALS,
  115.     [0x2a] = KC_BACKTICK,
  116.     [0x2b] = KC_BACKSPACE,
  117.     [0x2c] = KC_INSERT,
  118.     [0x2d] = 0,
  119.     [0x2e] = KC_NSLASH,
  120.     [0x2f] = KC_NTIMES,
  121.     [0x30] = 0,
  122.     [0x31] = 0,
  123.     [0x32] = KC_NPERIOD,
  124.     [0x33] = 0,
  125.     [0x34] = KC_HOME,
  126.     [0x35] = KC_TAB,
  127.     [0x36] = KC_Q,
  128.     [0x37] = KC_W,
  129.     [0x38] = KC_E,
  130.     [0x39] = KC_R,
  131.     [0x3a] = KC_T,
  132.     [0x3b] = KC_Y,
  133.     [0x3c] = KC_U,
  134.     [0x3d] = KC_I,
  135.     [0x3e] = KC_O,
  136.     [0x3f] = KC_P,
  137.     [0x40] = KC_LBRACKET,
  138.     [0x41] = KC_RBRACKET,
  139.     [0x42] = KC_DELETE,
  140.     [0x43] = 0,
  141.     [0x44] = KC_N7,
  142.     [0x45] = KC_N8,
  143.     [0x46] = KC_N9,
  144.     [0x47] = KC_NMINUS,
  145.     [0x48] = 0,
  146.     [0x49] = 0,
  147.     [0x4a] = KC_END,
  148.     [0x4b] = 0,
  149.     [0x4c] = KC_LCTRL,
  150.     [0x4d] = KC_A,
  151.     [0x4e] = KC_S,
  152.     [0x4f] = KC_D,
  153.     [0x50] = KC_F,
  154.     [0x51] = KC_G,
  155.     [0x52] = KC_H,
  156.     [0x53] = KC_J,
  157.     [0x54] = KC_K,
  158.     [0x55] = KC_L,
  159.     [0x56] = KC_SEMICOLON,
  160.     [0x57] = KC_QUOTE,
  161.     [0x58] = KC_BACKSLASH,
  162.     [0x59] = KC_ENTER,
  163.     [0x5a] = KC_NENTER,
  164.     [0x5b] = KC_N4,
  165.     [0x5c] = KC_N5,
  166.     [0x5d] = KC_N6,
  167.     [0x5e] = KC_N0,
  168.     [0x5f] = 0,
  169.     [0x60] = KC_PAGE_UP,
  170.     [0x61] = 0,
  171.     [0x62] = KC_NUM_LOCK,
  172.     [0x63] = KC_LSHIFT,
  173.     [0x64] = KC_Z,
  174.     [0x65] = KC_X,
  175.     [0x66] = KC_C,
  176.     [0x67] = KC_V,
  177.     [0x68] = KC_B,
  178.     [0x69] = KC_N,
  179.     [0x6a] = KC_M,
  180.     [0x6b] = KC_COMMA,
  181.     [0x6c] = KC_PERIOD,
  182.     [0x6d] = KC_SLASH,
  183.     [0x6e] = KC_RSHIFT,
  184.     [0x6f] = 0,
  185.     [0x70] = KC_N1,
  186.     [0x71] = KC_N2,
  187.     [0x72] = KC_N3,
  188.     [0x73] = 0,
  189.     [0x74] = 0,
  190.     [0x75] = 0,
  191.     [0x76] = 0,
  192.     [0x77] = KC_CAPS_LOCK,
  193.     [0x78] = 0,
  194.     [0x79] = KC_SPACE,
  195.     [0x7a] = 0,
  196.     [0x7b] = KC_PAGE_DOWN,
  197.     [0x7c] = 0,
  198.     [0x7d] = KC_NPLUS,
  199.     [0x7e] = 0,
  200.     [0x7f] = 0
  201. };
  202.  
  203. /** @}
  204.  */
  205.