Subversion Repositories HelenOS-historic

Rev

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

  1. /*
  2.  * Copyright (C) 2006 Martin Decky
  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. #include <arch/kbd.h>
  30. #include <ipc/ipc.h>
  31. #include <sysinfo.h>
  32.  
  33. irq_cmd_t cuda_cmds[1] = {
  34.     { CMD_PPC32_GETCHAR, 0, 0 }
  35. };
  36.  
  37. irq_code_t cuda_kbd = {
  38.     1,
  39.     cuda_cmds
  40. };
  41.  
  42.  
  43. #define SPECIAL     255
  44. #define FUNCTION_KEYS 0x100
  45.  
  46.  
  47. static int lchars[0x80] = {
  48.     'a',
  49.     's',
  50.     'd',
  51.     'f',
  52.     'h',
  53.     'g',
  54.     'z',
  55.     'x',
  56.     'c',
  57.     'v',
  58.     SPECIAL,
  59.     'b',
  60.     'q',
  61.     'w',
  62.     'e',
  63.     'r',
  64.     'y',
  65.     't',
  66.     '1',
  67.     '2',
  68.     '3',
  69.     '4',
  70.     '6',
  71.     '5',
  72.     '=',
  73.     '9',
  74.     '7',
  75.     '-',
  76.     '8',
  77.     '0',
  78.     ']',
  79.     'o',
  80.     'u',
  81.     '[',
  82.     'i',
  83.     'p',
  84.     '\n',                 /* Enter */
  85.     'l',
  86.     'j',
  87.     '\'',
  88.     'k',
  89.     ';',
  90.     '\\',
  91.     ',',
  92.     '/',
  93.     'n',
  94.     'm',
  95.     '.',
  96.     '\t',                 /* Tab */
  97.     ' ',
  98.     '`',
  99.     '\b',                 /* Backspace */
  100.     SPECIAL,
  101.     SPECIAL,              /* Escape */
  102.     SPECIAL,              /* Ctrl */
  103.     SPECIAL,              /* Alt */
  104.     SPECIAL,              /* Shift */
  105.     SPECIAL,              /* Caps-Lock */
  106.     SPECIAL,              /* RAlt */
  107.     SPECIAL,              /* Left */
  108.     SPECIAL,              /* Right */
  109.     SPECIAL,              /* Down */
  110.     SPECIAL,              /* Up */
  111.     SPECIAL,
  112.     SPECIAL,
  113.     '.',                  /* Keypad . */
  114.     SPECIAL,
  115.     '*',                  /* Keypad * */
  116.     SPECIAL,
  117.     '+',                  /* Keypad + */
  118.     SPECIAL,
  119.     SPECIAL,              /* NumLock */
  120.     SPECIAL,
  121.     SPECIAL,
  122.     SPECIAL,
  123.     '/',                  /* Keypad / */
  124.     '\n',                 /* Keypad Enter */
  125.     SPECIAL,
  126.     '-',                  /* Keypad - */
  127.     SPECIAL,
  128.     SPECIAL,
  129.     SPECIAL,
  130.     '0',                  /* Keypad 0 */
  131.     '1',                  /* Keypad 1 */
  132.     '2',                  /* Keypad 2 */
  133.     '3',                  /* Keypad 3 */
  134.     '4',                  /* Keypad 4 */
  135.     '5',                  /* Keypad 5 */
  136.     '6',                  /* Keypad 6 */
  137.     '7',                  /* Keypad 7 */
  138.     SPECIAL,
  139.     '8',                  /* Keypad 8 */
  140.     '9',                  /* Keypad 9 */
  141.     SPECIAL,
  142.     SPECIAL,
  143.     SPECIAL,
  144.     (FUNCTION_KEYS | 5),  /* F5 */
  145.     (FUNCTION_KEYS | 6),  /* F6 */
  146.     (FUNCTION_KEYS | 7),  /* F7 */
  147.     (FUNCTION_KEYS | 3),  /* F3 */
  148.     (FUNCTION_KEYS | 8),  /* F8 */
  149.     (FUNCTION_KEYS | 9),  /* F9 */
  150.     SPECIAL,
  151.     (FUNCTION_KEYS | 11), /* F11 */
  152.     SPECIAL,
  153.     (FUNCTION_KEYS | 13), /* F13 */
  154.     SPECIAL,
  155.     SPECIAL,              /* ScrollLock */
  156.     SPECIAL,
  157.     (FUNCTION_KEYS | 10), /* F10 */
  158.     SPECIAL,
  159.     (FUNCTION_KEYS | 12), /* F12 */
  160.     SPECIAL,
  161.     SPECIAL,              /* Pause */
  162.     SPECIAL,              /* Insert */
  163.     SPECIAL,              /* Home */
  164.     SPECIAL,              /* PageUp */
  165.     SPECIAL,              /* Delete */
  166.     (FUNCTION_KEYS | 4),  /* F4 */
  167.     SPECIAL,              /* End */
  168.     (FUNCTION_KEYS | 2),  /* F2 */
  169.     SPECIAL,              /* PageDown */
  170.     (FUNCTION_KEYS | 1)   /* F1 */
  171. };
  172.  
  173.  
  174. int kbd_arch_init(void)
  175. {
  176.     return (!ipc_register_irq(sysinfo_value("cuda.irq"), &cuda_kbd));
  177. }
  178.  
  179.  
  180. int kbd_arch_process(keybuffer_t *keybuffer, int scan_code)
  181. {
  182.     if (scan_code != -1) {
  183.         uint8_t scancode = (uint8_t) scan_code;
  184.    
  185.         if ((scancode & 0x80) != 0x80) {
  186.             int key = lchars[scancode & 0x7f];
  187.            
  188.             if (key != SPECIAL)
  189.                 keybuffer_push(keybuffer, key);
  190.         }
  191.     }
  192.    
  193.     return 1;
  194. }
  195.