Replace grub_checkkey with grub_getkey_noblock.
* grub-core/kern/term.c (grub_checkkey): Replaced with ... (grub_getkey_noblock): ... this. All users updated.
This commit is contained in:
parent
b500bcfeed
commit
a8f16eab1a
7 changed files with 28 additions and 36 deletions
|
@ -1,3 +1,10 @@
|
||||||
|
2012-02-18 Vladimir Serbinenko <phcoder@gmail.com>
|
||||||
|
|
||||||
|
Replace grub_checkkey with grub_getkey_noblock.
|
||||||
|
|
||||||
|
* grub-core/kern/term.c (grub_checkkey): Replaced with ...
|
||||||
|
(grub_getkey_noblock): ... this. All users updated.
|
||||||
|
|
||||||
2012-02-18 Vladimir Serbinenko <phcoder@gmail.com>
|
2012-02-18 Vladimir Serbinenko <phcoder@gmail.com>
|
||||||
|
|
||||||
* grub-core/kern/emu/console.c: Move to ...
|
* grub-core/kern/emu/console.c: Move to ...
|
||||||
|
|
|
@ -41,7 +41,7 @@ grub_cmd_cat (grub_extcmd_context_t ctxt, int argc, char **args)
|
||||||
grub_file_t file;
|
grub_file_t file;
|
||||||
char buf[GRUB_DISK_SECTOR_SIZE];
|
char buf[GRUB_DISK_SECTOR_SIZE];
|
||||||
grub_ssize_t size;
|
grub_ssize_t size;
|
||||||
int key = 0;
|
int key = GRUB_TERM_NO_KEY;
|
||||||
|
|
||||||
if (state[0].set)
|
if (state[0].set)
|
||||||
dos = 1;
|
dos = 1;
|
||||||
|
@ -77,8 +77,7 @@ grub_cmd_cat (grub_extcmd_context_t ctxt, int argc, char **args)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
while (grub_checkkey () >= 0 &&
|
while ((key = grub_getkey_noblock ()) != GRUB_TERM_ESC)
|
||||||
(key = grub_getkey ()) != GRUB_TERM_ESC)
|
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -151,7 +151,7 @@ play (unsigned tempo, struct note *note)
|
||||||
{
|
{
|
||||||
unsigned int to;
|
unsigned int to;
|
||||||
|
|
||||||
if (note->pitch == T_FINE || grub_checkkey () >= 0)
|
if (note->pitch == T_FINE || grub_getkey_noblock () != GRUB_TERM_NO_KEY)
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
grub_dprintf ("play", "pitch = %d, duration = %d\n", note->pitch,
|
grub_dprintf ("play", "pitch = %d, duration = %d\n", note->pitch,
|
||||||
|
@ -169,7 +169,8 @@ play (unsigned tempo, struct note *note)
|
||||||
}
|
}
|
||||||
|
|
||||||
to = grub_get_rtc () + BASE_TEMPO * note->duration / tempo;
|
to = grub_get_rtc () + BASE_TEMPO * note->duration / tempo;
|
||||||
while (((unsigned int) grub_get_rtc () <= to) && (grub_checkkey () < 0))
|
while (((unsigned int) grub_get_rtc () <= to)
|
||||||
|
&& (grub_getkey_noblock () == GRUB_TERM_NO_KEY))
|
||||||
;
|
;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -261,9 +262,6 @@ grub_cmd_play (grub_command_t cmd __attribute__ ((unused)),
|
||||||
|
|
||||||
beep_off ();
|
beep_off ();
|
||||||
|
|
||||||
while (grub_checkkey () > 0)
|
|
||||||
grub_getkey ();
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -54,7 +54,7 @@ grub_interruptible_millisleep (grub_uint32_t ms)
|
||||||
start = grub_get_time_ms ();
|
start = grub_get_time_ms ();
|
||||||
|
|
||||||
while (grub_get_time_ms () - start < ms)
|
while (grub_get_time_ms () - start < ms)
|
||||||
if (grub_checkkey () >= 0 && grub_getkey () == GRUB_TERM_ESC)
|
if (grub_getkey_noblock () == GRUB_TERM_ESC)
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -79,16 +79,11 @@ grub_xputs_dumb (const char *str)
|
||||||
|
|
||||||
void (*grub_xputs) (const char *str) = grub_xputs_dumb;
|
void (*grub_xputs) (const char *str) = grub_xputs_dumb;
|
||||||
|
|
||||||
static int pending_key = GRUB_TERM_NO_KEY;
|
|
||||||
|
|
||||||
int
|
int
|
||||||
grub_checkkey (void)
|
grub_getkey_noblock (void)
|
||||||
{
|
{
|
||||||
grub_term_input_t term;
|
grub_term_input_t term;
|
||||||
|
|
||||||
if (pending_key != GRUB_TERM_NO_KEY)
|
|
||||||
return pending_key;
|
|
||||||
|
|
||||||
if (grub_term_poll_usb)
|
if (grub_term_poll_usb)
|
||||||
grub_term_poll_usb ();
|
grub_term_poll_usb ();
|
||||||
|
|
||||||
|
@ -97,12 +92,12 @@ grub_checkkey (void)
|
||||||
|
|
||||||
FOR_ACTIVE_TERM_INPUTS(term)
|
FOR_ACTIVE_TERM_INPUTS(term)
|
||||||
{
|
{
|
||||||
pending_key = term->getkey (term);
|
int key = term->getkey (term);
|
||||||
if (pending_key != GRUB_TERM_NO_KEY)
|
if (key != GRUB_TERM_NO_KEY)
|
||||||
return pending_key;
|
return key;
|
||||||
}
|
}
|
||||||
|
|
||||||
return -1;
|
return GRUB_TERM_NO_KEY;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
@ -112,18 +107,15 @@ grub_getkey (void)
|
||||||
|
|
||||||
grub_refresh ();
|
grub_refresh ();
|
||||||
|
|
||||||
grub_checkkey ();
|
while (1)
|
||||||
while (pending_key == GRUB_TERM_NO_KEY)
|
|
||||||
{
|
{
|
||||||
|
ret = grub_getkey_noblock ();
|
||||||
|
if (ret != GRUB_TERM_NO_KEY)
|
||||||
|
return ret;
|
||||||
grub_cpu_idle ();
|
grub_cpu_idle ();
|
||||||
grub_checkkey ();
|
|
||||||
}
|
}
|
||||||
ret = pending_key;
|
|
||||||
pending_key = GRUB_TERM_NO_KEY;
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
grub_refresh (void)
|
grub_refresh (void)
|
||||||
{
|
{
|
||||||
|
|
|
@ -52,12 +52,8 @@ grub_wait_after_message (void)
|
||||||
|
|
||||||
endtime = grub_get_time_ms () + 10000;
|
endtime = grub_get_time_ms () + 10000;
|
||||||
|
|
||||||
while (grub_get_time_ms () < endtime)
|
while (grub_get_time_ms () < endtime
|
||||||
if (grub_checkkey () >= 0)
|
&& grub_getkey_noblock () == GRUB_TERM_NO_KEY);
|
||||||
{
|
|
||||||
grub_getkey ();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
grub_xputs ("\n");
|
grub_xputs ("\n");
|
||||||
}
|
}
|
||||||
|
@ -560,10 +556,10 @@ run_menu (grub_menu_t menu, int nested, int *auto_boot)
|
||||||
return default_entry;
|
return default_entry;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (grub_checkkey () >= 0 || timeout < 0)
|
c = grub_getkey_noblock ();
|
||||||
{
|
|
||||||
c = grub_getkey ();
|
|
||||||
|
|
||||||
|
if (c != GRUB_TERM_NO_KEY)
|
||||||
|
{
|
||||||
if (timeout >= 0)
|
if (timeout >= 0)
|
||||||
{
|
{
|
||||||
grub_env_unset ("timeout");
|
grub_env_unset ("timeout");
|
||||||
|
|
|
@ -320,7 +320,7 @@ grub_term_unregister_output (grub_term_output_t term)
|
||||||
|
|
||||||
void grub_putcode (grub_uint32_t code, struct grub_term_output *term);
|
void grub_putcode (grub_uint32_t code, struct grub_term_output *term);
|
||||||
int EXPORT_FUNC(grub_getkey) (void);
|
int EXPORT_FUNC(grub_getkey) (void);
|
||||||
int EXPORT_FUNC(grub_checkkey) (void);
|
int EXPORT_FUNC(grub_getkey_noblock) (void);
|
||||||
void grub_cls (void);
|
void grub_cls (void);
|
||||||
void EXPORT_FUNC(grub_refresh) (void);
|
void EXPORT_FUNC(grub_refresh) (void);
|
||||||
void grub_puts_terminal (const char *str, struct grub_term_output *term);
|
void grub_puts_terminal (const char *str, struct grub_term_output *term);
|
||||||
|
|
Loading…
Reference in a new issue