Specifications
CHAPTER 5. IMPLEMENTATION 38
When an input event occurs, the module reports this event by creating an abstract input
event IalEvent followed by a call to the library’s function event send(). The following
example illustrates this procedure:
/* Create abstract input event. */
IalEvent event;
/* Fill all members. */
event.sender = mod_data.token;
event.source = "Interface Name";
event.name = "Brightness Up";
event.raw = 0x130;
/* Send the event using libial. */
event_send(&event);
The member sender has to be set to the token of the reporting module. The value of
source should be set to the name of the original input interface from which the module has
received the event. If the module is able to determine a name for the event, the member name
should be set up. The same applies to the member raw: if available, it represents a unique
numeric value for the event.
Understanding the full scope of the associations between the modules and the daemon
is only possible by investigating the daemon in detail. Hence, the daemon and its run-time
behavior are discussed in the next section. Several different module implementations are
discussed after the description of the daemon. This will give the final explanation of the
context of the modules and the daemon.
5.4 Daemon
The daemon is the Input Abstraction Layer’s core component. It sets up the environment by
initializing the configuration and loading the modules. It is implemented with the focus of us-
ing as few resources as possible. The daemon is subdivided into three parts: the daemon core
(iald.c), the configuration file parser (iald conf.c) and the module loader (iald mod.c).
The daemon itself implements the command line parser and D-BUS functions. The configura-
tion file parser uses libxml2 to parse the daemon’s configuration file /etc/iald/iald.conf.
The functions provided by the module loader are used to locate, verify, initialize and start the
modules. The start-up of the daemon is partitioned into six stages:
– Stage 1: Load modules
– Stage 2: Parse configuration file
– Stage 3: Parse command line options
– Stage 4: Set up D-BUS environment
– Stage 5: Invoke modules
– Stage 6: Enter event loop