Remove checkkey on term level
This commit is contained in:
parent
7ae3eb6232
commit
df2174dded
13 changed files with 65 additions and 240 deletions
|
@ -102,49 +102,18 @@ grub_ncurses_setcolorstate (struct grub_term_output *term,
|
|||
}
|
||||
}
|
||||
|
||||
static int saved_char = ERR;
|
||||
|
||||
static int
|
||||
grub_ncurses_checkkey (struct grub_term_input *term __attribute__ ((unused)))
|
||||
{
|
||||
int c;
|
||||
|
||||
/* Check for SAVED_CHAR. This should not be true, because this
|
||||
means checkkey is called twice continuously. */
|
||||
if (saved_char != ERR)
|
||||
return saved_char;
|
||||
|
||||
wtimeout (stdscr, 100);
|
||||
c = getch ();
|
||||
/* If C is not ERR, then put it back in the input queue. */
|
||||
if (c != ERR)
|
||||
{
|
||||
saved_char = c;
|
||||
return c;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
static int
|
||||
grub_ncurses_getkey (struct grub_term_input *term __attribute__ ((unused)))
|
||||
{
|
||||
int c;
|
||||
|
||||
/* If checkkey has already got a character, then return it. */
|
||||
if (saved_char != ERR)
|
||||
{
|
||||
c = saved_char;
|
||||
saved_char = ERR;
|
||||
}
|
||||
else
|
||||
{
|
||||
wtimeout (stdscr, -1);
|
||||
c = getch ();
|
||||
}
|
||||
wtimeout (stdscr, 100);
|
||||
c = getch ();
|
||||
|
||||
switch (c)
|
||||
{
|
||||
case ERR:
|
||||
return -1;
|
||||
case KEY_LEFT:
|
||||
c = GRUB_TERM_LEFT;
|
||||
break;
|
||||
|
@ -288,7 +257,6 @@ grub_ncurses_fini (struct grub_term_output *term __attribute__ ((unused)))
|
|||
static struct grub_term_input grub_ncurses_term_input =
|
||||
{
|
||||
.name = "console",
|
||||
.checkkey = grub_ncurses_checkkey,
|
||||
.getkey = grub_ncurses_getkey,
|
||||
};
|
||||
|
||||
|
|
|
@ -1154,6 +1154,16 @@ LOCAL(bypass_table_end):
|
|||
|
||||
/*
|
||||
* int grub_console_getkey (void)
|
||||
* if there is a character pending, return it; otherwise return -1
|
||||
* BIOS call "INT 16H Function 01H" to check whether a character is pending
|
||||
* Call with %ah = 0x1
|
||||
* Return:
|
||||
* If key waiting to be input:
|
||||
* %ah = keyboard scan code
|
||||
* %al = ASCII character
|
||||
* Zero flag = clear
|
||||
* else
|
||||
* Zero flag = set
|
||||
* BIOS call "INT 16H Function 00H" to read character from keyboard
|
||||
* Call with %ah = 0x0
|
||||
* Return: %ah = keyboard scan code
|
||||
|
@ -1173,14 +1183,9 @@ FUNCTION(grub_console_getkey)
|
|||
* INT 16/AH = 1 before calling INT 16/AH = 0.
|
||||
*/
|
||||
|
||||
1:
|
||||
movb $1, %ah
|
||||
int $0x16
|
||||
jnz 2f
|
||||
hlt
|
||||
jmp 1b
|
||||
|
||||
2:
|
||||
jz notpending
|
||||
|
||||
movb $0, %ah
|
||||
int $0x16
|
||||
|
@ -1217,47 +1222,12 @@ FUNCTION(grub_console_getkey)
|
|||
popl %ebp
|
||||
ret
|
||||
|
||||
/*
|
||||
* int grub_console_checkkey (void)
|
||||
* if there is a character pending, return it; otherwise return -1
|
||||
* BIOS call "INT 16H Function 01H" to check whether a character is pending
|
||||
* Call with %ah = 0x1
|
||||
* Return:
|
||||
* If key waiting to be input:
|
||||
* %ah = keyboard scan code
|
||||
* %al = ASCII character
|
||||
* Zero flag = clear
|
||||
* else
|
||||
* Zero flag = set
|
||||
*/
|
||||
FUNCTION(grub_console_checkkey)
|
||||
pushl %ebp
|
||||
xorl %edx, %edx
|
||||
|
||||
call prot_to_real /* enter real mode */
|
||||
notpending:
|
||||
.code16
|
||||
|
||||
movb $0x1, %ah
|
||||
int $0x16
|
||||
|
||||
jz notpending
|
||||
|
||||
xorl %edx, %edx
|
||||
movw %ax, %dx
|
||||
DATA32 jmp pending
|
||||
|
||||
notpending:
|
||||
xorl %edx, %edx
|
||||
decl %edx
|
||||
|
||||
pending:
|
||||
DATA32 call real_to_prot
|
||||
.code32
|
||||
|
||||
movl %edx, %eax
|
||||
|
||||
popl %ebp
|
||||
ret
|
||||
decl %eax
|
||||
jmp 2b
|
||||
|
||||
|
||||
/*
|
||||
|
|
21
kern/term.c
21
kern/term.c
|
@ -78,6 +78,8 @@ grub_xputs_dumb (const char *str)
|
|||
|
||||
void (*grub_xputs) (const char *str) = grub_xputs_dumb;
|
||||
|
||||
static int pending_key = -1;
|
||||
|
||||
int
|
||||
grub_getkey (void)
|
||||
{
|
||||
|
@ -85,6 +87,12 @@ grub_getkey (void)
|
|||
|
||||
grub_refresh ();
|
||||
|
||||
if (pending_key != -1)
|
||||
{
|
||||
pending_key = -1;
|
||||
return pending_key;
|
||||
}
|
||||
|
||||
while (1)
|
||||
{
|
||||
if (grub_term_poll_usb)
|
||||
|
@ -92,9 +100,9 @@ grub_getkey (void)
|
|||
|
||||
FOR_ACTIVE_TERM_INPUTS(term)
|
||||
{
|
||||
int key = term->checkkey (term);
|
||||
int key = term->getkey (term);
|
||||
if (key != -1)
|
||||
return term->getkey (term);
|
||||
return key;
|
||||
}
|
||||
|
||||
grub_cpu_idle ();
|
||||
|
@ -106,14 +114,17 @@ grub_checkkey (void)
|
|||
{
|
||||
grub_term_input_t term;
|
||||
|
||||
if (pending_key != -1)
|
||||
return pending_key;
|
||||
|
||||
if (grub_term_poll_usb)
|
||||
grub_term_poll_usb ();
|
||||
|
||||
FOR_ACTIVE_TERM_INPUTS(term)
|
||||
{
|
||||
int key = term->checkkey (term);
|
||||
if (key != -1)
|
||||
return key;
|
||||
pending_key = term->getkey (term);
|
||||
if (pending_key != -1)
|
||||
return pending_key;
|
||||
}
|
||||
|
||||
return -1;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue