Author Topic: Oz 3.5.2, 6000: Usb Keyboard Mapping?  (Read 1871 times)

vputz

  • Full Member
  • ***
  • Posts: 163
    • View Profile
Oz 3.5.2, 6000: Usb Keyboard Mapping?
« on: March 11, 2005, 10:40:29 am »
Trying my Z6k, OZ 3.5.2, immensely happy, but for one thing...

I have a Stowaway keyboard hooked up via USB; letters and numbers come through OK, but symbols, control characters, arrow keys, etc are borked completely (tried this with other keyboards as well)--either they do nothing or they produce alternate characters, etc.

I remember this discussion, but from searches I never found if it was fixable/fixed.  Is there a solution to this problem?  If not for that, it's a fantastic portable solution... would really like to get the keyboard usable.

-->VPutz

mitchrl

  • Newbie
  • *
  • Posts: 33
    • View Profile
    • http://
Oz 3.5.2, 6000: Usb Keyboard Mapping?
« Reply #1 on: March 13, 2005, 06:29:25 am »
My reply is slightly OT as I have not tried oz on my 6000 yet. I believe the oz and sharp roms are similar enough that my comments may help.

There are two pieces to this puzzle, the kernel and the rom. The kernel has it's own key mapping but this is ignored by qt except for keycodes. Keycodes are mapped by the kernel and scancodes are mapped by qt. The kernel will associate a hardware key to a keycode, for example: 'A' is 1, 'B' is 2, etc. Then qt will associate a scancode with the keycode: 1 is 'a', shift 1 is 'A', fn 1 is '!', etc. This particular mapping is unique for the tosa (6000) keyboard and will vary by model.

Usb host functionality with hotplugging changes the keycode assignments assuming your usb keyboard is properly recognized. When a usb keyboard is attached, first hid.o is loaded and then usbkbd.o is loaded. Usbkbd changes the keycode mapping based on what is probably a standard us 101 keyboard. If you compare usb keyboards, especially the miniature ones, you'll see that keys are placed all over the place. This is one reason why some keys work, some keys don't work and some are wrong. Then you have to consider the qt scancode mappings. These do not change when you attach the usb keyboard. This is why the shift number keys are boogered.

The scancode problem is the easiest to fix. Just use keyhelper (I'm assuming there is a oz version in the feeds, correct me if I'm wrong). I think someone has posted a keyhelper config file in the 6000 hardware forum (look in the usb keyboards thread) which will get you started.

The keycode problem is a little more complicated. To fix this you will need the 6000 kernel source and a cross compiler. In usbkbd.c, you will find this section that changes the keycode mapping:

static unsigned char usb_kbd_keycode[256] = {
 0,  0,  0,  0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12,
13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 41, 42,
43, 44, 45, 46, 47, 48, 49, 50, 28, 34, 31, 65, 92, 51, 52, 55,
54,  0, 97, 95, 96, 70, 98, 99,100, 60, 33, 58, 94, 39, 88, 89,
90,110,117,120, 30, 40,115,  0,  0,  0,104,106, 81,105,107, 124,
121,123,122, 32, 82, 83, 85, 86, 87, 71, 72, 73, 74, 75, 76, 77,
78, 79, 80, 93,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
 0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
 0,  0,  0,  0,  0,  0,  0,101, 69, 53,  0,  0,  0,  0,  0,  0,
 0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
 0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
 0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
 0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
 0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
56, 27, 57, 29,111,112,113,114,  0,  0,  0,  0,  0,  0,  0,  0,
 0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
};

I'm using a model PSK-3100U mini keyboard which can be found on ebay as a "Traveller". I replaced the previous lines of code with this:

static unsigned char usb_kbd_keycode[256] = {
 0,  0,  0,  0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12,
13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 41, 42,
43, 44, 45, 46, 47, 48, 49, 50, 28, 34, 31, 65, 92, 51, 52, 55,
54, 53, 97, 95, 96, 70, 98, 99,100, 60, 33, 58, 94, 39, 88, 89,
90,110,117,120, 30, 40,115,  0,  0, 82,104,106, 81,105,107, 124,
121,123,122, 32, 82, 83, 85, 86, 87, 71, 72, 73, 74, 75, 76, 77,
78, 79, 80, 93,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
 0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
 0,  0,  0,  0,  0,  0,  0,101, 69, 53,  0,  0,  0,  0,  0,  0,
 0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
 0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
 0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
 0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
 0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
56, 27, 57, 29,111,112,113,114,  0,  0,  0,  0,  0,  0,  0,  0,
 0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
};

There are only a few changes here but enough to get my non-functioning keys working. Other models of keyboards will need to be customized as needed. You will need to go through the process of compiling a kernel but just do a "make modules" to create the usbkbd.o. Then copy the new module to your 6000.

Upon attaching the keyboard, I issue a "khctl reload" from the console. When I remove the keyboard, I issue "khctl disable". Without the "khctl disable", the key assignment on the built-in keyboard of the 6000 is screwed up.

So the short answer to your query is "Yes, but...".

What I would like to do next is automate the keyhelper part of this procedure. With hotplugging, there are places to tie these pieces together. Unfortunately, I have not been able to successfully send qcop messages from usbkbd.o or from scripts that are called by hotplugging. Any insight into this would be appreciated.

HTH,
Robert

vputz

  • Full Member
  • ***
  • Posts: 163
    • View Profile
Oz 3.5.2, 6000: Usb Keyboard Mapping?
« Reply #2 on: March 14, 2005, 09:58:59 am »
Quote from: mitchrl,Mar 13 2005, 11:29 AM
My reply is slightly OT as I have not tried oz on my 6000 yet. I believe the oz and sharp roms are similar enough that my comments may help.
Quote

Thanks a ton!  This is exactly what I was looking for.  I haven't tried KeyHelper yet (although I'll have to eventually--I'm a Dvorak user when touch-typing but am not going to try THAT with the mini-keyboard on the Tosa).  Modifying the usbkbd module sounds like the way to go.

Wow--yet ANOTHER thing to do in my "copious spare time" (heh).

-->VPutz