arch/ia64/src/kbd.c

Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 2006 Josef Cejka
00003  * All rights reserved.
00004  *
00005  * Redistribution and use in source and binary forms, with or without
00006  * modification, are permitted provided that the following conditions
00007  * are met:
00008  *
00009  * - Redistributions of source code must retain the above copyright
00010  *   notice, this list of conditions and the following disclaimer.
00011  * - Redistributions in binary form must reproduce the above copyright
00012  *   notice, this list of conditions and the following disclaimer in the
00013  *   documentation and/or other materials provided with the distribution.
00014  * - The name of the author may not be used to endorse or promote products
00015  *   derived from this software without specific prior written permission.
00016  *
00017  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
00018  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
00019  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
00020  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
00021  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
00022  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
00023  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
00024  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00025  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
00026  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00027  */
00028 
00037 #include <arch/kbd.h>
00038 #include <ipc/ipc.h>
00039 #include <sysinfo.h>
00040 #include <kbd.h>
00041 #include <keys.h>
00042 
00043 #define KEY_F1 0x504f1b
00044 #define KEY_F2 0x514f1b
00045 #define KEY_F3 0x524f1b
00046 #define KEY_F4 0x534f1b
00047 #define KEY_F5 0x7e35315b1b
00048 #define KEY_F6 0x7e37315b1b
00049 #define KEY_F7 0x7e38315b1b
00050 #define KEY_F8 0x7e39315b1b
00051 #define KEY_F9 0x7e30325b1b
00052 #define KEY_F10 0x7e31325b1b
00053 #define KEY_F11 0x7e33325b1b
00054 #define KEY_F12 0x7e34325b1b
00055 
00056 
00057 #define FUNCTION_KEYS 0x100
00058 
00059 irq_cmd_t ski_cmds[1] = {
00060         { CMD_IA64_GETCHAR, 0, 0, 2 }
00061 };
00062 
00063 irq_code_t ski_kbd = {
00064         1,
00065         ski_cmds
00066 };
00067 
00068 int kbd_arch_init(void)
00069 {
00070         if (sysinfo_value("kbd")) {
00071                 ipc_register_irq(sysinfo_value("kbd.irq"), &ski_kbd);
00072                 return 0;
00073         }       
00074         return 1;
00075 }
00076 
00077 /*
00078 * Please preserve this code (it can be used to determine scancodes)
00079 *
00080 int to_hex(int v) 
00081 {
00082     return "0123456789ABCDEF"[v];
00083 }
00084 */
00085 
00086 int kbd_arch_process(keybuffer_t *keybuffer, ipc_call_t *call) 
00087 {
00088         static unsigned long long buf=0;
00089         static int count=0;     
00090         static int esc_count=0;
00091         int scan_code = IPC_GET_ARG2(*call);
00092 
00093 
00094         /*
00095          * Please preserve this code (it can be used to determine scancodes)
00096          */
00097         //keybuffer_push(keybuffer, to_hex((scan_code>>4)&0xf));
00098         //keybuffer_push(keybuffer, to_hex(scan_code&0xf));
00099         //keybuffer_push(keybuffer, ' ');
00100         //keybuffer_push(keybuffer, ' ');
00101         //*/
00102         
00103         if (scan_code) {
00104                 buf |= (unsigned long long) scan_code<<(8*(count++));
00105         } else {
00106                 
00107 
00108                 if (buf == 0x1b) {
00109                         esc_count++;
00110                         if (esc_count == 3) {
00111                                 __SYSCALL0(SYS_DEBUG_ENABLE_CONSOLE);
00112                         }       
00113                 } else {
00114                         esc_count = 0;
00115                 }
00116         
00117                 if (!(buf & 0xff00)) {
00118                         keybuffer_push(keybuffer, buf);
00119                 } else {
00120                         switch (buf) {
00121                                 case KEY_F1:
00122                                         keybuffer_push(keybuffer, FUNCTION_KEYS | 1);
00123                                         break;
00124                                 case KEY_F2:
00125                                         keybuffer_push(keybuffer, FUNCTION_KEYS | 2);
00126                                         break;
00127                                 case KEY_F3:
00128                                         keybuffer_push(keybuffer, FUNCTION_KEYS | 3);
00129                                         break;
00130                                 case KEY_F4:
00131                                         keybuffer_push(keybuffer, FUNCTION_KEYS | 4);
00132                                         break;
00133                                 case KEY_F5:
00134                                         keybuffer_push(keybuffer, FUNCTION_KEYS | 5);
00135                                         break;
00136                                 case KEY_F6:
00137                                         keybuffer_push(keybuffer, FUNCTION_KEYS | 6);
00138                                         break;
00139                                 case KEY_F7:
00140                                         keybuffer_push(keybuffer, FUNCTION_KEYS | 7);
00141                                         break;
00142                                 case KEY_F8:
00143                                         keybuffer_push(keybuffer, FUNCTION_KEYS | 8);
00144                                         break;
00145                                 case KEY_F9:
00146                                         keybuffer_push(keybuffer, FUNCTION_KEYS | 9);
00147                                         break;
00148                                 case KEY_F10:
00149                                         keybuffer_push(keybuffer, FUNCTION_KEYS | 10);
00150                                         break;
00151                                 case KEY_F11:
00152                                         keybuffer_push(keybuffer, FUNCTION_KEYS | 11);
00153                                         break;
00154                                 case KEY_F12:
00155                                         keybuffer_push(keybuffer, FUNCTION_KEYS | 12);
00156                                         break;
00157                         }
00158                 }
00159                 buf = count = 0;
00160         }
00161 
00162         return  1;
00163 }
00164 

Generated on Sun Jun 18 18:00:18 2006 for HelenOS Userspace (ia64) by  doxygen 1.4.6