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>
35 #include <xkbcommon/xkbcommon.h>
38 typedef struct idev_data idev_data;
39 typedef struct idev_data_evdev idev_data_evdev;
40 typedef struct idev_data_keyboard idev_data_keyboard;
42 typedef struct idev_event idev_event;
43 typedef struct idev_device idev_device;
44 typedef struct idev_session idev_session;
45 typedef struct idev_context idev_context;
65 struct idev_data_evdev {
66 struct input_event event;
76 IDEV_KBDMOD_IDX_SHIFT,
79 IDEV_KBDMOD_IDX_LINUX,
83 IDEV_KBDMOD_SHIFT = 1 << IDEV_KBDMOD_IDX_SHIFT,
84 IDEV_KBDMOD_CTRL = 1 << IDEV_KBDMOD_IDX_CTRL,
85 IDEV_KBDMOD_ALT = 1 << IDEV_KBDMOD_IDX_ALT,
86 IDEV_KBDMOD_LINUX = 1 << IDEV_KBDMOD_IDX_LINUX,
87 IDEV_KBDMOD_CAPS = 1 << IDEV_KBDMOD_IDX_CAPS,
93 IDEV_KBDLED_IDX_SCROLL,
96 IDEV_KBDLED_NUM = 1 << IDEV_KBDLED_IDX_NUM,
97 IDEV_KBDLED_CAPS = 1 << IDEV_KBDLED_IDX_CAPS,
98 IDEV_KBDLED_SCROLL = 1 << IDEV_KBDLED_IDX_SCROLL,
101 struct idev_data_keyboard {
102 struct xkb_state *xkb_state;
107 uint32_t consumed_mods;
110 uint32_t *codepoints;
129 idev_data_evdev evdev;
130 idev_data_keyboard keyboard;
139 IDEV_EVENT_DEVICE_ADD,
140 IDEV_EVENT_DEVICE_REMOVE,
141 IDEV_EVENT_DEVICE_DATA,
150 } device_add, device_remove;
159 typedef int (*idev_event_fn) (idev_session *s, void *userdata, idev_event *ev);
165 void idev_device_enable(idev_device *d);
166 void idev_device_disable(idev_device *d);
173 IDEV_SESSION_CUSTOM = (1 << 0),
174 IDEV_SESSION_MANAGED = (1 << 1),
177 int idev_session_new(idev_session **out,
181 idev_event_fn event_fn,
183 idev_session *idev_session_free(idev_session *s);
185 DEFINE_TRIVIAL_CLEANUP_FUNC(idev_session*, idev_session_free);
187 bool idev_session_is_enabled(idev_session *s);
188 void idev_session_enable(idev_session *s);
189 void idev_session_disable(idev_session *s);
191 int idev_session_add_evdev(idev_session *s, struct udev_device *ud);
192 int idev_session_remove_evdev(idev_session *s, struct udev_device *ud);
198 int idev_context_new(idev_context **out, sd_event *event, sd_bus *sysbus);
199 idev_context *idev_context_ref(idev_context *c);
200 idev_context *idev_context_unref(idev_context *c);
202 DEFINE_TRIVIAL_CLEANUP_FUNC(idev_context*, idev_context_unref);