summaryrefslogtreecommitdiff
path: root/libxklavier/xklavier_xkb.c
blob: 13008a699dfe3cb6042f6abf7676ad1196153762 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
/*
 * Copyright (C) 2002-2006 Sergey V. Udaltsov <svu@gnome.org>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 * Boston, MA 02111-1307, USA.
 */

#include <time.h>
#include <stdlib.h>

#include <X11/Xatom.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>

#include "xklavier_private.h"
#include "xklavier_private_xkb.h"

#ifdef LIBXKBFILE_PRESENT

const gchar **
xkl_xkb_get_groups_names(XklEngine * engine)
{
	return (const gchar **) xkl_engine_backend(engine, XklXkb,
						   group_names);
}

const gchar **
xkl_xkb_get_indicators_names(XklEngine * engine)
{
	return (const gchar **) xkl_engine_backend(engine, XklXkb,
						   indicator_names);
}

gint
xkl_xkb_pause_listen(XklEngine * engine)
{
	XkbSelectEvents(xkl_engine_get_display(engine), XkbUseCoreKbd,
			XkbAllEventsMask, 0);
/*  XkbSelectEventDetails( xkl_display,
                         XkbUseCoreKbd,
                       XkbStateNotify,
                     0,
                   0 );

  !!_XklSelectInput( _xklRootWindow, 0 );
*/
	return 0;
}

gint
xkl_xkb_resume_listen(XklEngine * engine)
{
	/* What events we want */
#define XKB_EVT_MASK \
         (XkbStateNotifyMask| \
          XkbNamesNotifyMask| \
          XkbControlsNotifyMask| \
          XkbIndicatorStateNotifyMask| \
          XkbIndicatorMapNotifyMask| \
          XkbNewKeyboardNotifyMask)

	Display *display = xkl_engine_get_display(engine);
	XkbSelectEvents(display, XkbUseCoreKbd, XKB_EVT_MASK,
			XKB_EVT_MASK);

#define XKB_STATE_EVT_DTL_MASK \
         (XkbGroupStateMask)

	XkbSelectEventDetails(display,
			      XkbUseCoreKbd,
			      XkbStateNotify,
			      XKB_STATE_EVT_DTL_MASK,
			      XKB_STATE_EVT_DTL_MASK);

#define XKB_NAMES_EVT_DTL_MASK \
         (XkbGroupNamesMask|XkbIndicatorNamesMask)

	XkbSelectEventDetails(display,
			      XkbUseCoreKbd,
			      XkbNamesNotify,
			      XKB_NAMES_EVT_DTL_MASK,
			      XKB_NAMES_EVT_DTL_MASK);
	return 0;
}

guint
xkl_xkb_get_max_num_groups(XklEngine * engine)
{
	return xkl_engine_priv(engine,
			       features) & XKLF_MULTIPLE_LAYOUTS_SUPPORTED
	    ? XkbNumKbdGroups : 1;
}

guint
xkl_xkb_get_num_groups(XklEngine * engine)
{
	return xkl_engine_backend(engine, XklXkb,
				  cached_desc)->ctrls->num_groups;
}

#define KBD_MASK \
    ( 0 )
#define CTRLS_MASK \
  ( XkbSlowKeysMask )
#define NAMES_MASK \
  ( XkbGroupNamesMask | XkbIndicatorNamesMask )

void
xkl_xkb_free_all_info(XklEngine * engine)
{
	gint i;
	gchar **pi = xkl_engine_backend(engine, XklXkb, indicator_names);
	XkbDescPtr desc;

	for (i = 0; i < XkbNumIndicators; i++, pi++) {
		/* only free non-empty ones */
		if (*pi && **pi)
			XFree(*pi);
	}
	desc = xkl_engine_backend(engine, XklXkb, cached_desc);
	if (desc != NULL) {
		int i;
		char **group_name =
		    xkl_engine_backend(engine, XklXkb, group_names);
		for (i = desc->ctrls->num_groups; --i >= 0; group_name++)
			if (*group_name) {
				XFree(*group_name);
				*group_name = NULL;
			}
		XkbFreeKeyboard(desc, XkbAllComponentsMask, True);
		xkl_engine_backend(engine, XklXkb, cached_desc) = NULL;
	}

	/* just in case - never actually happens... */
	desc = xkl_engine_backend(engine, XklXkb, actual_desc);
	if (desc != NULL) {
		XkbFreeKeyboard(desc, XkbAllComponentsMask, True);
		xkl_engine_backend(engine, XklXkb, actual_desc) = NULL;
	}
}

