[patch] compose LED on a usb keyboard

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[patch] compose LED on a usb keyboard

Alexander Polakov-2
I got my hands on one of these sun keyboards with a compose key (and
LED).

uhidev0 at uhub2 port 2 configuration 1 interface 0 "Fujitsu Component Type 6 Keyboard" rev 1.00/1.02 addr 2
uhidev0: iclass 3/1
ukbd0 at uhidev0: 8 modifier keys, 6 key codes, country code 33
wskbd1 at ukbd0 mux 1
wskbd1: connecting to wsdisplay0

This diff adds support to the kernel:

Index: hidkbd.c
===================================================================
RCS file: /cvs/src/sys/dev/usb/hidkbd.c,v
retrieving revision 1.5
diff -u -p -r1.5 hidkbd.c
--- hidkbd.c 9 Nov 2011 14:22:38 -0000 1.5
+++ hidkbd.c 18 Apr 2012 23:53:55 -0000
@@ -485,6 +485,8 @@ hidkbd_set_leds(struct hidkbd *kbd, int
  *report |= 1 << kbd->sc_numloc.pos;
  if ((leds & WSKBD_LED_CAPS) && kbd->sc_capsloc.size == 1)
  *report |= 1 << kbd->sc_capsloc.pos;
+ if ((leds & WSKBD_LED_COMPOSE) && kbd->sc_compose.size == 1)
+ *report |= 1 << kbd->sc_compose.pos;
 
  return 1;
 }
@@ -613,6 +615,8 @@ hidkbd_parse_desc(struct hidkbd *kbd, in
     id, hid_output, &kbd->sc_capsloc, NULL);
  hid_locate(desc, dlen, HID_USAGE2(HUP_LEDS, HUD_LED_SCROLL_LOCK),
     id, hid_output, &kbd->sc_scroloc, NULL);
+ hid_locate(desc, dlen, HID_USAGE2(HUP_LEDS, HUD_LED_COMPOSE),
+    id, hid_output, &kbd->sc_compose, NULL);
 
  return (NULL);
 }
Index: hidkbdsc.h
===================================================================
RCS file: /cvs/src/sys/dev/usb/hidkbdsc.h,v
retrieving revision 1.2
diff -u -p -r1.2 hidkbdsc.h
--- hidkbdsc.h 9 Nov 2011 14:22:38 -0000 1.2
+++ hidkbdsc.h 18 Apr 2012 23:53:55 -0000
@@ -61,6 +61,7 @@ struct hidkbd {
  struct hid_location sc_numloc;
  struct hid_location sc_capsloc;
  struct hid_location sc_scroloc;
+ struct hid_location sc_compose;
  int sc_leds;
 
  /* state information */
Index: ukbd.c
===================================================================
RCS file: /cvs/src/sys/dev/usb/ukbd.c,v
retrieving revision 1.57
diff -u -p -r1.57 ukbd.c
--- ukbd.c 29 Jan 2012 11:04:19 -0000 1.57
+++ ukbd.c 18 Apr 2012 23:53:55 -0000
@@ -288,7 +288,8 @@ ukbd_attach(struct device *parent, struc
  }
 
  /* Flash the leds; no real purpose, just shows we're alive. */
- ukbd_set_leds(sc, WSKBD_LED_SCROLL | WSKBD_LED_NUM | WSKBD_LED_CAPS);
+ ukbd_set_leds(sc, WSKBD_LED_SCROLL | WSKBD_LED_NUM |
+          WSKBD_LED_CAPS | WSKBD_LED_COMPOSE);
  usbd_delay_ms(uha->parent->sc_udev, 400);
  ukbd_set_leds(sc, 0);

And this one is my first (failed) attempt to add support to
xf86-input-keyboard (it works, but comments say it all).
I'm in need of a helping hand here.

Index: bsd_kbd.c
===================================================================
RCS file: /cvs/xenocara/driver/xf86-input-keyboard/src/bsd_kbd.c,v
retrieving revision 1.17
diff -u -p -r1.17 bsd_kbd.c
--- bsd_kbd.c 29 Jun 2011 20:00:23 -0000 1.17
+++ bsd_kbd.c 19 Apr 2012 01:18:31 -0000
@@ -81,6 +81,8 @@ SetKbdLeds(InputInfoPtr pInfo, int leds)
     if (leds & XLED3)  real_leds |= LED_SCR;
     if (leds & XLED4)  real_leds |= LED_SCR;
 #endif
+    /* XXX: no idea where 0x10 comes from */
+    if (leds & 0x10) real_leds |= WSKBD_LED_COMPOSE;
 
     switch (pKbd->consType) {
 
@@ -91,7 +93,11 @@ SetKbdLeds(InputInfoPtr pInfo, int leds)
 #if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT)
  case SYSCONS:
  case PCVT:
+#if defined(WSCONS_SUPPORT) /* XXX */
+            ioctl(pInfo->fd, WSKBDIO_SETLEDS, &real_leds);
+#else
      ioctl(pInfo->fd, KDSETLED, real_leds);
+#endif
      break;
 #endif
 #if defined(WSCONS_SUPPORT)

--
Alexander Polakov | plhk.ru