Specifications

CHAPTER 5. IMPLEMENTATION 49
which should be observed. The second argument states the conditions that have to be met
to trigger an event. In the example two conditions are supplied: G IO IN and G IO ERR.
The condition G IO IN is fulfilled if data is pending to be read from the io channel. This
implies that an event on the interface /dev/interface has happened. The second condition
G IO ERR is fulfilled if an error occurred while reading from the io channel and therefore, from
/dev/interface. The argument event callback is the callback function which is invoked by
the event loop as soon as one of the given conditions is fulfilled. This callback function is called
with the parameter data (gpointer).
Figure 5.7 gives an overview of the event loop, events and callback functions. One function
(shown as “Function A”) was added to the event loop using g timeout add(). The other
function (“Function B”) was added using the combination of a GIOChannel and a watch created
by g io add watch(). On each iteration, the event loop evaluates if the interval for “Function
A” has elapsed. Once the time has elapsed, the function is invoked and the event loop continues
its iteration afterwards. Otherwise, the event loop continues without invoking “Function A”.
The same procedure applies to “Function B”: if a condition for the GIOChannel is fulfilled,
“Function B” is invoked. Otherwise, the event loop continues on.
Callback FunctionsEvent Loop
Time elapsed?
YesNo
YesNo
Contition fulfilled?
Timeout Event
I/O Channel Event
Function B
Function A
Events
Figure 5.7: Input Abstraction Layer Event Loop
5.5 Event Interface Module
The event interface module libial evdev is responsible for reporting any input events trig-
gered by an input device driver using the Linux input core (Chapter 2, §2.1). On that ground,
this module is responsible for generating abstract input events for the following input devices:
Regular keyboards (Chapter 2, §2.2)
USB keyboards (Chapter 2, §2.3)
Bluetooth keyboards (Chapter 2, §2.4)
Acer and Hewlett Packard function keys (Chapter 2, §2.7)
The reporting of keyboard input events realized with this module is most essential. As
pointed out in Chapter 2, §2.2 the keyboard handler only reports input events for which
a translation from scan- to keycode is available. But most Linux systems do not have a
translation table for special and multimedia keys by default. The event interface closes this