Skip to main content

USB Keyboard

3 replies [Last post]
Joined: 2006-10-11
Points: 0

I'm trying to add usb keyboard support to fb port and added something like below to midp/src/events/input_port/fb/native/fb_keymapping.c .

KeyMapping usb_keyboard_keys[] = {
{KEYMAP_KEY_UP, 0x48, 0xc8},
{KEYMAP_KEY_DOWN, 0x50, 0xd0},
{KEYMAP_KEY_LEFT, 0x4b, 0xcb},
{KEYMAP_KEY_RIGHT, 0x4d, 0xcd},

{KEYMAP_KEY_SELECT, 0x1c, 0x9c}, /* Enter key */
{KEYMAP_KEY_SPACE, 0x39, 0xb9}, /* Space key */

{KEYMAP_KEY_SOFT1, 0x3b, 0xbb}, /* F1 key */
{KEYMAP_KEY_SOFT2, 0x3c, 0xbc}, /* F2 key */

{KEYMAP_KEY_POWER, 0x3f, 0xbf}, /* F5 key */
{KEYMAP_KEY_SEND, 0x43, 0xc3}, /* F9 key */

{KEYMAP_MD_KEY_HOME, 0x47, 0xc7}, /* home button */
{KEYMAP_KEY_END, 0x01, 0x81}, /* Escape key */

{KEYMAP_KEY_BACKSPACE, 0x0e, 0x8e}, /* Backspace key */
{KEYMAP_KEY_CLEAR, 0x53, 0xd3}, /* Clear key */

{'q', 0x10, 0x90},
{'w', 0x11, 0x91},
{'e', 0x12, 0x92},
{'r', 0x13, 0x93},
{'t', 0x14, 0x94},
{'y', 0x15, 0x95},
{'u', 0x16, 0x96},
{'i', 0x17, 0x97},
{'o', 0x18, 0x98},
{'p', 0x19, 0x99},
{'a', 0x1e, 0x9e},
{'s', 0x1f, 0x9f},
{'d', 0x20, 0xa0},
{'f', 0x21, 0xa1},
{'g', 0x22, 0xa2},
{'h', 0x23, 0xa3},
{'j', 0x24, 0xa4},
{'k', 0x25, 0xa5},
{'l', 0x26, 0xa6},
{'z', 0x2c, 0xac},
{'x', 0x2d, 0xad},
{'c', 0x2e, 0xae},
{'v', 0x2f, 0xaf},
{'b', 0x30, 0xb0},
{'n', 0x31, 0xb1},
{'m', 0x32, 0xb2},

{'.', 0x35, 0xb5},

{KEYMAP_KEY_INVALID, 0, 0}, /* end of table */

But I was confused about handling caps lock or shift keys, since keyboard set to raw mode via ioctl(keyboardFd, KDSKBMODE, K_RAW) in fb_port.c.

What should be the preferred way of doing this?

Thanks in advance.

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Joined: 2007-01-05
Points: 0

Caps lock sucks anyhow, but Shift is quite useful =) I added shift support by adding a "shift is down" variable in the native code, and outputing upper case letters when shift was down instead of lower case (only for characters a-z). It's kind of an semihack, but it works just fine with only minor source code changes.

Joined: 2006-10-11
Points: 0

just the thing I'm trying now :)

I can control the caps lock programmatically, but it's not worth it.

How are you handling the multi byte keys?

Joined: 2007-01-05
Points: 0

What multi byte keys? (I guess that answers your question, I'm only handling A-Z basically).