1 /*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
4 This file is part of systemd.
6 Copyright (C) 2014 David Herrmann <dh.herrmann@gmail.com>
8 systemd is free software; you can redistribute it and/or modify it
9 under the terms of the GNU Lesser General Public License as published by
10 the Free Software Foundation; either version 2.1 of the License, or
11 (at your option) any later version.
13 systemd is distributed in the hope that it will be useful, but
14 WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 Lesser General Public License for more details.
18 You should have received a copy of the GNU Lesser General Public License
19 along with systemd; If not, see <http://www.gnu.org/licenses/>.
30 #include <linux/input.h>
33 #include <systemd/sd-bus.h>
34 #include <systemd/sd-event.h>
37 typedef struct idev_data idev_data;
38 typedef struct idev_data_evdev idev_data_evdev;
40 typedef struct idev_event idev_event;
41 typedef struct idev_device idev_device;
42 typedef struct idev_session idev_session;
43 typedef struct idev_context idev_context;
62 struct idev_data_evdev {
63 struct input_event event;
81 idev_data_evdev evdev;
90 IDEV_EVENT_DEVICE_ADD,
91 IDEV_EVENT_DEVICE_REMOVE,
92 IDEV_EVENT_DEVICE_DATA,
101 } device_add, device_remove;
110 typedef int (*idev_event_fn) (idev_session *s, void *userdata, idev_event *ev);
116 void idev_device_enable(idev_device *d);
117 void idev_device_disable(idev_device *d);
124 IDEV_SESSION_CUSTOM = (1 << 0),
125 IDEV_SESSION_MANAGED = (1 << 1),
128 int idev_session_new(idev_session **out,
132 idev_event_fn event_fn,
134 idev_session *idev_session_free(idev_session *s);
136 DEFINE_TRIVIAL_CLEANUP_FUNC(idev_session*, idev_session_free);
138 bool idev_session_is_enabled(idev_session *s);
139 void idev_session_enable(idev_session *s);
140 void idev_session_disable(idev_session *s);
142 int idev_session_add_evdev(idev_session *s, struct udev_device *ud);
143 int idev_session_remove_evdev(idev_session *s, struct udev_device *ud);
149 int idev_context_new(idev_context **out, sd_event *event, sd_bus *sysbus);
150 idev_context *idev_context_ref(idev_context *c);
151 idev_context *idev_context_unref(idev_context *c);
153 DEFINE_TRIVIAL_CLEANUP_FUNC(idev_context*, idev_context_unref);