support for unicode dead keys
Subsystems (2)
Hello,
the current keyboard mapping code allows for unicode characters in the keyboard maps. There is also a "compose" table which allows characters to be combined from two (=dead key) or three (=compose key) different keystrokes. This table, however, does not support unicode. This patch adds unicode support for composed chars:
drivers/char/defkeymap.c_shipped +1 -1
@@ -222,7 +222,7 @@ NULL, }; -struct kbdiacr accent_table[MAX_DIACR] = { +struct kbdiacruc accent_table[MAX_DIACR] = { {'`', 'A', '\300'}, {'`', 'a', '\340'}, {'\'', 'A', '\301'}, {'\'', 'a', '\341'}, {'^', 'A', '\302'}, {'^', 'a', '\342'},
drivers/char/keyboard.c +20 -5
@@ -329,7 +329,7 @@* in utf-8 already. UTF-8 is defined for words of up to 31 bits, * but we need only 16 bits here */ -static void to_utf8 (struct vc_data *vc,ushort c) +static void to_utf8 (struct vc_data *vc,unsigned int c) {if (c <0x80 )/* 0******* */
@@ -391,7 +391,7 @@* Otherwise, conclude that DIACR was not combining after all, * queue it and return CH. */ -static unsigned char handle_diacr (struct vc_data *vc,unsigned char ch) +static unsigned int handle_diacr (struct vc_data *vc,unsigned char ch) {int d = diacr;int i;
@@ -614,11 +614,26 @@static void k_self (struct vc_data *vc,unsigned char value,char up_flag,struct pt_regs *regs) { +unsigned int v; + +if (up_flag)return ;/* no action, if this is a key release */ -if (diacr) - value =handle_diacr (vc, value); +if (diacr) { + v =handle_diacr (vc, value); + +if (kbd->kbdmode ==VC_UNICODE ) { +to_utf8 (vc, v &0xFFFF ); +return ; + } + +/* +* this makes at least latin-1 compose chars work +* even when using unicode keymap in non-unicode mode +*/ + value = v &0xFF ; + }if (dead_key_next) { dead_key_next =0 ;
@@ -637,7 +652,7 @@ {if (up_flag)return ; - diacr = (diacr ?handle_diacr (vc, value) : value); + diacr = (diacr ?handle_diacr (vc, value) &0xff : value); }/*
drivers/char/vt_ioctl.c +59 -3
86 lines not on this page · raw message
drivers/s390/char/defkeymap.c +1 -1
@@ -148,7 +148,7 @@ 0, }; -struct kbdiacr accent_table[MAX_DIACR ] = { +struct kbdiacruc accent_table[MAX_DIACR ] = { {'^' ,'c' ,'\003' }, {'^' ,'d' ,'\004' }, {'^' ,'z' ,'\032' }, {'^' ,'\012' ,'\000' }, };
drivers/s390/char/keyboard.c +65 -11
110 lines not on this page · raw message
drivers/s390/char/keyboard.h +1 -1
@@ -25,7 +25,7 @@unsigned short **key_maps;char **func_table;fn_handler_fn **fn_handler; -struct kbdiacr *accent_table; +struct kbdiacruc *accent_table;unsigned int accent_table_size;unsigned char diacr;unsigned short sysrq;
include/linux/kbd_diacr.h +1 -1
@@ -2,7 +2,7 @@#define _DIACR_H#include <linux/kd.h> -extern struct kbdiacr accent_table[]; +extern struct kbdiacruc accent_table[];extern unsigned int accent_table_size;#endif /* _DIACR_H */
include/linux/kd.h +13 -0
@@ -122,12 +122,25 @@unsigned int kb_cnt;/* number of entries in following array */ struct kbdiacr kbdiacr[256 ];/* MAX_DIACR from keyboard.h */ }; +#define KDGKBDIACR 0x4B4A/* read kernel accent table */ #define KDSKBDIACR 0x4B4B/* write kernel accent table */ +struct kbdiacruc32 { +__u32 diacr, base, result; +}; +struct kbdiacrsuc32 { +unsigned int kb_cnt;/* number of entries in following array */ +struct kbdiacruc32 kbdiacruc[256 ];/* MAX_DIACR from keyboard.h */ +}; + +#define KDGKBDIACRUC 0x4BFA/* read kernel accent table - UCS */ +#define KDSKBDIACRUC 0x4BFB/* write kernel accent table - UCS */ +struct kbkeycode {unsigned int scancode, keycode; }; +#define KDGETKEYCODE 0x4B4C/* read kernel keycode table entry */ #define KDSETKEYCODE 0x4B4D/* write kernel keycode table entry */
include/linux/keyboard.h +6 -0
@@ -28,6 +28,12 @@extern unsigned short *key_maps[MAX_NR_KEYMAPS ];extern unsigned short plain_map[NR_KEYS ];extern unsigned char keyboard_type; + +struct kbdiacruc { +unsigned char diacr, base; +unsigned short result; +}; +#endif #define MAX_NR_FUNC 256/* max nr of strings assigned to keys */
(I did not manage to identify the author of the original patch that this one is based on....)
To take advantage of this kernel patch, a patched version of the kbd package can be used. You can get my kbd patch at
http://jikos.cz/~jbohac/tmp/kbd-1.12-to-2.00.diff
Please note, that this patch does much more changes to kbd than necessary for unicode compose chars to be used. I will split it into smaller patches eventually...
Regards,
Jirka
Signature · 2 lines
Jirka Bohac <[email protected]> SUSE Labs, SUSE CR
Hello,
there is also another UTF8 related patch (regarding composition of utf8 chars) that has not been merged yet:
http://marc.theaimsgroup.com/?l=linux-kernel&m=110292073210868&w=2
Jan Engelhardt