home *** CD-ROM | disk | FTP | other *** search
Text File | 2007-04-10 | 83.4 KB | 3,003 lines |
- #!/usr/bin/perl
-
- # ckbcomp -- compile XKB keyboard definitions to loadkeys format
- # Copyright © 2005,2006 Anton Zinoviev <anton@lml.bas.bg>
-
- # This program is free software; you can redistribute it and/or modify
- # it under the terms of the GNU General Public License as published by
- # the Free Software Foundation; either version 2 of the License, or
- # (at your option) any later version.
-
- # This program 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 General Public License for more details.
-
- # If you have not received a copy of the GNU General Public License
- # along with this program, write to the Free Software Foundation, Inc.,
- # 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
- use warnings 'all';
- use strict;
-
- sub debug {
- if (1) {
- print STDERR "@_";
- }
- }
-
- sub warning {
- print STDERR "WARNING: @_";
- }
-
- ########### ARGUMENTS ###############################################
-
- my $charmap;
- my $acm;
-
- my $verbosity = 0;
-
- my @xdirs = ('/etc/console-setup/ckb',
- '/usr/share/X11/xkb',
- '/etc/X11/xkb',
- '/usr/X11R6/lib/X11/xkb');
-
- my $keycodes;
- my $symbols;
-
- my $rules;
- my $model;
- my @layouts;
- my @variants = ();
- my @options = ();
- my $compact = 0;
-
- while (@ARGV) {
- $_ = shift @ARGV;
- if (s/^-//) {
- if (/^charmap$/) {
- if ($charmap) {
- die "$0: No more than one -charmap option is allowed\n";
- }
- $charmap = $ARGV[0];
- shift @ARGV;
- } elsif (/^v(erbose)?$/) {
- if ($verbosity) {
- die "$0: No more than one -verbose option is allowed\n";
- }
- if ($ARGV[0] =~ /^[0-9]|10$/) {
- $verbosity = $ARGV[0];
- shift @ARGV;
- } else {
- $verbosity = 5;
- }
- } elsif (/^I(.*)$/) {
- @xdirs = ($1, @xdirs);
- } elsif (/^keycodes$/) {
- if ($keycodes) {
- die "$0: No more than one -keycodes option is allowed\n";
- }
- $keycodes = $ARGV[0];
- shift @ARGV;
- } elsif (/^symbols$/) {
- if ($symbols) {
- die "$0: No more than one -symbols option is allowed\n";
- }
- $symbols = $ARGV[0];
- shift @ARGV;
- } elsif (/^rules$/) {
- if ($rules) {
- die "$0: No more than one -rules option is allowed\n";
- }
- $rules = $ARGV[0];
- shift @ARGV;
- } elsif (/^model$/) {
- if ($model) {
- die "$0: No more than one -model option is allowed\n";
- }
- $model = $ARGV[0];
- shift @ARGV;
- } elsif (/^layout$/) {
- if (@layouts) {
- die "$0: No more than one -layout option is allowed\n";
- }
- @layouts = split (/,/, $ARGV[0], -1);
- shift @ARGV;
- } elsif (/^variant$/) {
- if (@variants) {
- die "$0: No more than one -variant option is allowed\n";
- }
- @variants = split (/,/, $ARGV[0], -1);
- shift @ARGV;
- } elsif (/^option$/) {
- @options = (@options, split (/,/, $ARGV[0], -1));
- shift @ARGV;
- } elsif (/^help$|^-help$|^\?$/) {
- print <<EOT;
- Usage: ckbcomp [args] [<layout> [<variant> [<option> ... ]]]
- Where legal args are:
- -?,-help Print this message
- -charmap <name> Specifies the encoding to use
- -I<dir> Add <dir> to list of directories to be used
- -keycodes <name> Specifies keycodes component name
- -symbols <name> Specifies symbols component name
- -rules <name> Name of rules file to use
- -model <name> Specifies model used to choose component names
- -layout <name> Specifies layout used to choose component names
- -variant <name> Specifies layout variant used to choose component names
- -v[erbose] [<lvl>] Sets verbosity (1..10). Higher values yield
- more messages
- -option <name> Adds an option used to choose component names
- -compact Generate compact keymap
- EOT
- exit 0;
- } elsif (/^compact$/) {
- $compact = 1;
- } else {
- die "$0: Unknown option -$_\n";
- }
- } else {
- if (! @layouts) {
- @layouts = split (/,/, $_, -1);
- } elsif (! @variants) {
- @variants = split (/,/, $_, -1);
- @variants = ('') if (! @variants);
- } else {
- @options = (@options, split (/,/, $_, -1));
- }
- }
- }
-
- $rules = 'xorg' if (! $rules);
- $model = 'pc104' if (! $model);
-
- ########### GLOBAL VARIABLES #########################################
-
- my %rules_variables = (); # The variables defined in the rules file
-
- my $arch = 'at'; # The name of a mapping between X key codes and kernel
- # keycodes
-
- my %acmtable; # Unicode -> legacy code (defined only when -charmap is given)
-
- my %keycodes_table; # x keysym -> x key code
- my %aliases; # x keysym -> x keysym
-
- my %symbols_table; # x key code -> [[symbols for group0,...],
- # [symbols for group1,...], ...]
- my %types_table; # x key code -> key type (i.e. "PC_BREAK" or "TWO_LEVEL")
-
- my $augment_method = 1; # Constants for different XKB include methods
- my $override_method = 2;
- my $replace_method = 3;
- my $alternate_method = 4;
- my $ignore_method = 5; # This is not a XKB method and means "don't include"
-
- my $filename; # The name of the currently read file
- my $stream = ''; # The contents of $filename that still has not been parsed
- my $method = $override_method; # The current method (by default "override")
- my $base_group = 0; # The base group to include in (for "symbols" files only)
-
- my %kernel_modifiers = ('Shift' => 0x01,
- 'Shift_Lock' => 0x01,
- 'AltGr' => 0x02,
- 'AltGr_Lock' => 0x02,
- 'Control' => 0x04,
- 'Control_Lock' => 0x04,
- 'Alt' => 0x08,
- 'Alt_Lock' => 0x08,
- 'ShiftL' => 0x10,
- 'ShiftL_Lock' => 0x10,
- 'ShiftR' => 0x20,
- 'ShiftR_Lock' => 0x20);
-
- my @modifier_combinations = ('plain',
- 'shift',
- 'altgr',
- 'altgr shift',
- 'control',
- 'control shift',
- 'control altgr',
- 'control altgr shift',
- 'alt',
- 'alt shift',
- 'alt altgr',
- 'alt altgr shift',
- 'alt control',
- 'alt control shift',
- 'alt control altgr',
- 'alt control altgr shift',
- 'shiftl',
- 'shiftl shift',
- 'shiftl altgr',
- 'shiftl altgr shift',
- 'shiftl control',
- 'shiftl control shift',
- 'shiftl control altgr',
- 'shiftl control altgr shift',
- 'shiftl alt',
- 'shiftl alt shift',
- 'shiftl alt altgr',
- 'shiftl alt altgr shift',
- 'shiftl alt control',
- 'shiftl alt control shift',
- 'shiftl alt control altgr',
- 'shiftl alt control altgr shift',
- 'shiftr',
- 'shiftr shift',
- 'shiftr altgr',
- 'shiftr altgr shift',
- 'shiftr control',
- 'shiftr control shift',
- 'shiftr control altgr',
- 'shiftr control altgr shift',
- 'shiftr alt',
- 'shiftr alt shift',
- 'shiftr alt altgr',
- 'shiftr alt altgr shift',
- 'shiftr alt control',
- 'shiftr alt control shift',
- 'shiftr alt control altgr',
- 'shiftr alt control altgr shift',
- 'shiftr shiftl',
- 'shiftr shiftl shift',
- 'shiftr shiftl altgr',
- 'shiftr shiftl altgr shift',
- 'shiftr shiftl control',
- 'shiftr shiftl control shift',
- 'shiftr shiftl control altgr',
- 'shiftr shiftl control altgr shift',
- 'shiftr shiftl alt',
- 'shiftr shiftl alt shift',
- 'shiftr shiftl alt altgr',
- 'shiftr shiftl alt altgr shift',
- 'shiftr shiftl alt control',
- 'shiftr shiftl alt control shift',
- 'shiftr shiftl alt control altgr',
- 'shiftr shiftl alt control altgr shift',
- );
-
- # Some Unicodes cause the kernel/loadkeys to issue "Segmentation fault"
- my %forbidden;
- {
- for my $i (0xfd00..0xfdff) {
- $forbidden{$i} = 1;
- }
- }
-
- my %xkbsym_table = (
- # Control symbols
- 'BackSpace' => 'Delete', # 0008
- 'Tab' => 'Tab', # 0009
- 'Linefeed' => 'Linefeed', # 000a
- 'Return' => 'Return', # 000d
- 'Escape' => 'Escape', # 001b
- # Alphanumeric symbols
- 'space' => '0020',
- 'exclam' => '0021',
- 'quotedbl' => '0022',
- 'numbersign' => '0023',
- 'dollar' => '0024',
- 'percent' => '0025',
- 'ampersand' => '0026',
- 'apostrophe' => '0027',
- 'quoteright' => '0027',
- 'parenleft' => '0028',
- 'parenlef' => '0028', # Is this recognised by X ? (speling error)
- 'parenright' => '0029',
- 'asterisk' => '002a',
- 'asterix' => '002a', # Is this recognised by X ? (speling error)
- 'plus' => '002b',
- 'comma' => '002c',
- 'minus' => '002d',
- 'period' => '002e',
- 'slash' => '002f',
- '0' => '0030',
- '1' => '0031',
- '2' => '0032',
- '3' => '0033',
- '4' => '0034',
- '5' => '0035',
- '6' => '0036',
- '7' => '0037',
- '8' => '0038',
- '9' => '0039',
- 'colon' => '003a',
- 'semicolon' => '003b',
- 'less' => '003c',
- 'equal' => '003d',
- 'greater' => '003e',
- 'question' => '003f',
- 'at' => '0040',
- 'A' => '0041',
- 'B' => '0042',
- 'C' => '0043',
- 'D' => '0044',
- 'E' => '0045',
- 'F' => '0046',
- 'G' => '0047',
- 'H' => '0048',
- 'I' => '0049',
- 'J' => '004a',
- 'K' => '004b',
- 'L' => '004c',
- 'M' => '004d',
- 'N' => '004e',
- 'O' => '004f',
- 'P' => '0050',
- 'Q' => '0051',
- 'R' => '0052',
- 'S' => '0053',
- 'T' => '0054',
- 'U' => '0055',
- 'V' => '0056',
- 'W' => '0057',
- 'X' => '0058',
- 'Y' => '0059',
- 'Z' => '005a',
- 'bracketleft' => '005b',
- 'backslash' => '005c',
- 'bracketright' => '005d',
- 'asciicircum' => '005e',
- 'underscore' => '005f',
- 'grave' => '0060',
- 'quoteleft' => '0060',
- 'a' => '0061',
- 'b' => '0062',
- 'c' => '0063',
- 'd' => '0064',
- 'e' => '0065',
- 'f' => '0066',
- 'g' => '0067',
- 'h' => '0068',
- 'i' => '0069',
- 'j' => '006a',
- 'k' => '006b',
- 'l' => '006c',
- 'm' => '006d',
- 'n' => '006e',
- 'o' => '006f',
- 'p' => '0070',
- 'q' => '0071',
- 'r' => '0072',
- 's' => '0073',
- 't' => '0074',
- 'u' => '0075',
- 'v' => '0076',
- 'w' => '0077',
- 'x' => '0078',
- 'y' => '0079',
- 'z' => '007a',
- 'braceleft' => '007b',
- 'bar' => '007c',
- 'braceright' => '007d',
- 'asciitilde' => '007e',
- 'nobreakspace' => '00a0',
- 'exclamdown' => '00a1',
- 'cent' => '00a2',
- 'sterling' => '00a3',
- 'currency' => '00a4',
- 'yen' => '00a5',
- 'brokenbar' => '00a6',
- 'section' => '00a7',
- 'diaeresis' => '00a8',
- 'copyright' => '00a9',
- 'ordfeminine' => '00aa',
- 'guillemotleft' => '00ab',
- 'notsign' => '00ac',
- 'hyphen' => '00ad',
- 'registered' => '00ae',
- 'macron' => '00af',
- 'overbar' => '00af',
- 'degree' => '00b0',
- 'plusminus' => '00b1',
- 'twosuperior' => '00b2',
- 'threesuperior' => '00b3',
- 'acute' => '0027', # APOSTROPHE instead of ACUTE ACCENT
- 'mu' => '00b5',
- 'paragraph' => '00b6',
- 'periodcentered' => '00b7',
- 'cedilla' => '00b8',
- 'onesuperior' => '00b9',
- 'masculine' => '00ba',
- 'guillemotright' => '00bb',
- 'onequarter' => '00bc',
- 'onehalf' => '00bd',
- 'threequarters' => '00be',
- 'questiondown' => '00bf',
- 'Agrave' => '00c0',
- 'Aacute' => '00c1',
- 'Acircumflex' => '00c2',
- 'Atilde' => '00c3',
- 'Adiaeresis' => '00c4',
- 'Aring' => '00c5',
- 'AE' => '00c6',
- 'Ccedilla' => '00c7',
- 'Egrave' => '00c8',
- 'Eacute' => '00c9',
- 'Ecircumflex' => '00ca',
- 'Ediaeresis' => '00cb',
- 'Igrave' => '00cc',
- 'Iacute' => '00cd',
- 'Icircumflex' => '00ce',
- 'Idiaeresis' => '00cf',
- 'ETH' => '00d0',
- 'Eth' => '00d0',
- 'Ntilde' => '00d1',
- 'Ograve' => '00d2',
- 'Oacute' => '00d3',
- 'Ocircumflex' => '00d4',
- 'Otilde' => '00d5',
- 'Odiaeresis' => '00d6',
- 'multiply' => '00d7',
- 'Ooblique' => '00d8',
- 'Oslash' => '00d8',
- 'Ugrave' => '00d9',
- 'Uacute' => '00da',
- 'Ucircumflex' => '00db',
- 'Udiaeresis' => '00dc',
- 'Yacute' => '00dd',
- 'THORN' => '00de',
- 'Thorn' => '00de',
- 'ssharp' => '00df',
- 'agrave' => '00e0',
- 'aacute' => '00e1',
- 'acircumflex' => '00e2',
- 'atilde' => '00e3',
- 'adiaeresis' => '00e4',
- 'aring' => '00e5',
- 'ae' => '00e6',
- 'ccedilla' => '00e7',
- 'egrave' => '00e8',
- 'eacute' => '00e9',
- 'ecircumflex' => '00ea',
- 'ediaeresis' => '00eb',
- 'igrave' => '00ec',
- 'iacute' => '00ed',
- 'icircumflex' => '00ee',
- 'idiaeresis' => '00ef',
- 'eth' => '00f0',
- 'ntilde' => '00f1',
- 'ograve' => '00f2',
- 'oacute' => '00f3',
- 'ocircumflex' => '00f4',
- 'otilde' => '00f5',
- 'odiaeresis' => '00f6',
- 'division' => '00f7',
- 'oslash' => '00f8',
- 'ooblique' => '00f8',
- 'ugrave' => '00f9',
- 'uacute' => '00fa',
- 'ucircumflex' => '00fb',
- 'udiaeresis' => '00fc',
- 'yacute' => '00fd',
- 'thorn' => '00fe',
- 'ydiaeresis' => '00ff',
- 'Amacron' => '0100',
- 'amacron' => '0101',
- 'Abreve' => '0102',
- 'abreve' => '0103',
- 'Aogonek' => '0104',
- 'aogonek' => '0105',
- 'Cacute' => '0106',
- 'cacute' => '0107',
- 'Ccircumflex' => '0108',
- 'ccircumflex' => '0109',
- 'Cabovedot' => '010a',
- 'cabovedot' => '010b',
- 'Ccaron' => '010c',
- 'ccaron' => '010d',
- 'Dcaron' => '010e',
- 'dcaron' => '010f',
- 'Dstroke' => '0110',
- 'dstroke' => '0111',
- 'Emacron' => '0112',
- 'emacron' => '0113',
- 'Eabovedot' => '0116',
- 'eabovedot' => '0117',
- 'Eogonek' => '0118',
- 'eogonek' => '0119',
- 'Ecaron' => '011a',
- 'ecaron' => '011b',
- 'Gcircumflex' => '011c',
- 'gcircumflex' => '011d',
- 'Gbreve' => '011e',
- 'gbreve' => '011f',
- 'Gabovedot' => '0120',
- 'gabovedot' => '0121',
- 'Gcedilla' => '0122',
- 'gcedilla' => '0123',
- 'Hcircumflex' => '0124',
- 'hcircumflex' => '0125',
- 'Hstroke' => '0126',
- 'hstroke' => '0127',
- 'Itilde' => '0128',
- 'itilde' => '0129',
- 'Imacron' => '012a',
- 'imacron' => '012b',
- 'Iogonek' => '012e',
- 'iogonek' => '012f',
- 'Iabovedot' => '0130',
- 'idotless' => '0131',
- 'Jcircumflex' => '0134',
- 'jcircumflex' => '0135',
- 'Kcedilla' => '0136',
- 'kcedilla' => '0137',
- 'kra' => '0138',
- 'Lacute' => '0139',
- 'lacute' => '013a',
- 'Lcedilla' => '013b',
- 'lcedilla' => '013c',
- 'Lcaron' => '013d',
- 'lcaron' => '013e',
- 'Lstroke' => '0141',
- 'lstroke' => '0142',
- 'Nacute' => '0143',
- 'nacute' => '0144',
- 'Ncedilla' => '0145',
- 'ncedilla' => '0146',
- 'Ncaron' => '0147',
- 'ncaron' => '0148',
- 'ENG' => '014a',
- 'eng' => '014b',
- 'Omacron' => '014c',
- 'omacron' => '014d',
- 'Odoubleacute' => '0150',
- 'odoubleacute' => '0151',
- 'OE' => '0152',
- 'oe' => '0153',
- 'Racute' => '0154',
- 'racute' => '0155',
- 'Rcedilla' => '0156',
- 'rcedilla' => '0157',
- 'Rcaron' => '0158',
- 'rcaron' => '0159',
- 'Sacute' => '015a',
- 'sacute' => '015b',
- 'Scircumflex' => '015c',
- 'scircumflex' => '015d',
- 'Scedilla' => '015e',
- 'scedilla' => '015f',
- 'Scaron' => '0160',
- 'scaron' => '0161',
- 'Tcedilla' => '0162',
- 'tcedilla' => '0163',
- 'Tcaron' => '0164',
- 'tcaron' => '0165',
- 'Tslash' => '0166',
- 'tslash' => '0167',
- 'Utilde' => '0168',
- 'utilde' => '0169',
- 'Umacron' => '016a',
- 'umacron' => '016b',
- 'Ubreve' => '016c',
- 'ubreve' => '016d',
- 'Uring' => '016e',
- 'uring' => '016f',
- 'Udoubleacute' => '0170',
- 'udoubleacute' => '0171',
- 'Uogonek' => '0172',
- 'uogonek' => '0173',
- 'Ydiaeresis' => '0178',
- 'Zacute' => '0179',
- 'zacute' => '017a',
- 'Zabovedot' => '017b',
- 'zabovedot' => '017c',
- 'Zcaron' => '017d',
- 'zcaron' => '017e',
- 'SCHWA' => '018f', # Is this recognised by X ?
- 'Schwa' => '018f', # Is this recognised by X ?
- 'function' => '0192',
- 'Ohorn' => '01a0', # Is this recognised by X ?
- 'ohorn' => '01a1', # Is this recognised by X ?
- 'Uhorn' => '01af', # Is this recognised by X ?
- 'uhorn' => '01b0', # Is this recognised by X ?
- 'Gcaron' => '01e6', # Is this recognised by X ?
- 'gcaron' => '01e7', # Is this recognised by X ?
- 'schwa' => '0259', # Is this recognised by X ?
- 'caron' => '02c7',
- 'breve' => '02d8',
- 'abovedot' => '02d9',
- 'ogonek' => '02db',
- 'doubleacute' => '02dd',
- 'Greek_accentdieresis' => '0385',
- 'Greek_ALPHAaccent' => '0386',
- 'Greek_EPSILONaccent' => '0388',
- 'Greek_ETAaccent' => '0389',
- 'Greek_IOTAaccent' => '038a',
- 'Greek_OMICRONaccent' => '038c',
- 'Greek_UPSILONaccent' => '038e',
- 'Greek_OMEGAaccent' => '038f',
- 'Greek_iotaaccentdieresis' => '0390',
- 'Greek_ALPHA' => '0391',
- 'Greek_BETA' => '0392',
- 'Greek_GAMMA' => '0393',
- 'Greek_DELTA' => '0394',
- 'Greek_EPSILON' => '0395',
- 'Greek_ZETA' => '0396',
- 'Greek_ETA' => '0397',
- 'Greek_THETA' => '0398',
- 'Greek_IOTA' => '0399',
- 'Greek_KAPPA' => '039a',
- 'Greek_LAMBDA' => '039b',
- 'Greek_LAMDA' => '039b', # Is this recognised by X ? (speling error)
- 'Greek_MU' => '039c',
- 'Greek_NU' => '039d',
- 'Greek_XI' => '039e',
- 'Greek_OMICRON' => '039f',
- 'Greek_PI' => '03a0',
- 'Greek_RHO' => '03a1',
- 'Greek_SIGMA' => '03a3',
- 'Greek_TAU' => '03a4',
- 'Greek_UPSILON' => '03a5',
- 'Greek_PHI' => '03a6',
- 'Greek_CHI' => '03a7',
- 'Greek_PSI' => '03a8',
- 'Greek_OMEGA' => '03a9',
- 'Greek_IOTAdiaeresis' => '03aa',
- 'Greek_UPSILONdieresis' => '03ab',
- 'Greek_alphaaccent' => '03ac',
- 'Greek_epsilonaccent' => '03ad',
- 'Greek_etaaccent' => '03ae',
- 'Greek_iotaaccent' => '03af',
- 'Greek_upsilonaccentdieresis' => '03b0',
- 'Greek_alpha' => '03b1',
- 'Greek_beta' => '03b2',
- 'Greek_gamma' => '03b3',
- 'Greek_delta' => '03b4',
- 'Greek_epsilon' => '03b5',
- 'Greek_zeta' => '03b6',
- 'Greek_eta' => '03b7',
- 'Greek_theta' => '03b8',
- 'Greek_iota' => '03b9',
- 'Greek_kappa' => '03ba',
- 'Greek_lambda' => '03bb',
- 'Greek_lamda' => '03bb', # Is this recognised by X ? (speling error)
- 'Greek_mu' => '03bc',
- 'Greek_nu' => '03bd',
- 'Greek_xi' => '03be',
- 'Greek_omicron' => '03bf',
- 'Greek_pi' => '03c0',
- 'Greek_rho' => '03c1',
- 'Greek_finalsmallsigma' => '03c2',
- 'Greek_sigma' => '03c3',
- 'Greek_tau' => '03c4',
- 'Greek_upsilon' => '03c5',
- 'Greek_phi' => '03c6',
- 'Greek_chi' => '03c7',
- 'Greek_psi' => '03c8',
- 'Greek_omega' => '03c9',
- 'Greek_iotadieresis' => '03ca',
- 'Greek_upsilondieresis' => '03cb',
- 'Greek_omicronaccent' => '03cc',
- 'Greek_upsilonaccent' => '03cd',
- 'Greek_omegaaccent' => '03ce',
- 'Cyrillic_IO' => '0401',
- 'Serbian_DJE' => '0402',
- 'Macedonia_GJE' => '0403',
- 'Ukrainian_IE' => '0404',
- 'Macedonia_DSE' => '0405',
- 'Ukrainian_I' => '0406',
- 'Ukrainian_YI' => '0407',
- 'Cyrillic_JE' => '0408',
- 'Cyrillic_LJE' => '0409',
- 'Cyrillic_NJE' => '040a',
- 'Serbian_TSHE' => '040b',
- 'Macedonia_KJE' => '040c',
- 'Byelorussian_SHORTU' => '040e',
- 'Cyrillic_DZHE' => '040f',
- 'Cyrillic_A' => '0410',
- 'Cyrillic_BE' => '0411',
- 'Cyrillic_VE' => '0412',
- 'Cyrillic_GHE' => '0413',
- 'Cyrillic_DE' => '0414',
- 'Cyrillic_IE' => '0415',
- 'Cyrillic_ZHE' => '0416',
- 'Cyrillic_ZE' => '0417',
- 'Cyrillic_I' => '0418',
- 'Cyrillic_SHORTI' => '0419',
- 'Cyrillic_KA' => '041a',
- 'Cyrillic_EL' => '041b',
- 'Cyrillic_EM' => '041c',
- 'Cyrillic_EN' => '041d',
- 'Cyrillic_O' => '041e',
- 'Cyrillic_PE' => '041f',
- 'Cyrillic_ER' => '0420',
- 'Cyrillic_ES' => '0421',
- 'Cyrillic_TE' => '0422',
- 'Cyrillic_U' => '0423',
- 'Cyrillic_EF' => '0424',
- 'Cyrillic_HA' => '0425',
- 'Cyrillic_TSE' => '0426',
- 'Cyrillic_CHE' => '0427',
- 'Cyrillic_SHA' => '0428',
- 'Cyrillic_SHCHA' => '0429',
- 'Cyrillic_HARDSIGN' => '042a',
- 'Cyrillic_YERU' => '042b',
- 'Cyrillic_SOFTSIGN' => '042c',
- 'Cyrillic_E' => '042d',
- 'Cyrillic_YU' => '042e',
- 'Cyrillic_YA' => '042f',
- 'Cyrillic_a' => '0430',
- 'Cyrillic_be' => '0431',
- 'Cyrillic_ve' => '0432',
- 'Cyrillic_ghe' => '0433',
- 'Cyrillic_de' => '0434',
- 'Cyrillic_ie' => '0435',
- 'Cyrillic_zhe' => '0436',
- 'Cyrillic_ze' => '0437',
- 'Cyrillic_i' => '0438',
- 'Cyrillic_shorti' => '0439',
- 'Cyrillic_ka' => '043a',
- 'Cyrillic_el' => '043b',
- 'Cyrillic_em' => '043c',
- 'Cyrillic_en' => '043d',
- 'Cyrillic_o' => '043e',
- 'Cyrillic_pe' => '043f',
- 'Cyrillic_er' => '0440',
- 'Cyrillic_es' => '0441',
- 'Cyrillic_te' => '0442',
- 'Cyrillic_u' => '0443',
- 'Cyrillic_ef' => '0444',
- 'Cyrillic_ha' => '0445',
- 'Cyrillic_tse' => '0446',
- 'Cyrillic_che' => '0447',
- 'Cyrillic_sha' => '0448',
- 'Cyrillic_shcha' => '0449',
- 'Cyrillic_hardsign' => '044a',
- 'Cyrillic_yeru' => '044b',
- 'Cyrillic_softsign' => '044c',
- 'Cyrillic_e' => '044d',
- 'Cyrillic_yu' => '044e',
- 'Cyrillic_ya' => '044f',
- 'Cyrillic_io' => '0451',
- 'Serbian_dje' => '0452',
- 'Macedonia_gje' => '0453',
- 'Ukrainian_ie' => '0454',
- 'Macedonia_dse' => '0455',
- 'Ukrainian_i' => '0456',
- 'Ukrainian_yi' => '0457',
- 'Cyrillic_je' => '0458',
- 'Cyrillic_lje' => '0459',
- 'Cyrillic_nje' => '045a',
- 'Serbian_tshe' => '045b',
- 'Macedonia_kje' => '045c',
- 'Byelorussian_shortu' => '045e',
- 'Cyrillic_dzhe' => '045f',
- 'Ukrainian_GHE_WITH_UPTURN' => '0490', # Is this recognised by X ?
- 'Ukrainian_ghe_with_upturn' => '0491', # Is this recognised by X ?
- 'Cyrillic_GHE_bar' => '0492', # Is this recognised by X ?
- 'Cyrillic_ghe_bar' => '0493', # Is this recognised by X ?
- 'Cyrillic_KA_descender' => '049a', # Is this recognised by X ?
- 'Cyrillic_ka_descender' => '049b', # Is this recognised by X ?
- 'Cyrillic_KA_vertstroke' => '049c', # Is this recognised by X ?
- 'Cyrillic_ka_vertstroke' => '049d', # Is this recognised by X ?
- 'Cyrillic_EN_descender' => '04a2', # Is this recognised by X ?
- 'Cyrillic_en_descender' => '04a3', # Is this recognised by X ?
- 'Cyrillic_U_straight' => '04ae', # Is this recognised by X ?
- 'Cyrillic_u_straight' => '04af', # Is this recognised by X ?
- 'Cyrillic_U_straight_bar' => '04b0', # Is this recognised by X ?
- 'Cyrillic_u_straight_bar' => '04b1', # Is this recognised by X ?
- 'Cyrillic_HA_descender' => '04b2', # Is this recognised by X ?
- 'Cyrillic_ha_descender' => '04b3', # Is this recognised by X ?
- 'Cyrillic_CHE_vertstroke' => '04b8', # Is this recognised by X ?
- 'Cyrillic_che_vertstroke' => '04b9', # Is this recognised by X ?
- 'Cyrillic_SHHA' => '04ba', # Is this recognised by X ?
- 'Cyrillic_shha' => '04bb', # Is this recognised by X ?
- 'Cyrillic_SCHWA' => '04d8', # Is this recognised by X ?
- 'Cyrillic_schwa' => '04d9', # Is this recognised by X ?
- 'Cyrillic_O_bar' => '04e8', # Is this recognised by X ?
- 'Cyrillic_o_bar' => '04e9', # Is this recognised by X ?
- 'hebrew_aleph' => '05d0',
- 'hebrew_bet' => '05d1',
- 'hebrew_gimel' => '05d2',
- 'hebrew_dalet' => '05d3',
- 'hebrew_he' => '05d4',
- 'hebrew_waw' => '05d5',
- 'hebrew_zain' => '05d6',
- 'hebrew_chet' => '05d7',
- 'hebrew_tet' => '05d8',
- 'hebrew_yod' => '05d9',
- 'hebrew_finalkaph' => '05da',
- 'hebrew_kaph' => '05db',
- 'hebrew_lamed' => '05dc',
- 'hebrew_finalmem' => '05dd',
- 'hebrew_mem' => '05de',
- 'hebrew_finalnun' => '05df',
- 'hebrew_nun' => '05e0',
- 'hebrew_samech' => '05e1',
- 'hebrew_ayin' => '05e2',
- 'hebrew_finalpe' => '05e3',
- 'hebrew_pe' => '05e4',
- 'hebrew_finalzade' => '05e5',
- 'hebrew_zade' => '05e6',
- 'hebrew_qoph' => '05e7',
- 'hebrew_resh' => '05e8',
- 'hebrew_shin' => '05e9',
- 'hebrew_taw' => '05ea',
- 'Arabic_comma' => '060c',
- 'Arabic_semicolon' => '061b',
- 'Arabic_question_mark' => '061f',
- 'Arabic_hamza' => '0621',
- 'Arabic_maddaonalef' => '0622',
- 'Arabic_hamzaonalef' => '0623',
- 'Arabic_hamzaonwaw' => '0624',
- 'Arabic_hamzaunderalef' => '0625',
- 'Arabic_hamzaonyeh' => '0626',
- 'Arabic_alef' => '0627',
- 'Arabic_beh' => '0628',
- 'Arabic_tehmarbuta' => '0629',
- 'Arabic_teh' => '062a',
- 'Arabic_theh' => '062b',
- 'Arabic_jeem' => '062c',
- 'Arabic_hah' => '062d',
- 'Arabic_khah' => '062e',
- 'Arabic_dal' => '062f',
- 'Arabic_thal' => '0630',
- 'Arabic_ra' => '0631',
- 'Arabic_zain' => '0632',
- 'Arabic_seen' => '0633',
- 'Arabic_sheen' => '0634',
- 'Arabic_sad' => '0635',
- 'Arabic_dad' => '0636',
- 'Arabic_tah' => '0637',
- 'Arabic_zah' => '0638',
- 'Arabic_ain' => '0639',
- 'Arabic_ghain' => '063a',
- 'Arabic_tatweel' => '0640',
- 'Arabic_feh' => '0641',
- 'Arabic_qaf' => '0642',
- 'Arabic_kaf' => '0643',
- 'Arabic_lam' => '0644',
- 'Arabic_meem' => '0645',
- 'Arabic_noon' => '0646',
- 'Arabic_ha' => '0647',
- 'Arabic_heh' => '0647', # Is this recognised by X ?
- 'Arabic_waw' => '0648',
- 'Arabic_alefmaksura' => '0649',
- 'Arabic_yeh' => '064a',
- 'Arabic_fathatan' => '064b',
- 'Arabic_dammatan' => '064c',
- 'Arabic_kasratan' => '064d',
- 'Arabic_fatha' => '064e',
- 'Arabic_damma' => '064f',
- 'Arabic_kasra' => '0650',
- 'Arabic_shadda' => '0651',
- 'Arabic_sukun' => '0652',
- 'Arabic_madda_above' => '0653', # Is this recognised by X ?
- 'Arabic_hamza_above' => '0654', # Is this recognised by X ?
- 'Arabic_hamza_below' => '0655', # Is this recognised by X ?
- 'Arabic_superscript_alef' => '0670', # Is this recognised by X ?
- 'Thai_kokai' => '0e01',
- 'Thai_khokhai' => '0e02',
- 'Thai_khokhuat' => '0e03',
- 'Thai_khokhwai' => '0e04',
- 'Thai_khokhon' => '0e05',
- 'Thai_khorakhang' => '0e06',
- 'Thai_ngongu' => '0e07',
- 'Thai_chochan' => '0e08',
- 'Thai_choching' => '0e09',
- 'Thai_chochang' => '0e0a',
- 'Thai_soso' => '0e0b',
- 'Thai_chochoe' => '0e0c',
- 'Thai_yoying' => '0e0d',
- 'Thai_dochada' => '0e0e',
- 'Thai_topatak' => '0e0f',
- 'Thai_thothan' => '0e10',
- 'Thai_thonangmontho' => '0e11',
- 'Thai_thophuthao' => '0e12',
- 'Thai_nonen' => '0e13',
- 'Thai_dodek' => '0e14',
- 'Thai_totao' => '0e15',
- 'Thai_thothung' => '0e16',
- 'Thai_thothahan' => '0e17',
- 'Thai_thothong' => '0e18',
- 'Thai_nonu' => '0e19',
- 'Thai_bobaimai' => '0e1a',
- 'Thai_popla' => '0e1b',
- 'Thai_phophung' => '0e1c',
- 'Thai_fofa' => '0e1d',
- 'Thai_phophan' => '0e1e',
- 'Thai_fofan' => '0e1f',
- 'Thai_phosamphao' => '0e20',
- 'Thai_moma' => '0e21',
- 'Thai_yoyak' => '0e22',
- 'Thai_rorua' => '0e23',
- 'Thai_ru' => '0e24',
- 'Thai_loling' => '0e25',
- 'Thai_lu' => '0e26',
- 'Thai_wowaen' => '0e27',
- 'Thai_sosala' => '0e28',
- 'Thai_sorusi' => '0e29',
- 'Thai_sosua' => '0e2a',
- 'Thai_hohip' => '0e2b',
- 'Thai_lochula' => '0e2c',
- 'Thai_oang' => '0e2d',
- 'Thai_honokhuk' => '0e2e',
- 'Thai_paiyannoi' => '0e2f',
- 'Thai_saraa' => '0e30',
- 'Thai_maihanakat' => '0e31',
- 'Thai_saraaa' => '0e32',
- 'Thai_saraam' => '0e33',
- 'Thai_sarai' => '0e34',
- 'Thai_saraii' => '0e35',
- 'Thai_saraue' => '0e36',
- 'Thai_sarauee' => '0e37',
- 'Thai_sarau' => '0e38',
- 'Thai_sarauu' => '0e39',
- 'Thai_phinthu' => '0e3a',
- 'Thai_baht' => '0e3f',
- 'Thai_sarae' => '0e40',
- 'Thai_saraae' => '0e41',
- 'Thai_sarao' => '0e42',
- 'Thai_saraaimaimuan' => '0e43',
- 'Thai_saraaimaimalai' => '0e44',
- 'Thai_lakkhangyao' => '0e45',
- 'Thai_maiyamok' => '0e46',
- 'Thai_maitaikhu' => '0e47',
- 'Thai_maiek' => '0e48',
- 'Thai_maitho' => '0e49',
- 'Thai_maitri' => '0e4a',
- 'Thai_maichattawa' => '0e4b',
- 'Thai_thanthakhat' => '0e4c',
- 'Thai_nikhahit' => '0e4d',
- 'Thai_leksun' => '0e50',
- 'Thai_leknung' => '0e51',
- 'Thai_leksong' => '0e52',
- 'Thai_leksam' => '0e53',
- 'Thai_leksi' => '0e54',
- 'Thai_lekha' => '0e55',
- 'Thai_lekhok' => '0e56',
- 'Thai_lekchet' => '0e57',
- 'Thai_lekpaet' => '0e58',
- 'Thai_lekkao' => '0e59',
- 'Hangul_J_Kiyeog' => '11a8',
- 'Hangul_J_SsangKiyeog' => '11a9',
- 'Hangul_J_KiyeogSios' => '11aa',
- 'Hangul_J_Nieun' => '11ab',
- 'Hangul_J_NieunJieuj' => '11ac',
- 'Hangul_J_NieunHieuh' => '11ad',
- 'Hangul_J_Dikeud' => '11ae',
- 'Hangul_J_Rieul' => '11af',
- 'Hangul_J_RieulKiyeog' => '11b0',
- 'Hangul_J_RieulMieum' => '11b1',
- 'Hangul_J_RieulPieub' => '11b2',
- 'Hangul_J_RieulSios' => '11b3',
- 'Hangul_J_RieulTieut' => '11b4',
- 'Hangul_J_RieulPhieuf' => '11b5',
- 'Hangul_J_RieulHieuh' => '11b6',
- 'Hangul_J_Mieum' => '11b7',
- 'Hangul_J_Pieub' => '11b8',
- 'Hangul_J_PieubSios' => '11b9',
- 'Hangul_J_Sios' => '11ba',
- 'Hangul_J_SsangSios' => '11bb',
- 'Hangul_J_Ieung' => '11bc',
- 'Hangul_J_Jieuj' => '11bd',
- 'Hangul_J_Cieuc' => '11be',
- 'Hangul_J_Khieuq' => '11bf',
- 'Hangul_J_Tieut' => '11c0',
- 'Hangul_J_Phieuf' => '11c1',
- 'Hangul_J_Hieuh' => '11c2',
- 'Hangul_J_PanSios' => '11eb',
- 'Hangul_J_KkogjiDalrinIeung' => '11f0',
- 'Hangul_J_YeorinHieuh' => '11f9',
- 'Babovedot' => '1e02', # Is this recognised by X ?
- 'babovedot' => '1e03', # Is this recognised by X ?
- 'Dabovedot' => '1e0a', # Is this recognised by X ?
- 'dabovedot' => '1e0b', # Is this recognised by X ?
- 'Fabovedot' => '1e1e', # Is this recognised by X ?
- 'fabovedot' => '1e1f', # Is this recognised by X ?
- 'Mabovedot' => '1e40', # Is this recognised by X ?
- 'mabovedot' => '1e41', # Is this recognised by X ?
- 'Pabovedot' => '1e56', # Is this recognised by X ?
- 'pabovedot' => '1e57', # Is this recognised by X ?
- 'Sabovedot' => '1e60', # Is this recognised by X ?
- 'sabovedot' => '1e61', # Is this recognised by X ?
- 'Tabovedot' => '1e6a', # Is this recognised by X ?
- 'tabovedot' => '1e6b', # Is this recognised by X ?
- 'enspace' => '2002',
- 'emspace' => '2003',
- 'em3space' => '2004',
- 'em4space' => '2005',
- 'digitspace' => '2007',
- 'punctspace' => '2008',
- 'thinspace' => '2009',
- 'hairspace' => '200a',
- 'figdash' => '2012',
- 'endash' => '2013',
- 'emdash' => '2014',
- 'Greek_horizbar' => '2015',
- 'hebrew_doublelowline' => '2017',
- 'leftsinglequotemark' => '2018',
- 'rightsinglequotemark' => '2019',
- 'singlelowquotemark' => '201a',
- 'leftdoublequotemark' => '201c',
- 'rightdoublequotemark' => '201d',
- 'doublelowquotemark' => '201e',
- 'dagger' => '2020',
- 'doubledagger' => '2021',
- 'enfilledcircbullet' => '2022',
- 'doubbaselinedot' => '2025',
- 'ellipsis' => '2026',
- 'minutes' => '2032',
- 'seconds' => '2033',
- 'caret' => '2038',
- 'overline' => '203e',
- 'Korean_Won' => '20a9',
- 'DongSign' => '20ab', # Is this recognised by X ?
- 'EuroSign' => '20ac',
- 'Euro' => '20ac',
- 'careof' => '2105',
- 'numerosign' => '2116',
- 'phonographcopyright' => '2117',
- 'prescription' => '211e',
- 'trademark' => '2122',
- 'onethird' => '2153',
- 'twothirds' => '2154',
- 'onefifth' => '2155',
- 'twofifths' => '2156',
- 'threefifths' => '2157',
- 'fourfifths' => '2158',
- 'onesixth' => '2159',
- 'fivesixths' => '215a',
- 'oneeighth' => '215b',
- 'threeeighths' => '215c',
- 'fiveeighths' => '215d',
- 'seveneighths' => '215e',
- 'leftarrow' => '2190',
- 'uparrow' => '2191',
- 'rightarrow' => '2192',
- 'downarrow' => '2193',
- 'implies' => '21d2',
- 'ifonlyif' => '21d4',
- 'partialderivative' => '2202',
- 'nabla' => '2207',
- 'jot' => '2218',
- 'radical' => '221a',
- 'variation' => '221d',
- 'infinity' => '221e',
- 'logicaland' => '2227',
- 'upcaret' => '2227',
- 'downcaret' => '2228',
- 'logicalor' => '2228',
- 'intersection' => '2229',
- 'upshoe' => '2229',
- 'downshoe' => '222a',
- 'union' => '222a',
- 'integral' => '222b',
- 'therefore' => '2234',
- 'approximate' => '223c',
- 'similarequal' => '2243',
- 'notequal' => '2260',
- 'identical' => '2261',
- 'lessthanequal' => '2264',
- 'greaterthanequal' => '2265',
- 'includedin' => '2282',
- 'leftshoe' => '2282',
- 'includes' => '2283',
- 'rightshoe' => '2283',
- 'lefttack' => '22a2',
- 'righttack' => '22a3',
- 'uptack' => '22a4',
- 'downtack' => '22a5',
- 'upstile' => '2308',
- 'downstile' => '230a',
- 'telephonerecorder' => '2315',
- 'topintegral' => '2320',
- 'botintegral' => '2321',
- 'leftanglebracket' => '2329',
- 'rightanglebracket' => '232a',
- 'quad' => '2395',
- 'topleftparens' => '239b',
- 'botleftparens' => '239d',
- 'toprightparens' => '239e',
- 'botrightparens' => '23a0',
- 'topleftsqbracket' => '23a1',
- 'botleftsqbracket' => '23a3',
- 'toprightsqbracket' => '23a4',
- 'botrightsqbracket' => '23a6',
- 'leftmiddlecurlybrace' => '23a8',
- 'rightmiddlecurlybrace' => '23ac',
- 'leftradical' => '23b7',
- 'horizlinescan1' => '23ba',
- 'horizlinescan3' => '23bb',
- 'horizlinescan7' => '23bc',
- 'horizlinescan9' => '23bd',
- 'ht' => '2409',
- 'lf' => '240a',
- 'vt' => '240b',
- 'ff' => '240c',
- 'cr' => '240d',
- 'nl' => '2424',
- 'horizconnector' => '2500',
- 'horizlinescan5' => '2500',
- 'vertbar' => '2502',
- 'vertconnector' => '2502',
- 'topleftradical' => '250c',
- 'upleftcorner' => '250c',
- 'uprightcorner' => '2510',
- 'lowleftcorner' => '2514',
- 'lowrightcorner' => '2518',
- 'leftt' => '251c',
- 'rightt' => '2524',
- 'topt' => '252c',
- 'bott' => '2534',
- 'crossinglines' => '253c',
- 'checkerboard' => '2592',
- 'enfilledsqbullet' => '25aa',
- 'enopensquarebullet' => '25ab',
- 'filledrectbullet' => '25ac',
- 'openrectbullet' => '25ad',
- 'emfilledrect' => '25ae',
- 'emopenrectangle' => '25af',
- 'filledtribulletup' => '25b2',
- 'opentribulletup' => '25b3',
- 'filledrighttribullet' => '25b6',
- 'rightopentriangle' => '25b7',
- 'filledtribulletdown' => '25bc',
- 'opentribulletdown' => '25bd',
- 'filledlefttribullet' => '25c0',
- 'leftopentriangle' => '25c1',
- 'soliddiamond' => '25c6',
- 'circle' => '25cb',
- 'emopencircle' => '25cb',
- 'emfilledcircle' => '25cf',
- 'enopencircbullet' => '25e6',
- 'openstar' => '2606',
- 'telephone' => '260e',
- 'signaturemark' => '2613',
- 'leftpointer' => '261c',
- 'rightpointer' => '261e',
- 'femalesymbol' => '2640',
- 'malesymbol' => '2642',
- 'club' => '2663',
- 'heart' => '2665',
- 'diamond' => '2666',
- 'musicalflat' => '266d',
- 'musicalsharp' => '266f',
- 'checkmark' => '2713',
- 'ballotcross' => '2717',
- 'latincross' => '271d',
- 'maltesecross' => '2720',
- 'kana_comma' => '3001',
- 'kana_fullstop' => '3002',
- 'kana_openingbracket' => '300c',
- 'kana_closingbracket' => '300d',
- 'voicedsound' => '309b',
- 'semivoicedsound' => '309c',
- 'kana_a' => '30a1',
- 'kana_A' => '30a2',
- 'kana_i' => '30a3',
- 'kana_I' => '30a4',
- 'kana_u' => '30a5',
- 'kana_U' => '30a6',
- 'kana_e' => '30a7',
- 'kana_E' => '30a8',
- 'kana_o' => '30a9',
- 'kana_O' => '30aa',
- 'kana_KA' => '30ab',
- 'kana_KI' => '30ad',
- 'kana_KU' => '30af',
- 'kana_KE' => '30b1',
- 'kana_KO' => '30b3',
- 'kana_SA' => '30b5',
- 'kana_SHI' => '30b7',
- 'kana_SU' => '30b9',
- 'kana_SE' => '30bb',
- 'kana_SO' => '30bd',
- 'kana_TA' => '30bf',
- 'kana_CHI' => '30c1',
- 'kana_tsu' => '30c3',
- 'kana_TSU' => '30c4',
- 'kana_TE' => '30c6',
- 'kana_TO' => '30c8',
- 'kana_NA' => '30ca',
- 'kana_NI' => '30cb',
- 'kana_NU' => '30cc',
- 'kana_NE' => '30cd',
- 'kana_NO' => '30ce',
- 'kana_HA' => '30cf',
- 'kana_HI' => '30d2',
- 'kana_FU' => '30d5',
- 'kana_HE' => '30d8',
- 'kana_HO' => '30db',
- 'kana_MA' => '30de',
- 'kana_MI' => '30df',
- 'kana_MU' => '30e0',
- 'kana_ME' => '30e1',
- 'kana_MO' => '30e2',
- 'kana_ya' => '30e3',
- 'kana_YA' => '30e4',
- 'kana_yu' => '30e5',
- 'kana_YU' => '30e6',
- 'kana_yo' => '30e7',
- 'kana_YO' => '30e8',
- 'kana_RA' => '30e9',
- 'kana_RI' => '30ea',
- 'kana_RU' => '30eb',
- 'kana_RE' => '30ec',
- 'kana_RO' => '30ed',
- 'kana_WA' => '30ef',
- 'kana_WO' => '30f2',
- 'kana_N' => '30f3',
- 'kana_conjunctive' => '30fb',
- 'kana_middledot' => '30fb', # Is this recognised by X ?
- 'prolongedsound' => '30fc',
- 'Hangul_Kiyeog' => '3131',
- 'Hangul_SsangKiyeog' => '3132',
- 'Hangul_KiyeogSios' => '3133',
- 'Hangul_Nieun' => '3134',
- 'Hangul_NieunJieuj' => '3135',
- 'Hangul_NieunHieuh' => '3136',
- 'Hangul_Dikeud' => '3137',
- 'Hangul_SsangDikeud' => '3138',
- 'Hangul_Rieul' => '3139',
- 'Hangul_RieulKiyeog' => '313a',
- 'Hangul_RieulMieum' => '313b',
- 'Hangul_RieulPieub' => '313c',
- 'Hangul_RieulSios' => '313d',
- 'Hangul_RieulTieut' => '313e',
- 'Hangul_RieulPhieuf' => '313f',
- 'Hangul_RieulHieuh' => '3140',
- 'Hangul_Mieum' => '3141',
- 'Hangul_Pieub' => '3142',
- 'Hangul_SsangPieub' => '3143',
- 'Hangul_PieubSios' => '3144',
- 'Hangul_Sios' => '3145',
- 'Hangul_SsangSios' => '3146',
- 'Hangul_Ieung' => '3147',
- 'Hangul_Jieuj' => '3148',
- 'Hangul_SsangJieuj' => '3149',
- 'Hangul_Cieuc' => '314a',
- 'Hangul_Khieuq' => '314b',
- 'Hangul_Tieut' => '314c',
- 'Hangul_Phieuf' => '314d',
- 'Hangul_Hieuh' => '314e',
- 'Hangul_A' => '314f',
- 'Hangul_AE' => '3150',
- 'Hangul_YA' => '3151',
- 'Hangul_YAE' => '3152',
- 'Hangul_EO' => '3153',
- 'Hangul_E' => '3154',
- 'Hangul_YEO' => '3155',
- 'Hangul_YE' => '3156',
- 'Hangul_O' => '3157',
- 'Hangul_WA' => '3158',
- 'Hangul_WAE' => '3159',
- 'Hangul_OE' => '315a',
- 'Hangul_YO' => '315b',
- 'Hangul_U' => '315c',
- 'Hangul_WEO' => '315d',
- 'Hangul_WE' => '315e',
- 'Hangul_WI' => '315f',
- 'Hangul_YU' => '3160',
- 'Hangul_EU' => '3161',
- 'Hangul_YI' => '3162',
- 'Hangul_I' => '3163',
- 'Hangul_RieulYeorinHieuh' => '316d',
- 'Hangul_SunkyeongeumMieum' => '3171',
- 'Hangul_SunkyeongeumPieub' => '3178',
- 'Hangul_PanSios' => '317f',
- 'Hangul_KkogjiDalrinIeung' => '3181',
- 'Hangul_SunkyeongeumPhieuf' => '3184',
- 'Hangul_YeorinHieuh' => '3186',
- 'Hangul_AraeA' => '318d',
- 'Hangul_AraeAE' => '318e',
- # Keypad keys
- 'KP_Home' => 'VoidSymbol',
- 'KP_Left' => 'VoidSymbol',
- 'KP_Up' => 'VoidSymbol',
- 'KP_Right' => 'VoidSymbol',
- 'KP_Down' => 'VoidSymbol',
- 'KP_Prior' => 'VoidSymbol',
- 'KP_Page_Up' => 'VoidSymbol',
- 'KP_Next' => 'VoidSymbol',
- 'KP_Page_Down' => 'VoidSymbol',
- 'KP_End' => 'VoidSymbol',
- 'KP_Begin' => 'VoidSymbol',
- 'KP_Insert' => 'VoidSymbol',
- 'KP_Delete' => 'VoidSymbol',
- 'KP_Multiply' => 'KP_Multiply',
- 'KP_Add' => 'KP_Add',
- 'KP_Seprator' => 'KP_Comma', # Is this recognised by X ?
- 'KP_Separator' => 'KP_Comma',
- 'KP_Subtract' => 'KP_Subtract',
- 'KP_Decimal' => 'KP_Period',
- 'KP_Divide' => 'KP_Divide',
- 'KP_0' => 'KP_0',
- 'KP_1' => 'KP_1',
- 'KP_2' => 'KP_2',
- 'KP_3' => 'KP_3',
- 'KP_4' => 'KP_4',
- 'KP_5' => 'KP_5',
- 'KP_6' => 'KP_6',
- 'KP_7' => 'KP_7',
- 'KP_8' => 'KP_8',
- 'KP_9' => 'KP_9',
- 'KP_Enter' => 'KP_Enter',
- # Keypad keys with missing support in the kernel
- 'KP_Space' => 'space',
- 'KP_Equal' => 'equal',
- 'KP_Tab' => 'Tab',
- 'KP_F1' => 'F1',
- 'KP_F2' => 'F2',
- 'KP_F3' => 'F3',
- 'KP_F4' => 'F4',
- # Dead symbols
- 'dead_grave' => 'dead_grave',
- 'SunFA_Grave' => 'dead_grave', # Is this recognised by X ?
- 'dead_acute' => 'dead_acute',
- 'SunFA_Acute' => 'dead_acute', # Is this recognised by X ?
- 'dead_circumflex' => 'dead_circumflex',
- 'SunFA_Circum' => 'dead_circumflex', # Is this recognised by X ?
- 'dead_tilde' => 'dead_tilde',
- 'SunFA_Tilde' => 'dead_tilde',
- 'dead_breve' => 'dead_breve',
- 'dead_diaeresis' => 'dead_diaeresis',
- 'SunFA_Diaeresis' => 'dead_diaeresis', # Is this recognised by X ?
- 'dead_doubleacute' => 'dead_doubleacute',
- 'dead_caron' => 'dead_caron',
- 'dead_cedilla' => 'dead_cedilla',
- 'SunFA_Cedilla' => 'dead_cedilla', # Is this recognised by X ?
- 'dead_ogonek' => 'dead_ogonek',
- # Dead symbols with no support in the kernel
- 'dead_macron' => '005f', # underscore
- 'dead_abovedot' => '002e', # period
- 'dead_abovering' => '002a', # asterisk
- 'dead_belowdot' => '0323', # ???? Vietnamese
- 'dead_hook' => '0309', # ???? Vietnamese
- 'dead_iota' => '03b9', # ???? Greek
- 'dead_horn' => '031b', # ???? Greek
- # Modifiers
- 'Multi_key' => 'Compose',
- 'Mode_switch' => 'ShiftL',
- 'script_switch' => 'VoidSymbol',
- 'Shift_L' => 'Shift',
- 'Shift_R' => 'Shift',
- 'Control_L' => 'Control',
- 'Control_R' => 'Control',
- 'Caps_Lock' => 'Caps_Lock',
- 'Shift_Lock' => 'Shift_Lock',
- 'Meta_L' => 'Alt',
- 'Meta_R' => 'Alt',
- 'Alt_L' => 'Alt',
- 'Alt_R' => 'Alt',
- 'Super_L' => 'Alt',
- 'Super_R' => 'Alt',
- 'Hyper_L' => 'Alt',
- 'Hyper_R' => 'Alt',
- 'ISO_Lock' => 'Caps_Lock',
- 'ISO_Level2_Latch' => 'Shift',
- 'ISO_Level3_Shift' => 'AltGr',
- 'ISO_Level3_Latch' => 'AltGr',
- 'ISO_Level3_Lock' => 'AltGr_Lock',
- 'ISO_Group_Shift' => 'ShiftL',
- 'ISO_Group_Latch' => 'ShiftL',
- 'ISO_Group_Lock' => 'ShiftL_Lock',
- 'ISO_Next_Group' => 'ShiftL_Lock',
- 'ISO_Next_Group_Lock' => 'ShiftL_Lock',
- 'ISO_Prev_Group' => 'ShiftL_Lock',
- 'ISO_Prev_Group_Lock' => 'ShiftL_Lock',
- 'ISO_First_Group' => 'ShiftL_Lock',
- 'ISO_First_Group_Lock' => 'ShiftL_Lock',
- 'ISO_Last_Group' => 'ShiftL_Lock',
- 'ISO_Last_Group_Lock' => 'ShiftL_Lock',
- # Other symbols
- 'Nosymbol' => 'NoSymbol', # Is this recognised by X ?
- 'NoSymbol' => 'NoSymbol',
- 'any' => 'NoSymbol', # Is this recognised by X ?
- 'VoidSymbol' => 'VoidSymbol',
- 'voidsymbol' => 'VoidSymbol', # Is this recognised by X ?
- 'ISO_Left_Tab' => 'Tab',
- 'Clear' => 'VoidSymbol',
- 'Pause' => 'Pause',
- 'Scroll_Lock' => 'Scroll_Lock',
- 'Sys_Req' => 'VoidSymbol',
- 'Delete' => 'Remove',
- 'Codeinput' => 'VoidSymbol',
- 'SingleCandidate' => 'VoidSymbol',
- 'MultipleCandidate' => 'VoidSymbol',
- 'PreviousCandidate' => 'VoidSymbol',
- 'Home' => 'Home',
- 'Left' => 'Left',
- 'Up' => 'Up',
- 'Right' => 'Right',
- 'Down' => 'Down',
- 'Prior' => 'Prior',
- 'Page_Up' => 'PageUp',
- 'Next' => 'Next',
- 'Page_Down' => 'PageDown',
- 'End' => 'End',
- 'Begin' => 'VoidSymbol',
- 'Select' => 'Select',
- 'Print' => 'VoidSymbol',
- 'Execute' => 'VoidSymbol',
- 'Insert' => 'Insert',
- 'Undo' => 'VoidSymbol',
- 'Redo' => 'VoidSymbol',
- 'Menu' => 'VoidSymbol',
- 'Find' => 'Find',
- 'Cancel' => 'VoidSymbol',
- 'Help' => 'Help',
- 'Break' => 'Pause',
- 'Num_Lock' => 'Num_Lock',
- 'F1' => 'F1',
- 'F2' => 'F2',
- 'F3' => 'F3',
- 'F4' => 'F4',
- 'F5' => 'F5',
- 'F6' => 'F6',
- 'F7' => 'F7',
- 'F8' => 'F8',
- 'F9' => 'F9',
- 'F10' => 'F10',
- 'F11' => 'F11',
- 'L1' => 'F11',
- 'F12' => 'F12',
- 'L2' => 'F12',
- 'F13' => 'F13',
- 'L3' => 'F13',
- 'F14' => 'F14',
- 'L4' => 'F14',
- 'F15' => 'F15',
- 'L5' => 'F15',
- 'F16' => 'F16',
- 'L6' => 'F16',
- 'F17' => 'F17',
- 'L7' => 'F17',
- 'F18' => 'F18',
- 'L8' => 'F18',
- 'F19' => 'F19',
- 'L9' => 'F19',
- 'F20' => 'F20',
- 'L10' => 'F20',
- 'F21' => 'F21',
- 'R1' => 'F21',
- 'F22' => 'F22',
- 'R2' => 'F22',
- 'F23' => 'F23',
- 'R3' => 'F23',
- 'F24' => 'F24',
- 'R4' => 'F24',
- 'F25' => 'F25',
- 'R5' => 'F25',
- 'F26' => 'F26',
- 'R6' => 'F26',
- 'F27' => 'F27',
- 'R7' => 'F27',
- 'F28' => 'F28',
- 'R8' => 'F28',
- 'F29' => 'F29',
- 'R9' => 'F29',
- 'F30' => 'F30',
- 'R10' => 'F30',
- 'F31' => 'F31',
- 'R11' => 'F31',
- 'F32' => 'F32',
- 'R12' => 'F32',
- 'F33' => 'F33',
- 'R13' => 'F33',
- 'F34' => 'F34',
- 'R14' => 'F34',
- 'F35' => 'F35',
- 'R15' => 'F35',
- 'Terminate_Server' => 'VoidSymbol',
- 'Pointer_EnableKeys' => 'VoidSymbol',
- 'XF86_Switch_VT_1' => 'VoidSymbol',
- 'XF86_Switch_VT_2' => 'VoidSymbol',
- 'XF86_Switch_VT_3' => 'VoidSymbol',
- 'XF86_Switch_VT_4' => 'VoidSymbol',
- 'XF86_Switch_VT_5' => 'VoidSymbol',
- 'XF86_Switch_VT_6' => 'VoidSymbol',
- 'XF86_Switch_VT_7' => 'VoidSymbol',
- 'XF86_Switch_VT_8' => 'VoidSymbol',
- 'XF86_Switch_VT_9' => 'VoidSymbol',
- 'XF86_Switch_VT_10' => 'VoidSymbol',
- 'XF86_Switch_VT_11' => 'VoidSymbol',
- 'XF86_Switch_VT_12' => 'VoidSymbol',
- 'XF86_ClearGrab' => 'VoidSymbol',
- 'XF86_Ungrab' => 'VoidSymbol',
- 'XF86_Next_VMode' => 'VoidSymbol',
- 'XF86_Prev_VMode' => 'VoidSymbol',
- # I do not know the Unicodes of these
- 'leftcaret' => 'VoidSymbol', # Is this recognised by X ?
- '0x13a4' => 'VoidSymbol', # Spelling error ?
- 'guj_rra' => 'VoidSymbol', # Is this recognised by X ?
- 'guj_nnna' => 'VoidSymbol', # Is this recognised by X ?
- 'guj_llla' => 'VoidSymbol', # Is this recognised by X ?
- 'gur_visarga' => 'VoidSymbol', # Is this recognised by X ?
- 'gur_v_r' => 'VoidSymbol', # Is this recognised by X ?
- 'gur_v_r_s' => 'VoidSymbol', # Is this recognised by X ?
- 'Eisu_toggle' => 'VoidSymbol', # Is this recognised by X ?
- 'Zenkaku_Hankaku' => 'VoidSymbol', # Is this recognised by X ?
- 'Kanji' => 'VoidSymbol', # Is this recognised by X ?
- # XFree86 does not recognise these
- 'SunAudioLowerVolume' => 'VoidSymbol',
- 'SunAudioMute' => 'VoidSymbol',
- 'SunAudioRaiseVolume' => 'VoidSymbol',
- 'SunCopy' => 'VoidSymbol',
- 'SunCut' => 'VoidSymbol',
- 'SunAgain' => 'VoidSymbol',
- 'SunUndo' => 'VoidSymbol',
- 'SunFind' => 'VoidSymbol',
- 'SunStop' => 'VoidSymbol',
- 'SunF36' => 'VoidSymbol',
- 'SunF37' => 'VoidSymbol',
- 'SunFront' => 'VoidSymbol',
- 'SunOpen' => 'VoidSymbol',
- 'SunPaste' => 'VoidSymbol',
- 'SunPowerSwitch' => 'VoidSymbol',
- 'SunPowerSwitchShift' => 'VoidSymbol',
- 'SunProps' => 'VoidSymbol',
- 'SunSys_Req' => 'VoidSymbol',
- 'SunVideoDegauss' => 'VoidSymbol',
- 'SunVideoLowerBrightness' => 'VoidSymbol',
- 'SunVideoRaiseBrightness' => 'VoidSymbol',
- );
-
- if ($compact) {
- $xkbsym_table{'Mode_switch'} = 'AltGr';
- $xkbsym_table{'ISO_Group_Shift'} = 'AltGr';
- $xkbsym_table{'ISO_Group_Latch'} = 'AltGr';
- $xkbsym_table{'ISO_Group_Lock'} = 'AltGr_Lock';
- $xkbsym_table{'ISO_Next_Group'} = 'AltGr_Lock';
- $xkbsym_table{'ISO_Next_Group_Lock'} = 'AltGr_Lock';
- $xkbsym_table{'ISO_Prev_Group'} = 'AltGr_Lock';
- $xkbsym_table{'ISO_Prev_Group_Lock'} = 'AltGr_Lock';
- $xkbsym_table{'ISO_First_Group'} = 'AltGr_Lock';
- $xkbsym_table{'ISO_First_Group_Lock'} = 'AltGr_Lock';
- $xkbsym_table{'ISO_Last_Group'} = 'AltGr_Lock';
- $xkbsym_table{'ISO_Last_Group_Lock'} = 'AltGr_Lock';
- }
-
- my @controlsyms;
- my @metasyms;
- my @metacontrolsyms;
-
- {
- my %controlsyms_hash = (
- '@' => 'nul',
- 'h' => 'BackSpace',
- 'i' => 'Tab',
- 'j' => 'Linefeed',
- '[' => 'Escape',
- '\\' => 'Control_backslash',
- ']' => 'Control_bracketright',
- '^' => 'Control_asciicircum',
- '_' => 'Control_underscore',
- chr(0x08) => 'BackSpace',
- chr(0x09) => 'Tab',
- chr(0x0a) => 'Linefeed',
- chr(0x0d) => 'Control_m',
- chr(0x1b) => 'Escape',
- chr(0x7f) => 'BackSpace', # instead of 'Delete'
- # The following are Linux specific
- '2' => 'nul',
- '3' => 'Escape',
- '4' => 'Control_backslash',
- '5' => 'Control_bracketright',
- '6' => 'Control_asciicircum',
- '7' => 'Control_underscore',
- '8' => 'Delete',
- '\'' => 'Control_g', # apostrophe
- '`' => 'nul', # grave
- '.' => 'Compose',
- '?' => 'Delete',
- ' ' => 'nul',
- );
- for my $code (0 .. 255) {
- my $sym = chr ((0x41 <= $code && 0x5a >= $code) ? $code + 0x20 : $code);
- if (defined (my $special = $controlsyms_hash{$sym})) {
- $controlsyms[$code + 1] = $special;
- } elsif (0x40 <= $code && 0x5f >= $code
- || 0x61 <= $code && 0x7a >= $code) {
- $controlsyms[$code + 1] = "Control_". $sym;
- } else {
- $controlsyms[$code + 1] = 'VoidSymbol';
- }
- }
- $controlsyms[0] = 'NoSymbol';
-
- my %metasyms_hash = (
- ' ' => 'space',
- '`' => 'grave',
- '^' => 'asciicircum',
- '~' => 'asciitilde',
- '<' => 'less',
- '=' => 'equal',
- '>' => 'greater',
- '|' => 'bar',
- '_' => 'underscore',
- '-' => 'minus',
- ',' => 'comma',
- ';' => 'semicolon',
- ':' => 'colon',
- '!' => 'exclam',
- '?' => 'question',
- '/' => 'slash',
- '.' => 'period',
- '\'' => 'apostrophe',
- '"' => 'quotedbl',
- '(' => 'parenleft',
- ')' => 'parenright',
- '[' => 'bracketleft',
- ']' => 'bracketright',
- '{' => 'braceleft',
- '}' => 'braceright',
- '@' => 'at',
- '$' => 'dollar',
- '*' => 'asterisk',
- '\\' => 'backslash',
- '&' => 'ampersand',
- '#' => 'numbersign',
- '%' => 'percent',
- '+' => 'plus',
- '0' => 'zero',
- '1' => 'one',
- '2' => 'two',
- '3' => 'three',
- '4' => 'four',
- '5' => 'five',
- '6' => 'six',
- '7' => 'seven',
- '8' => 'eight',
- '9' => 'nine',
- chr(0x08) => 'BackSpace',
- chr(0x09) => 'Tab',
- chr(0x0a) => 'Linefeed',
- chr(0x0d) => 'Control_m',
- chr(0x1b) => 'Escape',
- chr(0x7f) => 'Delete',
- );
-
- for my $code (0 .. 255) {
- my $sym = chr($code);
- if (defined (my $special = $metasyms_hash{$sym})) {
- $sym = $special;
- }
- $metasyms[$code + 1] = "Meta_". $sym;
- }
-
- $metasyms[0] = 'NoSymbol';
-
- for my $code (1 .. 256) {
- my $control = $controlsyms[$code];
- if ($control eq 'Compose') {
- $metacontrolsyms[$code] = 'Compose';
- } elsif ($control eq 'NoSymbol') {
- $metacontrolsyms[$code] = 'NoSymbol';
- } elsif ($control eq 'VoidSymbol') {
- $metacontrolsyms[$code] = 'VoidSymbol';
- } else {
- $metacontrolsyms[$code] = 'Meta_'. $control;
- }
- }
-
- $metacontrolsyms[0] = 'NoSymbol';
-
- }
-
- ############ GLOBAL FUNCTIONS #########################################
-
- # Looks for $_[0] in the known directories and returns ready to use
- # file name
- sub xfilename {
- my $file = $_[0];
- (my $base = $file) =~ s/.*\/(.+)/$1/;
- for my $dir (@xdirs) {
- if (-f "$dir/$file") {
- return "$dir/$file";
- }
- if (-f "$dir/$base") {
- return "$dir/$base";
- }
- }
- die "$0: Can not find file \"$file\" in any known directory\n";
- }
-
- ########### READ THE RULES FILE #######################################
-
- # The string $_[0] matches the pattern $_[1].
- # The pattern may be "*", a variable name, or a plain string.
- # If the string is 'OPTIONS' then match the pattern against any of the
- # options from @options.
- sub matches_pattern {
- my ($string, $pattern) = @_;
- if ($string eq 'OPTIONS') {
- for my $option (@options) {
- next if ($option eq '');
- if ($pattern eq $option) {
- return 1;
- }
- }
- } else {
- if ($pattern eq '*') {
- return $string ne '';
- }
- if ($pattern =~ /^\$([a-zA-Z0-9]+)$/) {
- for my $member (@{$rules_variables{$1}}) {
- if ($string eq $member) {
- return 1;
- }
- }
- return 0;
- }
- if ($string eq $pattern) {
- return 1;
- }
- }
- return 0;
- }
-
- if (@layouts) {
- for my $i (0 .. $#layouts) {
- if (! defined $variants[$i]) {
- $variants[$i] = '';
- }
- }
- my $rules_keycodes;
- my $rules_symbols;
- open (RULES, xfilename ("rules/$rules"))
- or die "$0: ". xfilename ("rules/$rules") .": $!\n";
- my $oldline = '';
- my @antecedents;
- my $consequent_name;
- my $match_found = 0;
- while (<RULES>) {
- next if (/^\s*\/\//);
- next if (/^\s*$/);
- chomp;
- s/^\s*//;
- s/\s+/ /g;
- if ($oldline) {
- $_ = $oldline . $_;
- $oldline = '';
- }
- if (s/\\$/ /) {
- $oldline = $_;
- next;
- }
- if (/^! ?\$([a-zA-Z0-9]+) ?= ?(.+)$/) {
- $rules_variables{$1} = [ split ' ', $2 ];
- next;
- }
- if (/^! ?(.+)= ?(.+)$/) {
- @antecedents = split ' ', $1;
- ($consequent_name = $2) =~ s/ //g;
- foreach my $i (0 .. $#antecedents) {
- if ($antecedents[$i] eq 'model') {
- $antecedents[$i] = $model;
- } elsif ($antecedents[$i] eq 'layout' && @layouts == 1) {
- $antecedents[$i] = $layouts[0];
- } elsif ($antecedents[$i] =~ /layout\[([1-4])\]/) {
- if (@layouts > 1) {
- $antecedents[$i] = $layouts[$1 - 1];
- } else {
- $antecedents[$i] = '';
- }
- } elsif ($antecedents[$i] eq 'variant' && @variants == 1) {
- $antecedents[$i] = $variants[0];
- } elsif ($antecedents[$i] =~ /variant\[([1-4])\]/) {
- if (@variants > 1) {
- $antecedents[$i] = $variants[$1 - 1];
- } else {
- $antecedents[$i] = '';
- }
- } elsif ($antecedents[$i] eq 'option') {
- $antecedents[$i] = 'OPTIONS';
- } elsif ($antecedents[$i] eq 'layout'
- || $antecedents[$i] eq 'variant') {
- $antecedents[$i] = '';
- } else {
- die "Unknown name $antecedents[$i]\n";
- }
- if (! defined $antecedents[$i]) {
- $antecedents[$i] = '';
- }
- }
- $match_found = 0;
- next;
- }
- if (/^(.+)= ?(.+)$/) {
- next if ($match_found);
- my @antecedent_patterns = split ' ', $1;
- my $consequent = $2;
- @antecedent_patterns == @antecedents
- or die "Bad number of antecedents";
- my $matches = 1;
- for my $i (0 .. $#antecedents) {
- if (! matches_pattern ($antecedents[$i],
- $antecedent_patterns[$i])) {
- $matches = 0;
- last;
- }
- }
- if ($matches) {
- $match_found = $antecedents[0] ne 'OPTIONS';
- $consequent =~ s/ //g;
- $consequent =~ s/%\(/\(%/g;
- $consequent =~ s/%_/_%/g;
- $consequent =~ s/%m/$model/g;
- $consequent =~ s/%l\[1\]/$layouts[0]/g;
- $consequent =~ s/%l\[2\]/$layouts[1]/g;
- $consequent =~ s/%l\[3\]/$layouts[2]/g;
- $consequent =~ s/%l\[4\]/$layouts[3]/g;
- $consequent =~ s/%l/$layouts[0]/g;
- $consequent =~ s/%v\[1\]/$variants[0]/g;
- $consequent =~ s/%v\[2\]/$variants[1]/g;
- $consequent =~ s/%v\[3\]/$variants[2]/g;
- $consequent =~ s/%v\[4\]/$variants[3]/g;
- $consequent =~ s/%v/$variants[0]/g;
- $consequent =~ s/\(\)//g;
- if ($consequent =~ /^\+/) {
- if ($consequent_name eq 'keycodes') {
- $rules_keycodes = $rules_keycodes . $consequent;
- } elsif ($consequent_name eq 'symbols') {
- $rules_symbols = $rules_symbols . $consequent;
- }
- } else {
- if ($consequent_name eq 'keycodes') {
- if (! $rules_keycodes) {
- $rules_keycodes = $consequent;
- }
- } elsif ($consequent_name eq 'symbols') {
- if (! $rules_symbols) {
- $rules_symbols = $consequent;
- }
- }
- }
- }
- next;
- }
- die "Syntax error in the rules file: $_\n";
- }
- close RULES;
-
- if ($verbosity >= 1) {
- print STDERR "Acording to the rules file:\n"
- ." keycodes = $rules_keycodes\n"
- ." symbols = $rules_symbols\n";
- }
-
- if (! $keycodes) {
- $keycodes = $rules_keycodes;
- }
- if (! $symbols) {
- $symbols = $rules_symbols;
- }
- }
-
- if (! $keycodes) {
- die "$0: No keycodes, nor layout specified\n";
- }
- if (! $symbols) {
- die "$0: No symbols, nor layout specified\n";
- }
-
- ########### COMPUTE ARCH ###########################################
-
- if ($keycodes =~ /(^|\+|\|)macintosh\(old\)($|\+|\|)/) {
- $arch = 'macintosh';
- } elsif ($keycodes =~ /(^|\+|\|)ataritt(\([^\)]*\))?($|\+|\|)/) {
- $arch = 'ataritt';
- } elsif ($keycodes =~ /(^|\+|\|)amiga(\([^\)]*\))?($|\+|\|)/) {
- $arch = 'amiga';
- } elsif ($keycodes =~ /(^|\+|\|)sun(\(type[45][^\)]*\))?($|\+|\|)/) {
- $arch = 'sun';
- }
-
- ########### READ ACM ###############################################
-
- if ($charmap) {
- for my $acmfile ("${charmap}", "${charmap}.gz",
- "${charmap}.acm", "${charmap}.acm.gz",
- "/usr/share/consoletrans/${charmap}",
- "/usr/share/consoletrans/${charmap}.gz",
- "/usr/share/consoletrans/${charmap}.acm",
- "/usr/share/consoletrans/${charmap}.acm.gz",
- "acm/${charmap}.acm") {
- if (-f $acmfile) {
- $acm = $acmfile;
- last;
- }
- }
- (-f $acm) or die "$0: no ACM for ${charmap} exists\n";
- if ($acm =~ /gz$/) {
- open (ACM, '-|:utf8', "zcat $acm") or die "$0: $acm: $!\n";
- } else {
- open (ACM, '<:utf8', $acm) or die "$0: $acm: $!\n";
- }
- while (<ACM>) {
- s/\#.*//;
- chomp;
- next unless (/[^\s]/);
- if (/^\s*0x([0-9a-fA-F]{1,2})\s+\'([^\']+)\'\s*$/) {
- my $uni = ord ($2);
- my $c = hex ($1);
- $acmtable{$uni} = $c;
- } else {
- die "$0: Syntax error in ACM file: $_\n";
- }
- }
- close ACM;
- }
-
- # A hack to work around a bug in the kernel/loadkeys
- # Disabled for Ubuntu because the cure is worse than the disease:
- # https://bugs.launchpad.net/ubuntu/+source/console-setup/+bug/69725
- # However, Turkish still needs this behaviour.
- if (! $acm && grep { $_ eq 'tr' } @layouts) {
- $xkbsym_table{'Caps_Lock'} = 'Shift_Lock';
- $xkbsym_table{'ISO_Lock'} = 'Shift_Lock';
- }
-
- ########### PARSING ###############################################
-
- # Report a syntax error in $filename. $_[0] should describe what was
- # expected at $stream.
- sub syntax_error {
- die "$0: instead of \"". (substr ($stream, 0, 50))
- ."\" in $filename expected $_[0].\n";
- }
-
- # Opens the text file $_[0], reads it and saves its contents in $stream
- # The comments are removed, all new lines are replaced by spaces and
- # all redundant spaces are removed.
- sub file_to_string {
- my $file = $_[0];
- my $string = '';
- open (FILE, "$file") or die "$0: $file: $!\n";
- while (<FILE>) {
- chop;
- s{//.*}{};
- $string = $string . $_ .' ';
- }
- close FILE;
-
- my $normalized = '';
- my $final_letter = 0;
- while ($string) {
- if ($string =~ s/^\s+// && $final_letter && $string =~ /^[a-zA-Z0-9]/) {
- $normalized = $normalized .' ';
- $final_letter = 0;
- }
- if ($string =~ s/^([^\"\s]+)//) {
- $normalized = $normalized . $1;
- $final_letter = ($1 =~ /[a-zA-Z0-9]$/);
- next;
- }
- if ($string =~ s/^(\"[^\"]*(\"|$))//) {
- $normalized = $normalized . $1;
- $final_letter = 0;
- if ($2 ne '"') {
- die "$0: missing quote in ". (substr ($1, 0, 50)) ."...\n";
- }
- next;
- }
- (! $string ) or die "Internal error";
- }
- $stream = $normalized;
- }
-
- # removes from $stream initial sequence of xkb flags (default, partial,
- # hidden, etc.) Returns true if the "default" flag was among them.
- sub xkb_flags {
- my $default = 0;
- while ($stream =~ s/^(default|partial|hidden
- |alphanumeric_keys|modifier_keys
- |keypad_keys|function_keys
- |alternate_group)\s?(.*)/$2/ix) {
- $default = 1 if ($1 =~ /default/i);
- }
- return $default;
- }
-
- # Removes and returns identifier from $stream.
- sub xkb_identifier {
- if ($stream =~ s/^([a-zA-Z0-1_]+) ?(.*)/$2/) {
- return $1;
- } else {
- syntax_error "identifier";
- }
- }
-
- # Removes and returns a string from $stream.
- sub xkb_string {
- if ($stream =~ /^\"([^\"]*)\"(.*)/) {
- $stream = $2;
- return $1;
- } else {
- syntax_error "string";
- }
- }
-
- # Removes an include method name from $stream and returns $alternate_method,
- # $augment_method, $replace_method, or $override_method. If $stream
- # does not start with a method name, return the default method (i.e. $method)
- sub xkb_method {
- if ($stream =~ s/^alternate ?(.*)/$1/i) {
- return $alternate_method;
- } elsif ($stream =~ s/^augment ?(.*)/$1/i) {
- return $augment_method;
- } elsif ($stream =~ s/^replace ?(.*)/$1/i) {
- return $replace_method;
- } elsif ($stream =~ s/^override ?(.*)/$1/i) {
- return $override_method;
- } else {
- return $method;
- }
- }
-
- # If $stream starts with an include statement - process it and return true.
- # Otherwise return false. $_[0] is the file type ("symbols" or "keycodes")
- sub xkb_include {
- my $file_type = $_[0];
- if ($stream =~ s/^(include|replace|augment|override)\"([^\"]*)\";?
- (.*)/$3/ix) {
- my $method_name = $1;
- my $include_request = $2;
- if ($method != $ignore_method) {
- my $oldmethod = $method;
- if ($method_name =~ /replace/i) {
- $method = $replace_method;
- } elsif ($method_name =~ /augment/i) {
- $method = $augment_method;
- } elsif ($method_name =~ /override/i) {
- $method = $override_method;
- }
- &include_xkb_file ($file_type, $include_request);
- $method = $oldmethod;
- }
- return 1;
- } else {
- return 0;
- }
- }
-
- sub xkb_keycodes_definitions {
- my $oldmethod = $method;
- while ($stream) {
- $method = $oldmethod;
-
- if (xkb_include ('keycodes')) {
- next;
- }
-
- $method = xkb_method ();
-
- if ($stream =~ (s/^(minimum|maximum|indicator|virtual\sindicator)
- [^;]*;(.*)/$2/ix)) {
- next;
- }
-
- if ($stream =~ /^<([^>]*)>=/) {
- $stream =~ s/^<([^>]+)>=([0-9]*);(.*)/$3/
- or syntax_error "keycode definition";
- my $key = $1;
- my $code = $2;
- if ($method == $replace_method
- || $method == $override_method
- || ($method == $augment_method
- && ! defined $keycodes_table{$key})) {
- $keycodes_table{$key} = [ $code ];
- delete $aliases{$key};
- } elsif ($method == $alternate_method) {
- push @{$keycodes_table{$key}}, $code;
- }
- next;
- }
- if ($stream =~ /^alias/) {
- $stream =~ s/^alias<([^>]+)>=<([^>]+)>;(.*)/$3/
- or syntax_error "alias definition";
- my $alias = $1;
- my $key = $2;
- if ($method == $replace_method
- || $method == $override_method
- || ($method == $augment_method
- && ! defined $keycodes_table{$alias})) {
- $keycodes_table{$alias} = [];
- $aliases{$alias} = $key;
- }
- next;
- }
- last;
- }
- $method = $oldmethod;
- }
-
- # Fill @{$symbols_table{$code}[$group]} with symbols
- sub symbols_for_group {
- my $code = shift;
- my $group = shift;
- if ($method == $replace_method
- || ($method == $override_method
- && (@_ || ! defined $symbols_table{$code}[$group]))
- || ($method == $augment_method &&
- ! defined $symbols_table{$code})) {
- my $level = 0;
- for my $symbol (@_) {
- if ($symbol !~ /\(/ && $symbol =~ /./
- && ($symbol !~ /^nosymbol$/i
- || ! defined $symbols_table{$code}[$group][$level])) {
- $symbols_table{$code}[$group][$level] = $symbol;
- }
- $level++;
- }
- }
- }
-
- sub xkb_key {
- if ($stream =~ /^key</i) {
- $stream =~ s/^key<([^>]+)>\{([^\}]*?)\};(.*)/$3/i
- or syntax_error "key definition";
- my $key = $1;
- my $list = $2 .",";
- if ($verbosity >= 4 && ! defined $keycodes_table{$key}) {
- warning "No scan code for <$key> is defined.\n";
- }
- for my $code (@{$keycodes_table{$key}}) {
- if ($method == $replace_method) {
- $symbols_table{$code} = [];
- }
- my $group = $base_group;
- while ($list =~ /[^ ]/) {
- # [ X1, X2, ... ]
- if ($list =~ s/^\[([^\]]*?)\],(.*)/$2/) {
- (my $symbols = $1) =~ s/,/ /g;
- my @groupsymbols = split ' ', $symbols;
- symbols_for_group $code, $group, @groupsymbols;
- $group++;
- next;
- }
- # symbols[GroupN] = [ X1, X2, ... ]
- if ($list =~ (s/^symbols\[Group([1-4])\]
- =\[([^\]]*?)\],(.*)/$3/x)) {
- my $group = $1 - 1 + $base_group;
- (my $symbols = $2) =~ s/,/ /g;
- my @groupsymbols = split ' ', $symbols;
- symbols_for_group $code, $group, @groupsymbols;
- next;
- }
- # type = "...."
- if ($list =~ (s/^type=\"([^\"]+)\",(.*)/$2/)) {
- if ($method == $replace_method
- || $method == $override_method
- || ($method == $augment_method
- && ! defined $types_table{$code})) {
- $types_table{$code} = $1;
- }
- next;
- }
- # abracadabra
- # abracadabra = abra<cad>abra
- next if ($list =~ s/^[a-zA-Z0-9_]+(=[a-zA-Z0-9_<>]+)?,
- (.*)/$2/x);
- # abracadabra = "...."
- next if ($list =~ s/^[a-zA-Z0-9_]+=\"[^\"]+\",(.*)/$1/);
- # type[...] = "..."
- next if ($list =~ s/^type\[[a-zA-Z0-9_]+\]=\"[^\"]+\",
- (.*)/$1/x);
- die "$0: garbage in a key definition: \"$list\""
- ." in $filename.\n";
- }
- }
- return 1;
- } else {
- return 0;
- }
- }
-
- sub xkb_symbols_definitions {
- my $oldmethod = $method;
- while ($stream) {
- $method = $oldmethod;
-
- if (xkb_include ('symbols')) {
- next;
- }
-
- $method = xkb_method ();
-
- if ($stream =~ /^name/i) {
- $stream =~ s/^name\[[a-zA-Z0-9]+\]=\"[^\"]*\";(.*)/$1/i
- or syntax_error "group name";
- next;
- }
-
- if ($stream =~ s/^[a-zA-Z0-9]+\.[a-zA-Z0-9]+=.*?;(.*)/$1/i) {
- next;
- }
-
- if ($stream =~ s/^[a-zA-Z0-9]+\.[a-zA-Z0-9]+\[[a-zA-Z0-9]+\]
- =.*?;(.*)/$1/ix) {
- next;
- }
-
- if (xkb_key) {
- next;
- }
-
- if ($stream =~ /^(modifier_map|modmap|mod_map)/i) {
- $stream =~ (s/^(modifier_map|modmap|mod_map)\s?[a-zA-Z0-9_]+
- \{[^\}]*\};(.*)/$2/ix)
- or syntax_error "modifier_map";
- next;
- }
-
- if ($stream =~ /^virtual_modifiers/i) {
- $stream =~ (s/^virtual_modifiers\s?[a-zA-Z0-9_]+;(.*)/$1/ix)
- or syntax_error "virtual_modifiers";
- next;
- }
- last;
- }
- $method = $oldmethod;
- }
-
- sub xkb_definitions {
- my $file_type = $_[0];
- if ($file_type eq 'symbols') {
- xkb_symbols_definitions();
- } elsif ($file_type eq 'keycodes') {
- xkb_keycodes_definitions();
- } else {
- die "$0: Bad xkb file type $file_type\n";
- }
- }
-
- # Remove from $stream the characters up to the first unmatched "}"
- sub skip_to_brace {
- while ($stream && ($stream =~ s/^[^\}\{]*\{//)) {
- &skip_to_brace;
- }
- $stream =~ s/^[^\}\{]*(\}|$)//;
- }
-
- sub xkb_block_list {
- my $file_type = $_[0];
- my $block = $_[1];
- my $first = 1;
- my $ok = 0;
- my $mystream = $stream;
- while ($stream) {
- my $default = xkb_flags();
- xkb_identifier() eq "xkb_". $file_type
- or syntax_error "xkb_". $file_type;
- my $name = xkb_string();
- my $structured;
- if ($stream =~ s/^\{//) {
- $structured = 1;
- } else {
- $structured = 0;
- }
- if ($name eq $block || ($first && ! $block)) {
- xkb_definitions ($file_type);
- if ($structured) {
- $stream =~ s/^\};.*// or syntax_error "};";
- } else {
- $stream = '';
- }
- $ok = 1;
- } else {
- if ($structured) {
- skip_to_brace;
- $stream =~ s/^;// or syntax_error ";";
- } else {
- last;
- }
- }
- $first = 0;
- }
- if (! $ok) {
- $stream = $mystream;
- }
- return $ok;
- }
-
- sub include_xkb_file {
- my $file_type = $_[0];
- my $include_list = '^'. $_[1];
-
- my $oldmethod = $method;
- my $oldbase_group = $base_group;
- while ($include_list) {
- my $file;
- my $block;
- if ($include_list =~ (s/^(\^|\+|\|)([^\(\|\+]+)\(([^\)]+)\)
- :([1234])(.*)/$5/x)) {
- if ($1 eq '+') {
- $method = $override_method;
- } elsif ($1 eq '|') {
- $method = $augment_method;
- }
- $file = $2;
- $block = $3;
- $base_group = $4 - 1 + $base_group;
- } elsif ($include_list =~ (s/^(\^|\+|\|)([^\(\|\+]+)\(([^\)]+)\)
- (.*)/$4/x)) {
- if ($1 eq '+') {
- $method = $override_method;
- } elsif ($1 eq '|') {
- $method = $augment_method;
- }
- $file = $2;
- $block = $3;
- } elsif ($include_list =~ s/^(\^|\+|\|)([^\(\|\+]+):([1234])(.*)/$4/) {
- if ($1 eq '+') {
- $method = $override_method;
- } elsif ($1 eq '|') {
- $method = $augment_method;
- }
- $file = $2;
- $block = '';
- $base_group = $3 - 1 + $base_group;
- } elsif ($include_list =~ s/^(\^|\+|\|)([^\(\|\+]+)(.*)/$3/) {
- if ($1 eq '+') {
- $method = $override_method;
- } elsif ($1 eq '|') {
- $method = $augment_method;
- }
- $file = $2;
- $block = '';
- } else {
- die "$0: bad include list $include_list.\n";
- }
-
- my $oldstream = $stream;
- if ($file =~ /^\.?\//) {
- $stream = file_to_string ("$file");
- } else {
- $stream = file_to_string (xfilename "$file_type/$file");
- }
- my $oldfilename = $filename;
- $filename = $file;
- if (!xkb_block_list ($file_type, $block)) {
- warning "Can not found \"$block\" in \"$file\".\n";
- xkb_block_list ($file_type, '');
- }
- $stream = $oldstream;
- $filename = $oldfilename;
- $method = $oldmethod;
- $base_group = $oldbase_group;
- }
- }
-
- include_xkb_file 'keycodes', $keycodes;
-
- foreach my $alias (keys %aliases) {
- if (! defined $keycodes_table{$aliases{$alias}}) {
- die "$0: undefined keyname $aliases{$alias} in ".
- "an keycode alias definition in $filename.\n";
- }
- $keycodes_table{$alias} = [ @{$keycodes_table{$alias}},
- @{$keycodes_table{$aliases{$alias}}} ];
- }
-
- include_xkb_file 'symbols', $symbols;
-
- foreach my $key (keys %symbols_table) {
- foreach my $group (0 .. $#{$symbols_table{$key}}) {
- if (! defined $symbols_table{$key}[$group]) {
- $symbols_table{$key}[$group] = [];
- } else {
- foreach my $level (0 .. $#{$symbols_table{$key}[$group]}) {
- if (! defined $symbols_table{$key}[$group][$level]) {
- $symbols_table{$key}[$group][$level] = 'NoSymbol';
- }
- }
- }
- }
- if (! defined $types_table{$key}) {
- $types_table{$key} = 'DEFAULT';
- }
- }
-
- sub distance {
- my $x = $_[0];
- my $y = $_[1];
- my $bottom = $x & $y;
- # If groups differ prefer the zero group
- if (($x | 0x0f) != ($y | 0x0f)) {
- $bottom = $bottom & 0x0f;
- }
- return (($y - $bottom) << 6) | ($x - $bottom);
- }
-
- sub uni_to_legacy {
- my $uni = $_[0];
- if ($acm) {
- if ($uni <= 0x7f) {
- return sprintf "0x%02x", $uni;
- } elsif (defined $acmtable{$uni}) {
- return sprintf "0x%02x", $acmtable{$uni};
- } else {
- if ($verbosity >= 8) {
- warning sprintf ("Unicode U+%04x does not exist "
- ."in the legacy encoding\n", $uni);
- }
- return 'VoidSymbol';
- }
- } else {
- return 'U+'. sprintf ("%04x", $uni);
- }
- }
-
- sub x_to_kernelsym {
- my $xkeysym = $_[0];
- my $kernelkeysym = $xkbsym_table{$xkeysym};
- if (defined $kernelkeysym) {
- if ($kernelkeysym !~ /^[0-9a-fA-F]{4}$/) {
- return $kernelkeysym;
- }
- } else {
- $kernelkeysym = ($xkeysym =~ /^0x0?100([0-9a-fA-F]{4})/
- ? $1
- : ($xkeysym =~ /^U([0-9a-fA-F]+)/
- ? $1
- : undef));
- }
- if (defined $kernelkeysym) {
- my $uni = hex ($kernelkeysym);
- if (defined $forbidden{$uni}) {
- # warning "Forbidden Unicode \"U+$kernelkeysym\"\n";
- return 'VoidSymbol';
- } else {
- if (chr($uni) =~ /\p{IsAlpha}/) {
- my $legacy = uni_to_legacy ($uni);
- if ($legacy ne 'VoidSymbol') {
- return '+'. $legacy;
- } else {
- return $legacy;
- }
- } elsif ($uni <= 0x1f) {
- return $controlsyms[$uni + 1];
- } else {
- return uni_to_legacy ($uni);
- }
- }
- } else {
- warning "Unknown X keysym \"$xkeysym\"\n";
- return 'VoidSymbol';
- }
- }
-
- sub x_to_ascii {
- my $xkeysym = $_[0];
- my $kernelkeysym = $xkbsym_table{$xkeysym};
- if (defined $kernelkeysym) {
- if ($kernelkeysym eq 'Delete') {
- return 0x7f;
- } elsif ($kernelkeysym eq 'BackSpace') {
- return 0x08;
- } elsif ($kernelkeysym eq 'Tab') {
- return 0x09;
- } elsif ($kernelkeysym eq 'Linefeed') {
- return 0x0a;
- } elsif ($kernelkeysym eq 'Return') {
- return 0x0d;
- } elsif ($kernelkeysym eq 'Escape') {
- return 0x1b;
- } elsif ($kernelkeysym eq 'NoSymbol') {
- return -1;
- } elsif ($kernelkeysym !~ /^[0-9a-fA-F]{4}$/) {
- return undef;
- }
- } else {
- $kernelkeysym = ($xkeysym =~ /^0x0?100([0-9a-fA-F]{4})/
- ? $1
- : ($xkeysym =~ /^U([0-9a-fA-F]+)/
- ? $1
- : undef));
- }
- if (defined $kernelkeysym) {
- my $uni = hex ($kernelkeysym);
- if (0x00 <= $uni && 0x7f >= $uni) {
- return $uni;
- }
- }
- return undef;
- }
-
- # A vector of symbol codes for a key
- my @vector;
- # A vector with same length as @vector. Measures how well each element of
- # @vector represents the xkb symbol for the particular key. Bigger values
- # mean lower quality.
- my @quality;
-
- sub approximate {
- my ($coord, $new_sym, $new_quality) = @_;
- # $new_sym represents the xkb symbol for position $coord in @vector
- # with quality $new_quality
- if ((! defined $quality[$coord]
- || $quality[$coord] > $new_quality)
- && $new_sym ne 'VoidSymbol') {
- $vector[$coord] = $new_sym;
- $quality[$coord] = $new_quality;
- }
- }
-
- # Fill @vector with data for key number $_[0]
- sub flatten {
- my $key = $_[0];
- @vector = ();
- @quality = ();
- for my $group (0..3) {
- my $real_group = $group;
- if ($real_group == 3) {
- $real_group = 2;
- } elsif ($real_group == 2) {
- $real_group = 3;
- }
- while ($real_group > $#{$symbols_table{$key}}) {
- if ($real_group >= 2) {
- $real_group = $real_group - 2;
- } else {
- $real_group = $real_group - 1;
- }
- }
- next if ($real_group < 0);
- for my $level (0..3) {
- my $coord = $level + ($group << 4);
- my $real_level = $level;
- if ($types_table{$key} =~ /PC_BREAK|PC_SYSRQ
- |CTRL\+ALT|SHIFT\+ALT/x) {
- $real_level = 0;
- }
- while ($real_level > $#{$symbols_table{$key}[$real_group]}) {
- if ($real_level == 2) {
- $real_level = $real_level - 2;
- } else {
- $real_level = $real_level - 1;
- }
- }
- next if ($real_level < 0);
- my $xkeysym = $symbols_table{$key}[$real_group][$real_level];
- my $kernelkeysym = x_to_kernelsym ($xkeysym);
- $vector[$coord] = $kernelkeysym;
- my $ascii = x_to_ascii ($xkeysym);
- next unless (defined $ascii);
- for my $approximated_group (0 .. 3) {
- for my $approximated_level (0 .. 3) {
- my $approximated_coord = ($approximated_level
- + ($approximated_group << 4));
- my $distance = distance ($approximated_coord, $coord);
- approximate (($approximated_coord | 0x08),
- $metasyms[$ascii + 1], $distance);
- approximate (($approximated_coord | 0x04),
- $controlsyms[$ascii + 1], $distance);
- approximate (($approximated_coord | 0x0c),
- $metacontrolsyms[$ascii + 1], $distance);
- }
- }
- }
- if ($types_table{$key} eq 'PC_BREAK'
- && $#{$symbols_table{$key}[$real_group]} >= 1) {
- my $xkeysym = $symbols_table{$key}[$real_group][1];
- my $kernelkeysym = x_to_kernelsym ($xkeysym);
- if ($kernelkeysym ne 'VoidSymbol') {
- my $coord = ($group << 4);
- $vector[$coord + 4] = $kernelkeysym;
- $vector[$coord + 5] = $kernelkeysym;
- $vector[$coord + 6] = $kernelkeysym;
- $vector[$coord + 7] = $kernelkeysym;
- $vector[$coord + 12] = $kernelkeysym;
- $vector[$coord + 13] = $kernelkeysym;
- $vector[$coord + 14] = $kernelkeysym;
- $vector[$coord + 15] = $kernelkeysym;
- }
- } elsif ($types_table{$key} eq 'PC_SYSRQ'
- && $#{$symbols_table{$key}[$real_group]} >= 1) {
- my $xkeysym = $symbols_table{$key}[$real_group][1];
- my $kernelkeysym = x_to_kernelsym ($xkeysym);
- if ($kernelkeysym ne 'VoidSymbol') {
- my $coord = ($group << 4);
- $vector[$coord + 8] = $kernelkeysym;
- $vector[$coord + 9] = $kernelkeysym;
- $vector[$coord + 10] = $kernelkeysym;
- $vector[$coord + 11] = $kernelkeysym;
- $vector[$coord + 12] = $kernelkeysym;
- $vector[$coord + 13] = $kernelkeysym;
- $vector[$coord + 14] = $kernelkeysym;
- $vector[$coord + 15] = $kernelkeysym;
- }
- } elsif ($types_table{$key} eq 'CTRL+ALT'
- && $#{$symbols_table{$key}[$real_group]} >= 1) {
- my $xkeysym = $symbols_table{$key}[$real_group][1];
- my $kernelkeysym = x_to_kernelsym ($xkeysym);
- if ($kernelkeysym ne 'VoidSymbol') {
- my $coord = ($group << 4);
- $vector[$coord + 12] = $kernelkeysym;
- $vector[$coord + 13] = $kernelkeysym;
- $vector[$coord + 14] = $kernelkeysym;
- $vector[$coord + 15] = $kernelkeysym;
- }
- } elsif ($types_table{$key} eq 'SHIFT+ALT'
- && $#{$symbols_table{$key}[$real_group]} >= 1) {
- my $xkeysym = $symbols_table{$key}[$real_group][1];
- my $kernelkeysym = x_to_kernelsym ($xkeysym);
- if ($kernelkeysym ne 'VoidSymbol') {
- my $coord = ($group << 4);
- $vector[$coord + 9] = $kernelkeysym;
- $vector[$coord + 11] = $kernelkeysym;
- $vector[$coord + 13] = $kernelkeysym;
- $vector[$coord + 15] = $kernelkeysym;
- }
- }
- }
- for my $coord (0 .. 63) {
- if (! defined $vector[$coord]) {
- $vector[$coord] = 'VoidSymbol';
- }
- }
-
- for my $coord (0 .. 63) {
- next if ($coord & 0x0c); # If Control and/or Alt
- my $mask = $kernel_modifiers{$vector[$coord]};
- next unless (defined $mask);
- for my $mod (4, 8, 12) {
- if ($vector[$coord + $mod] eq 'VoidSymbol'
- && ($vector[($coord + $mod) | $mask] eq 'VoidSymbol')) {
- $vector[$coord + $mod] = $vector[$coord];
- }
- }
- }
-
- for my $coord (0 .. 63) {
- my $mask = $kernel_modifiers{$vector[$coord]};
- if (defined $mask) {
- $vector[$coord | $mask] = $vector[$coord];
- }
- }
-
- for my $coord (16 .. 63) {
- if ($vector[$coord] eq 'ShiftL') {
- $vector[$coord] = 'VoidSymbol';
- } elsif ($vector[$coord] eq 'ShiftL_Lock') {
- $vector[$coord] = 'VoidSymbol';
- }
- }
-
- for my $coord (0 .. 15) {
- if ($vector[$coord] eq 'ShiftL') {
- $vector[$coord + 16] = 'ShiftR';
- $vector[$coord + 32] = 'ShiftR';
- $vector[$coord + 48] = 'ShiftL';
- } elsif ($vector[$coord] eq 'ShiftL_Lock') {
- $vector[$coord + 16] = 'ShiftR_Lock';
- $vector[$coord + 32] = 'ShiftR_Lock';
- $vector[$coord + 48] = 'ShiftL_Lock';
- }
- }
-
- for my $group (0 .. 3) {
- my $kp = undef;
- for my $x (0 .. 15) {
- my $coord = 16 * $group + $x;
- if ($vector[$coord] =~ /^KP_/ && ! defined $kp) {
- $kp = $vector[$coord];
- }
- }
- if ($kp) {
- for my $x (0 .. 15) {
- my $coord = 16 * $group + $x;
- if ($vector[$coord] eq 'VoidSymbol') {
- $vector[$coord] = $kp;
- }
- }
- }
- }
-
- for my $group (0 .. 3) {
- my $coord = $group << 4;
- my $mainsym = $vector[$coord];
- if ($mainsym =~ /^F([0-9]+)$/) {
- my $num = $1;
- $vector[$coord + 1] = 'F'. ($num + 10);
- $vector[$coord + 2] = 'F'. ($num + 40);
- $vector[$coord + 3] = 'F'. ($num + 50);
- $vector[$coord + 4] = 'F'. ($num + 20);
- $vector[$coord + 5] = 'F'. ($num + 30);
- $vector[$coord + 6] = 'F'. ($num + 60);
- $vector[$coord + 7] = 'F'. ($num + 70);
- $vector[$coord + 8] = 'Console_'. $num;
- $vector[$coord + 9] = 'Console_'. ($num + 10);
- $vector[$coord + 12] = 'Console_'. $num;
- $vector[$coord + 13] = 'Console_'. ($num + 10);
- } elsif ($mainsym eq 'Scroll_Lock' || $mainsym eq 'Help') {
- $vector[$coord + 1] = 'Show_Memory';
- $vector[$coord + 2] = 'Show_Registers';
- $vector[$coord + 4] = 'Show_State';
- $vector[$coord + 8] = $mainsym; # or better 'Show_Registers' ?
- } elsif ($mainsym =~ /^KP_([0-9])$/) {
- my $num = $1;
- $vector[$coord + 2] = 'Hex_'. $num;
- $vector[$coord + 9] = 'Hex_'. $num;
- $vector[$coord + 8] = 'Ascii_'. $num;
- } elsif ($mainsym eq 'Num_Lock') {
- $vector[$coord + 2] = 'Hex_A';
- $vector[$coord + 9] = 'Hex_A';
- } elsif ($mainsym eq 'KP_Divide') {
- $vector[$coord + 2] = 'Hex_B';
- $vector[$coord + 9] = 'Hex_B';
- } elsif ($mainsym eq 'KP_Multiply') {
- $vector[$coord + 2] = 'Hex_C';
- $vector[$coord + 9] = 'Hex_C';
- } elsif ($mainsym eq 'KP_Subtract') {
- $vector[$coord + 2] = 'Hex_D';
- $vector[$coord + 9] = 'Hex_D';
- } elsif ($mainsym eq 'KP_Add') {
- $vector[$coord + 2] = 'Hex_E';
- $vector[$coord + 9] = 'Hex_E';
- } elsif ($mainsym eq 'KP_Enter') {
- $vector[$coord + 2] = 'Hex_F';
- $vector[$coord + 9] = 'Hex_F';
- } elsif ($mainsym eq 'Prior' || $mainsym eq 'PageUp') {
- $vector[$coord + 1] = 'Scroll_Backward';
- } elsif ($mainsym eq 'Next' || $mainsym eq 'PageDown') {
- $vector[$coord + 1] = 'Scroll_Forward';
- } elsif ($mainsym eq 'Left') {
- $vector[$coord + 8] = 'Decr_Console';
- } elsif ($mainsym eq 'Right') {
- $vector[$coord + 8] = 'Incr_Console';
- }
- }
- return @vector;
- }
-
- sub print_vector {
- my $kernel_code = $_[0];
- my $no_NoSymbol = 1;
- for my $mask (0 .. 63) {
- if ($vector[$mask] eq 'NoSymbol') {
- $no_NoSymbol = 0;
- last;
- }
- }
- if ($compact) {
- my $line = ($symbols =~ /:2/ # true if the keymap is non-latin
- ? "@vector[0, 1, 16, 17, 4, 20, 8, 24, 12, 28]"
- : "@vector[0, 1, 2, 3, 4, 6, 8, 10, 12, 14]");
- $line =~ s/NoSymbol/VoidSymbol/g;
- print "keycode $kernel_code = $line\n";
- } elsif ($no_NoSymbol) {
- print "keycode $kernel_code = @vector\n";
- } else {
- for my $mask (0 .. 63) {
- if ($vector[$mask] ne 'NoSymbol') {
- print "$modifier_combinations[$mask] keycode $kernel_code"
- ." = $vector[$mask]\n";
- }
- }
- }
- }
-
- my %at_scancodes = (
- 9 => 1,
- 10 => 2,
- 11 => 3,
- 12 => 4,
- 13 => 5,
- 14 => 6,
- 15 => 7,
- 16 => 8,
- 17 => 9,
- 18 => 10,
- 19 => 11,
- 20 => 12,
- 21 => 13,
- 22 => 14,
- 23 => 15,
- 24 => 16,
- 25 => 17,
- 26 => 18,
- 27 => 19,
- 28 => 20,
- 29 => 21,
- 30 => 22,
- 31 => 23,
- 32 => 24,
- 33 => 25,
- 34 => 26,
- 35 => 27,
- 36 => 28,
- 37 => 29,
- 38 => 30,
- 39 => 31,
- 40 => 32,
- 41 => 33,
- 42 => 34,
- 43 => 35,
- 44 => 36,
- 45 => 37,
- 46 => 38,
- 47 => 39,
- 48 => 40,
- 49 => 41,
- 50 => 42,
- 51 => 43,
- 52 => 44,
- 53 => 45,
- 54 => 46,
- 55 => 47,
- 56 => 48,
- 57 => 49,
- 58 => 50,
- 59 => 51,
- 60 => 52,
- 61 => 53,
- 62 => 54,
- 63 => 55,
- 64 => 56,
- 65 => 57,
- 66 => 58,
- 67 => 59,
- 68 => 60,
- 69 => 61,
- 70 => 62,
- 71 => 63,
- 72 => 64,
- 73 => 65,
- 74 => 66,
- 75 => 67,
- 76 => 68,
- 77 => 69,
- 78 => 70,
- 79 => 71,
- 80 => 72,
- 81 => 73,
- 82 => 74,
- 83 => 75,
- 84 => 76,
- 85 => 77,
- 86 => 78,
- 87 => 79,
- 88 => 80,
- 89 => 81,
- 90 => 82,
- 91 => 83,
- 92 => 84,
- 93 => -1, # fake key (KP_Equal)
- 94 => 86,
- 95 => 87,
- 96 => 88,
- 97 => 102,
- 98 => 103,
- 99 => 104,
- 100 => 105,
- 102 => 106,
- 103 => 107,
- 104 => 108,
- 105 => 109,
- 106 => 110,
- 107 => 111,
- 108 => 96,
- 109 => 97,
- 110 => 119,
- 111 => 99,
- 112 => 98,
- 113 => 100,
- 114 => 101,
- 115 => 125,
- 116 => 126,
- 117 => 127,
- 118 => -1, # Japanese
- 119 => -1, # Japanese
- 120 => -1, # Japanese
- 123 => -1,
- 124 => -1, # fake key
- 125 => -1, # fake key
- 126 => -1, # fake key
- 127 => -1, # fake key
- 128 => -1, # fake key
- 129 => -1, # Japanese
- 131 => -1, # Japanese
- 133 => 124, # Japanese
- 134 => 121, # Brasilian ABNT2
- 144 => -1, # Japanese
- 156 => -1, # fake key
- 208 => -1, # Japanese
- 211 => 89, # Brasilian ABNT2
- );
-
- if ($compact) {
- print "keymaps 0-4,6,8,10,12,14\n";
- } else {
- print "keymaps 0-63\n";
- }
- if ($arch eq 'at') {
- foreach my $key (sort {$a <=> $b} (keys %symbols_table)) {
- my $kernel_code = $at_scancodes{$key};
- if (! defined $kernel_code) {
- warning "Undefined kernel key code for $key\n";
- next;
- }
- next if ($kernel_code < 0);
- if ($kernel_code == 84) {
- @vector = ('Last_Console') x 64;
- } elsif ($kernel_code == 99) {
- @vector = ('Control_backslash') x 64;
- } elsif ($kernel_code == 101) {
- @vector = ('Break') x 64;
- } elsif ($kernel_code == 119) {
- @vector = ('Pause') x 64;
- } else {
- @vector = flatten ($key);
- }
- if ($kernel_code == 83 || $kernel_code == 111) {
- for my $coord (0, 16, 32, 48) {
- $vector[$coord + 6] = 'Boot';
- $vector[$coord + 12] = 'Boot';
- $vector[$coord + 14] = 'Boot';
- }
- }
- print_vector $kernel_code;
- }
- } elsif ($arch eq 'macintosh') {
- foreach my $key (sort {$a <=> $b} (keys %symbols_table)) {
- my $kernel_code = $key - 8;
- @vector = flatten ($key);
- print_vector $kernel_code;
- }
- print <<EOT
- keycode 127 =
- shift control keycode 127 = Boot
- EOT
- } elsif ($arch eq 'ataritt') {
- foreach my $key (sort {$a <=> $b} (keys %symbols_table)) {
- my $kernel_code = $key - 8;
- if ($kernel_code == 97) {
- @vector = ('F246', 'Break', 'F246', 'F246',
- 'F246', 'F246', 'F246', 'F246',
- 'Last_Console', 'F246', 'F246', 'F246',
- 'F246', 'F246', 'F246', 'F246') x 4;
- } else {
- @vector = flatten ($key);
- }
- if ($kernel_code == 83 || $kernel_code == 113) {
- for my $coord (0, 16, 32, 48) {
- $vector[$coord + 6] = 'Boot';
- $vector[$coord + 12] = 'Boot';
- $vector[$coord + 14] = 'Boot';
- }
- }
- print_vector $kernel_code;
- }
- } elsif ($arch eq 'amiga') {
- foreach my $key (sort {$a <=> $b} (keys %symbols_table)) {
- my $kernel_code = $key - 8;
- @vector = flatten ($key);
- if ($kernel_code == 60) {
- for my $coord (0, 16, 32, 48) {
- $vector[$coord + 6] = 'Boot';
- $vector[$coord + 12] = 'Boot';
- $vector[$coord + 14] = 'Boot';
- }
- }
- print_vector $kernel_code;
- }
- } elsif ($arch eq 'sun') {
- foreach my $key (sort {$a <=> $b} (keys %symbols_table)) {
- my $kernel_code = $key - 7;
- @vector = flatten ($key);
- if ($kernel_code == 50) {
- for my $coord (0, 16, 32, 48) {
- $vector[$coord + 6] = 'Boot';
- $vector[$coord + 12] = 'Boot';
- $vector[$coord + 14] = 'Boot';
- }
- }
- print_vector $kernel_code;
- }
- } else {
- die "$0: Unsupported keyboard type $arch\n";
- }
-
- print "strings as usual\n";
-
- if ($charmap && -f "/etc/console-setup/compose.${charmap}.inc") {
- system("cat /etc/console-setup/compose.${charmap}.inc");
- }
-
- exit 0;
-