Subversion Repositories HelenOS

Rev

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

  1. /*
  2.  * Copyright (c) 2006 Josef Cejka
  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 kbdmips32 mips32
  30.  * @brief   HelenOS mips32 arch dependent parts of uspace keyboard handler.
  31.  * @ingroup  kbd
  32.  * @{
  33.  */
  34.  
  35. /** @file
  36.  */
  37.  
  38. #include <genarch/nofb.h>
  39.  
  40. #define KEY_F1 0x504f1bL
  41. #define KEY_F2 0x514f1bL
  42. #define KEY_F3 0x524f1bL
  43. #define KEY_F4 0x534f1bL
  44. #define KEY_F5 0x35315b1bL
  45. #define KEY_F6 0x37315b1bL
  46. #define KEY_F7 0x38315b1bL
  47. #define KEY_F8 0x39315b1bL
  48. #define KEY_F9 0x30325b1bL
  49. #define KEY_F10 0x31325b1bL
  50. #define KEY_F11 0x33325b1bL
  51. #define KEY_F12 0x34325b1bL
  52.  
  53. /**
  54.  * Processes the key pressed - pushes the key code into the key buffer.
  55.  * Used in MSIM and Serengeti, i.e. non-framebuffer consoles.
  56.  */
  57. int kbd_process_no_fb(keybuffer_t *keybuffer, int scan_code)
  58. {
  59.     static unsigned long buf = 0;
  60.     static int count = 0;  
  61.    
  62.     if(scan_code == 0x7e) {
  63.         switch (buf) {
  64.         case KEY_F5:
  65.             keybuffer_push(keybuffer,FUNCTION_KEYS | 5);
  66.             buf = count = 0;
  67.             return 1;
  68.         case KEY_F6:
  69.             keybuffer_push(keybuffer,FUNCTION_KEYS | 6);
  70.             buf = count = 0;
  71.             return 1;
  72.         case KEY_F7:
  73.             keybuffer_push(keybuffer,FUNCTION_KEYS | 7);
  74.             buf = count = 0;
  75.             return 1;
  76.         case KEY_F8:
  77.             keybuffer_push(keybuffer,FUNCTION_KEYS | 8);
  78.             buf = count = 0;
  79.             return 1;
  80.         case KEY_F9:
  81.             keybuffer_push(keybuffer,FUNCTION_KEYS | 9);
  82.             buf = count = 0;
  83.             return 1;
  84.         case KEY_F10:
  85.             keybuffer_push(keybuffer,FUNCTION_KEYS | 10);
  86.             buf = count = 0;
  87.             return 1;
  88.         case KEY_F11:
  89.             keybuffer_push(keybuffer,FUNCTION_KEYS | 11);
  90.             buf = count = 0;
  91.             return 1;
  92.         case KEY_F12:
  93.             keybuffer_push(keybuffer,FUNCTION_KEYS | 12);
  94.             buf = count = 0;
  95.             return 1;
  96.         default:
  97.             keybuffer_push(keybuffer, buf & 0xff);
  98.             keybuffer_push(keybuffer, (buf >> 8) &0xff);
  99.             keybuffer_push(keybuffer, (buf >> 16) &0xff);
  100.             keybuffer_push(keybuffer, (buf >> 24) &0xff);
  101.             keybuffer_push(keybuffer, scan_code);
  102.             buf = count = 0;
  103.             return 1;
  104.         }
  105.     }
  106.  
  107.     buf |= ((unsigned long) scan_code)<<(8*(count++));
  108.    
  109.     if((buf & 0xff) != (KEY_F1 & 0xff)) {
  110.         keybuffer_push(keybuffer, buf);
  111.         buf = count = 0;
  112.         return 1;
  113.     }
  114.  
  115.     if (count <= 1)
  116.         return 1;
  117.  
  118.     if ((buf & 0xffff) != (KEY_F1 & 0xffff)
  119.         && (buf & 0xffff) != (KEY_F5 & 0xffff) ) {
  120.  
  121.         keybuffer_push(keybuffer, buf & 0xff);
  122.         keybuffer_push(keybuffer, (buf >> 8) &0xff);
  123.         buf = count = 0;
  124.         return 1;
  125.     }
  126.  
  127.     if (count <= 2)
  128.         return 1;
  129.  
  130.     switch (buf) {
  131.     case KEY_F1:
  132.         keybuffer_push(keybuffer,FUNCTION_KEYS | 1);
  133.         buf = count = 0;
  134.         return 1;
  135.     case KEY_F2:
  136.         keybuffer_push(keybuffer,FUNCTION_KEYS | 2);
  137.         buf = count = 0;
  138.         return 1;
  139.     case KEY_F3:
  140.         keybuffer_push(keybuffer,FUNCTION_KEYS | 3);
  141.         buf = count = 0;
  142.         return 1;
  143.     case KEY_F4:
  144.         keybuffer_push(keybuffer,FUNCTION_KEYS | 4);
  145.         buf = count = 0;
  146.         return 1;
  147.     }
  148.  
  149.  
  150.     if((buf & 0xffffff) != (KEY_F5 & 0xffffff)
  151.         && (buf & 0xffffff) != (KEY_F9 & 0xffffff)) {
  152.  
  153.         keybuffer_push(keybuffer, buf & 0xff);
  154.         keybuffer_push(keybuffer, (buf >> 8) & 0xff);
  155.         keybuffer_push(keybuffer, (buf >> 16) & 0xff);
  156.         buf=count=0;
  157.         return 1;
  158.     }
  159.  
  160.     if (count <= 3)
  161.         return 1;
  162.    
  163.     switch (buf) {
  164.     case KEY_F5:
  165.     case KEY_F6:
  166.     case KEY_F7:
  167.     case KEY_F8:
  168.     case KEY_F9:
  169.     case KEY_F10:
  170.     case KEY_F11:
  171.     case KEY_F12:
  172.         return 1;
  173.     default:
  174.         keybuffer_push(keybuffer, buf & 0xff);
  175.         keybuffer_push(keybuffer, (buf >> 8) &0xff);
  176.         keybuffer_push(keybuffer, (buf >> 16) &0xff);
  177.         keybuffer_push(keybuffer, (buf >> 24) &0xff);
  178.         buf = count = 0;
  179.         return 1;
  180.     }
  181.     return 1;
  182. }
  183.  
  184. /** @}
  185.  */