How to read keys from USB keyboard on AT91SAM9260

Hi Everyone,

I am using 2.6.26.3-olimex kernel(Embedded system) running on AT91SAM9260. I am using a Logitech USB keyboard.

It is detected as "/dev/input/event0".

I don't know how to detect key press events and read the keys?

Why can't I read the keys using scanf() like funtions?

Can anyone help me?

Regards,
Siva

Your embedded system's kernel may not have been built with keyboard support, being an embedded system...

Thanks for your response.

I have enabled the following options in the menuconfig file while building uImage.

Input Device Support --> Event Interface
Keyboards --> AT Keyboard
HID Devices --> USB Human Interface Device support
HID Devices --> PID device support
Special HID Drivers --> Logitech and Logitech force feedback

After booting the kernel, USB key board detected as "/dev/input/event0".

I don't know why I can't use this as stdin?

Am I missing some thing here?

You're getting closer. :slight_smile:

What kernel version? What options may depend on it. In my kernel at least, 2.6.27, you also need the <*>Generic Input Layer, under Input Device Support in Device Drivers.

I have enabled Generic Input Layer, under Input Device Support in Device Drivers.

But still I can not use USB key board as stdin.

Have I missed something else?

I'm reaching the limits of my knowledge here, I'm not sure how Linux decides what keyboard device to use with what physical terminal device. I do know that the keyboard does not literally become stdin -- that'd be an easy fix if it did, but the event interface reports raw key codes, not actual keystrokes. Instead linux pairs a physical keyboard with some sort of physical output device in order to create a terminal device to interact with.

I don't know what programs your embedded system actually has. I don't know what your embedded system actually is beyond what processor runs it. Your system may just not be configured to use it. The content of /etc/inittab, and the complete listing of /dev/, might be useful to figuring this out.

It'd also help if you replied more than once every three weeks.

Thanks for your response.

I am using AT91SAM9260 controller with Linux 2.6.30.4 kernel.

I have attached my /etc/initab/ entries and /dev/ entries.

Please have a look into them and share your views.

Well, your inittab makes one thing clear... Your system creates one and only one terminal, hardwired to the serial port and nothing else.

I don't know of any straightforward way to attach your keyboard to it instead, though, for a couple reasons:

  • A keyboard is not a terminal. You cannot write data to a keyboard. You need to somehow multiplex two things into one device here.
  • You could easily brick your machine here by messing up the primary terminal. Does it by any chance have a second serial port?

I've been looking for a way to multiplex two things into one device. Nothing yet. It might be necessary to create a pseudo-terminal device yourself and emulate it.