#include <gpxe/io.h>#include "console.h"Go to the source code of this file.
Defines | |
| #define | SHIFT 1 |
| #define | CONTROL 2 |
| #define | CAPS 4 |
Functions | |
| static int | get_scancode (void) |
| static int | kbd_havekey (void) |
| static int | kbd_ischar (void) |
| static int | kbd_getc (void) |
Variables | |
| static char | key_map [][128] |
| static int | cur_scan |
| static unsigned int | shift_state |
| struct console_driver pc_kbd_console | __console_driver |
| #define SHIFT 1 |
| #define CONTROL 2 |
| #define CAPS 4 |
| static int get_scancode | ( | void | ) | [static] |
Definition at line 40 of file pc_kbd.c.
References CAPS, CONTROL, inb, SHIFT, and shift_state.
Referenced by kbd_havekey().
00041 { 00042 int scan; 00043 00044 if ((inb(0x64) & 1) == 0) 00045 return 0; 00046 scan = inb(0x60); 00047 00048 switch (scan) { 00049 case 0x2a: 00050 case 0x36: 00051 shift_state |= SHIFT; 00052 break; 00053 case 0xaa: 00054 case 0xb6: 00055 shift_state &= ~SHIFT; 00056 break; 00057 case 0x1d: 00058 shift_state |= CONTROL; 00059 break; 00060 case 0x9d: 00061 shift_state &= ~CONTROL; 00062 break; 00063 case 0x3a: 00064 shift_state ^= CAPS; 00065 break; 00066 } 00067 00068 if (scan & 0x80) 00069 return 0; /* ignore break code or 0xe0 etc! */ 00070 return scan; 00071 }
| static int kbd_havekey | ( | void | ) | [static] |
Definition at line 73 of file pc_kbd.c.
References cur_scan, and get_scancode().
Referenced by kbd_ischar().
00074 { 00075 if (!cur_scan) 00076 cur_scan = get_scancode(); 00077 return cur_scan != 0; 00078 }
| static int kbd_ischar | ( | void | ) | [static] |
Definition at line 80 of file pc_kbd.c.
References cur_scan, kbd_havekey(), key_map, SHIFT, and shift_state.
Referenced by kbd_getc().
00081 { 00082 if (!kbd_havekey()) 00083 return 0; 00084 if (!key_map[shift_state & SHIFT][cur_scan]) { 00085 cur_scan = 0; 00086 return 0; 00087 } 00088 return 1; 00089 }
| static int kbd_getc | ( | void | ) | [static] |
Definition at line 91 of file pc_kbd.c.
References CAPS, CONTROL, cur_scan, kbd_ischar(), key_map, SHIFT, and shift_state.
00092 { 00093 int c; 00094 00095 while (!kbd_ischar()) 00096 ; 00097 c = key_map[shift_state & SHIFT][cur_scan]; 00098 if (shift_state & (CONTROL | CAPS)) { 00099 if ((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z')) { 00100 if (shift_state & CONTROL) 00101 c &= 0x1f; 00102 else if (shift_state & CAPS) 00103 c ^= ('A' ^ 'a'); 00104 } 00105 } 00106 cur_scan = 0; 00107 return c; 00108 }
char key_map[][128] [static] |
Initial value:
{
{
"\0\x1b""1234567890-=\b\t"
"qwertyuiop[]\r\0as"
"dfghjkl;'`\0\\zxcv"
"bnm,./\0*\0 \0\0\0\0\0\0"
"\0\0\0\0\0\0\0""789-456+1"
"230."
},{
"\0\x1b""!@#$%^&*()_+\b\t"
"QWERTYUIOP{}\r\0AS"
"DFGHJKL:\"~\0|ZXCV"
"BNM<>?\0\0\0 \0\0\0\0\0\0"
"\0\0\0\0\0\0\0""789-456+1"
"230."
}
}
Definition at line 16 of file pc_kbd.c.
Referenced by kbd_getc(), and kbd_ischar().
int cur_scan [static] |
unsigned int shift_state [static] |
| struct console_driver pc_kbd_console __console_driver |
1.5.7.1