[syslinux:master] kbd: Make getting the keyboard shift state a firmware method
syslinux-bot for H. Peter Anvin
hpa at zytor.com
Sun Apr 20 11:42:05 PDT 2014
Commit-ID: 61b98d65c9695200fe82570a999e29068a950d42
Gitweb: http://www.syslinux.org/commit/61b98d65c9695200fe82570a999e29068a950d42
Author: H. Peter Anvin <hpa at zytor.com>
AuthorDate: Sun, 20 Apr 2014 11:17:32 -0700
Committer: H. Peter Anvin <hpa at zytor.com>
CommitDate: Sun, 20 Apr 2014 11:19:25 -0700
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 at zytor.com>
---
com32/include/syslinux/firmware.h | 1 +
com32/menu/menumain.c | 12 +-----------
core/bios.c | 2 ++
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 6cc06a0..8a78af8 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 fc1376e..1d239a7 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 328c729..7fb37fe 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 35ef0b4..529673e 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
*/
More information about the Syslinux-commits
mailing list