Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I have written an character device, I want to declare it as the keyboard and use it to generate events from the virtual keyboard?

share|improve this question
    
Would it be more suitable to change the char device that you have written into an input device? Or is it not just for input events? –  Jeremy Kerr Oct 23 '12 at 1:03
    
How do I make it an input device? After that, How do I declare it as a keyboard? –  snihalani Oct 23 '12 at 3:19
    
That depends on the device that you've written. Generally, you'd register an input device with input_register_device, then send key events to the input stack using input_event. –  Jeremy Kerr Oct 23 '12 at 5:50
    
Is there a place where I can read how to write an input device and register my keyboard events? –  snihalani Oct 23 '12 at 15:08
    
... added details as an answer. –  Jeremy Kerr Oct 24 '12 at 6:52
show 2 more comments

1 Answer

up vote 0 down vote accepted

If you've written the character device driver yourself, and it is intended to be used as an input device, then you might be best off altering your driver to work as an input device instead of a generic character device.

Fortunately, there is some good documentation in the kernel tree, at:

Documentation/input/input-programming.txt

For an online version, take a look at the input-programming.txt file in the linux tree on kernel.org.

Basically, you'll create a struct input_dev, and register it with the input subsystem with input_register_device. Input events can then be sent to the input layer with input_event, or one of the helper functions like input_report_key.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.