Back to home page

Quest Cross Reference

 
 

    


Warning, cross-references for /kernel/drivers/input/keymap.c need to be fixed.

0001 /*                    The Quest Operating System
0002  *  Copyright (C) 2005-2010  Richard West, Boston University
0003  *
0004  *  This program is free software: you can redistribute it and/or modify
0005  *  it under the terms of the GNU General Public License as published by
0006  *  the Free Software Foundation, either version 3 of the License, or
0007  *  (at your option) any later version.
0008  *
0009  *  This program is distributed in the hope that it will be useful,
0010  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
0011  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0012  *  GNU General Public License for more details.
0013  *
0014  *  You should have received a copy of the GNU General Public License
0015  *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
0016  */
0017 
0018 #include "drivers/input/keyboard.h"
0019 
0020 
0021 /* US Keyboard map */
0022 static char lcase_scancode[128] =
0023     "\0\e1234567890-=\177\tqwertyuiop[]\n\0asdfghjkl;'`\0\\zxcvbnm,./\0*\0 \0\0\0\0\0\0\0\0\0\0\0\0\000789-456+1230.\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0";
0024 static char ucase_scancode[128] =
0025     "\0\e1234567890-=\177\tQWERTYUIOP[]\n\0ASDFGHJKL;'`\0\\ZXCVBNM,./\0*\0 \0\0\0\0\0\0\0\0\0\0\0\0\000789-456+1230.\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0";
0026 
0027 /* Retrieve the next keyboard event and translate it into an ASCII
0028  * char, or block. */
0029 uint8
0030 keymap_getchar (void)
0031 {
0032   int i;
0033   key_event e;
0034   bool shiftmod, ctrlmod, altmod;
0035   uint8 char_code = 0;
0036 
0037   while (!char_code) {
0038     keyboard_8042_next (&e);
0039 
0040     shiftmod = ctrlmod = altmod = FALSE;  
0041     for (i=0; i<KEY_EVENT_MAX; i++) {
0042       if (e.keys[i].present && e.keys[i].pressed) {
0043         switch (e.keys[i].scancode) {
0044         case 0x2A:              /* LSHIFT */
0045         case 0x36:              /* RSHIFT */
0046           shiftmod = TRUE; 
0047           break;
0048 
0049         case 0x1D:              /* LCTRL */
0050         case 0xE01D:            /* RCTRL */
0051           ctrlmod = TRUE;
0052           break;
0053 
0054         case 0x38:              /* LALT */
0055         case 0xE038:            /* RALT */
0056           altmod = TRUE;
0057           break;
0058 
0059         default:
0060           if(e.keys[i].scancode < 128 && e.keys[i].latest) 
0061             char_code = e.keys[i].scancode;
0062           break;
0063         }
0064       }
0065     }
0066   }
0067   
0068   if (shiftmod)
0069     return ucase_scancode[char_code];
0070   else
0071     return lcase_scancode[char_code];
0072 }
0073 
0074 /* 
0075  * Local Variables:
0076  * indent-tabs-mode: nil
0077  * mode: C
0078  * c-file-style: "gnu"
0079  * c-basic-offset: 2
0080  * End: 
0081  */
0082 
0083 /* vi: set et sw=2 sts=2: */