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 typedef void (*uterm_input_log_t) (void *data,
52 /* keep in sync with shl_xkb_mods */
53 enum uterm_input_modifier {
54 UTERM_SHIFT_MASK = (1 << 0),
55 UTERM_LOCK_MASK = (1 << 1),
56 UTERM_CONTROL_MASK = (1 << 2),
57 UTERM_ALT_MASK = (1 << 3),
58 UTERM_LOGO_MASK = (1 << 4),
61 /* keep in sync with TSM_VTE_INVALID */
62 #define UTERM_INPUT_INVALID 0xffffffff
64 struct uterm_input_event {
65 bool handled; /* user-controlled, default is false */
66 uint16_t keycode; /* linux keycode - KEY_* - linux/input.h */
67 uint32_t ascii; /* ascii keysym for @keycode */
68 unsigned int mods; /* active modifiers - uterm_modifier mask */
70 unsigned int num_syms; /* number of keysyms */
71 uint32_t *keysyms; /* XKB-common keysym-array - XKB_KEY_* */
72 uint32_t *codepoints; /* ucs4 unicode value or UTERM_INPUT_INVALID */
75 #define UTERM_INPUT_HAS_MODS(_ev, _mods) (((_ev)->mods & (_mods)) == (_mods))
77 typedef void (*uterm_input_cb) (struct uterm_input *input,
78 struct uterm_input_event *ev,
81 int uterm_input_new(struct uterm_input **out, struct ev_eloop *eloop,
82 const char *model, const char *layout, const char *variant,
83 const char *options, const char *keymap,
84 unsigned int repeat_delay, unsigned int repeat_rate,
85 uterm_input_log_t log, void *log_data);
86 void uterm_input_ref(struct uterm_input *input);
87 void uterm_input_unref(struct uterm_input *input);
89 void uterm_input_add_dev(struct uterm_input *input, const char *node);
90 void uterm_input_remove_dev(struct uterm_input *input, const char *node);
92 int uterm_input_register_cb(struct uterm_input *input, uterm_input_cb cb,
94 void uterm_input_unregister_cb(struct uterm_input *input, uterm_input_cb cb,
97 void uterm_input_sleep(struct uterm_input *input);
98 void uterm_input_wake_up(struct uterm_input *input);
99 bool uterm_input_is_awake(struct uterm_input *input);
101 #endif /* UTERM_UTERM_INPUT_H */