Added keysym to unicode translation mechanisms.
Signed-off-by: Michael Jumper <zhangmaike@users.sourceforge.net>
This commit is contained in:
parent
c667219fe7
commit
12d7353fb7
@ -42,6 +42,7 @@ AM_CFLAGS = -Werror -Wall -pedantic -Iinclude
|
||||
lib_LTLIBRARIES = libguac-client-rdp.la
|
||||
|
||||
libguac_client_rdp_la_SOURCES = src/client.c src/rdp_bitmap.c src/rdp_glyph.c src/rdp_pointer.c src/rdp_gdi.c src/guac_handlers.c src/rdp_cliprdr.c \
|
||||
src/unicode_convtable.c\
|
||||
src/rdp_keymap.c \
|
||||
src/rdp_keymap_base.c \
|
||||
src/rdp_keymap_en_us.c
|
||||
|
1055
protocols/rdp/include/unicode_convtable.h
Normal file
1055
protocols/rdp/include/unicode_convtable.h
Normal file
File diff suppressed because it is too large
Load Diff
56
protocols/rdp/src/unicode_convtable.c
Normal file
56
protocols/rdp/src/unicode_convtable.c
Normal file
@ -0,0 +1,56 @@
|
||||
/**
|
||||
* Copyright (C) 2012 Ulteo SAS
|
||||
* http://www.ulteo.com
|
||||
* Author Jocelyn DELALANDE <j.delalande@ulteo.com> 2012
|
||||
*
|
||||
* 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; version 2
|
||||
* of the License.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
**/
|
||||
|
||||
|
||||
#include "unicode_convtable.h"
|
||||
|
||||
int keysym2uni(int keysym) {
|
||||
init_unicode_tables();
|
||||
/* Default: no exception */
|
||||
int exception = 0;
|
||||
|
||||
if (keysym < 0x100000) {
|
||||
// Look for a 4-digits-form exception
|
||||
exception = keysym2uni_base[keysym];
|
||||
} else {
|
||||
// Look for a 7-digits-form exception
|
||||
/* Switch to look for 0x1001XXX 0x1002XXX or 0x1002XXX
|
||||
the tables only indexes on XXX
|
||||
*/
|
||||
switch(keysym & 0xFFFF000) {
|
||||
case 0x1000000:
|
||||
exception = keysym2uni_ext0[keysym & 0x0000FFF];
|
||||
break;
|
||||
case 0x1001000:
|
||||
exception = keysym2uni_ext1[keysym & 0x0000FFF];
|
||||
break;
|
||||
case 0x1002000:
|
||||
exception = keysym2uni_ext2[keysym & 0x0000FFF];
|
||||
break;
|
||||
}
|
||||
|
||||
/* If the keysym is not within exceptions, keysym = unicode */
|
||||
}
|
||||
if (exception != 0) {
|
||||
return exception;
|
||||
} else {
|
||||
return keysym;
|
||||
}
|
||||
}
|
93
protocols/rdp/tools/ini2dot_h_unimap.py
Normal file
93
protocols/rdp/tools/ini2dot_h_unimap.py
Normal file
@ -0,0 +1,93 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
# Copyright (C) 2012 Ulteo SAS
|
||||
# http://www.ulteo.com
|
||||
# Author Jocelyn DELALANDE <j.delalande@ulteo.com> 2012
|
||||
#
|
||||
# Converts a .ini file defining unicode exceptions to a dot_h file
|
||||
# The dot_h file defines an array of keysim->unicode
|
||||
#
|
||||
# Used to extract the keysym<->unicode mapping exceptions from
|
||||
# unicode_exception.ini (can be found in Ulteo patched version of xrdp)
|
||||
|
||||
import sys
|
||||
import ConfigParser
|
||||
|
||||
|
||||
class KeysymMaps:
|
||||
def __init__(self):
|
||||
# 4 digits keysyms
|
||||
self.base = []
|
||||
# Extented keysym starting with 0x1000
|
||||
self.ext0 = []
|
||||
# Extented keysym starting with 0x1001
|
||||
self.ext1 = []
|
||||
# Extented keysym starting with 0x1002
|
||||
self.ext2 = []
|
||||
|
||||
def insert(self, keysym, uni):
|
||||
# Main keysym table is 4-digit hexa keysyms
|
||||
# (most of 'em are 3-digits but they lack the leading zero)
|
||||
if len(keysym) <= 6:
|
||||
self.base.append((keysym[2:], uni))
|
||||
|
||||
elif keysym.startswith('0x100'):
|
||||
if keysym[:6] == '0x1000':
|
||||
self.ext0.append((keysym[6:], uni))
|
||||
elif keysym[:6] == '0x1001':
|
||||
self.ext1.append((keysym[6:], uni))
|
||||
elif keysym[:6] == '0x1002':
|
||||
self.ext2.append((keysym[6:], uni))
|
||||
|
||||
else:
|
||||
raise ValueError("Unexpected keysym : %s" % keysym)
|
||||
|
||||
else:
|
||||
raise ValueError("Unexpected keysym : %s" % keysym)
|
||||
|
||||
def get_h_content(self, base_name, ext0_name, ext1_name, ext2_name):
|
||||
out = ''
|
||||
maps = ((base_name, self.base),
|
||||
(ext0_name, self.ext0),
|
||||
(ext1_name, self.ext1),
|
||||
(ext2_name, self.ext2))
|
||||
|
||||
for var_name, kmap in maps:
|
||||
for keysym, uni in kmap:
|
||||
out += '%s[0x%s] = %s;\n' %(var_name, keysym, uni)
|
||||
out += '\n\n'
|
||||
return out
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
if len(sys.argv) < 2:
|
||||
print "ini2dot_h_unimap.py <ini_file>"
|
||||
exit(2)
|
||||
|
||||
inifile = sys.argv[1]
|
||||
|
||||
print "uni2keysym_map[]"
|
||||
|
||||
ini = ConfigParser.ConfigParser()
|
||||
ini.read([inifile])
|
||||
mapping = ini.items('unicode_exception')
|
||||
|
||||
maps = KeysymMaps()
|
||||
|
||||
|
||||
for uni, keysym in mapping:
|
||||
maps.insert(keysym, uni)
|
||||
|
||||
dot_h_content = \
|
||||
"""
|
||||
int keysm2uni_base[4096];
|
||||
int keysm2uni_ext0[4096];
|
||||
int keysm2uni_ext1[4096];
|
||||
int keysm2uni_ext2[4096];
|
||||
|
||||
|
||||
"""
|
||||
dot_h_content += maps.get_h_content('keysm2uni_base', 'keysm2uni_ext0',
|
||||
'keysm2uni_ext1', 'keysm2uni_ext2');
|
||||
|
||||
print dot_h_content
|
Loading…
Reference in New Issue
Block a user