• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2007 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package android.view;
18 
19 import android.text.method.MetaKeyKeyListener;
20 import android.util.AndroidRuntimeException;
21 import android.util.SparseIntArray;
22 import android.os.RemoteException;
23 import android.os.ServiceManager;
24 import android.util.SparseArray;
25 
26 import java.lang.Character;
27 
28 /**
29  * Describes the keys provided by a keyboard device and their associated labels.
30  */
31 public class KeyCharacterMap {
32     /**
33      * The id of the device's primary built in keyboard is always 0.
34      *
35      * @deprecated This constant should no longer be used because there is no
36      * guarantee that a device has a built-in keyboard that can be used for
37      * typing text.  There might not be a built-in keyboard, the built-in keyboard
38      * might be a {@link #NUMERIC} or {@link #SPECIAL_FUNCTION} keyboard, or there
39      * might be multiple keyboards installed including external keyboards.
40      * When interpreting key presses received from the framework, applications should
41      * use the device id specified in the {@link KeyEvent} received.
42      * When synthesizing key presses for delivery elsewhere or when translating key presses
43      * from unknown keyboards, applications should use the special {@link #VIRTUAL_KEYBOARD}
44      * device id.
45      */
46     @Deprecated
47     public static final int BUILT_IN_KEYBOARD = 0;
48 
49     /**
50      * The id of a generic virtual keyboard with a full layout that can be used to
51      * synthesize key events.  Typically used with {@link #getEvents}.
52      */
53     public static final int VIRTUAL_KEYBOARD = -1;
54 
55     /**
56      * A numeric (12-key) keyboard.
57      * <p>
58      * A numeric keyboard supports text entry using a multi-tap approach.
59      * It may be necessary to tap a key multiple times to generate the desired letter
60      * or symbol.
61      * </p><p>
62      * This type of keyboard is generally designed for thumb typing.
63      * </p>
64      */
65     public static final int NUMERIC = 1;
66 
67     /**
68      * A keyboard with all the letters, but with more than one letter per key.
69      * <p>
70      * This type of keyboard is generally designed for thumb typing.
71      * </p>
72      */
73     public static final int PREDICTIVE = 2;
74 
75     /**
76      * A keyboard with all the letters, and maybe some numbers.
77      * <p>
78      * An alphabetic keyboard supports text entry directly but may have a condensed
79      * layout with a small form factor.  In contrast to a {@link #FULL full keyboard}, some
80      * symbols may only be accessible using special on-screen character pickers.
81      * In addition, to improve typing speed and accuracy, the framework provides
82      * special affordances for alphabetic keyboards such as auto-capitalization
83      * and toggled / locked shift and alt keys.
84      * </p><p>
85      * This type of keyboard is generally designed for thumb typing.
86      * </p>
87      */
88     public static final int ALPHA = 3;
89 
90     /**
91      * A full PC-style keyboard.
92      * <p>
93      * A full keyboard behaves like a PC keyboard.  All symbols are accessed directly
94      * by pressing keys on the keyboard without on-screen support or affordances such
95      * as auto-capitalization.
96      * </p><p>
97      * This type of keyboard is generally designed for full two hand typing.
98      * </p>
99      */
100     public static final int FULL = 4;
101 
102     /**
103      * A keyboard that is only used to control special functions rather than for typing.
104      * <p>
105      * A special function keyboard consists only of non-printing keys such as
106      * HOME and POWER that are not actually used for typing.
107      * </p>
108      */
109     public static final int SPECIAL_FUNCTION = 5;
110 
111     /**
112      * This private-use character is used to trigger Unicode character
113      * input by hex digits.
114      */
115     public static final char HEX_INPUT = '\uEF00';
116 
117     /**
118      * This private-use character is used to bring up a character picker for
119      * miscellaneous symbols.
120      */
121     public static final char PICKER_DIALOG_INPUT = '\uEF01';
122 
123     /**
124      * Modifier keys may be chorded with character keys.
125      *
126      * @see {#link #getModifierBehavior()} for more details.
127      */
128     public static final int MODIFIER_BEHAVIOR_CHORDED = 0;
129 
130     /**
131      * Modifier keys may be chorded with character keys or they may toggle
132      * into latched or locked states when pressed independently.
133      *
134      * @see {#link #getModifierBehavior()} for more details.
135      */
136     public static final int MODIFIER_BEHAVIOR_CHORDED_OR_TOGGLED = 1;
137 
138     private static SparseArray<KeyCharacterMap> sInstances = new SparseArray<KeyCharacterMap>();
139 
140     private final int mDeviceId;
141     private int mPtr;
142 
nativeLoad(int id)143     private static native int nativeLoad(int id);
nativeDispose(int ptr)144     private static native void nativeDispose(int ptr);
145 
nativeGetCharacter(int ptr, int keyCode, int metaState)146     private static native char nativeGetCharacter(int ptr, int keyCode, int metaState);
nativeGetFallbackAction(int ptr, int keyCode, int metaState, FallbackAction outFallbackAction)147     private static native boolean nativeGetFallbackAction(int ptr, int keyCode, int metaState,
148             FallbackAction outFallbackAction);
nativeGetNumber(int ptr, int keyCode)149     private static native char nativeGetNumber(int ptr, int keyCode);
nativeGetMatch(int ptr, int keyCode, char[] chars, int metaState)150     private static native char nativeGetMatch(int ptr, int keyCode, char[] chars, int metaState);
nativeGetDisplayLabel(int ptr, int keyCode)151     private static native char nativeGetDisplayLabel(int ptr, int keyCode);
nativeGetKeyboardType(int ptr)152     private static native int nativeGetKeyboardType(int ptr);
nativeGetEvents(int ptr, int deviceId, char[] chars)153     private static native KeyEvent[] nativeGetEvents(int ptr, int deviceId, char[] chars);
154 
KeyCharacterMap(int deviceId, int ptr)155     private KeyCharacterMap(int deviceId, int ptr) {
156         mDeviceId = deviceId;
157         mPtr = ptr;
158     }
159 
160     @Override
finalize()161     protected void finalize() throws Throwable {
162         if (mPtr != 0) {
163             nativeDispose(mPtr);
164             mPtr = 0;
165         }
166     }
167 
168     /**
169      * Loads the key character maps for the keyboard with the specified device id.
170      *
171      * @param deviceId The device id of the keyboard.
172      * @return The associated key character map.
173      * @throws {@link UnavailableException} if the key character map
174      * could not be loaded because it was malformed or the default key character map
175      * is missing from the system.
176      */
load(int deviceId)177     public static KeyCharacterMap load(int deviceId) {
178         synchronized (sInstances) {
179             KeyCharacterMap map = sInstances.get(deviceId);
180             if (map == null) {
181                 int ptr = nativeLoad(deviceId); // might throw
182                 map = new KeyCharacterMap(deviceId, ptr);
183                 sInstances.put(deviceId, map);
184             }
185             return map;
186         }
187     }
188 
189     /**
190      * Gets the Unicode character generated by the specified key and meta
191      * key state combination.
192      * <p>
193      * Returns the Unicode character that the specified key would produce
194      * when the specified meta bits (see {@link MetaKeyKeyListener})
195      * were active.
196      * </p><p>
197      * Returns 0 if the key is not one that is used to type Unicode
198      * characters.
199      * </p><p>
200      * If the return value has bit {@link #COMBINING_ACCENT} set, the
201      * key is a "dead key" that should be combined with another to
202      * actually produce a character -- see {@link #getDeadChar} --
203      * after masking with {@link #COMBINING_ACCENT_MASK}.
204      * </p>
205      *
206      * @param keyCode The key code.
207      * @param metaState The meta key modifier state.
208      * @return The associated character or combining accent, or 0 if none.
209      */
get(int keyCode, int metaState)210     public int get(int keyCode, int metaState) {
211         metaState = KeyEvent.normalizeMetaState(metaState);
212         char ch = nativeGetCharacter(mPtr, keyCode, metaState);
213 
214         int map = COMBINING.get(ch);
215         if (map != 0) {
216             return map;
217         } else {
218             return ch;
219         }
220     }
221 
222     /**
223      * Gets the fallback action to perform if the application does not
224      * handle the specified key.
225      * <p>
226      * When an application does not handle a particular key, the system may
227      * translate the key to an alternate fallback key (specified in the
228      * fallback action) and dispatch it to the application.
229      * The event containing the fallback key is flagged
230      * with {@link KeyEvent#FLAG_FALLBACK}.
231      * </p>
232      *
233      * @param keyCode The key code.
234      * @param metaState The meta key modifier state.
235      * @param outFallbackAction The fallback action object to populate.
236      * @return True if a fallback action was found, false otherwise.
237      *
238      * @hide
239      */
getFallbackAction(int keyCode, int metaState, FallbackAction outFallbackAction)240     public boolean getFallbackAction(int keyCode, int metaState,
241             FallbackAction outFallbackAction) {
242         if (outFallbackAction == null) {
243             throw new IllegalArgumentException("fallbackAction must not be null");
244         }
245 
246         metaState = KeyEvent.normalizeMetaState(metaState);
247         return nativeGetFallbackAction(mPtr, keyCode, metaState, outFallbackAction);
248     }
249 
250     /**
251      * Gets the number or symbol associated with the key.
252      * <p>
253      * The character value is returned, not the numeric value.
254      * If the key is not a number, but is a symbol, the symbol is retuned.
255      * </p><p>
256      * This method is intended to to support dial pads and other numeric or
257      * symbolic entry on keyboards where certain keys serve dual function
258      * as alphabetic and symbolic keys.  This method returns the number
259      * or symbol associated with the key independent of whether the user
260      * has pressed the required modifier.
261      * </p><p>
262      * For example, on one particular keyboard the keys on the top QWERTY row generate
263      * numbers when ALT is pressed such that ALT-Q maps to '1'.  So for that keyboard
264      * when {@link #getNumber} is called with {@link KeyEvent#KEYCODE_Q} it returns '1'
265      * so that the user can type numbers without pressing ALT when it makes sense.
266      * </p>
267      *
268      * @param keyCode The key code.
269      * @return The associated numeric or symbolic character, or 0 if none.
270      */
getNumber(int keyCode)271     public char getNumber(int keyCode) {
272         return nativeGetNumber(mPtr, keyCode);
273     }
274 
275     /**
276      * Gets the first character in the character array that can be generated
277      * by the specified key code.
278      * <p>
279      * This is a convenience function that returns the same value as
280      * {@link #getMatch(int,char[],int) getMatch(keyCode, chars, 0)}.
281      * </p>
282      *
283      * @param keyCode The keycode.
284      * @param chars The array of matching characters to consider.
285      * @return The matching associated character, or 0 if none.
286      */
getMatch(int keyCode, char[] chars)287     public char getMatch(int keyCode, char[] chars) {
288         return getMatch(keyCode, chars, 0);
289     }
290 
291     /**
292      * Gets the first character in the character array that can be generated
293      * by the specified key code.  If there are multiple choices, prefers
294      * the one that would be generated with the specified meta key modifier state.
295      *
296      * @param keyCode The key code.
297      * @param chars The array of matching characters to consider.
298      * @param metaState The preferred meta key modifier state.
299      * @return The matching associated character, or 0 if none.
300      */
getMatch(int keyCode, char[] chars, int metaState)301     public char getMatch(int keyCode, char[] chars, int metaState) {
302         if (chars == null) {
303             throw new IllegalArgumentException("chars must not be null.");
304         }
305 
306         metaState = KeyEvent.normalizeMetaState(metaState);
307         return nativeGetMatch(mPtr, keyCode, chars, metaState);
308     }
309 
310     /**
311      * Gets the primary character for this key.
312      * In other words, the label that is physically printed on it.
313      *
314      * @param keyCode The key code.
315      * @return The display label character, or 0 if none (eg. for non-printing keys).
316      */
getDisplayLabel(int keyCode)317     public char getDisplayLabel(int keyCode) {
318         return nativeGetDisplayLabel(mPtr, keyCode);
319     }
320 
321     /**
322      * Get the character that is produced by putting accent on the character c.
323      * For example, getDeadChar('`', 'e') returns &egrave;.
324      *
325      * @param accent The accent character.  eg. '`'
326      * @param c The basic character.
327      * @return The combined character, or 0 if the characters cannot be combined.
328      */
getDeadChar(int accent, int c)329     public static int getDeadChar(int accent, int c) {
330         return DEAD.get((accent << 16) | c);
331     }
332 
333     /**
334      * Describes the character mappings associated with a key.
335      *
336      * @deprecated instead use {@link KeyCharacterMap#getDisplayLabel(int)},
337      * {@link KeyCharacterMap#getNumber(int)} and {@link KeyCharacterMap#get(int, int)}.
338      */
339     @Deprecated
340     public static class KeyData {
341         public static final int META_LENGTH = 4;
342 
343         /**
344          * The display label (see {@link #getDisplayLabel}).
345          */
346         public char displayLabel;
347         /**
348          * The "number" value (see {@link #getNumber}).
349          */
350         public char number;
351         /**
352          * The character that will be generated in various meta states
353          * (the same ones used for {@link #get} and defined as
354          * {@link KeyEvent#META_SHIFT_ON} and {@link KeyEvent#META_ALT_ON}).
355          *      <table>
356          *          <tr><th>Index</th><th align="left">Value</th></tr>
357          *          <tr><td>0</td><td>no modifiers</td></tr>
358          *          <tr><td>1</td><td>caps</td></tr>
359          *          <tr><td>2</td><td>alt</td></tr>
360          *          <tr><td>3</td><td>caps + alt</td></tr>
361          *      </table>
362          */
363         public char[] meta = new char[META_LENGTH];
364     }
365 
366     /**
367      * Get the character conversion data for a given key code.
368      *
369      * @param keyCode The keyCode to query.
370      * @param results A {@link KeyData} instance that will be filled with the results.
371      * @return True if the key was mapped.  If the key was not mapped, results is not modified.
372      *
373      * @deprecated instead use {@link KeyCharacterMap#getDisplayLabel(int)},
374      * {@link KeyCharacterMap#getNumber(int)} or {@link KeyCharacterMap#get(int, int)}.
375      */
376     @Deprecated
getKeyData(int keyCode, KeyData results)377     public boolean getKeyData(int keyCode, KeyData results) {
378         if (results.meta.length < KeyData.META_LENGTH) {
379             throw new IndexOutOfBoundsException(
380                     "results.meta.length must be >= " + KeyData.META_LENGTH);
381         }
382 
383         char displayLabel = nativeGetDisplayLabel(mPtr, keyCode);
384         if (displayLabel == 0) {
385             return false;
386         }
387 
388         results.displayLabel = displayLabel;
389         results.number = nativeGetNumber(mPtr, keyCode);
390         results.meta[0] = nativeGetCharacter(mPtr, keyCode, 0);
391         results.meta[1] = nativeGetCharacter(mPtr, keyCode, KeyEvent.META_SHIFT_ON);
392         results.meta[2] = nativeGetCharacter(mPtr, keyCode, KeyEvent.META_ALT_ON);
393         results.meta[3] = nativeGetCharacter(mPtr, keyCode,
394                 KeyEvent.META_ALT_ON | KeyEvent.META_SHIFT_ON);
395         return true;
396     }
397 
398     /**
399      * Get an array of KeyEvent objects that if put into the input stream
400      * could plausibly generate the provided sequence of characters.  It is
401      * not guaranteed that the sequence is the only way to generate these
402      * events or that it is optimal.
403      * <p>
404      * This function is primarily offered for instrumentation and testing purposes.
405      * It may fail to map characters to key codes.  In particular, the key character
406      * map for the {@link #BUILT_IN_KEYBOARD built-in keyboard} device id may be empty.
407      * Consider using the key character map associated with the
408      * {@link #VIRTUAL_KEYBOARD virtual keyboard} device id instead.
409      * </p><p>
410      * For robust text entry, do not use this function.  Instead construct a
411      * {@link KeyEvent} with action code {@link KeyEvent#ACTION_MULTIPLE} that contains
412      * the desired string using {@link KeyEvent#KeyEvent(long, String, int, int)}.
413      * </p>
414      *
415      * @param chars The sequence of characters to generate.
416      * @return An array of {@link KeyEvent} objects, or null if the given char array
417      *         can not be generated using the current key character map.
418      */
getEvents(char[] chars)419     public KeyEvent[] getEvents(char[] chars) {
420         if (chars == null) {
421             throw new IllegalArgumentException("chars must not be null.");
422         }
423         return nativeGetEvents(mPtr, mDeviceId, chars);
424     }
425 
426     /**
427      * Returns true if the specified key produces a glyph.
428      *
429      * @param keyCode The key code.
430      * @return True if the key is a printing key.
431      */
isPrintingKey(int keyCode)432     public boolean isPrintingKey(int keyCode) {
433         int type = Character.getType(nativeGetDisplayLabel(mPtr, keyCode));
434 
435         switch (type)
436         {
437             case Character.SPACE_SEPARATOR:
438             case Character.LINE_SEPARATOR:
439             case Character.PARAGRAPH_SEPARATOR:
440             case Character.CONTROL:
441             case Character.FORMAT:
442                 return false;
443             default:
444                 return true;
445         }
446     }
447 
448     /**
449      * Gets the keyboard type.
450      * Returns {@link #NUMERIC}, {@link #PREDICTIVE}, {@link #ALPHA} or {@link #FULL}.
451      * <p>
452      * Different keyboard types have different semantics.  Refer to the documentation
453      * associated with the keyboard type constants for details.
454      * </p>
455      *
456      * @return The keyboard type.
457      */
getKeyboardType()458     public int getKeyboardType() {
459         return nativeGetKeyboardType(mPtr);
460     }
461 
462     /**
463      * Gets a constant that describes the behavior of this keyboard's modifier keys
464      * such as {@link KeyEvent#KEYCODE_SHIFT_LEFT}.
465      * <p>
466      * Currently there are two behaviors that may be combined:
467      * </p>
468      * <ul>
469      * <li>Chorded behavior: When the modifier key is pressed together with one or more
470      * character keys, the keyboard inserts the modified keys and
471      * then resets the modifier state when the modifier key is released.</li>
472      * <li>Toggled behavior: When the modifier key is pressed and released on its own
473      * it first toggles into a latched state.  When latched, the modifier will apply
474      * to next character key that is pressed and will then reset itself to the initial state.
475      * If the modifier is already latched and the modifier key is pressed and release on
476      * its own again, then it toggles into a locked state.  When locked, the modifier will
477      * apply to all subsequent character keys that are pressed until unlocked by pressing
478      * the modifier key on its own one more time to reset it to the initial state.
479      * Toggled behavior is useful for small profile keyboards designed for thumb typing.
480      * </ul>
481      * <p>
482      * This function currently returns {@link #MODIFIER_BEHAVIOR_CHORDED} when the
483      * {@link #getKeyboardType() keyboard type} is {@link #FULL} or {@link #SPECIAL_FUNCTION} and
484      * {@link #MODIFIER_BEHAVIOR_CHORDED_OR_TOGGLED} otherwise.
485      * In the future, the function may also take into account global keyboard
486      * accessibility settings, other user preferences, or new device capabilities.
487      * </p>
488      *
489      * @return The modifier behavior for this keyboard.
490      *
491      * @see {@link #MODIFIER_BEHAVIOR_CHORDED}
492      * @see {@link #MODIFIER_BEHAVIOR_CHORDED_OR_TOGGLED}
493      */
getModifierBehavior()494     public int getModifierBehavior() {
495         switch (getKeyboardType()) {
496             case FULL:
497             case SPECIAL_FUNCTION:
498                 return MODIFIER_BEHAVIOR_CHORDED;
499             default:
500                 return MODIFIER_BEHAVIOR_CHORDED_OR_TOGGLED;
501         }
502     }
503 
504     /**
505      * Queries the framework about whether any physical keys exist on the
506      * any keyboard attached to the device that are capable of producing the given key code.
507      *
508      * @param keyCode The key code to query.
509      * @return True if at least one attached keyboard supports the specified key code.
510      */
deviceHasKey(int keyCode)511     public static boolean deviceHasKey(int keyCode) {
512         int[] codeArray = new int[1];
513         codeArray[0] = keyCode;
514         boolean[] ret = deviceHasKeys(codeArray);
515         return ret[0];
516     }
517 
518     /**
519      * Queries the framework about whether any physical keys exist on the
520      * any keyboard attached to the device that are capable of producing the given
521      * array of key codes.
522      *
523      * @param keyCodes The array of key codes to query.
524      * @return A new array of the same size as the key codes array whose elements
525      * are set to true if at least one attached keyboard supports the corresponding key code
526      * at the same index in the key codes array.
527      */
deviceHasKeys(int[] keyCodes)528     public static boolean[] deviceHasKeys(int[] keyCodes) {
529         boolean[] ret = new boolean[keyCodes.length];
530         IWindowManager wm = Display.getWindowManager();
531         try {
532             wm.hasKeys(keyCodes, ret);
533         } catch (RemoteException e) {
534             // no fallback; just return the empty array
535         }
536         return ret;
537     }
538 
539     /**
540      * Maps Unicode combining diacritical to display-form dead key
541      * (display character shifted left 16 bits).
542      */
543     private static SparseIntArray COMBINING = new SparseIntArray();
544 
545     /**
546      * Maps combinations of (display-form) dead key and second character
547      * to combined output character.
548      */
549     private static SparseIntArray DEAD = new SparseIntArray();
550 
551     /*
552      * TODO: Change the table format to support full 21-bit-wide
553      * accent characters and combined characters if ever necessary.
554      */
555     private static final int ACUTE = '\u00B4' << 16;
556     private static final int GRAVE = '`' << 16;
557     private static final int CIRCUMFLEX = '^' << 16;
558     private static final int TILDE = '~' << 16;
559     private static final int UMLAUT = '\u00A8' << 16;
560 
561     /*
562      * This bit will be set in the return value of {@link #get(int, int)} if the
563      * key is a "dead key."
564      */
565     public static final int COMBINING_ACCENT = 0x80000000;
566     /**
567      * Mask the return value from {@link #get(int, int)} with this value to get
568      * a printable representation of the accent character of a "dead key."
569      */
570     public static final int COMBINING_ACCENT_MASK = 0x7FFFFFFF;
571 
572     static {
573         COMBINING.put('\u0300', (GRAVE >> 16) | COMBINING_ACCENT);
574         COMBINING.put('\u0301', (ACUTE >> 16) | COMBINING_ACCENT);
575         COMBINING.put('\u0302', (CIRCUMFLEX >> 16) | COMBINING_ACCENT);
576         COMBINING.put('\u0303', (TILDE >> 16) | COMBINING_ACCENT);
577         COMBINING.put('\u0308', (UMLAUT >> 16) | COMBINING_ACCENT);
578 
579         DEAD.put(ACUTE | 'A', '\u00C1');
580         DEAD.put(ACUTE | 'C', '\u0106');
581         DEAD.put(ACUTE | 'E', '\u00C9');
582         DEAD.put(ACUTE | 'G', '\u01F4');
583         DEAD.put(ACUTE | 'I', '\u00CD');
584         DEAD.put(ACUTE | 'K', '\u1E30');
585         DEAD.put(ACUTE | 'L', '\u0139');
586         DEAD.put(ACUTE | 'M', '\u1E3E');
587         DEAD.put(ACUTE | 'N', '\u0143');
588         DEAD.put(ACUTE | 'O', '\u00D3');
589         DEAD.put(ACUTE | 'P', '\u1E54');
590         DEAD.put(ACUTE | 'R', '\u0154');
591         DEAD.put(ACUTE | 'S', '\u015A');
592         DEAD.put(ACUTE | 'U', '\u00DA');
593         DEAD.put(ACUTE | 'W', '\u1E82');
594         DEAD.put(ACUTE | 'Y', '\u00DD');
595         DEAD.put(ACUTE | 'Z', '\u0179');
596         DEAD.put(ACUTE | 'a', '\u00E1');
597         DEAD.put(ACUTE | 'c', '\u0107');
598         DEAD.put(ACUTE | 'e', '\u00E9');
599         DEAD.put(ACUTE | 'g', '\u01F5');
600         DEAD.put(ACUTE | 'i', '\u00ED');
601         DEAD.put(ACUTE | 'k', '\u1E31');
602         DEAD.put(ACUTE | 'l', '\u013A');
603         DEAD.put(ACUTE | 'm', '\u1E3F');
604         DEAD.put(ACUTE | 'n', '\u0144');
605         DEAD.put(ACUTE | 'o', '\u00F3');
606         DEAD.put(ACUTE | 'p', '\u1E55');
607         DEAD.put(ACUTE | 'r', '\u0155');
608         DEAD.put(ACUTE | 's', '\u015B');
609         DEAD.put(ACUTE | 'u', '\u00FA');
610         DEAD.put(ACUTE | 'w', '\u1E83');
611         DEAD.put(ACUTE | 'y', '\u00FD');
612         DEAD.put(ACUTE | 'z', '\u017A');
613         DEAD.put(CIRCUMFLEX | 'A', '\u00C2');
614         DEAD.put(CIRCUMFLEX | 'C', '\u0108');
615         DEAD.put(CIRCUMFLEX | 'E', '\u00CA');
616         DEAD.put(CIRCUMFLEX | 'G', '\u011C');
617         DEAD.put(CIRCUMFLEX | 'H', '\u0124');
618         DEAD.put(CIRCUMFLEX | 'I', '\u00CE');
619         DEAD.put(CIRCUMFLEX | 'J', '\u0134');
620         DEAD.put(CIRCUMFLEX | 'O', '\u00D4');
621         DEAD.put(CIRCUMFLEX | 'S', '\u015C');
622         DEAD.put(CIRCUMFLEX | 'U', '\u00DB');
623         DEAD.put(CIRCUMFLEX | 'W', '\u0174');
624         DEAD.put(CIRCUMFLEX | 'Y', '\u0176');
625         DEAD.put(CIRCUMFLEX | 'Z', '\u1E90');
626         DEAD.put(CIRCUMFLEX | 'a', '\u00E2');
627         DEAD.put(CIRCUMFLEX | 'c', '\u0109');
628         DEAD.put(CIRCUMFLEX | 'e', '\u00EA');
629         DEAD.put(CIRCUMFLEX | 'g', '\u011D');
630         DEAD.put(CIRCUMFLEX | 'h', '\u0125');
631         DEAD.put(CIRCUMFLEX | 'i', '\u00EE');
632         DEAD.put(CIRCUMFLEX | 'j', '\u0135');
633         DEAD.put(CIRCUMFLEX | 'o', '\u00F4');
634         DEAD.put(CIRCUMFLEX | 's', '\u015D');
635         DEAD.put(CIRCUMFLEX | 'u', '\u00FB');
636         DEAD.put(CIRCUMFLEX | 'w', '\u0175');
637         DEAD.put(CIRCUMFLEX | 'y', '\u0177');
638         DEAD.put(CIRCUMFLEX | 'z', '\u1E91');
639         DEAD.put(GRAVE | 'A', '\u00C0');
640         DEAD.put(GRAVE | 'E', '\u00C8');
641         DEAD.put(GRAVE | 'I', '\u00CC');
642         DEAD.put(GRAVE | 'N', '\u01F8');
643         DEAD.put(GRAVE | 'O', '\u00D2');
644         DEAD.put(GRAVE | 'U', '\u00D9');
645         DEAD.put(GRAVE | 'W', '\u1E80');
646         DEAD.put(GRAVE | 'Y', '\u1EF2');
647         DEAD.put(GRAVE | 'a', '\u00E0');
648         DEAD.put(GRAVE | 'e', '\u00E8');
649         DEAD.put(GRAVE | 'i', '\u00EC');
650         DEAD.put(GRAVE | 'n', '\u01F9');
651         DEAD.put(GRAVE | 'o', '\u00F2');
652         DEAD.put(GRAVE | 'u', '\u00F9');
653         DEAD.put(GRAVE | 'w', '\u1E81');
654         DEAD.put(GRAVE | 'y', '\u1EF3');
655         DEAD.put(TILDE | 'A', '\u00C3');
656         DEAD.put(TILDE | 'E', '\u1EBC');
657         DEAD.put(TILDE | 'I', '\u0128');
658         DEAD.put(TILDE | 'N', '\u00D1');
659         DEAD.put(TILDE | 'O', '\u00D5');
660         DEAD.put(TILDE | 'U', '\u0168');
661         DEAD.put(TILDE | 'V', '\u1E7C');
662         DEAD.put(TILDE | 'Y', '\u1EF8');
663         DEAD.put(TILDE | 'a', '\u00E3');
664         DEAD.put(TILDE | 'e', '\u1EBD');
665         DEAD.put(TILDE | 'i', '\u0129');
666         DEAD.put(TILDE | 'n', '\u00F1');
667         DEAD.put(TILDE | 'o', '\u00F5');
668         DEAD.put(TILDE | 'u', '\u0169');
669         DEAD.put(TILDE | 'v', '\u1E7D');
670         DEAD.put(TILDE | 'y', '\u1EF9');
671         DEAD.put(UMLAUT | 'A', '\u00C4');
672         DEAD.put(UMLAUT | 'E', '\u00CB');
673         DEAD.put(UMLAUT | 'H', '\u1E26');
674         DEAD.put(UMLAUT | 'I', '\u00CF');
675         DEAD.put(UMLAUT | 'O', '\u00D6');
676         DEAD.put(UMLAUT | 'U', '\u00DC');
677         DEAD.put(UMLAUT | 'W', '\u1E84');
678         DEAD.put(UMLAUT | 'X', '\u1E8C');
679         DEAD.put(UMLAUT | 'Y', '\u0178');
680         DEAD.put(UMLAUT | 'a', '\u00E4');
681         DEAD.put(UMLAUT | 'e', '\u00EB');
682         DEAD.put(UMLAUT | 'h', '\u1E27');
683         DEAD.put(UMLAUT | 'i', '\u00EF');
684         DEAD.put(UMLAUT | 'o', '\u00F6');
685         DEAD.put(UMLAUT | 't', '\u1E97');
686         DEAD.put(UMLAUT | 'u', '\u00FC');
687         DEAD.put(UMLAUT | 'w', '\u1E85');
688         DEAD.put(UMLAUT | 'x', '\u1E8D');
689         DEAD.put(UMLAUT | 'y', '\u00FF');
690     }
691 
692     /**
693      * Thrown by {@link KeyCharacterMap#load} when a key character map could not be loaded.
694      */
695     public static class UnavailableException extends AndroidRuntimeException {
UnavailableException(String msg)696         public UnavailableException(String msg) {
697             super(msg);
698         }
699     }
700 
701     /**
702      * Specifies a substitute key code and meta state as a fallback action
703      * for an unhandled key.
704      * @hide
705      */
706     public static final class FallbackAction {
707         public int keyCode;
708         public int metaState;
709     }
710 }
711