widget/gonk/GonkKeyMapping.h

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     1 /* Copyright 2012 Mozilla Foundation and Mozilla contributors
     2  *
     3  * Licensed under the Apache License, Version 2.0 (the "License");
     4  * you may not use this file except in compliance with the License.
     5  * You may obtain a copy of the License at
     6  *
     7  *     http://www.apache.org/licenses/LICENSE-2.0
     8  *
     9  * Unless required by applicable law or agreed to in writing, software
    10  * distributed under the License is distributed on an "AS IS" BASIS,
    11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    12  * See the License for the specific language governing permissions and
    13  * limitations under the License.
    14  */
    16 #ifndef GONKKEYMAPPING_H
    17 #define GONKKEYMAPPING_H
    19 #include "libui/android_keycodes.h"
    20 #include "mozilla/EventForwards.h"
    22 namespace mozilla {
    23 namespace widget {
    25 /* See libui/KeycodeLabels.h for the mapping */
    26 static const unsigned long kKeyMapping[] = {
    27     0,
    28     0, // SOFT_LEFT
    29     0, // SOFT_RIGHT
    30     NS_VK_HOME, // HOME
    31     0, // BACK
    32     0, // CALL
    33     NS_VK_SLEEP, // ENDCALL
    34     NS_VK_0,
    35     NS_VK_1,
    36     NS_VK_2,
    37     NS_VK_3,
    38     NS_VK_4,
    39     NS_VK_5,
    40     NS_VK_6,
    41     NS_VK_7,
    42     NS_VK_8,
    43     NS_VK_9,
    44     NS_VK_ASTERISK,
    45     NS_VK_HASH,
    46     NS_VK_UP,
    47     NS_VK_DOWN,
    48     NS_VK_LEFT,
    49     NS_VK_RIGHT,
    50     NS_VK_SELECT,
    51     NS_VK_PAGE_UP,   // VOLUME_UP
    52     NS_VK_PAGE_DOWN, // VOLUME_DOWN
    53     NS_VK_SLEEP,     // POWER
    54     NS_VK_PRINTSCREEN, // CAMERA
    55     NS_VK_CLEAR,
    56     NS_VK_A,
    57     NS_VK_B,
    58     NS_VK_C,
    59     NS_VK_D,
    60     NS_VK_E,
    61     NS_VK_F,
    62     NS_VK_G,
    63     NS_VK_H,
    64     NS_VK_I,
    65     NS_VK_J,
    66     NS_VK_K,
    67     NS_VK_L,
    68     NS_VK_M,
    69     NS_VK_N,
    70     NS_VK_O,
    71     NS_VK_P,
    72     NS_VK_Q,
    73     NS_VK_R,
    74     NS_VK_S,
    75     NS_VK_T,
    76     NS_VK_U,
    77     NS_VK_V,
    78     NS_VK_W,
    79     NS_VK_X,
    80     NS_VK_Y,
    81     NS_VK_Z,
    82     NS_VK_COMMA,
    83     NS_VK_PERIOD,
    84     0,
    85     0,
    86     0,
    87     0,
    88     NS_VK_TAB,
    89     NS_VK_SPACE,
    90     NS_VK_META, // SYM
    91     0, // EXPLORER
    92     0, // ENVELOPE
    93     NS_VK_RETURN, // ENTER
    94     NS_VK_BACK,
    95     NS_VK_BACK_QUOTE, // GRAVE
    96     NS_VK_HYPHEN_MINUS,
    97     NS_VK_EQUALS,
    98     NS_VK_OPEN_BRACKET,
    99     NS_VK_CLOSE_BRACKET,
   100     NS_VK_BACK_SLASH,
   101     NS_VK_SEMICOLON,
   102     NS_VK_QUOTE,
   103     NS_VK_SLASH,
   104     NS_VK_AT,
   105     0, // NUM
   106     NS_VK_F1, // HEADSETHOOK
   107     0, // FOCUS
   108     NS_VK_PLUS,
   109     NS_VK_CONTEXT_MENU,
   110     0, // NOTIFICATION
   111     NS_VK_F5, // SEARCH
   112     0, // MEDIA_PLAY_PAUSE
   113     0, // MEDIA_STOP
   114     0, // MEDIA_NEXT
   115     0, // MEDIA_PREVIOUS
   116     0, // MEDIA_REWIND
   117     0, // MEDIA_FAST_FORWARD
   118     0, // MUTE
   119     0, // PAGE_UP
   120     0, // PAGE_DOWN
   121     0, // PICTSYMBOLS
   122     0, // SWITCH_CHARSET
   123     0, // BUTTON_A
   124     0, // BUTTON_B
   125     0, // BUTTON_C
   126     0, // BUTTON_X
   127     0, // BUTTON_Y
   128     0, // BUTTON_Z
   129     0, // BUTTON_L1
   130     0, // BUTTON_R1
   131     0, // BUTTON_L2
   132     0, // BUTTON_R2
   133     0, // BUTTON_THUMBL
   134     0, // BUTTON_THUMBR
   135     0, // BUTTON_START
   136     0, // BUTTON_SELECT
   137     0, // BUTTON_MODE
   138     0, // ESCAPE
   139     NS_VK_DELETE,
   140     0, // CTRL_LEFT
   141     0, // CTRL_RIGHT
   142     NS_VK_CAPS_LOCK,
   143     NS_VK_SCROLL_LOCK,
   144     0, // META_LEFT
   145     0, // META_RIGHT
   146     0, // FUNCTION
   147     0, // SYSRQ
   148     0, // BREAK
   149     NS_VK_HOME, // MOVE_HOME
   150     NS_VK_END,
   151     NS_VK_INSERT,
   152     0, // FORWARD
   153     0, // MEDIA_PLAY
   154     0, // MEDIA_PAUSE
   155     0, // MEDIA_CLOSE
   156     0, // MEDIA_EJECT
   157     0, // MEDIA_RECORD
   158     NS_VK_F1,
   159     NS_VK_F2,
   160     NS_VK_F3,
   161     NS_VK_F4,
   162     NS_VK_F5,
   163     NS_VK_F6,
   164     NS_VK_F7,
   165     NS_VK_F8,
   166     NS_VK_F9,
   167     NS_VK_F10,
   168     NS_VK_F11,
   169     NS_VK_F12,
   170     NS_VK_NUM_LOCK,
   171     NS_VK_NUMPAD0,
   172     NS_VK_NUMPAD1,
   173     NS_VK_NUMPAD2,
   174     NS_VK_NUMPAD3,
   175     NS_VK_NUMPAD4,
   176     NS_VK_NUMPAD5,
   177     NS_VK_NUMPAD6,
   178     NS_VK_NUMPAD7,
   179     NS_VK_NUMPAD8,
   180     NS_VK_NUMPAD9,
   181     NS_VK_DIVIDE,
   182     NS_VK_MULTIPLY,
   183     NS_VK_SUBTRACT,
   184     NS_VK_ADD,
   185     NS_VK_PERIOD,
   186     NS_VK_COMMA,
   187     NS_VK_RETURN,
   188     NS_VK_EQUALS,
   189     // There are more but we don't map them
   190 };
   192 static KeyNameIndex GetKeyNameIndex(int aKeyCode)
   193 {
   194     switch (aKeyCode) {
   195 #define NS_NATIVE_KEY_TO_DOM_KEY_NAME_INDEX(aNativeKey, aKeyNameIndex) \
   196     case aNativeKey: return aKeyNameIndex;
   198 #include "NativeKeyToDOMKeyName.h"
   200 #undef NS_NATIVE_KEY_TO_DOM_KEY_NAME_INDEX
   202     case AKEYCODE_0:
   203     case AKEYCODE_1:
   204     case AKEYCODE_2:
   205     case AKEYCODE_3:
   206     case AKEYCODE_4:
   207     case AKEYCODE_5:
   208     case AKEYCODE_6:
   209     case AKEYCODE_7:
   210     case AKEYCODE_8:
   211     case AKEYCODE_9:
   212     case AKEYCODE_STAR:
   213     case AKEYCODE_POUND:
   214     case AKEYCODE_A:
   215     case AKEYCODE_B:
   216     case AKEYCODE_C:
   217     case AKEYCODE_D:
   218     case AKEYCODE_E:
   219     case AKEYCODE_F:
   220     case AKEYCODE_G:
   221     case AKEYCODE_H:
   222     case AKEYCODE_I:
   223     case AKEYCODE_J:
   224     case AKEYCODE_K:
   225     case AKEYCODE_L:
   226     case AKEYCODE_M:
   227     case AKEYCODE_N:
   228     case AKEYCODE_O:
   229     case AKEYCODE_P:
   230     case AKEYCODE_Q:
   231     case AKEYCODE_R:
   232     case AKEYCODE_S:
   233     case AKEYCODE_T:
   234     case AKEYCODE_U:
   235     case AKEYCODE_V:
   236     case AKEYCODE_W:
   237     case AKEYCODE_X:
   238     case AKEYCODE_Y:
   239     case AKEYCODE_Z:
   240     case AKEYCODE_COMMA:
   241     case AKEYCODE_PERIOD:
   242     case AKEYCODE_SPACE:
   243     case AKEYCODE_GRAVE:
   244     case AKEYCODE_MINUS:
   245     case AKEYCODE_EQUALS:
   246     case AKEYCODE_LEFT_BRACKET:
   247     case AKEYCODE_RIGHT_BRACKET:
   248     case AKEYCODE_BACKSLASH:
   249     case AKEYCODE_SEMICOLON:
   250     case AKEYCODE_APOSTROPHE:
   251     case AKEYCODE_SLASH:
   252     case AKEYCODE_AT:
   253     case AKEYCODE_PLUS:
   254     case AKEYCODE_NUMPAD_0:
   255     case AKEYCODE_NUMPAD_1:
   256     case AKEYCODE_NUMPAD_2:
   257     case AKEYCODE_NUMPAD_3:
   258     case AKEYCODE_NUMPAD_4:
   259     case AKEYCODE_NUMPAD_5:
   260     case AKEYCODE_NUMPAD_6:
   261     case AKEYCODE_NUMPAD_7:
   262     case AKEYCODE_NUMPAD_8:
   263     case AKEYCODE_NUMPAD_9:
   264     case AKEYCODE_NUMPAD_DIVIDE:
   265     case AKEYCODE_NUMPAD_MULTIPLY:
   266     case AKEYCODE_NUMPAD_SUBTRACT:
   267     case AKEYCODE_NUMPAD_ADD:
   268     case AKEYCODE_NUMPAD_DOT:
   269     case AKEYCODE_NUMPAD_COMMA:
   270     case AKEYCODE_NUMPAD_EQUALS:
   271     case AKEYCODE_NUMPAD_LEFT_PAREN:
   272     case AKEYCODE_NUMPAD_RIGHT_PAREN:
   273         return KEY_NAME_INDEX_USE_STRING;
   275     default:
   276         return KEY_NAME_INDEX_Unidentified;
   277     }
   278 }
   280 } // namespace widget
   281 } // namespace mozilla
   283 #endif /* GONKKEYMAPPING_H */

mercurial