2 * uterm - Linux User-Space Terminal Input Handling
4 * Copyright (c) 2011-2013 David Herrmann <dh.herrmann@googlemail.com>
6 * Permission is hereby granted, free of charge, to any person obtaining
7 * a copy of this software and associated documentation files
8 * (the "Software"), to deal in the Software without restriction, including
9 * without limitation the rights to use, copy, modify, merge, publish,
10 * distribute, sublicense, and/or sell copies of the Software, and to
11 * permit persons to whom the Software is furnished to do so, subject to
12 * the following conditions:
14 * The above copyright notice and this permission notice shall be included
15 * in all copies or substantial portions of the Software.
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
21 * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
22 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
23 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
28 * This input object can combine multiple linux input devices into a single
29 * device and notifies the application about events. It has several different
30 * keyboard backends so the full XKB feature set is available.
33 #ifndef UTERM_UTERM_INPUT_H
34 #define UTERM_UTERM_INPUT_H
43 /* keep in sync with shl_xkb_mods */
44 enum uterm_input_modifier {
45 UTERM_SHIFT_MASK = (1 << 0),
46 UTERM_LOCK_MASK = (1 << 1),
47 UTERM_CONTROL_MASK = (1 << 2),
48 UTERM_ALT_MASK = (1 << 3),
49 UTERM_LOGO_MASK = (1 << 4),
52 /* keep in sync with TSM_VTE_INVALID */
53 #define UTERM_INPUT_INVALID 0xffffffff
55 struct uterm_input_event {
56 bool handled; /* user-controlled, default is false */
57 uint16_t keycode; /* linux keycode - KEY_* - linux/input.h */
58 uint32_t ascii; /* ascii keysym for @keycode */
59 unsigned int mods; /* active modifiers - uterm_modifier mask */
61 unsigned int num_syms; /* number of keysyms */
62 uint32_t *keysyms; /* XKB-common keysym-array - XKB_KEY_* */
63 uint32_t *codepoints; /* ucs4 unicode value or UTERM_INPUT_INVALID */
66 #define UTERM_INPUT_HAS_MODS(_ev, _mods) (((_ev)->mods & (_mods)) == (_mods))
68 typedef void (*uterm_input_cb) (struct uterm_input *input,
69 struct uterm_input_event *ev,
72 int uterm_input_new(struct uterm_input **out, struct ev_eloop *eloop,
73 const char *model, const char *layout, const char *variant,
74 const char *options, unsigned int repeat_delay,
75 unsigned int repeat_rate);
76 void uterm_input_ref(struct uterm_input *input);
77 void uterm_input_unref(struct uterm_input *input);
79 void uterm_input_add_dev(struct uterm_input *input, const char *node);
80 void uterm_input_remove_dev(struct uterm_input *input, const char *node);
82 int uterm_input_register_cb(struct uterm_input *input, uterm_input_cb cb,
84 void uterm_input_unregister_cb(struct uterm_input *input, uterm_input_cb cb,
87 void uterm_input_sleep(struct uterm_input *input);
88 void uterm_input_wake_up(struct uterm_input *input);
89 bool uterm_input_is_awake(struct uterm_input *input);
91 #endif /* UTERM_UTERM_INPUT_H */