Imported nyu's multi-input
This commit is contained in:
parent
2322a12693
commit
8eca55a6eb
6 changed files with 54 additions and 38 deletions
|
@ -48,13 +48,20 @@ grub_cmd_keystatus (grub_extcmd_t cmd,
|
|||
if (state[2].set)
|
||||
expect_mods |= GRUB_TERM_STATUS_ALT;
|
||||
|
||||
grub_dprintf ("keystatus", "expect_mods: %d\n", expect_mods);
|
||||
|
||||
/* Without arguments, just check whether getkeystatus is supported at
|
||||
all. */
|
||||
if (!grub_cur_term_input->getkeystatus)
|
||||
return grub_error (GRUB_ERR_TEST_FAILURE, "false");
|
||||
grub_dprintf ("keystatus", "expect_mods: %d\n", expect_mods);
|
||||
if (!expect_mods)
|
||||
return 0;
|
||||
if (expect_mods == 0)
|
||||
{
|
||||
grub_term_input_t term;
|
||||
|
||||
FOR_ACTIVE_TERM_INPUTS (term)
|
||||
if (term->getkeystatus)
|
||||
return 0;
|
||||
|
||||
return grub_error (GRUB_ERR_TEST_FAILURE, "false");
|
||||
}
|
||||
|
||||
mods = grub_getkeystatus ();
|
||||
grub_dprintf ("keystatus", "mods: %d\n", mods);
|
||||
|
|
|
@ -197,14 +197,14 @@ struct grub_term_output
|
|||
};
|
||||
typedef struct grub_term_output *grub_term_output_t;
|
||||
|
||||
extern struct grub_handler_class EXPORT_VAR(grub_term_input_class);
|
||||
extern struct grub_term_output *EXPORT_VAR(grub_term_outputs);
|
||||
extern struct grub_term_input *EXPORT_VAR(grub_term_inputs);
|
||||
|
||||
static inline void
|
||||
grub_term_register_input (const char *name __attribute__ ((unused)),
|
||||
grub_term_input_t term)
|
||||
{
|
||||
grub_handler_register (&grub_term_input_class, GRUB_AS_HANDLER (term));
|
||||
grub_list_push (GRUB_AS_LIST_P (&grub_term_inputs), GRUB_AS_LIST (term));
|
||||
}
|
||||
|
||||
static inline void
|
||||
|
@ -217,7 +217,7 @@ grub_term_register_output (const char *name __attribute__ ((unused)),
|
|||
static inline void
|
||||
grub_term_unregister_input (grub_term_input_t term)
|
||||
{
|
||||
grub_handler_unregister (&grub_term_input_class, GRUB_AS_HANDLER (term));
|
||||
grub_list_remove (GRUB_AS_LIST_P (&grub_term_inputs), GRUB_AS_LIST (term));
|
||||
}
|
||||
|
||||
static inline void
|
||||
|
@ -226,18 +226,7 @@ grub_term_unregister_output (grub_term_output_t term)
|
|||
grub_list_remove (GRUB_AS_LIST_P (&grub_term_outputs), GRUB_AS_LIST (term));
|
||||
}
|
||||
|
||||
static inline grub_err_t
|
||||
grub_term_set_current_input (grub_term_input_t term)
|
||||
{
|
||||
return grub_handler_set_current (&grub_term_input_class,
|
||||
GRUB_AS_HANDLER (term));
|
||||
}
|
||||
|
||||
static inline grub_term_input_t
|
||||
grub_term_get_current_input (void)
|
||||
{
|
||||
return (grub_term_input_t) grub_term_input_class.cur_handler;
|
||||
}
|
||||
#define FOR_ACTIVE_TERM_INPUTS(var) for (var = grub_term_inputs; var; var = var->next)
|
||||
|
||||
void EXPORT_FUNC(grub_putchar) (int c);
|
||||
void EXPORT_FUNC(grub_putcode) (grub_uint32_t code,
|
||||
|
|
|
@ -975,7 +975,9 @@ grub_abort (void)
|
|||
{
|
||||
grub_printf ("\nAborted.");
|
||||
|
||||
if (grub_term_get_current_input ())
|
||||
#ifndef GRUB_UTIL
|
||||
if (grub_term_inputs)
|
||||
#endif
|
||||
{
|
||||
grub_printf (" Press any key to exit.");
|
||||
grub_getkey ();
|
||||
|
|
48
kern/term.c
48
kern/term.c
|
@ -21,15 +21,10 @@
|
|||
#include <grub/mm.h>
|
||||
#include <grub/misc.h>
|
||||
#include <grub/env.h>
|
||||
|
||||
struct grub_handler_class grub_term_input_class =
|
||||
{
|
||||
.name = "terminal_input"
|
||||
};
|
||||
|
||||
#define grub_cur_term_input grub_term_get_current_input ()
|
||||
#include <grub/cpu/time.h>
|
||||
|
||||
struct grub_term_output *grub_term_outputs;
|
||||
struct grub_term_input *grub_term_inputs;
|
||||
|
||||
void (*grub_newline_hook) (void) = NULL;
|
||||
|
||||
|
@ -85,22 +80,49 @@ grub_putchar (int c)
|
|||
int
|
||||
grub_getkey (void)
|
||||
{
|
||||
return (grub_cur_term_input->getkey) ();
|
||||
grub_term_input_t term;
|
||||
|
||||
while (1)
|
||||
{
|
||||
FOR_ACTIVE_TERM_INPUTS(term)
|
||||
{
|
||||
int key = term->checkkey ();
|
||||
if (key != -1)
|
||||
return term->getkey ();
|
||||
}
|
||||
|
||||
grub_cpu_idle ();
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
grub_checkkey (void)
|
||||
{
|
||||
return (grub_cur_term_input->checkkey) ();
|
||||
grub_term_input_t term;
|
||||
|
||||
FOR_ACTIVE_TERM_INPUTS(term)
|
||||
{
|
||||
int key = term->checkkey ();
|
||||
if (key != -1)
|
||||
return key;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
int
|
||||
grub_getkeystatus (void)
|
||||
{
|
||||
if (grub_cur_term_input->getkeystatus)
|
||||
return (grub_cur_term_input->getkeystatus) ();
|
||||
else
|
||||
return 0;
|
||||
int status = 0;
|
||||
grub_term_input_t term;
|
||||
|
||||
FOR_ACTIVE_TERM_INPUTS(term)
|
||||
{
|
||||
if (term->getkeystatus)
|
||||
status |= term->getkeystatus ();
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -377,7 +377,6 @@ grub_console_init (void)
|
|||
grub_term_register_output ("console", &grub_ncurses_term_output);
|
||||
grub_term_register_input ("console", &grub_ncurses_term_input);
|
||||
grub_term_set_current_output (&grub_ncurses_term_output);
|
||||
grub_term_set_current_input (&grub_ncurses_term_input);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -46,9 +46,6 @@ grub_refresh (void)
|
|||
fflush (stdout);
|
||||
}
|
||||
|
||||
struct grub_handler_class grub_term_input_class;
|
||||
struct grub_handler_class grub_term_output_class;
|
||||
|
||||
int
|
||||
grub_getkey (void)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue