/* sendkey.c - fake keystroke. */
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2009 Free Software Foundation, Inc.
*
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
GRUB_MOD_LICENSE ("GPLv2+");
/* Length of sendkey. */
static int keylen = 0;
static int noled = 0;
{
{0, 0, 0, 0, 0, 0}
};
static int simple_flag_offsets[]
= {5, 6, 4, 7, 11, 1, 0, 10, 13, 14, 12, 15, 9, 3, 8, 2};
struct
{
};
/* The table for key symbols. If the "shifted" member of an entry is
NULL, the entry does not have shifted state. Copied from GRUB Legacy setkey fuction */
{
{"escape", 0, 0x1b, 0, 0x01},
{"1", "exclam", '1', '!', 0x02},
{"2", "at", '2', '@', 0x03},
{"3", "numbersign", '3', '#', 0x04},
{"4", "dollar", '4', '$', 0x05},
{"5", "percent", '5', '%', 0x06},
{"6", "caret", '6', '^', 0x07},
{"7", "ampersand", '7', '&', 0x08},
{"8", "asterisk", '8', '*', 0x09},
{"9", "parenleft", '9', '(', 0x0a},
{"0", "parenright", '0', ')', 0x0b},
{"minus", "underscore", '-', '_', 0x0c},
{"equal", "plus", '=', '+', 0x0d},
{"backspace", 0, '\b', 0, 0x0e},
{"tab", 0, '\t', 0, 0x0f},
{"q", "Q", 'q', 'Q', 0x10},
{"w", "W", 'w', 'W', 0x11},
{"e", "E", 'e', 'E', 0x12},
{"r", "R", 'r', 'R', 0x13},
{"t", "T", 't', 'T', 0x14},
{"y", "Y", 'y', 'Y', 0x15},
{"u", "U", 'u', 'U', 0x16},
{"i", "I", 'i', 'I', 0x17},
{"o", "O", 'o', 'O', 0x18},
{"p", "P", 'p', 'P', 0x19},
{"bracketleft", "braceleft", '[', '{', 0x1a},
{"bracketright", "braceright", ']', '}', 0x1b},
{"enter", 0, '\r', 0, 0x1c},
{"control", 0, 0, 0, 0x1d},
{"a", "A", 'a', 'A', 0x1e},
{"s", "S", 's', 'S', 0x1f},
{"d", "D", 'd', 'D', 0x20},
{"f", "F", 'f', 'F', 0x21},
{"g", "G", 'g', 'G', 0x22},
{"h", "H", 'h', 'H', 0x23},
{"j", "J", 'j', 'J', 0x24},
{"k", "K", 'k', 'K', 0x25},
{"l", "L", 'l', 'L', 0x26},
{"semicolon", "colon", ';', ':', 0x27},
{"quote", "doublequote", '\'', '"', 0x28},
{"backquote", "tilde", '`', '~', 0x29},
{"shift", 0, 0, 0, 0x2a},
{"backslash", "bar", '\\', '|', 0x2b},
{"z", "Z", 'z', 'Z', 0x2c},
{"x", "X", 'x', 'X', 0x2d},
{"c", "C", 'c', 'C', 0x2e},
{"v", "V", 'v', 'V', 0x2f},
{"b", "B", 'b', 'B', 0x30},
{"n", "N", 'n', 'N', 0x31},
{"m", "M", 'm', 'M', 0x32},
{"comma", "less", ',', '<', 0x33},
{"period", "greater", '.', '>', 0x34},
{"slash", "question", '/', '?', 0x35},
{"rshift", 0, 0, 0, 0x36},
{"numasterisk", 0, '*', 0, 0x37},
{"alt", 0, 0, 0, 0x38},
{"space", 0, ' ', 0, 0x39},
{"capslock", 0, 0, 0, 0x3a},
{"F1", 0, 0, 0, 0x3b},
{"F2", 0, 0, 0, 0x3c},
{"F3", 0, 0, 0, 0x3d},
{"F4", 0, 0, 0, 0x3e},
{"F5", 0, 0, 0, 0x3f},
{"F6", 0, 0, 0, 0x40},
{"F7", 0, 0, 0, 0x41},
{"F8", 0, 0, 0, 0x42},
{"F9", 0, 0, 0, 0x43},
{"F10", 0, 0, 0, 0x44},
{"num7", "numhome", '7', 0, 0x47},
{"num8", "numup", '8', 0, 0x48},
{"num9", "numpgup", '9', 0, 0x49},
{"numminus", 0, '-', 0, 0x4a},
{"num4", "numleft", '4', 0, 0x4b},
{"num5", "numcenter", '5', 0, 0x4c},
{"num6", "numright", '6', 0, 0x4d},
{"numplus", 0, '-', 0, 0x4e},
{"num1", "numend", '1', 0, 0x4f},
{"num2", "numdown", '2', 0, 0x50},
{"num3", "numpgdown", '3', 0, 0x51},
{"num0", "numinsert", '0', 0, 0x52},
{"numperiod", "numdelete", 0, 0x7f, 0x53},
{"F11", 0, 0, 0, 0x57},
{"F12", 0, 0, 0, 0x58},
{"numenter", 0, '\r', 0, 0xe0},
{"numslash", 0, '/', 0, 0xe0},
{"delete", 0, 0x7f, 0, 0xe0},
{"insert", 0, 0xe0, 0, 0x52},
{"home", 0, 0xe0, 0, 0x47},
{"end", 0, 0xe0, 0, 0x4f},
{"pgdown", 0, 0xe0, 0, 0x51},
{"pgup", 0, 0xe0, 0, 0x49},
{"down", 0, 0xe0, 0, 0x50},
{"up", 0, 0xe0, 0, 0x48},
{"left", 0, 0xe0, 0, 0x4b},
{"right", 0, 0xe0, 0, 0x4d}
};
/* Set a simple flag in flags variable
OUTOFFSET - offset of flag in FLAGS,
OP - action id
*/
static void
{
if (op == 2)
{
}
else
{
if (op == 1)
else
}
}
static int
{
return 2;
return 0;
return 1;
return 2;
}
static grub_err_t
grub_sendkey_postboot (void)
{
/* For convention: pointer to flags. */
*((char *) 0x41a) = 0x1e;
*((char *) 0x41c) = 0x1e;
return GRUB_ERR_NONE;
}
/* Set keyboard buffer to our sendkey */
static grub_err_t
{
/* For convention: pointer to flags. */
/* Set the sendkey. */
*((char *) 0x41a) = 0x1e;
/* Transform "any ctrl" to "right ctrl" flag. */
/* Transform "any alt" to "right alt" flag. */
/* Transform "right ctrl" to "any ctrl" flag. */
/* Transform "right alt" to "any alt" flag. */
/* Write new LED state */
if (!noled)
{
int value = 0;
int failed;
/* Try 5 times */
{
value = 0;
/* Send command change LEDs */
/* Wait */
do
if (value == 0xfa)
{
/* Set new LEDs*/
break;
}
}
}
return GRUB_ERR_NONE;
}
static grub_err_t
{
auto int find_key_code (char *key);
auto int find_ascii_code (char *key);
{
unsigned i;
for (i = 0; i < sizeof (keysym_table) / sizeof (keysym_table[0]); i++)
{
if (keysym_table[i].unshifted_name
return keysym_table[i].keycode;
else if (keysym_table[i].shifted_name
return keysym_table[i].keycode;
}
return 0;
}
{
unsigned i;
for (i = 0; i < sizeof (keysym_table) / sizeof (keysym_table[0]); i++)
{
if (keysym_table[i].unshifted_name
return keysym_table[i].unshifted_ascii;
else if (keysym_table[i].shifted_name
return keysym_table[i].shifted_ascii;
}
return 0;
}
andmask = 0xffffffff;
ormask = 0;
{
int i;
keylen = 0;
{
int key_code;
if (key_code)
{
}
}
}
{
unsigned i;
for (i = 0; i < sizeof (simple_flag_offsets)
/ sizeof (simple_flag_offsets[0]); i++)
grub_sendkey_parse_op(state[i]));
}
/* Set noled. */
/ sizeof (simple_flag_offsets[0])].set);
return GRUB_ERR_NONE;
}
{
N_("[KEYSTROKE1] [KEYSTROKE2] ..."),
}
{
}