Home

How to write plugins for the input feedback daemon in MeeGo Touch

Introduction

The input feedbacks of the Meego devices are controlled by a daemon (meegofeedbackd) in the MeeGo Touch Framework. The daemon handles the available actuators via plug-ins called *backends*. The backends have a minimal set of functions what should be implemented and some functional requirements are placed to work with daemon flawlessly.

Feedback volume configuration categories and configuration keys

The feedbacks are identified by name. For instance, the user touches a button on the screen, the "press" feedback is played. A feedback is composed of one or more *handles* which is an effect played via an actuator. For example, the "press" feedback will play an audio and a vibra effect simultaneously. The handles are loaded/unloaded and played with the backends. The daemon does not know anything about the handles, it is only a generic pointer, but the backend contains the logic to understand the data behind. On the other hand, the daemon hides the input feedback interfaces from the backends. The backend purely manages the actuator hardware and the handles and nothing else. Two default, official plug-ins are shipped in the Harmattan program:

As it is stated above, the official backends do not use the lower level interfaces (e.g. kernel drivers) of the actuators, but an other daemon provides interface for the hardware. A good reason is that other daemons handle e.g. permissions among the programs and users to access the hardware resources. To play effects on an actuator, the connection should be established/initialized for the resource. The backends connect to the hardware resources and a dropped connection needs notification to the meegofeedbackd to reconnect later again.

Example

The backends must comply with the basic requirements of the Qt managed plug-ins (QPluginLoader) and the declaration in libmeegofeedback:

In the list above, the MfBackendBase class is inherited from the MfBackendInterface and QObject to provide common functions of the backends (e.g. reconnection logic). A Qt plug-in must be an abstract declaration, therefore, an additional inheritance was needed to implement these.

Abstract methods in a new backend

A backend should have implementation for the following pure virtual and virtual methods:

Implementation details

There are dummy plug-ins included in the source package of the meegofeedbackd as examples. Please note that the test plug-in are mainly meant for testing purposes. The daemon calls some wrapper functions in the MfBackendBase to implement some common logic in the functions to avoid code duplications. When the following virtual functions are called from the input feedback daemon, you can be sure, the following pre-requisites are checked and no need to verify in your backend implementation:

The following notes describe more detailed functional requirements against the backends:

Threaded and non-threaded backends

The backend plug-ins should be installed in the directory /usr/lib/meegofeedbackd and making a symlink into the directory threaded-backends. The form of the symlink is "XX-libmeegofeedback-backendname.so". The intention of this is to have a number instead of XX and the backends will be loaded in increasing order.

The official backends (vibra and audio) are symlinked to the non-threaded directory, which means that if a feedback is played, the audio and the vibra effects are played by calling the play() function of the backends sequentially from the sam thread. It places a requirement for any non-threaded backends: the play function must return back immediately. The recommended use of the 3-rd party plug-ins is to specify them as threaded, which means that their play() function is called in a separate thread to avoid blocking of the play() function calls of the non-threaded backends.


Copyright © 2010 Nokia Corporation
MeeGo Touch