Subversion Repositories HelenOS

Rev

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