Use direct translation between keysym and Unicode, rather than table (see http://www.x.org/wiki/KeySyms, same translation used from Unicode to keysym by the Guacmole JS client). Remove related files.
This commit is contained in:
parent
8a8924dc7d
commit
6da3c29606
@ -42,7 +42,6 @@ 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
|
||||
|
@ -1,52 +0,0 @@
|
||||
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is libguac-client-rdp.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Jocelyn DELALANDE <j.delalande@ulteo.com> Ulteo SAS - http://www.ulteo.com
|
||||
*
|
||||
* Portions created by the Initial Developer are Copyright (C) 2012 Ulteo SAS.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef _GUAC_UNICODE_CONVTABLE_H
|
||||
#define _GUAC_UNICODE_CONVTABLE_H
|
||||
|
||||
int keysym2uni(int keysym);
|
||||
|
||||
/* Keysym->unicode Exceptions tables */
|
||||
int keysym2uni_base[65536];
|
||||
int keysym2uni_ext0[4096];
|
||||
int keysym2uni_ext1[4096];
|
||||
int keysym2uni_ext2[4096];
|
||||
|
||||
/* Fill global tables, if needed (only on first call) */
|
||||
void init_unicode_tables();
|
||||
|
||||
#endif
|
@ -62,7 +62,6 @@
|
||||
#include "rdp_keymap.h"
|
||||
#include "rdp_cliprdr.h"
|
||||
#include "guac_handlers.h"
|
||||
#include "unicode_convtable.h"
|
||||
|
||||
void __guac_rdp_update_keysyms(guac_client* client, const int* keysym_string, int from, int to);
|
||||
int __guac_rdp_send_keysym(guac_client* client, int keysym, int pressed);
|
||||
@ -329,7 +328,7 @@ int __guac_rdp_send_keysym(guac_client* client, int keysym, int pressed) {
|
||||
freerdp* rdp_inst = guac_client_data->rdp_inst;
|
||||
|
||||
/* If keysym can be in lookup table */
|
||||
//if (keysym <= 0xFFFF) {
|
||||
if (keysym <= 0xFFFF) {
|
||||
|
||||
/* Look up scancode mapping */
|
||||
const guac_rdp_keysym_desc* keysym_desc =
|
||||
@ -363,29 +362,33 @@ int __guac_rdp_send_keysym(guac_client* client, int keysym, int pressed) {
|
||||
if (keysym_desc->clear_keysyms != NULL)
|
||||
__guac_rdp_update_keysyms(client, keysym_desc->clear_keysyms, 1, 1);
|
||||
|
||||
return 0;
|
||||
|
||||
} else {
|
||||
/* Fall back to unicode events if undefined inside current keymap */
|
||||
int unicode_code = keysym2uni(keysym);
|
||||
guac_client_log_info(client, "Translated keysym:0x%x to unicode:0x%x (pressed=%d flag=%d)",
|
||||
keysym, unicode_code, pressed, pressed ? KBD_FLAGS_DOWN : KBD_FLAGS_RELEASE);
|
||||
}
|
||||
}
|
||||
|
||||
/* LibfreeRDP seems not to take into account the DOWN/RELEASE flags.
|
||||
* So we send only on of the two key events.
|
||||
*/
|
||||
if (pressed) {
|
||||
rdp_inst->input->UnicodeKeyboardEvent(
|
||||
rdp_inst->input,
|
||||
//pressed ? KBD_FLAGS_DOW : KBD_FLAGS_RELEASE, <- not
|
||||
// taken into account
|
||||
0,
|
||||
unicode_code);
|
||||
} else {
|
||||
|
||||
guac_client_log_info(client, "Ignoring release");
|
||||
}
|
||||
}
|
||||
//}
|
||||
/* Fall back to unicode events if undefined inside current keymap */
|
||||
|
||||
/* Only send when key pressed - Unicode events do not have DOWN/RELEASE flags */
|
||||
if (pressed) {
|
||||
|
||||
/* Translate keysym into codepoint */
|
||||
int codepoint;
|
||||
if (keysym <= 0xFF)
|
||||
codepoint = keysym;
|
||||
else
|
||||
codepoint = keysym & 0xFFFFFF;
|
||||
|
||||
guac_client_log_info(client, "Translated keysym 0x%x to U+%04X", keysym, codepoint);
|
||||
|
||||
/* Send Unicode event */
|
||||
rdp_inst->input->UnicodeKeyboardEvent(
|
||||
rdp_inst->input,
|
||||
0, codepoint);
|
||||
}
|
||||
|
||||
else
|
||||
guac_client_log_info(client, "Ignoring key release (Unicode event)");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,129 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
# ***** BEGIN LICENSE BLOCK *****
|
||||
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
#
|
||||
# The contents of this file are subject to the Mozilla Public License Version
|
||||
# 1.1 (the "License"); you may not use this file except in compliance with
|
||||
# the License. You may obtain a copy of the License at
|
||||
# http://www.mozilla.org/MPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
# for the specific language governing rights and limitations under the
|
||||
# License.
|
||||
#
|
||||
# The Original Code is libguac-client-rdp.
|
||||
#
|
||||
# The Initial Developer of the Original Code is
|
||||
# Jocelyn DELALANDE <j.delalande@ulteo.com> Ulteo SAS - http://www.ulteo.com
|
||||
#
|
||||
# Portions created by the Initial Developer are Copyright (C) 2012 Ulteo SAS.
|
||||
#
|
||||
# Contributor(s):
|
||||
#
|
||||
# Alternatively, the contents of this file may be used under the terms of
|
||||
# either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
# in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
# of those above. If you wish to allow use of your version of this file only
|
||||
# under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
# use your version of this file under the terms of the MPL, indicate your
|
||||
# decision by deleting the provisions above and replace them with the notice
|
||||
# and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
# the provisions above, a recipient may use your version of this file under
|
||||
# the terms of any one of the MPL, the GPL or the LGPL.
|
||||
#
|
||||
# ***** END LICENSE BLOCK *****
|
||||
|
||||
# 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)
|
||||
#
|
||||
# Such an ini file can be found at
|
||||
# http://www.ulteo.com/home/en/download/sourcecode (xrdp folder)
|
||||
#
|
||||
|
||||
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