Modify it to adjust Tizen IVI enviroment
[platform/upstream/kmscon.git] / src / uterm_input.h
1 /*
2  * uterm - Linux User-Space Terminal Input Handling
3  *
4  * Copyright (c) 2011-2013 David Herrmann <dh.herrmann@googlemail.com>
5  *
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:
13  *
14  * The above copyright notice and this permission notice shall be included
15  * in all copies or substantial portions of the Software.
16  *
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.
24  */
25
26 /*
27  * Input Devices
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.
31  */
32
33 #ifndef UTERM_UTERM_INPUT_H
34 #define UTERM_UTERM_INPUT_H
35
36 #include <eloop.h>
37 #include <inttypes.h>
38 #include <stdbool.h>
39 #include <stdlib.h>
40
41 struct uterm_input;
42
43 typedef void (*uterm_input_log_t) (void *data,
44                                    const char *file,
45                                    int line,
46                                    const char *func,
47                                    const char *subs,
48                                    unsigned int sev,
49                                    const char *format,
50                                    va_list args);
51
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),
59 };
60
61 /* keep in sync with TSM_VTE_INVALID */
62 #define UTERM_INPUT_INVALID 0xffffffff
63
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 */
69
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 */
73 };
74
75 #define UTERM_INPUT_HAS_MODS(_ev, _mods) (((_ev)->mods & (_mods)) == (_mods))
76
77 typedef void (*uterm_input_cb) (struct uterm_input *input,
78                                 struct uterm_input_event *ev,
79                                 void *data);
80
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);
88
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);
91
92 int uterm_input_register_cb(struct uterm_input *input, uterm_input_cb cb,
93                             void *data);
94 void uterm_input_unregister_cb(struct uterm_input *input, uterm_input_cb cb,
95                                void *data);
96
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);
100
101 #endif /* UTERM_UTERM_INPUT_H */