Page tree
Skip to end of metadata
Go to start of metadata

Main benefits of new API:

  • It was not possible to differentiate between different input devices of the same type.
  • New input logic(grab interfaces) is included, which is very different than default input logic of weston.
  • Input devices can be grouped into wayland seats using udev rules. Then, these seats can be accepted or declined as a group by applications.

How to build with new Input Handling APIs

Configure it with the cmake flag "WITH_ILM_INPUT":

$ git clone http://git.projects.genivi.org/wayland-ivi-extension.git
$ mkdir build-wayland-ivi-extension
$ cd build-wayland-ivi-extension
$ cmake ./ -DWITH_ILM_INPUT=1 ../wayland-ivi-extension
$ make
$ make install 

These files should be installed after successful install:

.
└── usr
    ├── bin
    │   ├── EGLWLInputEventExample
    │   ├── EGLWLMockNavigation
    │   └── LayerManagerControl
    └── lib
        ├── libilmClient.so.1.3.91
        ├── libilmCommon.so.1.3.91
        ├── libilmControl.so.1.3.91
        ├── libilmInput.so.1.3.91
        └── weston
            ├── ivi-controller.so
            └── ivi-input-controller.so

Start weston with new API

A minimalistic weston.ini for the new API:

[core]
shell=ivi-shell.so

[ivi-shell]
ivi-module=ivi-controller.so,ivi-input-controller.so

This comment will show up at weston startup, if it is started with the new ILM APIs:

ivi-input-controller module loaded successfully!

Basic Use

There is always at least one wayland seat in the system. This seat is called "default" seat. All input devices belongs to default seat, if no udev rules are written to group input devices to another seat. Every surface has initially accepted by the default seat.

The list of recognized input devices of default seat is shown from a process :

t_ilm_string seats[] = {"default"};
ilmInputDevice bitmask;

ilm_getInputDeviceCapabilities(seats[1], &bitmask));

or from the command line:

$ /usr/bin/LayerManagerControl get input device default capabilities 

example output of the command:

keyboard
touch

Keyboard Focus

Start InputEventExample with surface id 50 for the demonstration:

$/usr/bin/EGLWLInputEventExample -s 50 &

Control its acceptance:

$/usr/bin/LayerManagerControl get surface 50 acceptance 

It should have acceptance to default seat:

$default

Then, keyboard focus can be set with the command:

$/usr/bin/LayerManagerControl set surfaces 50 input focus keyboard 

or in the source code:

t_ilm_surface *surfaceIDs = {50};
t_ilm_uint num_surfaces = 1;
ilmInputDevice device = ILM_INPUT_DEVICE_KEYBOARD;
t_ilm_bool is_set = ILM_TRUE;

ilm_setInputFocus(surfaceIDs, num_surfaces, device, is_set) 

to unset the keyboard focus:

$/usr/bin/LayerManagerControl unset surfaces 50 input focus keyboard 

or in the source code:

t_ilm_surface *surfaceIDs = {50};
t_ilm_uint num_surfaces = 1;
ilmInputDevice device = ILM_INPUT_DEVICE_KEYBOARD;
t_ilm_bool is_set = ILM_FALSE;

ilm_setInputFocus(surfaceIDs, num_surfaces, device, is_set)

Pointer Focus

Start InputEventExample with surface id 50 for the demonstration:

$/usr/bin/EGLWLInputEventExample -s 50 &

Control its acceptance:

$/usr/bin/LayerManagerControl get surface 50 acceptance 

It should have acceptance to default seat:

$default

Check the capabilities of the default seat:

$ /usr/bin/LayerManagerControl get input device default capabilities 

it should have a pointer device:

keyboard
pointer
touch

There are two ways to set pointer focus to a surface:

  • Using ilm_setInputFocus API
  • Clicking (button event) to the surface with the pointer device

Setting pointer focus with the API:

$/usr/bin/LayerManagerControl set surfaces 50 input focus pointer 

or in the source code:

t_ilm_surface *surfaceIDs = {50};
t_ilm_uint num_surfaces = 1;
ilmInputDevice device = ILM_INPUT_DEVICE_POINTER;
t_ilm_bool is_set = ILM_TRUE;

ilm_setInputFocus(surfaceIDs, num_surfaces, device, is_set) 

to unset the pointer focus:

$/usr/bin/LayerManagerControl unset surfaces 50 input focus pointer 

or in the source code:

t_ilm_surface *surfaceIDs = {50};
t_ilm_uint num_surfaces = 1;
ilmInputDevice device = ILM_INPUT_DEVICE_POINTER;
t_ilm_bool is_set = ILM_FALSE;

ilm_setInputFocus(surfaceIDs, num_surfaces, device, is_set)

Touch Focus

Start InputEventExample with surface id 50 for the demonstration:

$/usr/bin/EGLWLInputEventExample -s 50 &

