1.1 --- a/pkg/devices/input/include/input-event-loop.h Fri May 18 18:43:30 2018 +0200
1.2 +++ b/pkg/devices/input/include/input-event-loop.h Fri May 18 22:34:51 2018 +0200
1.3 @@ -23,66 +23,53 @@
1.4
1.5 #ifdef __cplusplus
1.6
1.7 +#include <l4/devices/event-loop.h>
1.8 +
1.9 #include <l4/re/event>
1.10 #include <l4/sys/capability>
1.11 #include <l4/sys/icu>
1.12
1.13 -#include <pthread.h>
1.14 -#include <pthread-l4.h>
1.15 -
1.16 -/* POSIX-thread-compatible handler function type. */
1.17 -
1.18 -typedef void (*Event_handler)(L4Re::Event_buffer::Event &, void *);
1.19 +typedef L4Re::Event_buffer::Event Event_type;
1.20
1.21 /* Input event loop abstraction. */
1.22
1.23 -class Input_event_loop
1.24 +class Input_event_loop : public Event_loop
1.25 {
1.26 - /* Notification interrupt capability. */
1.27 -
1.28 - L4::Cap<L4::Irq> _irq;
1.29 -
1.30 + /* Handler function type. */
1.31 +
1.32 + typedef void (*Event_handler)(Event_type &, void *);
1.33 +
1.34 /* External handler function. */
1.35 -
1.36 +
1.37 Event_handler _handler;
1.38
1.39 - /* Private data for the handler. */
1.40 -
1.41 - void *_priv;
1.42 -
1.43 /* Event buffer and notification interrupt capability. */
1.44
1.45 L4Re::Event_buffer _event_buffer;
1.46
1.47 - /* Thread properties. */
1.48 + /* Notification interrupt capability. */
1.49
1.50 - int _priority;
1.51 - pthread_t _pthread;
1.52 + L4::Cap<L4::Irq> _irq;
1.53
1.54 public:
1.55 - /* Initialise the event loop with a notification interrupt, thread priority,
1.56 - event handler function and private data, and an event buffer. */
1.57 + /* Initialise the event loop with an event handler function and private data,
1.58 + an event buffer, a notification interrupt, and a thread priority. */
1.59
1.60 - explicit Input_event_loop(L4::Cap<L4::Irq> irq,
1.61 - Event_handler handler, void *priv,
1.62 + explicit Input_event_loop(Event_handler handler, void *priv,
1.63 L4Re::Event_buffer event_buffer,
1.64 + L4::Cap<L4::Irq> irq,
1.65 int priority=0x20)
1.66 - : _irq(irq), _handler(handler), _priv(priv), _event_buffer(event_buffer),
1.67 - _priority(priority)
1.68 + : _handler(handler), Event_loop(priv, priority), _event_buffer(event_buffer), _irq(irq)
1.69 {
1.70 }
1.71
1.72 - /* Static main loop function for event-handling thread. */
1.73 -
1.74 - static void *event_loop(void *data);
1.75 -
1.76 /* Event handler method. */
1.77
1.78 - void handle();
1.79 + virtual void handle();
1.80
1.81 /* Initiation function. */
1.82
1.83 - void start();
1.84 + virtual void start(l4_umword_t label=0xDF00);
1.85 };
1.86
1.87 #endif