Merge Mainline.
This commit is contained in:
commit
85fd555441
191 changed files with 9311 additions and 1208 deletions
123
grub-core/term/arc/console.c
Normal file
123
grub-core/term/arc/console.c
Normal file
|
@ -0,0 +1,123 @@
|
|||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2011 Free Software Foundation, Inc.
|
||||
*
|
||||
* GRUB is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* GRUB 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 GRUB. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <grub/arc/arc.h>
|
||||
#include <grub/arc/console.h>
|
||||
#include <grub/term.h>
|
||||
#include <grub/terminfo.h>
|
||||
|
||||
/* FIXME: use unicode. */
|
||||
|
||||
static int
|
||||
readkey (struct grub_term_input *term __attribute__ ((unused)))
|
||||
{
|
||||
unsigned long count;
|
||||
char chr;
|
||||
|
||||
if (GRUB_ARC_FIRMWARE_VECTOR->get_read_status (GRUB_ARC_STDIN))
|
||||
return -1;
|
||||
|
||||
if (GRUB_ARC_FIRMWARE_VECTOR->read (GRUB_ARC_STDIN, &chr, 1, &count))
|
||||
return -1;
|
||||
if (!count)
|
||||
return -1;
|
||||
return chr;
|
||||
}
|
||||
|
||||
static void
|
||||
put (struct grub_term_output *term __attribute__ ((unused)), const int c)
|
||||
{
|
||||
unsigned long count;
|
||||
char chr = c;
|
||||
|
||||
GRUB_ARC_FIRMWARE_VECTOR->write (GRUB_ARC_STDOUT, &chr, 1, &count);
|
||||
}
|
||||
|
||||
static struct grub_terminfo_output_state grub_console_terminfo_output;
|
||||
|
||||
static grub_err_t
|
||||
grub_console_init_output (struct grub_term_output *term)
|
||||
{
|
||||
struct grub_arc_display_status *info = NULL;
|
||||
if (GRUB_ARC_SYSTEM_PARAMETER_BLOCK->firmware_vector_length
|
||||
>= ((char *) (&GRUB_ARC_FIRMWARE_VECTOR->getdisplaystatus + 1)
|
||||
- (char *) GRUB_ARC_FIRMWARE_VECTOR)
|
||||
&& GRUB_ARC_FIRMWARE_VECTOR->getdisplaystatus)
|
||||
info = GRUB_ARC_FIRMWARE_VECTOR->getdisplaystatus (GRUB_ARC_STDOUT);
|
||||
if (info)
|
||||
{
|
||||
grub_console_terminfo_output.width = info->w;
|
||||
grub_console_terminfo_output.height = info->h;
|
||||
}
|
||||
grub_terminfo_output_init (term);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct grub_terminfo_input_state grub_console_terminfo_input =
|
||||
{
|
||||
.readkey = readkey
|
||||
};
|
||||
|
||||
static struct grub_terminfo_output_state grub_console_terminfo_output =
|
||||
{
|
||||
.put = put,
|
||||
.width = 80,
|
||||
.height = 36
|
||||
};
|
||||
|
||||
static struct grub_term_input grub_console_term_input =
|
||||
{
|
||||
.name = "console",
|
||||
.init = grub_terminfo_input_init,
|
||||
.getkey = grub_terminfo_getkey,
|
||||
.data = &grub_console_terminfo_input
|
||||
};
|
||||
|
||||
static struct grub_term_output grub_console_term_output =
|
||||
{
|
||||
.name = "console",
|
||||
.init = grub_console_init_output,
|
||||
.putchar = grub_terminfo_putchar,
|
||||
.getxy = grub_terminfo_getxy,
|
||||
.getwh = grub_terminfo_getwh,
|
||||
.gotoxy = grub_terminfo_gotoxy,
|
||||
.cls = grub_terminfo_cls,
|
||||
.setcolorstate = grub_terminfo_setcolorstate,
|
||||
.setcursor = grub_terminfo_setcursor,
|
||||
.flags = GRUB_TERM_CODE_TYPE_ASCII,
|
||||
.data = &grub_console_terminfo_output,
|
||||
.normal_color = GRUB_TERM_DEFAULT_NORMAL_COLOR,
|
||||
.highlight_color = GRUB_TERM_DEFAULT_HIGHLIGHT_COLOR,
|
||||
};
|
||||
|
||||
void
|
||||
grub_console_init_early (void)
|
||||
{
|
||||
grub_term_register_input ("console", &grub_console_term_input);
|
||||
grub_term_register_output ("console", &grub_console_term_output);
|
||||
}
|
||||
|
||||
void grub_terminfo_init (void);
|
||||
|
||||
void
|
||||
grub_console_init_lately (void)
|
||||
{
|
||||
grub_terminfo_init ();
|
||||
grub_terminfo_output_register (&grub_console_term_output, "arc");
|
||||
}
|
|
@ -111,12 +111,12 @@ static const struct
|
|||
{0x38, GRUB_KEYBOARD_KEY_RIGHT_ALT},
|
||||
{0x47, GRUB_KEYBOARD_KEY_HOME},
|
||||
{0x48, GRUB_KEYBOARD_KEY_UP},
|
||||
{0x49, GRUB_KEYBOARD_KEY_NPAGE},
|
||||
{0x49, GRUB_KEYBOARD_KEY_PPAGE},
|
||||
{0x4b, GRUB_KEYBOARD_KEY_LEFT},
|
||||
{0x4d, GRUB_KEYBOARD_KEY_RIGHT},
|
||||
{0x4f, GRUB_KEYBOARD_KEY_END},
|
||||
{0x50, GRUB_KEYBOARD_KEY_DOWN},
|
||||
{0x51, GRUB_KEYBOARD_KEY_PPAGE},
|
||||
{0x51, GRUB_KEYBOARD_KEY_NPAGE},
|
||||
{0x52, GRUB_KEYBOARD_KEY_INSERT},
|
||||
{0x53, GRUB_KEYBOARD_KEY_DELETE},
|
||||
};
|
||||
|
@ -259,7 +259,7 @@ grub_keyboard_controller_write (grub_uint8_t c)
|
|||
grub_outb (c, KEYBOARD_REG_DATA);
|
||||
}
|
||||
|
||||
#if !defined (GRUB_MACHINE_MIPS_YEELOONG) && !defined (GRUB_MACHINE_QEMU)
|
||||
#if !defined (GRUB_MACHINE_MIPS_LOONGSON) && !defined (GRUB_MACHINE_QEMU)
|
||||
|
||||
static grub_uint8_t
|
||||
grub_keyboard_controller_read (void)
|
||||
|
@ -332,7 +332,7 @@ set_scancodes (void)
|
|||
return;
|
||||
}
|
||||
|
||||
#if !(defined (GRUB_MACHINE_MIPS_YEELOONG) || defined (GRUB_MACHINE_QEMU))
|
||||
#if !(defined (GRUB_MACHINE_MIPS_LOONGSON) || defined (GRUB_MACHINE_QEMU))
|
||||
current_set = 1;
|
||||
return;
|
||||
#endif
|
||||
|
@ -431,11 +431,11 @@ fetch_key (int *is_break)
|
|||
if (!ret)
|
||||
{
|
||||
if (was_ext)
|
||||
grub_printf ("Unknown key 0xe0+0x%02x from set %d\n",
|
||||
at_key, current_set);
|
||||
grub_dprintf ("atkeyb", "Unknown key 0xe0+0x%02x from set %d\n",
|
||||
at_key, current_set);
|
||||
else
|
||||
grub_printf ("Unknown key 0x%02x from set %d\n",
|
||||
at_key, current_set);
|
||||
grub_dprintf ("atkeyb", "Unknown key 0x%02x from set %d\n",
|
||||
at_key, current_set);
|
||||
return -1;
|
||||
}
|
||||
return ret;
|
||||
|
@ -569,7 +569,7 @@ grub_keyboard_controller_init (struct grub_term_input *term __attribute__ ((unus
|
|||
keyboard_controller_wait_until_ready ();
|
||||
grub_inb (KEYBOARD_REG_DATA);
|
||||
}
|
||||
#if defined (GRUB_MACHINE_MIPS_YEELOONG) || defined (GRUB_MACHINE_QEMU)
|
||||
#if defined (GRUB_MACHINE_MIPS_LOONGSON) || defined (GRUB_MACHINE_QEMU)
|
||||
grub_keyboard_controller_orig = 0;
|
||||
grub_keyboard_orig_set = 2;
|
||||
#else
|
||||
|
|
|
@ -130,6 +130,7 @@ static struct grub_video_render_target *text_layer;
|
|||
static unsigned int bitmap_width;
|
||||
static unsigned int bitmap_height;
|
||||
static struct grub_video_bitmap *bitmap;
|
||||
static int blend_text_bg;
|
||||
|
||||
static struct grub_dirty_region dirty_region;
|
||||
|
||||
|
@ -476,26 +477,27 @@ redraw_screen_rect (unsigned int x, unsigned int y,
|
|||
/* Render background layer. */
|
||||
grub_video_fill_rect (color, x, ty, width, h);
|
||||
}
|
||||
|
||||
/* Render text layer as blended. */
|
||||
grub_video_blit_render_target (text_layer, GRUB_VIDEO_BLIT_BLEND, x, y,
|
||||
x - virtual_screen.offset_x,
|
||||
y - virtual_screen.offset_y,
|
||||
width, height);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Render background layer. */
|
||||
color = virtual_screen.bg_color_display;
|
||||
grub_video_fill_rect (color, x, y, width, height);
|
||||
|
||||
/* Render text layer as replaced (to get texts background color). */
|
||||
grub_video_blit_render_target (text_layer, GRUB_VIDEO_BLIT_REPLACE, x, y,
|
||||
x - virtual_screen.offset_x,
|
||||
y - virtual_screen.offset_y,
|
||||
width, height);
|
||||
}
|
||||
|
||||
if (blend_text_bg)
|
||||
/* Render text layer as blended. */
|
||||
grub_video_blit_render_target (text_layer, GRUB_VIDEO_BLIT_BLEND, x, y,
|
||||
x - virtual_screen.offset_x,
|
||||
y - virtual_screen.offset_y,
|
||||
width, height);
|
||||
else
|
||||
/* Render text layer as replaced (to get texts background color). */
|
||||
grub_video_blit_render_target (text_layer, GRUB_VIDEO_BLIT_REPLACE, x, y,
|
||||
x - virtual_screen.offset_x,
|
||||
y - virtual_screen.offset_y,
|
||||
width, height);
|
||||
|
||||
/* Restore saved viewport. */
|
||||
grub_video_set_viewport (saved_view.x, saved_view.y,
|
||||
saved_view.width, saved_view.height);
|
||||
|
@ -1127,6 +1129,7 @@ grub_gfxterm_background_image_cmd (grub_extcmd_context_t ctxt,
|
|||
{
|
||||
grub_video_bitmap_destroy (bitmap);
|
||||
bitmap = 0;
|
||||
blend_text_bg = 0;
|
||||
|
||||
/* Mark whole screen as dirty. */
|
||||
dirty_region_add (0, 0, window.width, window.height);
|
||||
|
@ -1166,6 +1169,8 @@ grub_gfxterm_background_image_cmd (grub_extcmd_context_t ctxt,
|
|||
/* If bitmap was loaded correctly, display it. */
|
||||
if (bitmap)
|
||||
{
|
||||
blend_text_bg = 1;
|
||||
|
||||
/* Determine bitmap dimensions. */
|
||||
bitmap_width = grub_video_bitmap_get_width (bitmap);
|
||||
bitmap_height = grub_video_bitmap_get_height (bitmap);
|
||||
|
@ -1180,6 +1185,48 @@ grub_gfxterm_background_image_cmd (grub_extcmd_context_t ctxt,
|
|||
return grub_errno;
|
||||
}
|
||||
|
||||
static grub_err_t
|
||||
grub_gfxterm_background_color_cmd (grub_command_t cmd __attribute__ ((unused)),
|
||||
int argc, char **args)
|
||||
{
|
||||
grub_video_rgba_color_t color;
|
||||
struct grub_video_render_target *old_target;
|
||||
|
||||
if (argc != 1)
|
||||
return grub_error (GRUB_ERR_BAD_ARGUMENT, "missing operand");
|
||||
|
||||
/* Check that we have video adapter active. */
|
||||
if (grub_video_get_info (NULL) != GRUB_ERR_NONE)
|
||||
return grub_errno;
|
||||
|
||||
if (grub_video_parse_color (args[0], &color) != GRUB_ERR_NONE)
|
||||
return grub_errno;
|
||||
|
||||
/* Destroy existing background bitmap if loaded. */
|
||||
if (bitmap)
|
||||
{
|
||||
grub_video_bitmap_destroy (bitmap);
|
||||
bitmap = 0;
|
||||
|
||||
/* Mark whole screen as dirty. */
|
||||
dirty_region_add (0, 0, window.width, window.height);
|
||||
}
|
||||
|
||||
/* Set the background and border colors. The background color needs to be
|
||||
compatible with the text layer. */
|
||||
grub_video_get_active_render_target (&old_target);
|
||||
grub_video_set_active_render_target (text_layer);
|
||||
virtual_screen.bg_color = grub_video_map_rgba_color (color);
|
||||
grub_video_set_active_render_target (old_target);
|
||||
virtual_screen.bg_color_display = grub_video_map_rgba_color (color);
|
||||
blend_text_bg = 1;
|
||||
|
||||
/* Mark whole screen as dirty. */
|
||||
dirty_region_add (0, 0, window.width, window.height);
|
||||
|
||||
return GRUB_ERR_NONE;
|
||||
}
|
||||
|
||||
static struct grub_term_output grub_video_term =
|
||||
{
|
||||
.name = "gfxterm",
|
||||
|
@ -1201,6 +1248,7 @@ static struct grub_term_output grub_video_term =
|
|||
};
|
||||
|
||||
static grub_extcmd_t background_image_cmd_handle;
|
||||
static grub_command_t background_color_cmd_handle;
|
||||
|
||||
GRUB_MOD_INIT(gfxterm)
|
||||
{
|
||||
|
@ -1211,10 +1259,16 @@ GRUB_MOD_INIT(gfxterm)
|
|||
N_("[-m (stretch|normal)] FILE"),
|
||||
N_("Load background image for active terminal."),
|
||||
background_image_cmd_options);
|
||||
background_color_cmd_handle =
|
||||
grub_register_command ("background_color",
|
||||
grub_gfxterm_background_color_cmd,
|
||||
N_("COLOR"),
|
||||
N_("Set background color for active terminal."));
|
||||
}
|
||||
|
||||
GRUB_MOD_FINI(gfxterm)
|
||||
{
|
||||
grub_unregister_command (background_color_cmd_handle);
|
||||
grub_unregister_extcmd (background_image_cmd_handle);
|
||||
grub_term_unregister_output (&grub_video_term);
|
||||
}
|
||||
|
|
|
@ -37,7 +37,8 @@ static const grub_port_t serial_hw_io_addr[] = GRUB_MACHINE_SERIAL_PORTS;
|
|||
|
||||
/* Convert speed to divisor. */
|
||||
static unsigned short
|
||||
serial_get_divisor (unsigned int speed)
|
||||
serial_get_divisor (const struct grub_serial_port *port __attribute__ ((unused)),
|
||||
const struct grub_serial_config *config)
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
|
@ -63,13 +64,16 @@ serial_get_divisor (unsigned int speed)
|
|||
|
||||
/* Set the baud rate. */
|
||||
for (i = 0; i < ARRAY_SIZE (divisor_tab); i++)
|
||||
if (divisor_tab[i].speed == speed)
|
||||
/* UART in Yeeloong runs twice the usual rate. */
|
||||
#ifdef GRUB_MACHINE_MIPS_YEELOONG
|
||||
return 2 * divisor_tab[i].div;
|
||||
#else
|
||||
return divisor_tab[i].div;
|
||||
if (divisor_tab[i].speed == config->speed)
|
||||
{
|
||||
/* internal Loongson UART runs twice the usual rate. */
|
||||
#ifdef GRUB_MACHINE_MIPS_LOONGSON
|
||||
if (port->port == 0xbff003f8)
|
||||
return 2 * divisor_tab[i].div;
|
||||
else
|
||||
#endif
|
||||
return divisor_tab[i].div;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -93,7 +97,7 @@ do_real_config (struct grub_serial_port *port)
|
|||
|
||||
port->broken = 0;
|
||||
|
||||
divisor = serial_get_divisor (port->config.speed);
|
||||
divisor = serial_get_divisor (port, &port->config);
|
||||
|
||||
/* Turn off the interrupt. */
|
||||
grub_outb (0, port->port + UART_IER);
|
||||
|
@ -111,8 +115,8 @@ do_real_config (struct grub_serial_port *port)
|
|||
| stop_bits[port->config.stop_bits]);
|
||||
grub_outb (status, port->port + UART_LCR);
|
||||
|
||||
/* In Yeeloong serial port has only 3 wires. */
|
||||
#ifndef GRUB_MACHINE_MIPS_YEELOONG
|
||||
/* On Loongson machines serial port has only 3 wires. */
|
||||
#ifndef GRUB_MACHINE_MIPS_LOONGSON
|
||||
/* Enable the FIFO. */
|
||||
grub_outb (UART_ENABLE_FIFO_TRIGGER1, port->port + UART_FCR);
|
||||
|
||||
|
@ -188,7 +192,7 @@ serial_hw_configure (struct grub_serial_port *port,
|
|||
{
|
||||
unsigned short divisor;
|
||||
|
||||
divisor = serial_get_divisor (config->speed);
|
||||
divisor = serial_get_divisor (port, config);
|
||||
if (divisor == 0)
|
||||
return grub_error (GRUB_ERR_BAD_ARGUMENT, "bad speed");
|
||||
|
||||
|
|
|
@ -26,6 +26,9 @@
|
|||
#include <grub/extcmd.h>
|
||||
#include <grub/i18n.h>
|
||||
#include <grub/list.h>
|
||||
#ifdef GRUB_MACHINE_MIPS_LOONGSON
|
||||
#include <grub/machine/kernel.h>
|
||||
#endif
|
||||
|
||||
GRUB_MOD_LICENSE ("GPLv3+");
|
||||
|
||||
|
@ -297,18 +300,23 @@ grub_serial_register (struct grub_serial_port *port)
|
|||
port->term_in = in;
|
||||
port->term_out = out;
|
||||
grub_terminfo_output_register (out, "vt100");
|
||||
#ifdef GRUB_MACHINE_MIPS_YEELOONG
|
||||
if (grub_strcmp (port->name, "com0") == 0)
|
||||
#ifdef GRUB_MACHINE_MIPS_LOONGSON
|
||||
if (grub_strcmp (port->name,
|
||||
(grub_arch_machine == GRUB_ARCH_MACHINE_YEELOONG)
|
||||
? "com0" : "com2") == 0)
|
||||
{
|
||||
grub_term_register_input_active ("serial_*", in);
|
||||
grub_term_register_output_active ("serial_*", out);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
grub_term_register_input ("serial_*", in);
|
||||
grub_term_register_output ("serial_*", out);
|
||||
grub_term_register_input_inactive ("serial_*", in);
|
||||
grub_term_register_output_inactive ("serial_*", out);
|
||||
}
|
||||
#else
|
||||
grub_term_register_input ("serial_*", in);
|
||||
grub_term_register_output ("serial_*", out);
|
||||
#endif
|
||||
|
||||
return GRUB_ERR_NONE;
|
||||
}
|
||||
|
|
|
@ -36,6 +36,9 @@
|
|||
|
||||
GRUB_MOD_LICENSE ("GPLv3+");
|
||||
|
||||
#define ANSI_C0 0x9b
|
||||
#define ANSI_C0_STR "\x9b"
|
||||
|
||||
static struct grub_term_output *terminfo_outputs;
|
||||
|
||||
/* Get current terminfo name. */
|
||||
|
@ -123,6 +126,20 @@ grub_terminfo_set_current (struct grub_term_output *term,
|
|||
return grub_errno;
|
||||
}
|
||||
|
||||
if (grub_strcmp ("arc", str) == 0)
|
||||
{
|
||||
data->name = grub_strdup ("arc");
|
||||
data->gotoxy = grub_strdup (ANSI_C0_STR "%i%p1%d;%p2%dH");
|
||||
data->cls = grub_strdup (ANSI_C0_STR "2J");
|
||||
data->reverse_video_on = grub_strdup (ANSI_C0_STR "7m");
|
||||
data->reverse_video_off = grub_strdup (ANSI_C0_STR "0m");
|
||||
data->cursor_on = 0;
|
||||
data->cursor_off = 0;
|
||||
data->setcolor = grub_strdup (ANSI_C0_STR "3%p1%dm"
|
||||
ANSI_C0_STR "4%p2%dm");
|
||||
return grub_errno;
|
||||
}
|
||||
|
||||
if (grub_strcmp ("ieee1275", str) == 0)
|
||||
{
|
||||
data->name = grub_strdup ("ieee1275");
|
||||
|
@ -369,8 +386,6 @@ grub_terminfo_getwh (struct grub_term_output *term)
|
|||
return (data->width << 8) | data->height;
|
||||
}
|
||||
|
||||
#define ANSI_C0 0x9b
|
||||
|
||||
static void
|
||||
grub_terminfo_readkey (struct grub_term_input *term, int *keys, int *len,
|
||||
int (*readkey) (struct grub_term_input *term))
|
||||
|
@ -430,7 +445,8 @@ grub_terminfo_readkey (struct grub_term_input *term, int *keys, int *len,
|
|||
{'K', GRUB_TERM_KEY_END},
|
||||
{'P', GRUB_TERM_KEY_DC},
|
||||
{'?', GRUB_TERM_KEY_PPAGE},
|
||||
{'/', GRUB_TERM_KEY_NPAGE}
|
||||
{'/', GRUB_TERM_KEY_NPAGE},
|
||||
{'@', GRUB_TERM_KEY_INSERT},
|
||||
};
|
||||
|
||||
static struct
|
||||
|
@ -445,6 +461,14 @@ grub_terminfo_readkey (struct grub_term_input *term, int *keys, int *len,
|
|||
{'5', GRUB_TERM_KEY_PPAGE},
|
||||
{'6', GRUB_TERM_KEY_NPAGE}
|
||||
};
|
||||
char fx_key[] =
|
||||
{ 'P', 'Q', 'w', 'x', 't', 'u',
|
||||
'q', 'r', 'p', 'M', 'A', 'B' };
|
||||
unsigned fx_code[] =
|
||||
{ GRUB_TERM_KEY_F1, GRUB_TERM_KEY_F2, GRUB_TERM_KEY_F3,
|
||||
GRUB_TERM_KEY_F4, GRUB_TERM_KEY_F5, GRUB_TERM_KEY_F6,
|
||||
GRUB_TERM_KEY_F7, GRUB_TERM_KEY_F8, GRUB_TERM_KEY_F9,
|
||||
GRUB_TERM_KEY_F10, GRUB_TERM_KEY_F11, GRUB_TERM_KEY_F12 };
|
||||
unsigned i;
|
||||
|
||||
if (c == '\e')
|
||||
|
@ -465,17 +489,53 @@ grub_terminfo_readkey (struct grub_term_input *term, int *keys, int *len,
|
|||
return;
|
||||
}
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE (four_code_table); i++)
|
||||
if (four_code_table[i].key == c)
|
||||
switch (c)
|
||||
{
|
||||
case 'O':
|
||||
CONTINUE_READ;
|
||||
for (i = 0; i < ARRAY_SIZE (fx_key); i++)
|
||||
if (fx_key[i] == c)
|
||||
{
|
||||
keys[0] = fx_code[i];
|
||||
*len = 1;
|
||||
return;
|
||||
}
|
||||
return;
|
||||
|
||||
case '0':
|
||||
{
|
||||
int num = 0;
|
||||
CONTINUE_READ;
|
||||
if (c != '~')
|
||||
if (c != '0' && c != '1')
|
||||
return;
|
||||
keys[0] = three_code_table[i].ascii;
|
||||
num = (c - '0') * 10;
|
||||
CONTINUE_READ;
|
||||
if (c < '0' || c > '9')
|
||||
return;
|
||||
num += (c - '0');
|
||||
if (num == 0 || num > 12)
|
||||
return;
|
||||
CONTINUE_READ;
|
||||
if (c != 'q')
|
||||
return;
|
||||
keys[0] = fx_code[num - 1];
|
||||
*len = 1;
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
default:
|
||||
for (i = 0; i < ARRAY_SIZE (four_code_table); i++)
|
||||
if (four_code_table[i].key == c)
|
||||
{
|
||||
CONTINUE_READ;
|
||||
if (c != '~')
|
||||
return;
|
||||
keys[0] = three_code_table[i].ascii;
|
||||
*len = 1;
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
#undef CONTINUE_READ
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue