Subversion Repositories HelenOS

Rev

Rev 3582 | 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. #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, Serengeti and Niagara, 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 == 0x7e) {
  64.         switch (buf) {
  65.         case KEY_F5:
  66.             keybuffer_push(keybuffer,FUNCTION_KEYS | 5);
  67.             buf = count = 0;
  68.             return 1;
  69.         case KEY_F6:
  70.             keybuffer_push(keybuffer,FUNCTION_KEYS | 6);
  71.             buf = count = 0;
  72.             return 1;
  73.         case KEY_F7:
  74.             keybuffer_push(keybuffer,FUNCTION_KEYS | 7);
  75.             buf = count = 0;
  76.             return 1;
  77.         case KEY_F8:
  78.             keybuffer_push(keybuffer,FUNCTION_KEYS | 8);
  79.             buf = count = 0;
  80.             return 1;
  81.         case KEY_F9:
  82.             keybuffer_push(keybuffer,FUNCTION_KEYS | 9);
  83.             buf = count = 0;
  84.             return 1;
  85.         case KEY_F10:
  86.             keybuffer_push(keybuffer,FUNCTION_KEYS | 10);
  87.             buf = count = 0;
  88.             return 1;
  89.         case KEY_F11:
  90.             keybuffer_push(keybuffer,FUNCTION_KEYS | 11);
  91.             buf = count = 0;
  92.             return 1;
  93.         case KEY_F12:
  94.             keybuffer_push(keybuffer,FUNCTION_KEYS | 12);
  95.             buf = count = 0;
  96.             return 1;
  97.         default:
  98.             keybuffer_push(keybuffer, buf & 0xff);
  99.             keybuffer_push(keybuffer, (buf >> 8) &0xff);
  100.             keybuffer_push(keybuffer, (buf >> 16) &0xff);
  101.             keybuffer_push(keybuffer, (buf >> 24) &0xff);
  102.             keybuffer_push(keybuffer, scan_code);
  103.             buf = count = 0;
  104.             return 1;
  105.         }
  106.     }
  107.  
  108.     buf |= ((unsigned long) scan_code)<<(8*(count++));
  109.    
  110.     if((buf & 0xff) != (KEY_F1 & 0xff)) {
  111.         keybuffer_push(keybuffer, buf);
  112.         buf = count = 0;
  113.         return 1;
  114.     }
  115.  
  116.     if (count <= 1)
  117.         return 1;
  118.  
  119.     if ((buf & 0xffff) != (KEY_F1 & 0xffff)
  120.         && (buf & 0xffff) != (KEY_F5 & 0xffff) ) {
  121.  
  122.         keybuffer_push(keybuffer, buf & 0xff);
  123.         keybuffer_push(keybuffer, (buf >> 8) &0xff);
  124.         buf = count = 0;
  125.         return 1;
  126.     }
  127.  
  128.     if (count <= 2)
  129.         return 1;
  130.  
  131.     switch (buf) {
  132.     case KEY_F1:
  133.         keybuffer_push(keybuffer,FUNCTION_KEYS | 1);
  134.         buf = count = 0;
  135.         return 1;
  136.     case KEY_F2:
  137.         keybuffer_push(keybuffer,FUNCTION_KEYS | 2);
  138.         buf = count = 0;
  139.         return 1;
  140.     case KEY_F3:
  141.         keybuffer_push(keybuffer,FUNCTION_KEYS | 3);
  142.         buf = count = 0;
  143.         return 1;
  144.     case KEY_F4:
  145.         keybuffer_push(keybuffer,FUNCTION_KEYS | 4);
  146.         buf = count = 0;
  147.         return 1;
  148.     }
  149.  
  150.  
  151.     if((buf & 0xffffff) != (KEY_F5 & 0xffffff)
  152.         && (buf & 0xffffff) != (KEY_F9 & 0xffffff)) {
  153.  
  154.         keybuffer_push(keybuffer, buf & 0xff);
  155.         keybuffer_push(keybuffer, (buf >> 8) & 0xff);
  156.         keybuffer_push(keybuffer, (buf >> 16) & 0xff);
  157.         buf=count=0;
  158.         return 1;
  159.     }
  160.  
  161.     if (count <= 3)
  162.         return 1;
  163.    
  164.     switch (buf) {
  165.     case KEY_F5:
  166.     case KEY_F6:
  167.     case KEY_F7:
  168.     case KEY_F8:
  169.     case KEY_F9:
  170.     case KEY_F10:
  171.     case KEY_F11:
  172.     case KEY_F12:
  173.         return 1;
  174.     default:
  175.         keybuffer_push(keybuffer, buf & 0xff);
  176.         keybuffer_push(keybuffer, (buf >> 8) &0xff);
  177.         keybuffer_push(keybuffer, (buf >> 16) &0xff);
  178.         keybuffer_push(keybuffer, (buf >> 24) &0xff);
  179.         buf = count = 0;
  180.         return 1;
  181.     }
  182.  
  183.     return 1;
  184. }
  185.  
  186. /** @}
  187.  */
  188.