From caa649f52714a3a2c5d9ee1f4085c0f4ab637780 Mon Sep 17 00:00:00 2001 From: macallan Date: Sat, 8 Nov 2014 16:52:35 +0000 Subject: [PATCH] nicely ask the keyboard to distinguish between left and right Control, Alt and Shift keys. Welcome to the world of accents and diacritics! --- sys/dev/adb/adb_kbd.c | 26 ++++++++++++++++++++++++-- sys/dev/adb/adb_keymap.h | 6 ++++-- sys/dev/adb/adb_usb_map.c | 10 +++++----- 3 files changed, 33 insertions(+), 9 deletions(-) diff --git a/sys/dev/adb/adb_kbd.c b/sys/dev/adb/adb_kbd.c index 3a42e30e2885..3a3e05299f72 100644 --- a/sys/dev/adb/adb_kbd.c +++ b/sys/dev/adb/adb_kbd.c @@ -1,4 +1,4 @@ -/* $NetBSD: adb_kbd.c,v 1.22 2013/11/18 11:02:34 nisimura Exp $ */ +/* $NetBSD: adb_kbd.c,v 1.23 2014/11/08 16:52:35 macallan Exp $ */ /* * Copyright (C) 1998 Colin Wood @@ -32,7 +32,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: adb_kbd.c,v 1.22 2013/11/18 11:02:34 nisimura Exp $"); +__KERNEL_RCSID(0, "$NetBSD: adb_kbd.c,v 1.23 2014/11/08 16:52:35 macallan Exp $"); #include #include @@ -190,6 +190,7 @@ adbkbd_attach(device_t parent, device_t self, void *aux) #if NWSMOUSE > 0 struct wsmousedev_attach_args am; #endif + uint8_t buffer[2]; sc->sc_dev = self; sc->sc_ops = aaa->ops; @@ -333,6 +334,27 @@ adbkbd_attach(device_t parent, device_t self, void *aux) break; } + /* + * try to switch to extended protocol + * as in, tell the keyboard to distinguish between left and right + * Shift, Control and Alt keys + */ + cmd = ADBLISTEN(sc->sc_adbdev->current_addr, 3); + buffer[0] = sc->sc_adbdev->current_addr; + buffer[1] = 3; + sc->sc_msg_len = 0; + sc->sc_ops->send(sc->sc_ops->cookie, sc->sc_poll, cmd, 2, buffer); + adbkbd_wait(sc, 10); + + cmd = ADBTALK(sc->sc_adbdev->current_addr, 3); + sc->sc_msg_len = 0; + sc->sc_ops->send(sc->sc_ops->cookie, sc->sc_poll, cmd, 0, NULL); + adbkbd_wait(sc, 10); + if ((sc->sc_msg_len == 4) && (sc->sc_buffer[3] == 3)) { + printf("%s: extended protocol enabled\n", + device_xname(sc->sc_dev)); + } + if (adbkbd_is_console && (adbkbd_console_attached == 0)) { wskbd_cnattach(&adbkbd_consops, sc, &adbkbd_keymapdata); adbkbd_console_attached = 1; diff --git a/sys/dev/adb/adb_keymap.h b/sys/dev/adb/adb_keymap.h index f66cccbbf0ee..334d4db98e1a 100644 --- a/sys/dev/adb/adb_keymap.h +++ b/sys/dev/adb/adb_keymap.h @@ -1,4 +1,4 @@ -/* $NetBSD: adb_keymap.h,v 1.4 2012/08/29 02:44:07 macallan Exp $ */ +/* $NetBSD: adb_keymap.h,v 1.5 2014/11/08 16:52:35 macallan Exp $ */ /*- * Copyright (c) 1997 The NetBSD Foundation, Inc. @@ -148,7 +148,9 @@ static const keysym_t akbd_keydesc_us[] = { KC(120),KS_Cmd_Screen1, KS_f2, KC(121),KS_Cmd_ScrollFastDown, KS_Next, KC(122),KS_Cmd_Screen0, KS_f1, - + KC(123), KS_Shift_R, + KC(124), KS_Alt_R, + KC(125), KS_Control_R, KC(127), KS_Cmd_Debugger, }; diff --git a/sys/dev/adb/adb_usb_map.c b/sys/dev/adb/adb_usb_map.c index 1468fcfac8d1..b39985c20ff9 100644 --- a/sys/dev/adb/adb_usb_map.c +++ b/sys/dev/adb/adb_usb_map.c @@ -1,4 +1,4 @@ -/* $NetBSD: adb_usb_map.c,v 1.1 2012/08/29 02:44:07 macallan Exp $ */ +/* $NetBSD: adb_usb_map.c,v 1.2 2014/11/08 16:52:35 macallan Exp $ */ /*- * Copyright (c) 2006 Michael Lorenz @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: adb_usb_map.c,v 1.1 2012/08/29 02:44:07 macallan Exp $"); +__KERNEL_RCSID(0, "$NetBSD: adb_usb_map.c,v 1.2 2014/11/08 16:52:35 macallan Exp $"); #include #include @@ -158,9 +158,9 @@ keysym_t adb_to_usb[] = { /* 120, KS_f2 */ 59, /* 121, KS_Next */ 78, /* 122, KS_f1 */ 58, -/* 123 */ 0, -/* 124 */ 0, -/* 125 */ 0, +/* 123, KS_Shift_R */ 229, +/* 124, KS_Alt_R */ 230, +/* 125, KS_Control_R */ 228, /* 126 */ 0, /* 127, KS_Cmd_Debugger */ 102 };