Input: Hard-keys input support using libinput and weston 1.8.0

Peter Hutterer peter.hutterer at who-t.net
Thu Nov 5 23:29:56 PST 2015


On Mon, Nov 02, 2015 at 11:51:03AM +0530, Vikas Patil wrote:
> On Mon, Nov 2, 2015 at 7:56 AM, Peter Hutterer <peter.hutterer at who-t.net> wrote:
> >
> > On Fri, Oct 30, 2015 at 11:43:34AM +0530, Vikas Patil wrote:
> > > I have a requirement where Hard-Keys input events (e.g. Home button, Back
> > > button, Volume buttons or Volume Rotary Knobs) needs to be injected into
> > > weston compositor and passed to application or application can listen on
> > > those events using wayland/weston some way.
> >hardkey button
> > probably best to explain the use-case you have in a bit more detail, there
> > may be more than one solution (or zero, come to think of it :)
> >
> 
> I like to provide a wayland/weston APIs to application developer to
> handle hardkey button events (something similar wl_touch, wl_keyboard
> usage, in my case it can be wl_hardkey may be). I have five hard-keys
> on IVI device connected via GPIO (button 1, button 2, power button,
> rotatry knob (connected to two gpio)). These keys usage it not clear
> to me at the moment but any application can use I think. Will give
> more information once I get.
> 
> Is there any other method available without providing standard wayland
> API to application developer to detect hard key evevnt and act on it?

not that I'm aware of. Injection of arbitrary events is not easy, though you
could look up what virtual keyboards do, I forgot how they work in detail
under layout.

But long term we probably need to figure out a wayland protocol to let us do
this. This isn't the only use-case where it's required, braille keyboards
come to mind for example.

> One possible way to implement this is to inject hardkey event as
> keyboard event to "evdev but not sure what all changes are required in
> complete input stack? I think need to start with evdev modification to
> throw the events with require data.
> 
> 
> > > Does weston 1.8.0 and libinput supports such kind of inputs? Or Do I need
> > > to extend the full path of input (evdev -> libinput -> weston) to support
> > > this? How much effort require for this?Thanks
> > >
> > > Could you give some suggestions/ideas to start this as I am very new to
> > > input handling? It would be also helpful if you could refer me some
> > > docs/links to understand this?
> >
> > libinput forwards key events from evdev devices pretty much as-is, weston
> > handles it depending on the keyboard layout. so one solution is to create a
> > uinput device that generates those events and let the rest of the stack do
> > the thing it does anyway. That requires root privs to create the uinput
> > device though.
> >
> 
> Thanks for the suggestion. Will look into uinput. Does this means
> application then would be able to handle the hardkey as mapped key
> (e.g. button 1 mapped tp A) events inside app?

if you're going the uinput route, your device will look like a physical
keyboard and all mappings are done in userspace. e.g. KEY_Q may end up
being mapped to 'a' if a French layout is applied.
you won't have control over this mapping on the uinput level.

Cheers,
   Peter

> 
> > http://wayland.freedesktop.org/libinput/doc/latest/ has a simple
> > architecture diagram.
> > you can't inject events into libinput directly, and afaik there is no
> > waylan protocol extension to allow you to this there either.
> >
> 
> 
> Best Regards,
> Vikash


More information about the wayland-devel mailing list