Control its acceptance:

$/usr/bin/LayerManagerControl get surface 50 acceptance 

It should have acceptance to default seat:

$default

Check the capabilities of the default seat:

$ /usr/bin/LayerManagerControl get input device default capabilities 

it should have a touch device:

keyboard
pointer
touch

There are two ways to set touch focus to a surface:

  • Using ilm_setInputFocus API
  • Touching (touch down event) to the surface on the touchscreen.

Setting pointer focus with the API:

$/usr/bin/LayerManagerControl set surfaces 50 input focus touch 

or in the source code:

t_ilm_surface *surfaceIDs = {50};
t_ilm_uint num_surfaces = 1;
ilmInputDevice device = ILM_INPUT_DEVICE_TOUCH;
t_ilm_bool is_set = ILM_TRUE;

ilm_setInputFocus(surfaceIDs, num_surfaces, device, is_set) 

to unset the pointer focus:

$/usr/bin/LayerManagerControl unset surfaces 50 input focus touch 

or in the source code:

t_ilm_surface *surfaceIDs = {50};
t_ilm_uint num_surfaces = 1;
ilmInputDevice device = ILM_INPUT_DEVICE_TOUCH;
t_ilm_bool is_set = ILM_FALSE;

ilm_setInputFocus(surfaceIDs, num_surfaces, device, is_set)

Advanced Use

It is not possible to differentiate multiple input devices of the same typ, if they are not grouped into different seats. Different seats should be defined with udev rules to be able to route their inputs into different applications.

Grouping input devices to different seats

Udev rules are used to group input devices to seats. Udev provides these match keys:

  • KERNELS - match against the kernel name for the device, or the kernel name for any of the parent devices
  • SUBSYSTEMS - match against the subsystem of the device, or the subsystem of any of the parent devices
  • DRIVERS - match against the name of the driver backing the device, or the name of the driver backing any of the parent devices
  • ATTRS - match a sysfs attribute of the device, or a sysfs attribute of any of the parent devices

A seat can be defined for every input device:

ATTRS{name}=="<sysfs name of the pointer>", ENV{WL_SEAT}="seat_pointer"
ATTRS{name}=="<sysfs name of the keyboard 1>", ENV{WL_SEAT}="seat_keyboard_1"
ATTRS{name}=="<sysfs name of the keyboard 2>", ENV{WL_SEAT}="seat_keyboard_2"

or multiple input devices can be grouped into one seat:

ATTRS{name}=="<sysfs name of the pointer>", ENV{WL_SEAT}="seat_pointer"
ATTRS{name}=="<sysfs name of the keyboard 1>", ENV{WL_SEAT}="seat_keyboard"
ATTRS{name}=="<sysfs name of the keyboard 2>", ENV{WL_SEAT}="seat_keyboard"

Example use-case[edit]

There are two applications on this example use-case:

  • Media Player with Surface-ID = 100
  • Bluetooth Telephone with Surface-ID = 200

There are two group of buttons on the steering wheel of the car:

  • Volume Up/Down buttons
  • Open/Close conversation buttons

Desired behaviour is:

  • Media Player should get input events only from Volume Up/Down buttons
  • Bluetooth Telephone application should get input events from Volume Up/Down and Open/Close conversation buttons

First, udev rules should be written to separete both button groups:

ATTRS{name}=="<sysfs name of the device with volume buttons>", ENV{WL_SEAT}="seat_volume"
ATTRS{name}=="<sysfs name of the device with conversation buttons>", ENV{WL_SEAT}="seat_conversation"

Second, input acceptance of Media Player and Telephone application are modified for the desired behaviour:

$ /usr/bin/LayerManagerControl set surface 100 input acceptance to seat_volume
$ /usr/bin/LayerManagerControl set surface 200 input acceptance to seat_volume,seat_conversation

or source code:

t_ilm_surface surface_media = 100, surface_telephone = 200;
t_ilm_string media_seats[] = {"seat_volume"};
t_ilm_string telephone_seats[] = {"seat_volume","seat_conversation"};

/* Set input acceptance for media player */
ilm_setInputAcceptanceOn(surface_media, 1, media_seats));

/* Set input acceptance for bluetooth telephone */
ilm_setInputAcceptanceOn(surface_telephone, 2, telephone_seats));

Third, set keyboard focus for both of the applications:

$ /usr/bin/LayerManagerControl set surfaces 100,200 input focus keyboard

or source code:

t_ilm_surface surfaces [] = {100,200};
ilmInputDevice device = ILM_INPUT_DEVICE_KEYBOARD;
t_ilm_bool enabled = ILM_TRUE;

/* Set keyboard focus */
ilm_setInputFocus(surfaces, 2, device, enabled);

 

 

Copied from MediaWiki
Last Edit: 10:31, 25 June 2015‎ Emre.ucan

  • No labels