Regroup actions into current vs. deprecated, resize vmod
[platform/upstream/libxkbcommon.git] / include / X11 / extensions / XKBcommon.h
1 /*
2 Copyright 1985, 1987, 1990, 1998  The Open Group
3 Copyright 2008  Dan Nicholson
4
5 Permission is hereby granted, free of charge, to any person obtaining a
6 copy of this software and associated documentation files (the "Software"),
7 to deal in the Software without restriction, including without limitation
8 the rights to use, copy, modify, merge, publish, distribute, sublicense,
9 and/or sell copies of the Software, and to permit persons to whom the
10 Software is furnished to do so, subject to the following conditions:
11
12 The above copyright notice and this permission notice shall be included in
13 all copies or substantial portions of the Software.
14
15 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
19 ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
22 Except as contained in this notice, the names of the authors or their
23 institutions shall not be used in advertising or otherwise to promote the
24 sale, use or other dealings in this Software without prior written
25 authorization from the authors.
26 */
27
28 #ifndef _XKBCOMMON_H_
29 #define _XKBCOMMON_H_
30
31 #include <stdint.h>
32 #include <stdio.h>
33 #include <X11/Xfuncproto.h>
34 #include <X11/extensions/XKBstrcommon.h>
35 #include <X11/extensions/XKBrulescommon.h>
36
37 /* Action structures used in the server */
38
39 #define XkbcAnyActionDataSize 18
40 typedef struct _XkbcAnyAction {
41     unsigned char   type;
42     unsigned char   pad[XkbcAnyActionDataSize];
43 } XkbcAnyAction;
44
45 typedef struct _XkbcModAction {
46     unsigned char   type;
47     uint8_t         flags;
48     uint32_t        mask;
49     uint32_t        real_mods;
50     uint32_t        vmods;
51 } XkbcModAction;
52
53 typedef struct _XkbcGroupAction {
54     unsigned char   type;
55     unsigned char   flags;
56     int16_t         group;
57 } XkbcGroupAction;
58
59 typedef struct _XkbcISOAction {
60     unsigned char   type;
61     uint8_t         flags;
62     int16_t         group;
63     uint32_t        mask;
64     uint32_t        vmods;
65     uint32_t        real_mods;
66     uint8_t         affect;
67 } XkbcISOAction;
68
69 typedef struct _XkbcCtrlsAction {
70     unsigned char   type;
71     unsigned char   flags;
72     uint32_t        ctrls;
73 } XkbcCtrlsAction;
74
75 typedef struct _XkbcDeviceBtnAction {
76     unsigned char   type;
77     unsigned char   flags;
78     uint16_t        device;
79     uint16_t        button;
80     uint8_t         count;
81 } XkbcDeviceBtnAction;
82
83 typedef struct _XkbcDeviceValuatorAction {
84     unsigned char   type;
85     uint8_t         v1_what;
86     uint16_t        device;
87     uint16_t        v1_index;
88     int16_t         v1_value;
89     uint16_t        v2_index;
90     int16_t         v2_value;
91     uint8_t         v2_what;
92 } XkbcDeviceValuatorAction;
93
94 typedef struct _XkbcPtrDfltAction {
95     unsigned char   type;
96     uint8_t         flags;
97     uint8_t         affect;
98     uint8_t         value;
99 } XkbcPtrDfltAction;
100
101 typedef struct _XkbcSwitchScreenAction {
102     unsigned char   type;
103     uint8_t         flags;
104     uint8_t         screen;
105 } XkbcSwitchScreenAction;
106
107 typedef union _XkbcAction {
108     XkbcAnyAction            any;
109     XkbcModAction            mods;
110     XkbcGroupAction          group;
111     XkbcISOAction            iso;
112     XkbcCtrlsAction          ctrls;
113     XkbcDeviceBtnAction      devbtn;
114     XkbcDeviceValuatorAction devval;
115     XkbcPtrDfltAction        dflt;
116     XkbcSwitchScreenAction   screen;
117     XkbRedirectKeyAction     redirect; /* XXX wholly unnecessary? */
118     XkbPtrAction             ptr; /* XXX delete for DeviceValuator */
119     XkbPtrBtnAction          btn; /* XXX delete for DeviceBtn */
120     XkbMessageAction         msg; /* XXX just delete */
121     unsigned char           type;
122 } XkbcAction;
123
124 typedef struct _XkbcServerMapRec {
125     unsigned short      num_acts;
126     unsigned short      size_acts;
127
128 #if defined(__cplusplus) || defined(c_plusplus)
129     /* explicit is a C++ reserved word */
130     unsigned char *     c_explicit;
131 #else
132     unsigned char *     explicit;
133 #endif
134
135     XkbcAction          *acts;
136     XkbBehavior         *behaviors;
137     unsigned short      *key_acts;
138     unsigned char       *explicits;
139     uint32_t            vmods[XkbNumVirtualMods];
140     uint32_t            *vmodmap;
141 } XkbcServerMapRec, *XkbcServerMapPtr;
142
143 /* Common keyboard description structure */
144 typedef struct _XkbcDesc {
145     unsigned int        defined;
146     unsigned short      flags;
147     unsigned short      device_spec;
148     KeyCode             min_key_code;
149     KeyCode             max_key_code;
150
151     XkbControlsPtr      ctrls;
152     XkbcServerMapPtr    server;
153     XkbClientMapPtr     map;
154     XkbIndicatorPtr     indicators;
155     XkbNamesPtr         names;
156     XkbCompatMapPtr     compat;
157     XkbGeometryPtr      geom;
158 } XkbcDescRec, *XkbcDescPtr;
159
160 _XFUNCPROTOBEGIN
161
162 extern void
163 XkbcInitAtoms(void);
164
165 extern XkbcDescPtr
166 XkbcCompileKeymapFromRules(const XkbRMLVOSet *rmlvo);
167
168 extern XkbcDescPtr
169 XkbcCompileKeymapFromComponents(const XkbComponentNamesPtr ktcsg);
170
171 extern XkbcDescPtr
172 XkbcCompileKeymapFromFile(FILE *inputFile, const char *mapName);
173
174 extern XkbComponentListPtr
175 XkbcListComponents(XkbComponentNamesPtr ptrns, int *maxMatch);
176
177 /*
178  * Canonicalises component names by prepending the relevant component from
179  * 'old' to the one in 'names' when the latter has a leading '+' or '|', and
180  * by replacing a '%' with the relevant component, e.g.:
181  *
182  * names        old           output
183  * ------------------------------------------
184  * +bar         foo           foo+bar
185  * |quux        baz           baz|quux
186  * foo+%|baz    bar           foo+bar|baz
187  *
188  * If a component in names needs to be modified, the existing value will be
189  * free()d, and a new one allocated with malloc().
190  */
191 extern void
192 XkbcCanonicaliseComponents(XkbComponentNamesPtr names,
193                            const XkbComponentNamesPtr old);
194
195 /*
196  * Converts a keysym to a string; will return unknown Unicode codepoints
197  * as "Ua1b2", and other unknown keysyms as "0xabcd1234".
198  *
199  * The string returned may become invalidated after the next call to
200  * XkbcKeysymToString: if you need to preserve it, then you must
201  * duplicate it.
202  */
203 extern char *
204 XkbcKeysymToString(KeySym ks);
205
206 /*
207  * See XkbcKeysymToString comments: this function will accept any string
208  * from that function.
209  */
210 extern KeySym
211 XkbcStringToKeysym(const char *s);
212
213 _XFUNCPROTOEND
214
215 #endif /* _XKBCOMMON_H_ */