[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 4/5] Update key type assigment routine.
From: |
Diego Nieto Cid |
Subject: |
[PATCH 4/5] Update key type assigment routine. |
Date: |
Wed, 11 Aug 2010 20:51:50 -0300 |
---
xkb.c | 47 +++++++++++++++++++++++++++++++++--------------
1 files changed, 33 insertions(+), 14 deletions(-)
diff --git a/xkb.c b/xkb.c
index 9da51a2..00fa6e0 100644
--- a/xkb.c
+++ b/xkb.c
@@ -388,28 +388,47 @@ iskeypad (int width, int *sym)
/* Get the keytype (the keytype determines which modifiers are used
for shifting.
+ See FindAutomaticType@xkbcomp/symbols.c
+
These rules are used:
- * If the width is 1 the keytype is ONE_LEVEL.
- * If the first symbol is lowercase and the second is uppercase
- (latin alphabeth) the keytype is ALPHABETHIC.
- * If one of the symbols is in the keypad range the keytype is KEYPAD.
- * Else the keytype is TWO_LEVEL. */
+ Simple recipe:
+ - ONE_LEVEL for width 0/1
+ - ALPHABETIC for 2 shift levels, with lower/upercase
+ - KEYPAD for keypad keys.
+ - TWO_LEVEL for other 2 shift level keys.
+ and the same for four level keys.
+
+ Otherwise, the key type is TWO_LEVEL.
+ */
static struct keytype *
get_keytype (int width, symbol *sym)
{
- struct keytype *ktfound;
+ struct keytype *ktfound = NULL;
- if (!width || !sym)
+ if (!sym)
ktfound = keytype_find ("TWO_LEVEL");
- else if (iskeypad (width, sym))
- ktfound = keytype_find ("KEYPAD");
- else if (width == 1)
+ else if ((width == 1) || (width == 0))
ktfound = keytype_find ("ONE_LEVEL");
- else if (width >= 2 && islatin_lower (sym[0]) && islatin_upper (sym[1]))
- ktfound = keytype_find ("ALPHABETIC");
- else
- ktfound = keytype_find ("TWO_LEVEL");
+ else if (width == 2) {
+ if (islatin_lower (sym[0]) && islatin_upper (sym[1]))
+ ktfound = keytype_find ("ALPHABETIC");
+ else if (iskeypad (width, sym))
+ ktfound = keytype_find ("KEYPAD");
+ else
+ ktfound = keytype_find ("TWO_LEVEL");
+ }
+ else if (width <= 4) {
+ if (islatin_lower (sym[0]) && islatin_upper (sym[1]))
+ if (islatin_lower(sym[2]) && islatin_upper(sym[3]))
+ ktfound = keytype_find ("FOUR_LEVEL_ALPHABETIC");
+ else
+ ktfound = keytype_find ("FOUR_LEVEL_SEMIALPHABETIC");
+ else if (iskeypad (2, sym))
+ ktfound = keytype_find ("FOUR_LEVEL_KEYPAD");
+ else
+ ktfound = keytype_find ("FOUR_LEVEL");
+ }
if (!ktfound)
ktfound = keytype_find ("TWO_LEVEL");
--
1.7.2
- [PATCH 0/8] Bring console-driver-xkb up to date, Diego Nieto Cid, 2010/08/04
- [PATCH 1/8] Update the parser to work with current XKB files., Diego Nieto Cid, 2010/08/04
- Re: [PATCH 1/8] Update the parser to work with current XKB files., olafBuddenhagen, 2010/08/11
- Re: [PATCH 1/8] Update the parser to work, Diego Nieto Cid, 2010/08/11
- [PATCH 1/5] Add type to $$ in mid-rules., Diego Nieto Cid, 2010/08/11
- [PATCH 2/5] Lexer support for keycodes with +/- symbols and arbitrary level numbers., Diego Nieto Cid, 2010/08/11
- [PATCH 3/5] Skip to main file's default section when needed., Diego Nieto Cid, 2010/08/11
- [PATCH 4/5] Update key type assigment routine.,
Diego Nieto Cid <=
- [PATCH 5/5] Recreate xkb/keymap/hurd from xkeyboard-config-1.8's xfree86 keymap., Diego Nieto Cid, 2010/08/11
- [PATCH 4/8] Remove glue code and use mig to regenerate it., Diego Nieto Cid, 2010/08/04
- [PATCH 3/8] Rule vmod returns an int with the vmod's bit on., Diego Nieto Cid, 2010/08/04
- [PATCH 2/8] Avoid hashing garbage for short keynames., Diego Nieto Cid, 2010/08/04
[PATCH 5/8] Update code borrowed from console-client., Diego Nieto Cid, 2010/08/04
[PATCH 6/8] Add missing functions to input_driver_test., Diego Nieto Cid, 2010/08/04