Subversion Repositories HelenOS

Rev

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