static gboolean
xkl_xkb_load_actual_desc(XklEngine * engine)
{
	gboolean rv = FALSE;
	Status status;

	Display *display = xkl_engine_get_display(engine);
	XkbDescPtr desc = XkbGetMap(display, KBD_MASK, XkbUseCoreKbd);
	xkl_engine_backend(engine, XklXkb, actual_desc) = desc;
	if (desc != NULL) {
		rv = Success == (status = XkbGetControls(display,
							 CTRLS_MASK,
							 desc)) &&
		    Success == (status = XkbGetNames(display,
						     NAMES_MASK,
						     desc)) &&
		    Success == (status = XkbGetIndicatorMap(display,
							    XkbAllIndicatorsMask,
							    desc));
		if (!rv) {
			xkl_last_error_message =
			    "Could not load controls/names/indicators";
			xkl_debug(0, "%s: %d\n",
				  xkl_last_error_message, status);
			XkbFreeKeyboard(desc, XkbAllComponentsMask, True);
			xkl_engine_backend(engine, XklXkb, actual_desc) =
			    NULL;
		}
	}
	return rv;
}

gboolean
xkl_xkb_if_cached_info_equals_actual(XklEngine * engine)
{
	gint i;
	Atom *pa1, *pa2;
	gboolean rv = FALSE;

	if (xkl_xkb_load_actual_desc(engine)) {
		/* First, compare the number of groups */
		XkbDescPtr cached =
		    xkl_engine_backend(engine, XklXkb, cached_desc);
		XkbDescPtr actual =
		    xkl_engine_backend(engine, XklXkb, actual_desc);

		if (cached->ctrls->num_groups == actual->ctrls->num_groups) {
			/* Then, compare group names, just atoms */
			pa1 = cached->names->groups;
			pa2 = actual->names->groups;
			for (i = cached->ctrls->num_groups; --i >= 0;
			     pa1++, pa2++)
				if (*pa1 != *pa2)
					break;

			/* Then, compare indicator names, just atoms */
			if (i < 0) {
				pa1 = cached->names->indicators;
				pa2 = actual->names->indicators;
				for (i = XkbNumIndicators; --i >= 0;
				     pa1++, pa2++)
					if (*pa1 != *pa2)
						break;
				rv = i < 0;
			}
		}
    /* 
     * in case of failure, reuse in _XklXkbLoadAllInfo
     * in case of success - free it
     */
		if (rv) {
			XkbFreeKeyboard(actual,
					XkbAllComponentsMask, True);
			xkl_engine_backend(engine, XklXkb, actual_desc) =
			    NULL;
		}
	} else {
		xkl_debug(0,
			  "Could not load the XkbDescPtr for comparison\n");
	}
	return rv;
}

/*
 * Load some XKB parameters
 */
gboolean
xkl_xkb_load_all_info(XklEngine * engine)
{
	gint i;
	Atom *pa;
	gchar **group_name;
	gchar **pi = xkl_engine_backend(engine, XklXkb, indicator_names);
	Display *display = xkl_engine_get_display(engine);
	XkbDescPtr actual =
	    xkl_engine_backend(engine, XklXkb, actual_desc);
	XkbDescPtr cached;

	if (actual == NULL)
		if (!xkl_xkb_load_actual_desc(engine)) {
			xkl_last_error_message = "Could not load keyboard";
			return FALSE;
		}

	/* take it from the cache (in most cases LoadAll is called from ResetAll which in turn ...) */
	cached = actual = xkl_engine_backend(engine, XklXkb, actual_desc);
	xkl_engine_backend(engine, XklXkb, cached_desc) =
	    xkl_engine_backend(engine, XklXkb, actual_desc);
	xkl_engine_backend(engine, XklXkb, actual_desc) = NULL;

	/* First, output the number of the groups */
	xkl_debug(200, "found %d groups\n", cached->ctrls->num_groups);

	/* Then, cache (and output) the names of the groups */
	pa = cached->names->groups;
	group_name = xkl_engine_backend(engine, XklXkb, group_names);
	for (i = cached->ctrls->num_groups; --i >= 0; pa++, group_name++) {
		*group_name =
		    XGetAtomName(display,
				 *pa == None ? XInternAtom(display,
							   "-",
							   False) : *pa);
		xkl_debug(200, "Group %d has name [%s]\n", i, *group_name);
	}

	xkl_engine_priv(engine, last_error_code) =
	    XkbGetIndicatorMap(display, XkbAllIndicatorsMask, cached);

	if (xkl_engine_priv(engine, last_error_code) != Success) {
		xkl_last_error_message = "Could not load indicator map";
		return FALSE;
	}

	/* Then, cache (and output) the names of the indicators */
	pa = cached->names->indicators;
	for (i = XkbNumIndicators; --i >= 0; pi++, pa++) {
		Atom a = *pa;
		if (a != None)
			*pi = XGetAtomName(display, a);
		else
			*pi = "";

		xkl_debug(200, "Indicator[%d] is %s\n", i, *pi);
	}

	xkl_debug(200, "Real indicators are %X\n",
		  cached->indicators->phys_indicators);

	g_signal_emit_by_name(engine, "X-config-changed");

	return TRUE;
}

