Add keypad sequences to UTF-8 keysym printing Signed-off-by: Daniel Stone <daniel@fooishbar.org>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
diff --git a/src/keysym-utf.c b/src/keysym-utf.c
index 141cc01..cb8f304 100644
--- a/src/keysym-utf.c
+++ b/src/keysym-utf.c
@@ -39,7 +39,7 @@
#include "utils.h"
struct codepair {
- uint16_t keysym;
+ xkb_keysym_t keysym;
uint16_t ucs;
} keysymtab[] = {
{ 0x01a1, 0x0104 }, /* Aogonek Ą LATIN CAPITAL LETTER A WITH OGONEK */
@@ -829,6 +829,18 @@ struct codepair {
{ 0x20aa, 0x20aa }, /* NewSheqelSign ₪ NEW SHEQEL SIGN */
{ 0x20ab, 0x20ab }, /* DongSign ₫ DONG SIGN */
{ 0x20ac, 0x20ac }, /* EuroSign € EURO SIGN */
+
+ { 0xff80, 0x0020 }, /* KP_Space SPACE */
+ { 0xffaa, 0x002a }, /* KP_Multiply * ASTERISK */
+ { 0xffab, 0x002b }, /* KP_Plus + PLUS SIGN */
+ /* XXX: It's debatable what KP_Separator and KP_Decimal should represent,
+ * as well as locale-specific. So just enforce English colonial
+ * hegemony on the world for the time being. */
+ { 0xffac, 0x002e }, /* KP_Separator . FULL STOP */
+ { 0xffad, 0x002d }, /* KP_Subtract - HYPHEN-MINUS */
+ { 0xffae, 0x002e }, /* KP_Decimal . FULL STOP */
+ { 0xffaf, 0x002f }, /* KP_Divide / SOLIDUS */
+ { 0xffbd, 0x003d }, /* KP_Equal = EQUAL SIGN */
};
_X_EXPORT uint32_t
@@ -843,6 +855,9 @@ xkb_keysym_to_utf32(xkb_keysym_t keysym)
(keysym >= 0x00a0 && keysym <= 0x00ff))
return keysym;
+ if (keysym >= 0xffb0 && keysym <= 0xffb9)
+ return keysym - (0xffb0 - 0x0030);
+
/* also check for directly encoded 24-bit UCS characters */
if ((keysym & 0xff000000) == 0x01000000)
return keysym & 0x00ffffff;
diff --git a/test/xkey.c b/test/xkey.c
index c7391f6..d36b870 100644
--- a/test/xkey.c
+++ b/test/xkey.c
@@ -72,5 +72,12 @@ main(void)
assert(test_utf8(XKB_KEY_hebrew_aleph, "א"));
assert(test_utf8(XKB_KEY_Arabic_sheen, "ش"));
+ assert(test_utf8(XKB_KEY_space, " "));
+ assert(test_utf8(XKB_KEY_KP_Space, " "));
+ assert(test_utf8(XKB_KEY_9, "9"));
+ assert(test_utf8(XKB_KEY_KP_9, "9"));
+ assert(test_utf8(XKB_KEY_KP_Multiply, "*"));
+ assert(test_utf8(XKB_KEY_KP_Subtract, "-"));
+
return 0;
}