9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: erik quanstrom <quanstro@quanstro.net>
To: 9fans@9fans.net
Subject: [9fans] usb/kb
Date: Thu, 20 Mar 2014 11:19:41 -0400	[thread overview]
Message-ID: <f3314edf6383d411a8f90c01115a047c@mikro.quanstro.net> (raw)

i've made some improvements to 9atom's usb/kb.  they're a little
extensive, so i thought i'd request some feedback before i start
sending patches to sources.  the code is all in atom.

the reason i embarked on this was because the keypad wouldn't
work, and kb didn't play nice with japanese keyboards.  and it
turned out the root cause was fairly deep.

a bit of background.  the ps/2 keyboard driver sets led state.
the led state changes the scancodes produced.  so 9/pgup on
the keypad produces pgup with numlock off, and 9 with it on.
(my ibm keyboards don't behave like this, but that's the theory)

so after making the usb led work i realized that usb doesn't
change the usb keycode.  the driver must track this, and make
changes accordingly.  this requires some processing at the
usb code level (not the scan code output to /dev/kbin!).

since it's no longer a static range of bytes that gets escape scan
codes, it seemed that the escapes should be part of the usb code
to scan code tables.  this is because many different usb codes can
map to the same scan code.  (and we wouldn't know to escape it
or not.)  the pseudo code looks something like this

	for(;;){
		usbcode = getkey();
		switch(usbcode){
		case numlock ... kanashift:
			kbd->led ^= thisled;
			setleds(kbd);
			break;
		}
		scancode = usbtoscancode(usbcode, kbd->led);
		...
	}

so a few details that should now work are
- japanese keyboards,
- usb leds
- usb num lock.  the scroll lock and kana lights should also
work.  caps lock is disabled, and i didn't know what to do with
the compose led.  might be nice to light when composing, but
that would require usb/kb to do the composition itself, so
- the keypad works!
- f11, f12 work
- f13-f24 work but largely do strange things due to the fact that
page up/page down are mapped into this area.  we should consider
moving them safely out of the f-key range.
- keyboard restarting should work properly now, and not crash.
i think we were using the wrong eid.
- keyboards that present an Eboth endpoint should be recognized.

- erik



             reply	other threads:[~2014-03-20 15:19 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-03-20 15:19 erik quanstrom [this message]
2014-03-26  2:20 ` 岡本健二
2014-03-26 14:04   ` erik quanstrom
2014-03-27  1:06     ` kokamoto
2014-03-27  1:23       ` erik quanstrom

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=f3314edf6383d411a8f90c01115a047c@mikro.quanstro.net \
    --to=quanstro@quanstro.net \
    --cc=9fans@9fans.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).