3 # ***** BEGIN LICENSE BLOCK *****
4 # Version: MPL 1.1/GPL 2.0/LGPL 2.1
6 # The contents of this file are subject to the Mozilla Public License Version
7 # 1.1 (the "License"); you may not use this file except in compliance with
8 # the License. You may obtain a copy of the License at
9 # http://www.mozilla.org/MPL/
11 # Software distributed under the License is distributed on an "AS IS" basis,
12 # WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13 # for the specific language governing rights and limitations under the
16 # The Original Code is libguac-client-rdp.
18 # The Initial Developer of the Original Code is
19 # Jocelyn DELALANDE <j.delalande@ulteo.com> Ulteo SAS - http://www.ulteo.com
21 # Portions created by the Initial Developer are Copyright (C) 2012 Ulteo SAS.
25 # Alternatively, the contents of this file may be used under the terms of
26 # either the GNU General Public License Version 2 or later (the "GPL"), or
27 # the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
28 # in which case the provisions of the GPL or the LGPL are applicable instead
29 # of those above. If you wish to allow use of your version of this file only
30 # under the terms of either the GPL or the LGPL, and not to allow others to
31 # use your version of this file under the terms of the MPL, indicate your
32 # decision by deleting the provisions above and replace them with the notice
33 # and other provisions required by the GPL or the LGPL. If you do not delete
34 # the provisions above, a recipient may use your version of this file under
35 # the terms of any one of the MPL, the GPL or the LGPL.
37 # ***** END LICENSE BLOCK *****
39 # Converts a .ini file defining unicode exceptions to a dot_h file
40 # The dot_h file defines an array of keysim->unicode
42 # Used to extract the keysym<->unicode mapping exceptions from
43 # unicode_exception.ini (can be found in Ulteo patched version of xrdp)
45 # Such an ini file can be found at
46 # http://www.ulteo.com/home/en/download/sourcecode (xrdp folder)
57 # Extented keysym starting with 0x1000
59 # Extented keysym starting with 0x1001
61 # Extented keysym starting with 0x1002
64 def insert(self, keysym, uni):
65 # Main keysym table is 4-digit hexa keysyms
66 # (most of 'em are 3-digits but they lack the leading zero)
68 self.base.append((keysym[2:], uni))
70 elif keysym.startswith('0x100'):
71 if keysym[:6] == '0x1000':
72 self.ext0.append((keysym[6:], uni))
73 elif keysym[:6] == '0x1001':
74 self.ext1.append((keysym[6:], uni))
75 elif keysym[:6] == '0x1002':
76 self.ext2.append((keysym[6:], uni))
79 raise ValueError("Unexpected keysym : %s" % keysym)
82 raise ValueError("Unexpected keysym : %s" % keysym)
84 def get_h_content(self, base_name, ext0_name, ext1_name, ext2_name):
86 maps = ((base_name, self.base),
87 (ext0_name, self.ext0),
88 (ext1_name, self.ext1),
89 (ext2_name, self.ext2))
91 for var_name, kmap in maps:
92 for keysym, uni in kmap:
93 out += '%s[0x%s] = %s;\n' %(var_name, keysym, uni)
98 if __name__ == '__main__':
100 print "ini2dot_h_unimap.py <ini_file>"
103 inifile = sys.argv[1]
105 print "uni2keysym_map[]"
107 ini = ConfigParser.ConfigParser()
109 mapping = ini.items('unicode_exception')
114 for uni, keysym in mapping:
115 maps.insert(keysym, uni)
119 int keysm2uni_base[4096];
120 int keysm2uni_ext0[4096];
121 int keysm2uni_ext1[4096];
122 int keysm2uni_ext2[4096];
126 dot_h_content += maps.get_h_content('keysm2uni_base', 'keysm2uni_ext0',
127 'keysm2uni_ext1', 'keysm2uni_ext2');