void
xkl_xkb_lock_group(XklEngine * engine, gint group)
{
	Display *display = xkl_engine_get_display(engine);
	xkl_debug(100, "Posted request for change the group to %d ##\n",
		  group);
	XkbLockGroup(display, XkbUseCoreKbd, group);
	XSync(display, False);
}

/*
 * Updates current internal state from X state
 */
void
xkl_xkb_get_server_state(XklEngine * engine, XklState * current_state_out)
{
	XkbStateRec state;
	Display *display = xkl_engine_get_display(engine);

	current_state_out->group = 0;
	if (Success == XkbGetState(display, XkbUseCoreKbd, &state))
		current_state_out->group = state.locked_group;

	if (Success ==
	    XkbGetIndicatorState(display, XkbUseCoreKbd,
				 &current_state_out->indicators))
		current_state_out->indicators &=
		    xkl_engine_backend(engine, XklXkb,
				       cached_desc)->indicators->
		    phys_indicators;
	else
		current_state_out->indicators = 0;
}

/*
 * Actually taken from mxkbledpanel, valueChangedProc
 */
gboolean
xkl_xkb_set_indicator(XklEngine * engine, gint indicator_num, gboolean set)
{
	XkbIndicatorMapPtr map;
	Display *display = xkl_engine_get_display(engine);
	XkbDescPtr cached =
	    xkl_engine_backend(engine, XklXkb, cached_desc);

	map = cached->indicators->maps + indicator_num;

	/* The 'flags' field tells whether this indicator is automatic
	 * (XkbIM_NoExplicit - 0x80), explicit (XkbIM_NoAutomatic - 0x40),
	 * or neither (both - 0xC0).
	 *
	 * If NoAutomatic is set, the server ignores the rest of the 
	 * fields in the indicator map (i.e. it disables automatic control 
	 * of the LED).   If NoExplicit is set, the server prevents clients 
	 * from explicitly changing the value of the LED (using the core 
	 * protocol *or* XKB).   If NoAutomatic *and* NoExplicit are set, 
	 * the LED cannot be changed (unless you change the map first).   
	 * If neither NoAutomatic nor NoExplicit are set, the server will 
	 * change the LED according to the indicator map, but clients can 
	 * override that (until the next automatic change) using the core 
	 * protocol or XKB.
	 */
	switch (map->flags & (XkbIM_NoExplicit | XkbIM_NoAutomatic)) {
	case XkbIM_NoExplicit | XkbIM_NoAutomatic:
		{
			/* Can do nothing. Just ignore the indicator */
			return TRUE;
		}

	case XkbIM_NoAutomatic:
		{
			if (cached->names->
			    indicators[indicator_num] != None)
				XkbSetNamedIndicator(display,
						     XkbUseCoreKbd,
						     cached->names->
						     indicators
						     [indicator_num], set,
						     False, NULL);
			else {
				XKeyboardControl xkc;
				xkc.led = indicator_num;
				xkc.led_mode =
				    set ? LedModeOn : LedModeOff;
				XChangeKeyboardControl(display,
						       KBLed | KBLedMode,
						       &xkc);
				XSync(display, False);
			}

			return TRUE;
		}

	case XkbIM_NoExplicit:
		break;
	}

	/* The 'ctrls' field tells what controls tell this indicator to
	 * to turn on:  RepeatKeys (0x1), SlowKeys (0x2), BounceKeys (0x4),
	 *              StickyKeys (0x8), MouseKeys (0x10), AccessXKeys (0x20),
	 *              TimeOut (0x40), Feedback (0x80), ToggleKeys (0x100),
	 *              Overlay1 (0x200), Overlay2 (0x400), GroupsWrap (0x800),
	 *              InternalMods (0x1000), IgnoreLockMods (0x2000),
	 *              PerKeyRepeat (0x3000), or ControlsEnabled (0x4000)
	 */
	if (map->ctrls) {
		gulong which = map->ctrls;

		XkbGetControls(display, XkbAllControlsMask, cached);
		if (set)
			cached->ctrls->enabled_ctrls |= which;
		else
			cached->ctrls->enabled_ctrls &= ~which;
		XkbSetControls(display, which | XkbControlsEnabledMask,
			       cached);
	}

	/* The 'which_groups' field tells when this indicator turns on
	 * for the 'groups' field:  base (0x1), latched (0x2), locked (0x4),
	 * or effective (0x8).
	 */
	if (map->groups) {
		gint i;
		guint group = 1;

		/* Turning on a group indicator is kind of tricky.  For
		 * now, we will just Latch or Lock the first group we find
		 * if that is what this indicator does.  Otherwise, we're
		 * just going to punt and get out of here.
		 */
		if (set) {
			for (i = XkbNumKbdGroups; --i >= 0;)
				if ((1 << i) & map->groups) {
					group = i;
					break;
				}
			if (map->
			    which_groups & (XkbIM_UseLocked |
					    XkbIM_UseEffective)) {
				/* Important: Groups should be ignored here - because they are handled separately! */
				/* XklLockGroup( group ); */
			} else if (map->which_groups & XkbIM_UseLatched)
				XkbLatchGroup(display, XkbUseCoreKbd,
					      group);
			else {
				/* Can do nothing. Just ignore the indicator */
				return TRUE;
			}
		} else
			/* Turning off a group indicator will mean that we just
			 * Lock the first group that this indicator doesn't watch.
			 */
		{
			for (i = XkbNumKbdGroups; --i >= 0;)
				if (!((1 << i) & map->groups)) {
					group = i;
					break;
				}
			xkl_xkb_lock_group(engine, group);
		}
	}

	/* The 'which_mods' field tells when this indicator turns on
	 * for the modifiers:  base (0x1), latched (0x2), locked (0x4),
	 *                     or effective (0x8).
	 *
	 * The 'real_mods' field tells whether this turns on when one of 
	 * the real X modifiers is set:  Shift (0x1), Lock (0x2), Control (0x4),
	 * Mod1 (0x8), Mod2 (0x10), Mod3 (0x20), Mod4 (0x40), or Mod5 (0x80). 
	 *
	 * The 'virtual_mods' field tells whether this turns on when one of
	 * the virtual modifiers is set.
	 *
	 * The 'mask' field tells what real X modifiers the virtual_modifiers
	 * map to?
	 */
	if (map->mods.real_mods || map->mods.mask) {
		guint affect, mods;

		affect = (map->mods.real_mods | map->mods.mask);

		mods = set ? affect : 0;

		if (map->
		    which_mods & (XkbIM_UseLocked | XkbIM_UseEffective))
			XkbLockModifiers(display, XkbUseCoreKbd,
					 affect, mods);
		else if (map->which_mods & XkbIM_UseLatched)
			XkbLatchModifiers(display, XkbUseCoreKbd,
					  affect, mods);
		else {
			return TRUE;
		}
	}
	return TRUE;
}

