Update contrib.
1 // Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of the License "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // template\template_variant\specific\keymap.cpp
15 // This file is part of the Template Base port
16 // The keyboard lookup tables giving the function to be carried out
17 // and the new state of the keyboard
24 #define ARRAY_LENGTH(array) (sizeof(array)/sizeof(array[0]))
28 // Scancode conversion tables
29 // --------------------------
30 // The scancode conversion is arranged as a tree of tables which are used to
31 // convert a scancode to a keycode, taking into account the modifier state
32 // (shift, control, fn)
34 // How the tables work:
35 // --------------------
36 // Firstly, there is a distinction between the "scancodes" used in scanning
37 // the keyboard, and the "scancodes" used in this files.
39 // Typically the keyboard driver already contains a table to convert hardware
40 // key location codes produced during keyboard scanning into EPOC "scancodes".
41 // EPOC scancodes are defined for "standard" keys like shift, backspace,
42 // escape, in the TStdScanCode enum (see E32KEYS.H), and should be ASCII codes
43 // for normal characters. The keyboard driver should add these EPOC scancodes
44 // to the event queue, not hardware-dependant key locations.
46 // For now on "scancode" refers to EPOC scancodes:
48 // The keyboard is divided into a number of "blocks" of contiguous scancodes
50 // Blocks map to keycodes in a keycode table, and several blocks can be
51 // grouped and map to a single keycode table. Blocks map into the keycode
52 // table in the order they are declared. For example, if two scancode blocks
53 // with a range of 5 scancodes map to a single 10-entry keycode table, scancodes
54 // which fall in the first block will map to the first 5 entries in the keycode
55 // table, scancodes falling in the second block map the the next 5 entries in
58 // In theory it is possible to have multiple [keycode,scancode blocks] groups
59 // but there is little point doing this - grouping all the scancode blocks
60 // with a single keycode table holding all possible keycode values is usually
61 // sufficient (and simpler). However, there are some special cases where this
62 // is useful - the most obvious example is handling of shift and caps lock.
63 // The shift key implies everything that the caps-lock key does (upper case
64 // letters) plus some shifted characters for other keys. This is done by
65 // defining two tables - the first handles only caps-lock (upper case), the
66 // second handles all other keys that are affected only by shift. If caps-
67 // lock is active, only the caps-lock table is used. If shift is pressed both
68 // the caps-lock and shift tables are scanned for the conversion. This allows
69 // a base table to be extended with "extras", much like deriving a class from
70 // base class and extending it.
73 // There is one or more [keycode table, scancode blocks] group for each
74 // modifier state - e.g. a lower-case table, upper-case, ctrl, ctrl-shift.
75 // This is the root of the table.
77 // When converting a scancode the key translator first obtains the correct
78 // conversion tables for the modifier state. It then traverses all the scancode
79 // blocks looking for one which contains the scancode being converted. Once
80 // a matching scancode range is located, the key translator maps this into
81 // its position in the associated keycode table to obtain the converted keycode.
83 // The key tables below appear more complicated than they really are because of
84 // the intermediate structures that hold pointers to other structures. The
85 // important structures are:
86 // SScanCodeBlock - contains a "start" and "end" for a scancode range
87 // SConvSubTable - groups a number of scanode blocks with a keycode table
88 // SConvTableNode - points to SConvSubTables for each modifier state
89 // SConvTable - the root of the translation table - points to 1..n SConvTableNode
91 // The keycode tables are just an array of TUint16.
98 // Keys which are not affected by modifier state
102 // This is a simple example of scancode to keycode mapping. The first block
103 // in scanCodeBlock_unmodifiable is a range of several scancodes, so maps to
104 // several entries in the keycode table convKeyCodes_unmodifiable.
105 // EStdKeyLeftShift -> maps to -> EKeyLeftShift
106 // EStdKeyRightShift -> maps to -> EKeyRightShift
108 // EStdKeyScrollLock -> maps to -> EKeyScrollLock
110 LOCAL_D const SScanCodeBlock scanCodeBlock_unmodifiable[]=
112 {EStdKeyLeftShift, EStdKeyScrollLock}, // range 1: left shift to scroll lock
115 LOCAL_D const TUint16 convKeyCodes_unmodifiable[]=
135 // Base conversion table
136 // this table traps all of the keyboard's scanCodes except those in
137 // convKeyCodes_unmodifiable. It appears last in the top-level table and
138 // is used to convert any scancode that is not converted by any of the
141 LOCAL_D const SScanCodeBlock scanCodeBlock_base[]=
143 {EStdKeyNull, EStdKeyDownArrow}, // scancode range 1
144 {'0', '9'}, // scancode range 2
145 {'A', 'Z'}, // scancode range 3
146 {EStdKeyF1, EStdKeyDictaphoneRecord}, // scancode range 4
149 LOCAL_D const TUint16 convKeyCodes_base[]=
151 EKeyNull, // scancode range 1 mapping starts here
169 '0', // scancode range 2 mapping starts here
179 'a', // scancode range 3 mapping starts here
205 EKeyF1, // scancode range 4 mapping starts here
250 EKeyNull, // numeric keypad '5'
274 // caps-lock: this table traps those scanCodes which are affected by caps-lock
276 LOCAL_D const SScanCodeBlock scanCodeBlock_capsLock[]=
278 {'A', 'Z'} // only alpha keys are affected by caps-lock
281 LOCAL_D const TUint16 convKeyCodes_capsLock[]=
314 // shift: this table traps those scanCodes which are affected
315 // by normal shift key EXCEPT for those scanCodes affected by caps-lock
318 LOCAL_D const SScanCodeBlock scanCodeBlock_shift[]=
321 {EStdKeyXXX, EStdKeyEquals},
324 LOCAL_D const TUint16 convKeyCodes_shift[]=
329 '#', /*ELatin1Pound,*/
336 '~', /*ELatin1LogicNot,*/
353 // func: this table traps those scanCodes which are affected
354 // by the func key but not shift
356 LOCAL_D const SScanCodeBlock scanCodeBlock_func[]=
358 {EStdKeyEscape, EStdKeyEscape},
360 {EStdKeyComma, EStdKeyComma},
361 {EStdKeyLeftArrow, EStdKeyDownArrow},
364 LOCAL_D const TUint16 convKeyCodes_func[]=
378 // func: this table traps those scanCodes which are affected
379 // by func and shift - this is for func pressed, shift not pressed
381 //LOCAL_D const SScanCodeBlock scanCodeBlock_funcUnshifted[]=
386 //LOCAL_D const TUint16 convKeyCodes_funcUnshifted[]=
394 // func: this table traps those scanCodes which are affected
395 // by func and shift - this is for func and shift both pressed
397 //LOCAL_D const SScanCodeBlock scanCodeBlock_funcShifted[]=
402 //LOCAL_D const TUint16 convKeyCodes_funcShifted[]=
410 // ctrl: this table traps those scanCodes which are affected by ctrl
412 LOCAL_D const SScanCodeBlock scanCodeBlock_ctrl[]=
415 // NOTE: The space key gets handled elsewhere, otherwise it gets
416 // thrown away as a NULL key
417 // {EStdKeySpace, EStdKeySpace},
420 {EStdKeyComma, EStdKeyComma},
423 LOCAL_D const TUint16 convKeyCodes_ctrl[]=
460 // Each set of scancode+keycode tables must be grouped into a SConvSubTable.
461 // The lines below define a number of SConvSubTables for each of the groups
464 LOCAL_D const SConvSubTable
465 convSubTable_unmodifiable= // table for unmodifiable keys
467 &convKeyCodes_unmodifiable[0], // the keycode table
469 ARRAY_LENGTH(scanCodeBlock_unmodifiable), // number of scancode blocks
470 &scanCodeBlock_unmodifiable[0] // pointer to scancode blocks
473 convSubTable_base= // table for base keys
475 &convKeyCodes_base[0], // keycode table
477 ARRAY_LENGTH(scanCodeBlock_base), // number of scancode blocks
478 &scanCodeBlock_base[0] // pointer to scancode blocks
481 convSubTable_capsLock=
483 &convKeyCodes_capsLock[0],
485 ARRAY_LENGTH(scanCodeBlock_capsLock),
486 &scanCodeBlock_capsLock[0]
491 &convKeyCodes_shift[0],
493 ARRAY_LENGTH(scanCodeBlock_shift),
494 &scanCodeBlock_shift[0]
499 &convKeyCodes_func[0],
501 ARRAY_LENGTH(scanCodeBlock_func),
502 &scanCodeBlock_func[0]
505 // convSubTable_funcUnshifted=
507 // &convKeyCodes_funcUnshifted[0],
509 // ARRAY_LENGTH(scanCodeBlock_funcUnshifted),
510 // &scanCodeBlock_funcUnshifted[0]
513 // convSubTable_funcShifted=
515 // &convKeyCodes_funcShifted[0],
517 // ARRAY_LENGTH(scanCodeBlock_funcShifted),
518 // &scanCodeBlock_funcShifted[0]
523 &convKeyCodes_ctrl[0],
525 ARRAY_LENGTH(scanCodeBlock_ctrl),
526 &scanCodeBlock_ctrl[0]
533 // We need to declare arrays of SConvSubTable for each modifier state we
534 // are going to handle. As mentioned above, it is possible to have several
535 // [keycode table, scancode blocks] groups scanned for each keyboard state.
537 // Some modifier states use more than one conversion group. The simple example
538 // is handling of caps-lock and shift.
540 // Caps-lock means all letters are upper-case
541 // shift means all letters are upper case AND some other keys return control characters
543 // Obviously the shift key means everything cpas-lock means PLUS a bit more. So
544 // we define two tables, the caps-lock table defines only the uppercase conversion,
545 // and the shift table defines all OTHER shifted keys not already handled by
546 // caps-lock. The caps-lock modifier state then only scans the caps-lock table, and
547 // the shift state scans both tables.
549 LOCAL_D const SConvSubTable
550 * const convSubTableArray_unmodifiable[]={&convSubTable_unmodifiable},
551 * const convSubTableArray_base[]={&convSubTable_base},
554 // The caps-lock state scans only the caps-lock table, to handle
555 // conversion to upper case
557 * const convSubTableArray_capsLock[]={&convSubTable_capsLock},
559 // The shift table scans the caps-lock table to handle upper case,
560 // and also the shift table which handles some keys that are not affected
561 // by caps lock (such as 0-9).
563 * const convSubTableArray_shift[]={&convSubTable_capsLock, &convSubTable_shift},
565 // Pressing shift with caps-lock active reverts to lower-case letters,
566 // but other keys remain shifted. This time we only scan the shift table
567 // so only the non-alpha keys will be shifted
569 * const convSubTableArray_capsLockShift[]={&convSubTable_shift},
572 // Like the shift/caps-lock situation, the function key has two states,
573 // shifted and unshifted. Also, some keys may be independant of whether
574 // the shift key is pressed. So there are three tables defined. One declares
575 // all keys that are independant of shift state, the other two tables handle
576 // shifted and unshifted func.
578 // Unshifted func uses the independant set + funcUnshifted
580 // * const convSubTableArray_func[]={&convSubTable_func, &convSubTable_funcUnshifted},
581 * const convSubTableArray_func[]={&convSubTable_func},
583 // Shifted func uses the independant set + funcShifted
585 // * const convSubTableArray_funcShift[]={&convSubTable_func,&convSubTable_funcShifted},
587 // This keyboard table makes control independant of func and shift
589 * const convSubTableArray_ctrl[]={&convSubTable_ctrl};
594 // This is the top of the scancode conversion tree. It is a set of pointers
595 // to the SConvSubTable arrays declared above.
597 // The order of these nodes is VITAL, as the scanCode/modifiers are
598 // searched for a match in this order
600 // The modifier state is matched by using a mask and a compare value. This is
603 // match is true if ( (modifierState & mask) == compareValue
605 // For example, if the mask is (EModifierFunc|EModifierShift) and the
606 // compare value is EModifierFunc, this will match ANY combination of
607 // modifiers that has func pressed and shift not pressed
609 LOCAL_D const SConvTableNode convTableNodes[]=
613 0, // modifier mask = no modifiers
614 0 // modifier compare = no modifiers
616 ARRAY_LENGTH(convSubTableArray_unmodifiable), // number of SConvSubTables
617 &convSubTableArray_unmodifiable[0] // pointer to SConvSubTable array
621 EModifierCtrl, // modifier mask = check for ctrl
622 EModifierCtrl // modifier compare = anything with ctrl pressed
624 ARRAY_LENGTH(convSubTableArray_ctrl),
625 &convSubTableArray_ctrl[0]
630 // Check for Func pressed
635 ARRAY_LENGTH(convSubTableArray_func),
636 &convSubTableArray_func[0]
641 // Check for caps-lock pressed, shift not pressed
643 EModifierCapsLock|EModifierShift,
646 ARRAY_LENGTH(convSubTableArray_capsLock),
647 &convSubTableArray_capsLock[0]
652 // Check for caps-lock not pressed, shift pressed
654 EModifierShift|EModifierCapsLock,
657 ARRAY_LENGTH(convSubTableArray_shift),
658 &convSubTableArray_shift[0]
663 // Check for caps-lock pressed, shift pressed
665 EModifierCapsLock|EModifierShift,
666 EModifierCapsLock|EModifierShift
668 ARRAY_LENGTH(convSubTableArray_capsLockShift),
669 &convSubTableArray_capsLockShift[0]
673 // This is the base table. It must appear last so that it can
674 // provide a default conversion for any scancodes that are not
675 // handled by any of the tables above
681 ARRAY_LENGTH(convSubTableArray_base),
682 &convSubTableArray_base[0]
687 // The top-level exported data structure of all the conversion tables
688 // This just points to the SConvTableNodes above
690 LOCAL_D const SConvTable ConvTable=
692 ARRAY_LENGTH(convTableNodes),
696 // The list of scan-codes on the numeric keypad
697 LOCAL_D const SScanCodeBlock keypadScanCodeBlockArray[]=
699 {EStdKeyNumLock, EStdKeyNumLock},
700 {EStdKeyNkpForwardSlash, EStdKeyNkpFullStop}
703 LOCAL_D const SScanCodeBlockList ConvTableKeypadScanCodes=
705 ARRAY_LENGTH(keypadScanCodeBlockArray),
706 &keypadScanCodeBlockArray[0]
712 // List of keycodes that do not autorepeat
714 // These are usually control keys like shift, ctrl, escape
716 LOCAL_D const TUint16 nonAutorepKeyCodeArray[]=
742 // Declare blocks of non-autorepeating keycodes
744 LOCAL_D const SKeyCodeList ConvTableNonAutorepKeyCodes=
746 ARRAY_LENGTH(nonAutorepKeyCodeArray), // number of keycode arrays
747 &nonAutorepKeyCodeArray[0] // pointer to arrays
755 /////////////////////////////////////////////////////////////////////
756 // Keyboard state tables
759 // What these tables do
760 // --------------------
762 // These tables control the way "special" keystrokes modify the behaviour
763 // of the keyboard. There are two major uses for this:
765 // - handling modifier keys e.g. caps-lock, shift, alt, fn and defining
766 // what modifier flags are affected by these keypresses
768 // - switching the keyboard into special states (see below)
773 // Keyboard states are used to switch the keyboard into a special mode where it
774 // can be used to enter unusual characters. There are two uses for this:
776 // - entering numeric codes, by pressing ctrl and typing the decimal code
777 // - entering accented characters by pressing a key combination which
778 // enters "accented mode" then pressing a key. There can be multiple
781 // You can see an example of accented modes on a Psion Series 5 by
782 // pressing Fn+Z, followed by A - this will produce an a with an umlaut (ä)
784 // These tables are also used to select simpler states such as caps-lock
788 // The main data structure is a SFuncTableEntry. Each of these contains
791 // 1. modifier match - this works the same way as the scancode conversion
792 // tables above, there is a mask and a compare value
794 // 2. a keycode patters - this is used to match with the keycode or keycodes
795 // that the state should respond to. This is a TKeyCodePattern structure
796 // which defines what sort of match should be performed.
798 // 3. a function and state change structure, SFuncAndState. This defines the
799 // state to change to, the function to perform, and a parameter for the
800 // function if required.
802 // TKeyCodePattern structures have two fields. The first is a keycode value
803 // and is only used for some match types. The second field select the type
804 // of match to perform:
806 // EAnyKey - match any key
807 // EAnyAlphaNumeric - match any alpha or numeric key
808 // EAnyAlpha - match any alpha key
809 // EAnyAlphaLowerCase - match any lower-case key
810 // EAnyAlphaUpperCase - match any upper-case key
811 // EAnyDecimalDigit - match any decimal digit
812 // EAnyModifierKey - match any modifier key (e.g. alt, fn, ctrl)
813 // EMatchKey - match if equal to keycode value in first field
814 // EMatchLeftOrRight - match if equal to keycode value or (keycode value + 1)
815 // EMatchKeyCaseInsens - like EMatchKey but perform case-insensitive comparison
819 // the "array" parameter must be a true array and not a pointer
820 #define ARRAY_LENGTH(array) (sizeof(array)/sizeof(array[0]))
822 #define TABLE_ENTRY_ANOTHER_CTRL_DIGIT \
825 EModifierKeyUp|EModifierFunc, \
830 EAnyDigitGivenRadix \
842 // This table is searched for a match if a match has not been
843 // found in the current state's table
846 LOCAL_D const SFuncTableEntry defaultTable[]=
850 // prevent key up events generating keycodes
853 EModifierKeyUp, // mask = key up
854 EModifierKeyUp // match = key up - i.e. accept any key up event
857 EKeyNull, // dummy value, not used
858 EAnyKey // accept any key
861 EStateUnchanged, // state will not change
862 EDoNothing, // no action to perform
868 // prevent any modifier key (e.g. shift, ctrl) from changing state
871 0, // match any modifier state
875 EKeyNull, // dummy value
876 EAnyModifierKey // match any modifier key
879 EStateUnchanged, // don't change state
880 EDoNothing, // nothing to do
886 // filter out any unprocessed codes
889 0, // match any modifier state
893 EKeyNull, // dummy value
894 EAnyKey // match any key
897 EStateNormal, // switch back to normal keyboard state
898 EDoNothing, // nothing to do
907 // This table controls which keys change which modifiers;
908 // NOTE: the state field in this table is ignored
911 LOCAL_D const SFuncTableEntry modifierTable[]=
915 EModifierKeyUp, // check key-up modifier flag
916 0 // make sure it's zero (i.e. ignore key-up events)
920 // Here we want to match only the caps-lock key. We specify the
921 // keycode we are looking for in the first field, and EMatchKey
922 // in the second field
924 EKeyCapsLock, // we want to respond to caps-lock key
925 EMatchKey // match caps-lock only
928 EStateUnchanged, // ignored
929 EToggleModifier, // function = toggle modifier state
930 EModifierCapsLock // this is the modifier to toggle
939 EKeyNumLock, // this one matched num-lock
940 EMatchKey // match only num-lock
943 EStateUnchanged, // ignored
944 EToggleModifier, // function = toggle modifier state
945 EModifierNumLock // this is the modifier to toggle
954 EKeyScrollLock, // match scroll-lock key
959 EToggleModifier, // function = toggle modifier
960 EModifierScrollLock // modifier to toggle
969 EKeyLeftAlt, // match left alt key
973 EStateUnchanged, // ignored
974 ETurnOnModifier, // function = turn on a modifier
975 EModifierAlt|EModifierLeftAlt // alt turns on this modifier combination
980 EModifierKeyUp, // goes with previous table, this handles the alt
981 EModifierKeyUp // key being released
984 EKeyLeftAlt, // match left alt key again
989 ETurnOffModifier, // function = turn off the modifier
990 EModifierLeftAlt // modifier to turn off
995 EModifierKeyUp, // key down event (key-up flag == 0)
999 EKeyLeftFunc, // match left fn key
1003 EStateUnchanged, // ignored
1004 ETurnOnModifier, // function = turn on modifier
1005 EModifierFunc|EModifierLeftFunc // modifier combination to turn on
1010 EModifierKeyUp, // goes with above table, this matched the
1011 EModifierKeyUp // left-fn key up event
1014 EKeyLeftFunc, // match left fn key
1018 EStateUnchanged, // ignored
1019 ETurnOffModifier, // function = turn off modifier
1020 EModifierLeftFunc // modifier to turn off
1025 EModifierKeyUp, // key down event (key-up flag == 0)
1029 EKeyLeftShift, // match left shift key
1033 EStateUnchanged, // ignored
1034 ETurnOnModifier, // function = turn on modifier
1035 EModifierShift|EModifierLeftShift // modifier combination to turn on
1040 EModifierKeyUp, // goes with above table, matches left shift
1041 EModifierKeyUp // key up event
1044 EKeyLeftShift, // match left shift key
1048 EStateUnchanged, // ignored
1049 ETurnOffModifier, // turn off modifier
1050 EModifierLeftShift // modifier to turn off
1055 EModifierKeyUp, // key down event (key-up flag == 0)
1059 EKeyLeftCtrl, // match left ctrl key
1063 EStateUnchanged, // ignored
1064 ETurnOnModifier, // function = turn on modifier
1065 EModifierCtrl|EModifierLeftCtrl // modifier combination to turn on
1070 EModifierKeyUp, // goes with above table, matches left ctrl
1071 EModifierKeyUp // key up event
1074 EKeyLeftCtrl, // match left ctrl key
1078 EStateUnchanged, // ignored
1079 ETurnOffModifier, // function = turn off modifier
1080 EModifierLeftCtrl // modifier to turn off
1085 EModifierKeyUp, // key down event (key-up flag == 0)
1089 EKeyRightAlt, // match right alt key
1093 EStateUnchanged, // ignored
1094 ETurnOnModifier, // function = turn on modifier
1095 EModifierAlt|EModifierRightAlt // modifier combination to turn on
1100 EModifierKeyUp, // goes with above table, matches right alt
1101 EModifierKeyUp // key up event
1104 EKeyRightAlt, // match right alt key
1108 EStateUnchanged, // ignored
1109 ETurnOffModifier, // function = turn off modifier
1110 EModifierRightAlt // modifier to turn off
1115 EModifierKeyUp, // key down event (key-up flag == 0)
1119 EKeyRightFunc, // match right fn key
1123 EStateUnchanged, // ignored
1124 ETurnOnModifier, // function = turn on modifier
1125 EModifierFunc|EModifierRightFunc // modifier combination to turn on
1130 EModifierKeyUp, // goes with above table, matches right fn
1131 EModifierKeyUp // key up event
1134 EKeyRightFunc, // match right fn key
1138 EStateUnchanged, // ignored
1139 ETurnOffModifier, // function = turn off modifier
1140 EModifierRightFunc // modifier to turn off
1145 EModifierKeyUp, // key down event (key-up flag == 0)
1149 EKeyRightShift, // match right shift key
1153 EStateUnchanged, // ignored
1154 ETurnOnModifier, // function = turn on modifier
1155 EModifierShift|EModifierRightShift // modifier combinatoin to turn on
1160 EModifierKeyUp, // goes with above table, handles right shift
1161 EModifierKeyUp // key up event
1164 EKeyRightShift, // match right shift key
1168 EStateUnchanged, // ignored
1169 ETurnOffModifier, // function = turn off modifier
1170 EModifierRightShift // modifier to turn off
1175 EModifierKeyUp, // key down event (key-up flag == 0)
1179 EKeyRightCtrl, // match right ctrl key
1183 EStateUnchanged, // ignored
1184 ETurnOnModifier, // function = turn on modifier
1185 EModifierCtrl|EModifierRightCtrl // modifier combination to turn on
1190 EModifierKeyUp, // goes with above table, matched right ctrl
1191 EModifierKeyUp // key up event
1194 EKeyRightCtrl, // match right ctrl key
1198 EStateUnchanged, // ignored
1199 ETurnOffModifier, // function = turn off modifier
1200 EModifierRightCtrl // modifier to turn off
1207 // TO DO: (optional)
1209 // Tables corresponding to keyboard states.
1211 // There are 13 keyboard states. States 0 to 9 can be used to create alternative
1212 // keyboard layouts for entering accented or unusual characters. Switching into
1213 // these states is done by a keypress. Implementation of the states is optional
1214 // depending on how many special state you want - you may implement 10 states,
1215 // you might decide not to implement any.
1217 // State 10 is the normal state. The table for state 10 defines which keypresses
1218 // change to other states.
1220 // States 11 and 12 are used when entering the numeric code of a character. State
1221 // 11 is for entering a specific number of digits. State 12 is for accepting
1222 // digits until Ctrl is released.
1225 // As before, each SFuncTableEntry entry defines:
1226 // - modifier conditions that must be matched
1227 // - a keycode match pattern (typically an exact key match)
1228 // - the function to perform and new state
1230 // Switching into states 0..9,11,12 is done by entries in table10
1233 //LOCAL_D const SFuncTableEntry table0[]=
1235 // TABLE_ENTRY_ANOTHER_CTRL_DIGIT
1238 LOCAL_D const SFuncTableEntry table1[]=
1241 // Table for special keyboard state 1
1242 // This state is entered by pressing Fn+q (see table10)
1244 // The table makes certain keys return accented characters
1249 // Function must be release, and this must be a key down event
1251 EModifierFunc|EModifierKeyUp,
1256 // match an 'e' keypress, convert to an ae ligature (æ)
1262 EStateNormal, // switch back to state normal (table10)
1263 EPassSpecialKeyThru, // turn keypress into a special character
1264 ELatin1LcAe // this is the character to pass on
1269 EModifierFunc|EModifierKeyUp,
1278 EPassSpecialKeyThru,
1284 EModifierFunc|EModifierKeyUp,
1293 EPassSpecialKeyThru,
1299 EModifierFunc|EModifierKeyUp,
1308 EPassSpecialKeyThru,
1314 EModifierFunc|EModifierKeyUp,
1323 EPassSpecialKeyThru,
1329 EModifierFunc|EModifierKeyUp,
1338 EPassSpecialKeyThru,
1344 EModifierFunc|EModifierKeyUp,
1353 EPassSpecialKeyThru,
1359 EModifierFunc|EModifierKeyUp,
1368 EPassSpecialKeyThru,
1374 EModifierFunc|EModifierKeyUp,
1383 EPassSpecialKeyThru,
1389 EModifierFunc|EModifierKeyUp,
1398 EPassSpecialKeyThru,
1404 EModifierFunc|EModifierKeyUp,
1413 EPassSpecialKeyThru,
1419 EModifierFunc|EModifierKeyUp,
1428 EPassSpecialKeyThru,
1432 TABLE_ENTRY_ANOTHER_CTRL_DIGIT
1435 LOCAL_D const SFuncTableEntry table2[]=
1438 // Table for special keyboard state 2
1439 // This state is entered by pressing Fn+z (see table10)
1441 // The table makes certain keys return accented characters
1442 // See table1 for an explanation of the contents
1446 EModifierFunc|EModifierKeyUp,
1455 EPassSpecialKeyThru,
1461 EModifierFunc|EModifierKeyUp,
1470 EPassSpecialKeyThru,
1476 EModifierFunc|EModifierKeyUp,
1485 EPassSpecialKeyThru,
1491 EModifierFunc|EModifierKeyUp,
1500 EPassSpecialKeyThru,
1506 EModifierFunc|EModifierKeyUp,
1515 EPassSpecialKeyThru,
1521 EModifierFunc|EModifierKeyUp,
1530 EPassSpecialKeyThru,
1536 EModifierFunc|EModifierKeyUp,
1545 EPassSpecialKeyThru,
1549 TABLE_ENTRY_ANOTHER_CTRL_DIGIT
1552 LOCAL_D const SFuncTableEntry table3[]=
1555 // Table for special keyboard state 3
1556 // This state is entered by pressing Fn+x (see table10)
1558 // The table makes certain keys return accented characters
1562 EModifierFunc|EModifierKeyUp,
1571 EPassSpecialKeyThru,
1577 EModifierFunc|EModifierKeyUp,
1586 EPassSpecialKeyThru,
1592 EModifierFunc|EModifierKeyUp,
1601 EPassSpecialKeyThru,
1607 EModifierFunc|EModifierKeyUp,
1616 EPassSpecialKeyThru,
1622 EModifierFunc|EModifierKeyUp,
1631 EPassSpecialKeyThru,
1637 EModifierFunc|EModifierKeyUp,
1646 EPassSpecialKeyThru,
1650 TABLE_ENTRY_ANOTHER_CTRL_DIGIT
1653 LOCAL_D const SFuncTableEntry table4[]=
1656 // Table for special keyboard state 4
1657 // This state is entered by pressing Fn+c (see table10)
1659 // The table makes certain keys return accented characters
1663 EModifierFunc|EModifierKeyUp,
1672 EPassSpecialKeyThru,
1678 EModifierFunc|EModifierKeyUp,
1687 EPassSpecialKeyThru,
1693 EModifierFunc|EModifierKeyUp,
1702 EPassSpecialKeyThru,
1708 EModifierFunc|EModifierKeyUp,
1717 EPassSpecialKeyThru,
1723 EModifierFunc|EModifierKeyUp,
1732 EPassSpecialKeyThru,
1738 EModifierFunc|EModifierKeyUp,
1747 EPassSpecialKeyThru,
1753 EModifierFunc|EModifierKeyUp,
1762 EPassSpecialKeyThru,
1766 TABLE_ENTRY_ANOTHER_CTRL_DIGIT
1769 LOCAL_D const SFuncTableEntry table5[]=
1772 // Table for special keyboard state 5
1773 // This state is entered by pressing Fn+v (see table10)
1775 // The table makes certain keys return accented characters
1779 EModifierFunc|EModifierKeyUp,
1788 EPassSpecialKeyThru,
1794 EModifierFunc|EModifierKeyUp,
1803 EPassSpecialKeyThru,
1809 EModifierFunc|EModifierKeyUp,
1818 EPassSpecialKeyThru,
1824 EModifierFunc|EModifierKeyUp,
1833 EPassSpecialKeyThru,
1837 TABLE_ENTRY_ANOTHER_CTRL_DIGIT
1840 LOCAL_D const SFuncTableEntry table6[]=
1843 // Table for special keyboard state 6
1844 // This state is entered by pressing Fn+b (see table6)
1846 // The table makes certain keys return accented characters
1850 EModifierFunc|EModifierKeyUp,
1859 EPassSpecialKeyThru,
1865 EModifierFunc|EModifierKeyUp,
1874 EPassSpecialKeyThru,
1880 EModifierFunc|EModifierKeyUp,
1889 EPassSpecialKeyThru,
1895 EModifierFunc|EModifierKeyUp,
1904 EPassSpecialKeyThru,
1910 EModifierFunc|EModifierKeyUp,
1919 EPassSpecialKeyThru,
1925 EModifierFunc|EModifierKeyUp,
1934 EPassSpecialKeyThru,
1938 TABLE_ENTRY_ANOTHER_CTRL_DIGIT
1942 // TO DO: (optional)
1944 // State 7,8,9 aren't used in this example.
1945 // You can implement them if you want more special states
1948 //LOCAL_D const SFuncTableEntry table7[]=
1950 // TABLE_ENTRY_ANOTHER_CTRL_DIGIT
1953 //LOCAL_D const SFuncTableEntry table8[]=
1955 // TABLE_ENTRY_ANOTHER_CTRL_DIGIT
1958 //LOCAL_D const SFuncTableEntry table9[]=
1960 // TABLE_ENTRY_ANOTHER_CTRL_DIGIT
1964 LOCAL_D const SFuncTableEntry table10[]=
1967 // TO DO: (optional)
1969 // Table keyboard state 10 - the normal state
1971 // This table controls which keys switch into the special states
1977 // Make sure key-up events are ignored by handling them first and
1996 // Check for ctrl-number presses
1997 // This will enter state EStateCtrlDigits (state 12) which allows
1998 // entry of a numeric keycode
2001 EModifierCtrl|EModifierFunc|EModifierKeyUp,
2009 EStateDerivedFromDigitEntered,
2016 // Any other key events that have not been trapped are just
2017 // passed through unchanged
2035 //LOCAL_D const SFuncTableEntry table11[]=
2037 // TABLE_ENTRY_ANOTHER_CTRL_DIGIT
2040 LOCAL_D const SFuncTableEntry table12[]=
2043 // Table 12 handles entring digit codes. The keyboard will remain in this
2044 // state until the Ctrl key is released
2049 // Look for a key up event
2056 // Match either left or right Ctrl key (i.e. this matches a Ctrl key release)
2062 EStateNormal, // return to normal state (table10)
2063 EPassCtrlDigitsThru, // and pass through the numeric code we have accumulated
2067 TABLE_ENTRY_ANOTHER_CTRL_DIGIT
2072 // TO DO: (optional)
2074 // Array of state control tables above. If a state is not used set the array
2075 // size to zero and the pointer to NULL
2077 // The tables must be declared here in order from table 0 to table 12
2079 LOCAL_D const SFuncTable genFuncTables[]=
2085 0, // state 0 not used, size = 0
2086 NULL // state 0 not used, pointer = NULL
2092 ARRAY_LENGTH(table1), // size of table 1
2093 &table1[0] // pointer to table 1
2099 ARRAY_LENGTH(table2),
2106 ARRAY_LENGTH(table3),
2113 ARRAY_LENGTH(table4),
2120 ARRAY_LENGTH(table5),
2127 ARRAY_LENGTH(table6),
2155 ARRAY_LENGTH(table10),
2169 ARRAY_LENGTH(table12),
2176 // Root of the state modifier tables
2178 LOCAL_D const SFuncTables FuncTables=
2182 // The default processing table
2184 ARRAY_LENGTH(defaultTable),
2189 // The modifier control table
2191 ARRAY_LENGTH(modifierTable),
2195 // The state control tables
2197 ARRAY_LENGTH(genFuncTables),
2203 // The following exported functions give the key translator access to
2204 // the control tables above
2206 EXPORT_C void KeyDataSettings(TRadix &aRadix,TCtrlDigitsTermination &aCtrlDigitsTermination,TInt &aDefaultCtrlDigitsMaxCount,
2207 TInt &aMaximumCtrlDigitsMaxCount)
2210 aCtrlDigitsTermination=ETerminationByCtrlUp;
2211 aDefaultCtrlDigitsMaxCount=3;
2212 aMaximumCtrlDigitsMaxCount=10;
2215 EXPORT_C void KeyDataFuncTable(SFuncTables &aFuncTables)
2217 aFuncTables=FuncTables;
2220 EXPORT_C void KeyDataConvTable(SConvTable &aConvTable, TUint &aConvTableFirstScanCode,TUint &aConvTableLastScanCode,
2221 SScanCodeBlockList &aKeypadScanCode,SKeyCodeList &aNonAutorepKeyCodes)
2223 aConvTable=ConvTable;
2224 aConvTableFirstScanCode=scanCodeBlock_base[0].firstScanCode;
2225 aConvTableLastScanCode=scanCodeBlock_base[ARRAY_LENGTH(scanCodeBlock_base)-1].lastScanCode;
2226 aKeypadScanCode=ConvTableKeypadScanCodes;
2227 aNonAutorepKeyCodes=ConvTableNonAutorepKeyCodes;