diff options
author | H. Peter Anvin <hpa@zytor.com> | 2014-04-20 11:17:32 -0700 |
---|---|---|
committer | H. Peter Anvin <hpa@zytor.com> | 2014-04-20 11:19:25 -0700 |
commit | 61b98d65c9695200fe82570a999e29068a950d42 (patch) | |
tree | 6c8a073706b98c2becc0a43a7c3321d398e927c1 | |
parent | fdad168405fd97471f5086dee84b2ebe14e314d3 (diff) | |
download | syslinux-61b98d65c9695200fe82570a999e29068a950d42.tar.gz |
kbd: Make getting the keyboard shift state a firmware method
Getting the keyboard shift state is a firmware method. It is
unfortunately unclear if it is even possible on EFI.
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
-rw-r--r-- | com32/include/syslinux/firmware.h | 1 | ||||
-rw-r--r-- | com32/menu/menumain.c | 12 | ||||
-rw-r--r-- | core/bios.c | 2 | ||||
-rw-r--r-- | core/conio.c | 21 |
4 files changed, 24 insertions, 12 deletions
diff --git a/com32/include/syslinux/firmware.h b/com32/include/syslinux/firmware.h index 6cc06a08..8a78af88 100644 --- a/com32/include/syslinux/firmware.h +++ b/com32/include/syslinux/firmware.h @@ -21,6 +21,7 @@ struct output_ops { struct input_ops { char (*getchar)(char *); int (*pollchar)(void); + uint8_t (*shiftflags)(void); }; struct adv_ops { diff --git a/com32/menu/menumain.c b/com32/menu/menumain.c index fc1376eb..1d239a7f 100644 --- a/com32/menu/menumain.c +++ b/com32/menu/menumain.c @@ -611,17 +611,7 @@ static const char *edit_cmdline(const char *input, int top) static inline int shift_is_held(void) { -#ifdef __FIRMWARE_BIOS__ - com32sys_t reg; - - memset(®, 0, sizeof reg); - reg.eax.b[1] = 0x02; - __intcall(0x16, ®, ®); - - return !!(reg.eax.b[0] & 0x5d); /* Caps/Scroll/Alt/Shift */ -#else - return 0; /* Need to implement this */ -#endif + return !!(kbd_shiftflags() & 0x5d); /* Caps/Scroll/Alt/Shift */ } static void print_timeout_message(int tol, int row, const char *msg) diff --git a/core/bios.c b/core/bios.c index 328c729a..7fb37fec 100644 --- a/core/bios.c +++ b/core/bios.c @@ -148,10 +148,12 @@ struct output_ops bios_output_ops = { extern char bios_getchar(char *); extern int bios_pollchar(void); +extern uint8_t bios_shiftflags(void); struct input_ops bios_input_ops = { .getchar = bios_getchar, .pollchar = bios_pollchar, + .shiftflags = bios_shiftflags, }; static void bios_get_serial_console_info(uint16_t *iobase, uint16_t *divisor, diff --git a/core/conio.c b/core/conio.c index 35ef0b4e..529673eb 100644 --- a/core/conio.c +++ b/core/conio.c @@ -2,7 +2,7 @@ * ----------------------------------------------------------------------- * * Copyright 1994-2008 H. Peter Anvin - All Rights Reserved - * Copyright 2009 Intel Corporation; author: H. Peter Anvin + * Copyright 2009-2014 Intel Corporation; author: H. Peter Anvin * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -268,6 +268,25 @@ char bios_getchar(char *hi) return data; } +uint8_t bios_shiftflags(void) +{ + com32sys_t reg; + + memset(®, 0, sizeof reg); + reg.eax.b[1] = 0x02; + __intcall(0x16, ®, ®); + + return reg.eax.b[0]; +} + +__export uint8_t kbd_shiftflags(void) +{ + if (firmware->i_ops->shiftflags) + return firmware->i_ops->shiftflags(); + else + return 0; /* Unavailable on this firmware */ +} + /* * getchar: Read a character from keyboard or serial port */ |