[prev in list] [next in list] [prev in thread] [next in thread]
List: openbsd-tech
Subject: Fix Apple ADB iso keyboards: swapped keys
From: Martin Pieuchot <mpieuchot () nolizard ! org>
Date: 2011-12-26 17:32:59
Message-ID: 20111226173259.GF12280 () goiaba ! nolizard ! org
[Download RAW message or body]
Apple ISO keyboards have two keys swapped compare to Apple ANSI (us)
keyboards.
It's why when using a European keyboard layout under X11 the key below
"Esc" and the key on the right of "Left Shift" are swapped.
It's also a problem when using a us layout with an ISO keyboard: the "~"
key isn't mapped.
The diff below fixes this issue for ADB keyboards by swapping the
keycodes of the two keys for all ISO keyboards. I've also updated
the console layouts accordingly.
It also removes an #ifdef in the raw map conversion for X11 which
corresponds to a no longer needed workaround for this bug.
Ok?
Martin
Index: akbd.c
===================================================================
RCS file: /cvs/src/sys/dev/adb/akbd.c,v
retrieving revision 1.11
diff -u -p -r1.11 akbd.c
--- akbd.c 9 Nov 2011 14:22:37 -0000 1.11
+++ akbd.c 20 Dec 2011 20:23:15 -0000
@@ -127,6 +127,7 @@ akbdattach(struct device *parent, struct
sc->sc_leds = (u_int8_t)0x00; /* initially off */
sc->sc_caps = 0;
+ sc->sc_iso = 0;
adbinfo.siServiceRtPtr = (Ptr)akbd_adbcomplete;
adbinfo.siDataAreaAddr = (caddr_t)sc;
@@ -138,6 +139,7 @@ akbdattach(struct device *parent, struct
break;
case ADB_ISOKBD:
printf("standard keyboard (ISO layout)\n");
+ sc->sc_iso = 1;
break;
case ADB_EXTKBD:
cmd = ADBTALK(sc->adbaddr, 1);
@@ -164,6 +166,7 @@ akbdattach(struct device *parent, struct
break;
case ADB_EXTISOKBD:
printf("extended keyboard (ISO layout)\n");
+ sc->sc_iso = 1;
#ifdef notyet
blinkleds(sc);
#endif
@@ -173,12 +176,14 @@ akbdattach(struct device *parent, struct
break;
case ADB_ISOKBDII:
printf("keyboard II (ISO layout)\n");
+ sc->sc_iso = 1;
break;
case ADB_PBKBD:
printf("PowerBook keyboard\n");
break;
case ADB_PBISOKBD:
printf("PowerBook keyboard (ISO layout)\n");
+ sc->sc_iso = 1;
break;
case ADB_ADJKPD:
printf("adjustable keypad\n");
@@ -189,12 +194,14 @@ akbdattach(struct device *parent, struct
break;
case ADB_ADJISOKBD:
printf("adjustable keyboard (ISO layout)\n");
+ sc->sc_iso = 1;
break;
case ADB_ADJJAPKBD:
printf("adjustable keyboard (Japanese layout)\n");
break;
case ADB_PBEXTISOKBD:
printf("PowerBook extended keyboard (ISO layout)\n");
+ sc->sc_iso = 1;
break;
case ADB_PBEXTJAPKBD:
printf("PowerBook extended keyboard (Japanese layout)\n");
@@ -222,6 +229,7 @@ akbdattach(struct device *parent, struct
break;
case ADB_IBITISOKBD:
printf("iBook keyboard with inverted T (ISO layout)\n");
+ sc->sc_iso = 1;
break;
default:
printf("mapped device (%d)\n", sc->handler_id);
@@ -511,6 +519,19 @@ akbd_capslockwrapper(struct akbd_softc *
akbd_input(sc, key);
}
+static inline int
+akbd_iso_swap(int keycode)
+{
+ switch (keycode) {
+ case 10:
+ return (50);
+ case 50:
+ return (10);
+ default:
+ return (keycode);
+ }
+}
+
int adb_polledkey;
void
akbd_input(struct akbd_softc *sc, int key)
@@ -520,6 +541,9 @@ akbd_input(struct akbd_softc *sc, int ke
press = ADBK_PRESS(key);
val = ADBK_KEYVAL(key);
+
+ if (sc->sc_iso)
+ val = akbd_iso_swap(val);
type = press ? WSCONS_EVENT_KEY_DOWN : WSCONS_EVENT_KEY_UP;
Index: akbdmap.h
===================================================================
RCS file: /cvs/src/sys/dev/adb/akbdmap.h,v
retrieving revision 1.6
diff -u -p -r1.6 akbdmap.h
--- akbdmap.h 23 Oct 2011 19:16:31 -0000 1.6
+++ akbdmap.h 11 Dec 2011 20:50:48 -0000
@@ -44,11 +44,7 @@ unsigned char keyboard[128] = {
RAWKEY_x,
RAWKEY_c,
RAWKEY_v,
-#ifdef FIX_SV_X_KBDBUG
- RAWKEY_grave,
-#else
RAWKEY_less,
-#endif
RAWKEY_b,
RAWKEY_q,
RAWKEY_w,
@@ -88,11 +84,7 @@ unsigned char keyboard[128] = {
RAWKEY_period,
RAWKEY_Tab,
RAWKEY_space,
-#ifdef FIX_SV_X_KBDBUG
- RAWKEY_less,
-#else
RAWKEY_grave,
-#endif
RAWKEY_Delete,
RAWKEY_KP_Enter,
RAWKEY_Escape,
@@ -304,7 +296,7 @@ static const keysym_t akbd_keydesc_fr[]
KC(4), KS_h, KS_H, KS_Igrave, KS_Icircumflex,
KC(6), KS_w, KS_W, KS_less, KS_greater,
KC(8), KS_c, KS_C, KS_copyright, KS_cent,
- KC(10), KS_at, KS_numbersign,
+ KC(10), KS_less, KS_greater,
KC(11), KS_b, KS_B, KS_ssharp,
KC(12), KS_a, KS_A, KS_ae, KS_AE,
KC(13), KS_z, KS_Z, KS_Acircumflex, KS_Aring,
@@ -339,7 +331,7 @@ static const keysym_t akbd_keydesc_fr[]
KC(45), KS_n, KS_N, KS_dead_tilde,
KC(46), KS_comma, KS_question, KS_voidSymbol, KS_questiondown,
KC(47), KS_colon, KS_slash, KS_division, KS_backslash,
- KC(50), KS_less, KS_greater,
+ KC(50), KS_at, KS_numbersign,
KC(52), KS_Alt_R,
KC(55), KS_Meta_L, /* Command */
KC(58), KS_Mode_switch, KS_Multi_key, /* Option */
@@ -374,15 +366,15 @@ static const keysym_t akbd_keydesc_jp[]
static const keysym_t akbd_keydesc_uk[] = {
/* pos normal shifted altgr shift-altgr */
- KC(10), KS_section, KS_plusminus,
KC(20), KS_3, KS_sterling, KS_numbersign,
+ KC(50), KS_section, KS_plusminus,
KC(52), KS_KP_Enter,
KC(58), KS_Mode_switch, KS_Multi_key, /* Option */
};
static const keysym_t akbd_keydesc_sv[] = {
/* pos normal shifted altgr shift-altgr */
- KC(10), KS_section, KS_degree,
+ KC(10), KS_less, KS_greater, KS_bar,
KC(19), KS_2, KS_quotedbl, KS_at,
KC(21), KS_4, KS_dollar,
KC(22), KS_6, KS_ampersand,
@@ -400,7 +392,7 @@ static const keysym_t akbd_keydesc_sv[]
KC(43), KS_comma, KS_semicolon,
KC(44), KS_minus, KS_underscore,
KC(47), KS_period, KS_colon,
- KC(50), KS_less, KS_greater, KS_bar,
+ KC(50), KS_section, KS_degree,
KC(58), KS_Mode_switch,KS_Multi_key,
};
@@ -420,7 +412,7 @@ static const keysym_t akbd_keydesc_de[]
KC(6), KS_y, KS_Y, KS_yen,
KC(7), KS_x, KS_X, KS_voidSymbol, KS_Ugrave,
KC(8), KS_c, KS_C, KS_ccedilla, KS_Ccedilla,
- KC(10), KS_dead_circumflex,KS_degree,
+ KC(10), KS_less, KS_greater,
KC(12), KS_q, KS_Q, KS_guillemotleft,KS_guillemotright,
KC(15), KS_r, KS_R, KS_registered, KS_cedilla,
KC(16), KS_z, KS_Z,
@@ -451,24 +443,24 @@ static const keysym_t akbd_keydesc_de[]
KC(45), KS_n, KS_N, KS_dead_tilde,
KC(46), KS_m, KS_M, KS_mu,
KC(47), KS_period, KS_colon,
- KC(50), KS_less, KS_greater,
+ KC(50), KS_dead_circumflex,KS_degree,
KC(52), KS_Multi_key,
KC(58), KS_Mode_switch,
};
static const keysym_t akbd_keydesc_de_nodead[] = {
/* pos normal shifted altgr shift-altgr */
- KC(10), KS_asciicircum, KS_degree,
KC(22), KS_6, KS_ampersand, KS_bracketright,KS_asciicircum,
KC(24), KS_acute, KS_grave, KS_apostrophe,
KC(32), KS_u, KS_U, KS_diaeresis, KS_Aacute,
KC(45), KS_n, KS_N, KS_asciitilde,
+ KC(50), KS_asciicircum, KS_degree,
};
static const keysym_t akbd_keydesc_sf[] = {
/* pos normal shifted altgr shift-altgr */
KC(6), KS_y,
- KC(10), KS_paragraph, KS_degree,
+ KC(10), KS_less, KS_greater,
KC(16), KS_z,
KC(18), KS_plus, KS_1,
KC(19), KS_quotedbl, KS_2,
@@ -490,12 +482,12 @@ static const keysym_t akbd_keydesc_sf[]
KC(43), KS_period, KS_colon,
KC(46), KS_comma, KS_semicolon,
KC(47), KS_minus, KS_underscore,
- KC(50), KS_less, KS_greater,
+ KC(50), KS_paragraph, KS_degree,
};
static const keysym_t akbd_keydesc_es[] = {
/* pos normal shifted altgr shift-altgr */
- KC(10), KS_degree, KS_ordfeminine, KS_backslash,
+ KC(10), KS_less, KS_greater,
KC(18), KS_1, KS_exclam, KS_bar,
KC(19), KS_2, KS_quotedbl, KS_at,
KC(20), KS_3, KS_periodcentered, KS_numbersign,
@@ -516,7 +508,7 @@ static const keysym_t akbd_keydesc_es[]
KC(43), KS_comma, KS_semicolon,
KC(44), KS_minus, KS_underscore,
KC(47), KS_period, KS_colon,
- KC(50), KS_less, KS_greater,
+ KC(50), KS_degree, KS_ordfeminine, KS_backslash,
KC(55), KS_Alt_L, /* Command */
KC(58), KS_Mode_switch, KS_Multi_key, /* Option */
};
@@ -524,7 +516,7 @@ static const keysym_t akbd_keydesc_es[]
static const keysym_t akbd_keydesc_pt[] = {
/* pos normal shifted altgr shift-altgr */
KC(7), KS_x, KS_X, KS_guillemotleft, KS_guillemotright,
- KC(10), KS_section, KS_plusminus,
+ KC(10), KS_less, KS_greater,
KC(19), KS_2, KS_quotedbl, KS_at,
KC(20), KS_3, KS_numbersign, KS_sterling,
KC(22), KS_6, KS_ampersand,
@@ -541,7 +533,7 @@ static const keysym_t akbd_keydesc_pt[]
KC(43), KS_comma, KS_semicolon,
KC(44), KS_minus, KS_underscore,
KC(47), KS_period, KS_colon,
- KC(50), KS_less, KS_greater,
+ KC(50), KS_section, KS_plusminus,
KC(58), KS_Mode_switch, KS_Multi_key, /* Option */
};
@@ -592,7 +584,7 @@ static const keysym_t akbd_keydesc_sg[]
KC(6), KS_y, KS_Y, KS_yen, KS_ydiaeresis,
KC(7), KS_x, KS_X, KS_voidSymbol, KS_ydiaeresis,
KC(8), KS_c, KS_C, KS_copyright,
- KC(10), KS_section, KS_degree,
+ KC(10), KS_less, KS_greater,
KC(12), KS_q, KS_Q,
KC(15), KS_r, KS_R, KS_registered, KS_Egrave,
KC(16), KS_z, KS_Z, KS_voidSymbol, KS_Aacute,
@@ -623,7 +615,7 @@ static const keysym_t akbd_keydesc_sg[]
KC(45), KS_n, KS_N, KS_dead_tilde,
KC(46), KS_m, KS_M, KS_mu,
KC(47), KS_period, KS_colon, KS_voidSymbol, KS_division,
- KC(50), KS_less, KS_greater,
+ KC(50), KS_section, KS_degree,
KC(52), KS_Multi_key,
KC(58), KS_Mode_switch,
};
Index: akbdvar.h
===================================================================
RCS file: /cvs/src/sys/dev/adb/akbdvar.h,v
retrieving revision 1.3
diff -u -p -r1.3 akbdvar.h
--- akbdvar.h 9 Nov 2011 14:22:37 -0000 1.3
+++ akbdvar.h 11 Dec 2011 20:27:04 -0000
@@ -46,6 +46,7 @@ struct akbd_softc {
int handler_id; /* type of keyboard */
u_int8_t sc_leds; /* current LED state */
+ u_int8_t sc_iso;
int sc_caps; /* capslock key state */
struct device *sc_wskbddev;
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic