summaryrefslogtreecommitdiff
path: root/payloads/libpayload
diff options
context:
space:
mode:
Diffstat (limited to 'payloads/libpayload')
-rw-r--r--payloads/libpayload/drivers/usb/usbhid.c3
-rw-r--r--payloads/libpayload/include/libpayload.h7
-rw-r--r--payloads/libpayload/libc/console.c10
3 files changed, 18 insertions, 2 deletions
diff --git a/payloads/libpayload/drivers/usb/usbhid.c b/payloads/libpayload/drivers/usb/usbhid.c
index f14bda0c04..b8c04f1d1a 100644
--- a/payloads/libpayload/drivers/usb/usbhid.c
+++ b/payloads/libpayload/drivers/usb/usbhid.c
@@ -391,7 +391,8 @@ usb_hid_set_protocol (usbdev_t *dev, interface_descriptor_t *interface, hid_prot
static struct console_input_driver cons = {
.havekey = usbhid_havechar,
- .getchar = usbhid_getchar
+ .getchar = usbhid_getchar,
+ .input_type = CONSOLE_INPUT_TYPE_USB,
};
diff --git a/payloads/libpayload/include/libpayload.h b/payloads/libpayload/include/libpayload.h
index 10a4505c30..14f8a38164 100644
--- a/payloads/libpayload/include/libpayload.h
+++ b/payloads/libpayload/include/libpayload.h
@@ -247,12 +247,18 @@ int set_option_from_string(const struct nvram_accessor *nvram, struct cb_cmos_op
* @defgroup console Console functions
* @{
*/
+typedef enum {
+ CONSOLE_INPUT_TYPE_UNKNOWN = 0,
+ CONSOLE_INPUT_TYPE_USB,
+} console_input_type;
+
void console_init(void);
int putchar(unsigned int c);
int puts(const char *s);
int havekey(void);
int getchar(void);
int getchar_timeout(int *ms);
+console_input_type last_key_input_type(void);
extern int last_putchar;
@@ -261,6 +267,7 @@ struct console_input_driver {
struct console_input_driver *next;
int (*havekey) (void);
int (*getchar) (void);
+ console_input_type input_type;
};
struct console_output_driver;
diff --git a/payloads/libpayload/libc/console.c b/payloads/libpayload/libc/console.c
index fce6de4fa0..54844db79b 100644
--- a/payloads/libpayload/libc/console.c
+++ b/payloads/libpayload/libc/console.c
@@ -33,6 +33,7 @@
struct console_output_driver *console_out;
struct console_input_driver *console_in;
+static console_input_type last_getchar_input_type;
void console_add_output_driver(struct console_output_driver *out)
{
@@ -115,8 +116,10 @@ int getchar(void)
#endif
struct console_input_driver *in;
for (in = console_in; in != 0; in = in->next)
- if (in->havechar())
+ if (in->havechar()) {
+ last_getchar_input_type = in->input_type;
return in->getchar();
+ }
}
}
@@ -135,3 +138,8 @@ int getchar_timeout(int *ms)
return 0;
}
+
+console_input_type last_key_input_type(void)
+{
+ return last_getchar_input_type;
+}