#endif

gint
xkl_xkb_init(XklEngine * engine)
{
	Display *display = xkl_engine_get_display(engine);

#ifdef LIBXKBFILE_PRESENT
	gint opcode;
	gboolean xkl_xkb_ext_present;

	xkl_engine_priv(engine, backend_id) = "XKB";
	xkl_engine_priv(engine, features) = XKLF_CAN_TOGGLE_INDICATORS |
	    XKLF_CAN_OUTPUT_CONFIG_AS_ASCII |
	    XKLF_CAN_OUTPUT_CONFIG_AS_BINARY;
	xkl_engine_priv(engine, activate_config_rec) =
	    xkl_xkb_activate_config_rec;
	xkl_engine_priv(engine, init_config_registry) =
	    xkl_xkb_init_config_registry;
	xkl_engine_priv(engine, load_config_registry) =
	    xkl_xkb_load_config_registry;
	xkl_engine_priv(engine, write_config_rec_to_file) =
	    xkl_xkb_write_config_rec_to_file;
	xkl_engine_priv(engine, get_groups_names) =
	    xkl_xkb_get_groups_names;
	xkl_engine_priv(engine, get_indicators_names) =
	    xkl_xkb_get_indicators_names;
	xkl_engine_priv(engine, get_max_num_groups) =
	    xkl_xkb_get_max_num_groups;
	xkl_engine_priv(engine, get_num_groups) = xkl_xkb_get_num_groups;
	xkl_engine_priv(engine, lock_group) = xkl_xkb_lock_group;
	xkl_engine_priv(engine, process_x_event) = xkl_xkb_process_x_event;
	xkl_engine_priv(engine, free_all_info) = xkl_xkb_free_all_info;
	xkl_engine_priv(engine, if_cached_info_equals_actual) =
	    xkl_xkb_if_cached_info_equals_actual;
	xkl_engine_priv(engine, load_all_info) = xkl_xkb_load_all_info;
	xkl_engine_priv(engine, get_server_state) =
	    xkl_xkb_get_server_state;
	xkl_engine_priv(engine, pause_listen) = xkl_xkb_pause_listen;
	xkl_engine_priv(engine, resume_listen) = xkl_xkb_resume_listen;
	xkl_engine_priv(engine, set_indicators) = xkl_xkb_set_indicators;
	xkl_engine_priv(engine, finalize) = xkl_xkb_term;

	if (getenv("XKL_XKB_DISABLE") != NULL)
		return -1;

	xkl_engine_priv(engine, backend) = g_new0(XklXkb, 1);

	xkl_xkb_ext_present = XkbQueryExtension(display,
						&opcode,
						&xkl_engine_backend(engine,
								    XklXkb,
								    event_type),
						&xkl_engine_backend(engine,
								    XklXkb,
								    error_code),
						NULL, NULL);
	if (!xkl_xkb_ext_present) {
		XSetErrorHandler((XErrorHandler)
				 xkl_engine_priv(engine,
						 default_error_handler));
		return -1;
	}

	xkl_debug(160,
		  "xkbEvenType: %X, xkbError: %X, display: %p, root: "
		  WINID_FORMAT "\n", xkl_engine_backend(engine, XklXkb,
							event_type),
		  xkl_engine_backend(engine, XklXkb, error_code), display,
		  xkl_engine_priv(engine, root_window));

	xkl_engine_priv(engine, base_config_atom) =
	    XInternAtom(display, _XKB_RF_NAMES_PROP_ATOM, False);
	xkl_engine_priv(engine, backup_config_atom) =
	    XInternAtom(display, "_XKB_RULES_NAMES_BACKUP", False);

	xkl_engine_priv(engine, default_model) = "pc101";
	xkl_engine_priv(engine, default_layout) = "us";

	/* First, we have to assign xkl_vtable - 
	   because this function uses it */

	if (xkl_xkb_multiple_layouts_supported(engine))
		xkl_engine_priv(engine, features) |=
		    XKLF_MULTIPLE_LAYOUTS_SUPPORTED;

	return 0;
#else
	xkl_debug(160,
		  "NO XKB LIBS, display: %p, root: " WINID_FORMAT
		  "\n", display, xkl_engine_priv(engine, root_window));
	return -1;
#endif
}

void
xkl_xkb_term(XklEngine * engine)
{
}

#ifdef LIBXKBFILE_PRESENT
const gchar *
xkl_xkb_event_get_name(gint xkb_type)
{
	/* Not really good to use the fact of consecutivity
	   but XKB protocol extension is already standartized so... */
	static const gchar *evt_names[] = {
		"XkbNewKeyboardNotify",
		"XkbMapNotify",
		"XkbStateNotify",
		"XkbControlsNotify",
		"XkbIndicatorStateNotify",
		"XkbIndicatorMapNotify",
		"XkbNamesNotify",
		"XkbCompatMapNotify",
		"XkbBellNotify",
		"XkbActionMessage",
		"XkbAccessXNotify",
		"XkbExtensionDeviceNotify",
		"LASTEvent"
	};
	xkb_type -= XkbNewKeyboardNotify;
	if (xkb_type < 0 ||
	    xkb_type >= (sizeof(evt_names) / sizeof(evt_names[0])))
		return "UNKNOWN/OOR";
	return evt_names[xkb_type];
}
#endif