[syslinux:master] kbd: Use the extended keyboard state query for bios_shiftflags()

syslinux-bot for H. Peter Anvin hpa at zytor.com
Sun Apr 20 11:42:06 PDT 2014


Commit-ID:  b8752b88492d8f321037ad29e56a2fdf9e798e15
Gitweb:     http://www.syslinux.org/commit/b8752b88492d8f321037ad29e56a2fdf9e798e15
Author:     H. Peter Anvin <hpa at zytor.com>
AuthorDate: Sun, 20 Apr 2014 11:23:13 -0700
Committer:  H. Peter Anvin <hpa at zytor.com>
CommitDate: Sun, 20 Apr 2014 11:23:13 -0700

kbd: Use the extended keyboard state query for bios_shiftflags()

Mixing extended and non-extended keyboard functions can be a bad idea.

Signed-off-by: H. Peter Anvin <hpa at zytor.com>

---
 core/conio.c | 21 ++++++++++++++++++---
 1 file changed, 18 insertions(+), 3 deletions(-)

diff --git a/core/conio.c b/core/conio.c
index 529673e..427228e 100644
--- a/core/conio.c
+++ b/core/conio.c
@@ -271,12 +271,27 @@ char bios_getchar(char *hi)
 uint8_t bios_shiftflags(void)
 {
 	com32sys_t reg;
+	uint8_t ah, al;
 
 	memset(&reg, 0, sizeof reg);
-	reg.eax.b[1] = 0x02;
+	reg.eax.b[1] = 0x12;
 	__intcall(0x16, &reg, &reg);
-
-	return reg.eax.b[0];
+	ah = reg.eax.b[1];
+	al = reg.eax.b[0];
+
+	/*
+	 * According to the Interrupt List, "many machines" don't correctly
+	 * fold the Alt state, presumably because it might be AltGr.
+	 * Explicitly fold the Alt and Ctrl states; it fits our needs
+	 * better.
+	 */
+
+	if (ah & 0x0a)
+		al |= 0x08;
+	if (ah & 0x05)
+		al |= 0x04;
+
+	return al;
 }
 
 __export uint8_t kbd_shiftflags(void)


More information about the Syslinux-commits mailing list