Back to index

im-sdk  12.3.91
KeyMap.c
Go to the documentation of this file.
00001 /*
00002 Copyright 1990-2001 Sun Microsystems, Inc. All Rights Reserved.
00003 
00004 Permission is hereby granted, free of charge, to any person obtaining a
00005 copy of this software and associated documentation files (the
00006 "Software"), to deal in the Software without restriction, including
00007 without limitation the rights to use, copy, modify, merge, publish,
00008 distribute, sublicense, and/or sell copies of the Software, and to
00009 permit persons to whom the Software is furnished to do so, subject to
00010 the following conditions: The above copyright notice and this
00011 permission notice shall be included in all copies or substantial
00012 portions of the Software.
00013 
00014 
00015 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
00016 OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
00017 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
00018 IN NO EVENT SHALL THE OPEN GROUP OR SUN MICROSYSTEMS, INC. BE LIABLE
00019 FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
00020 CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH
00021 THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE EVEN IF
00022 ADVISED IN ADVANCE OF THE POSSIBILITY OF SUCH DAMAGES.
00023 
00024 
00025 Except as contained in this notice, the names of The Open Group and/or
00026 Sun Microsystems, Inc. shall not be used in advertising or otherwise to
00027 promote the sale, use or other dealings in this Software without prior
00028 written authorization from The Open Group and/or Sun Microsystems,
00029 Inc., as applicable.
00030 
00031 
00032 X Window System is a trademark of The Open Group
00033 
00034 OSF/1, OSF/Motif and Motif are registered trademarks, and OSF, the OSF
00035 logo, LBX, X Window System, and Xinerama are trademarks of the Open
00036 Group. All other trademarks and registered trademarks mentioned herein
00037 are the property of their respective owners. No right, title or
00038 interest in or to any trademark, service mark, logo or trade name of
00039 Sun Microsystems, Inc. or its licensors is granted.
00040 
00041 */
00042  
00043 #ifndef XK_KATAKANA
00044 #define XK_KATAKANA
00045 #endif
00046 
00047 #include <ctype.h>
00048 #include <X11/Xlib.h>
00049 #include <X11/Xutil.h>
00050 #include <X11/keysym.h>
00051 #include <X11/Sunkeysym.h>
00052 #include <X11/Xmd.h>
00053 
00054 /*
00055 #include "KeyMap.h"
00056 */
00057 
00058 #define kana_table 1 /* for japanese kana support */
00059 
00060 typedef struct KEYMAP_ENTRY {
00061     long awtKey;
00062     KeySym x11Key;
00063     Bool printable;
00064 } KeymapEntry;
00065 
00066 #if kana_table
00067 typedef struct KEYMAP_ENTRY2 {
00068     long awtKey;
00069     KeySym x11Key;
00070     KeySym alt_x11Key;
00071     int keychar;
00072     Bool printable;
00073     KeyCode keycode;
00074 } KeymapEntry2;
00075 #endif
00076 
00077 static int awt_MetaMask = 0;
00078 static int awt_AltMask = 0;
00079 static int awt_NumLockMask = 0;
00080 static int awt_KanaLockMask = 0;
00081 
00082 #ifdef linux
00083 #include <X11/Xatom.h>
00084 static int KanaMode = -1;
00085 static Atom kanawin_atom = 0;
00086 static Atom kanaflag_atom = 0;
00087 static Window kana_w = 0;
00088 #endif /* linux */
00089 
00090 /* extract the definitions below from java header files */
00091 #undef java_awt_event_KeyEvent_COMPONENT_EVENT_MASK
00092 #define java_awt_event_KeyEvent_COMPONENT_EVENT_MASK 1LL
00093 #undef java_awt_event_KeyEvent_CONTAINER_EVENT_MASK
00094 #define java_awt_event_KeyEvent_CONTAINER_EVENT_MASK 2LL
00095 #undef java_awt_event_KeyEvent_FOCUS_EVENT_MASK
00096 #define java_awt_event_KeyEvent_FOCUS_EVENT_MASK 4LL
00097 #undef java_awt_event_KeyEvent_KEY_EVENT_MASK
00098 #define java_awt_event_KeyEvent_KEY_EVENT_MASK 8LL
00099 #undef java_awt_event_KeyEvent_MOUSE_EVENT_MASK
00100 #define java_awt_event_KeyEvent_MOUSE_EVENT_MASK 16LL
00101 #undef java_awt_event_KeyEvent_MOUSE_MOTION_EVENT_MASK
00102 #define java_awt_event_KeyEvent_MOUSE_MOTION_EVENT_MASK 32LL
00103 #undef java_awt_event_KeyEvent_WINDOW_EVENT_MASK
00104 #define java_awt_event_KeyEvent_WINDOW_EVENT_MASK 64LL
00105 #undef java_awt_event_KeyEvent_ACTION_EVENT_MASK
00106 #define java_awt_event_KeyEvent_ACTION_EVENT_MASK 128LL
00107 #undef java_awt_event_KeyEvent_ADJUSTMENT_EVENT_MASK
00108 #define java_awt_event_KeyEvent_ADJUSTMENT_EVENT_MASK 256LL
00109 #undef java_awt_event_KeyEvent_ITEM_EVENT_MASK
00110 #define java_awt_event_KeyEvent_ITEM_EVENT_MASK 512LL
00111 #undef java_awt_event_KeyEvent_TEXT_EVENT_MASK
00112 #define java_awt_event_KeyEvent_TEXT_EVENT_MASK 1024LL
00113 #undef java_awt_event_KeyEvent_RESERVED_ID_MAX
00114 #define java_awt_event_KeyEvent_RESERVED_ID_MAX 1999L
00115 #undef java_awt_event_KeyEvent_serialVersionUID
00116 #define java_awt_event_KeyEvent_serialVersionUID -1825314779160409405LL
00117 #undef java_awt_event_KeyEvent_COMPONENT_FIRST
00118 #define java_awt_event_KeyEvent_COMPONENT_FIRST 100L
00119 #undef java_awt_event_KeyEvent_COMPONENT_LAST
00120 #define java_awt_event_KeyEvent_COMPONENT_LAST 103L
00121 #undef java_awt_event_KeyEvent_COMPONENT_MOVED
00122 #define java_awt_event_KeyEvent_COMPONENT_MOVED 100L
00123 #undef java_awt_event_KeyEvent_COMPONENT_RESIZED
00124 #define java_awt_event_KeyEvent_COMPONENT_RESIZED 101L
00125 #undef java_awt_event_KeyEvent_COMPONENT_SHOWN
00126 #define java_awt_event_KeyEvent_COMPONENT_SHOWN 102L
00127 #undef java_awt_event_KeyEvent_COMPONENT_HIDDEN
00128 #define java_awt_event_KeyEvent_COMPONENT_HIDDEN 103L
00129 #undef java_awt_event_KeyEvent_serialVersionUID
00130 #define java_awt_event_KeyEvent_serialVersionUID 8101406823902992965LL
00131 #undef java_awt_event_KeyEvent_SHIFT_MASK
00132 #define java_awt_event_KeyEvent_SHIFT_MASK 1L
00133 #undef java_awt_event_KeyEvent_CTRL_MASK
00134 #define java_awt_event_KeyEvent_CTRL_MASK 2L
00135 #undef java_awt_event_KeyEvent_META_MASK
00136 #define java_awt_event_KeyEvent_META_MASK 4L
00137 #undef java_awt_event_KeyEvent_ALT_MASK
00138 #define java_awt_event_KeyEvent_ALT_MASK 8L
00139 #undef java_awt_event_KeyEvent_BUTTON1_MASK
00140 #define java_awt_event_KeyEvent_BUTTON1_MASK 16L
00141 #undef java_awt_event_KeyEvent_BUTTON2_MASK
00142 #define java_awt_event_KeyEvent_BUTTON2_MASK 8L
00143 #undef java_awt_event_KeyEvent_BUTTON3_MASK
00144 #define java_awt_event_KeyEvent_BUTTON3_MASK 4L
00145 #undef java_awt_event_KeyEvent_KEY_FIRST
00146 #define java_awt_event_KeyEvent_KEY_FIRST 400L
00147 #undef java_awt_event_KeyEvent_KEY_LAST
00148 #define java_awt_event_KeyEvent_KEY_LAST 402L
00149 #undef java_awt_event_KeyEvent_KEY_TYPED
00150 #define java_awt_event_KeyEvent_KEY_TYPED 400L
00151 #undef java_awt_event_KeyEvent_KEY_PRESSED
00152 #define java_awt_event_KeyEvent_KEY_PRESSED 401L
00153 #undef java_awt_event_KeyEvent_KEY_RELEASED
00154 #define java_awt_event_KeyEvent_KEY_RELEASED 402L
00155 #undef java_awt_event_KeyEvent_VK_ENTER
00156 #define java_awt_event_KeyEvent_VK_ENTER 10L
00157 #undef java_awt_event_KeyEvent_VK_BACK_SPACE
00158 #define java_awt_event_KeyEvent_VK_BACK_SPACE 8L
00159 #undef java_awt_event_KeyEvent_VK_TAB
00160 #define java_awt_event_KeyEvent_VK_TAB 9L
00161 #undef java_awt_event_KeyEvent_VK_CANCEL
00162 #define java_awt_event_KeyEvent_VK_CANCEL 3L
00163 #undef java_awt_event_KeyEvent_VK_CLEAR
00164 #define java_awt_event_KeyEvent_VK_CLEAR 12L
00165 #undef java_awt_event_KeyEvent_VK_SHIFT
00166 #define java_awt_event_KeyEvent_VK_SHIFT 16L
00167 #undef java_awt_event_KeyEvent_VK_CONTROL
00168 #define java_awt_event_KeyEvent_VK_CONTROL 17L
00169 #undef java_awt_event_KeyEvent_VK_ALT
00170 #define java_awt_event_KeyEvent_VK_ALT 18L
00171 #undef java_awt_event_KeyEvent_VK_PAUSE
00172 #define java_awt_event_KeyEvent_VK_PAUSE 19L
00173 #undef java_awt_event_KeyEvent_VK_CAPS_LOCK
00174 #define java_awt_event_KeyEvent_VK_CAPS_LOCK 20L
00175 #undef java_awt_event_KeyEvent_VK_ESCAPE
00176 #define java_awt_event_KeyEvent_VK_ESCAPE 27L
00177 #undef java_awt_event_KeyEvent_VK_SPACE
00178 #define java_awt_event_KeyEvent_VK_SPACE 32L
00179 #undef java_awt_event_KeyEvent_VK_PAGE_UP
00180 #define java_awt_event_KeyEvent_VK_PAGE_UP 33L
00181 #undef java_awt_event_KeyEvent_VK_PAGE_DOWN
00182 #define java_awt_event_KeyEvent_VK_PAGE_DOWN 34L
00183 #undef java_awt_event_KeyEvent_VK_END
00184 #define java_awt_event_KeyEvent_VK_END 35L
00185 #undef java_awt_event_KeyEvent_VK_HOME
00186 #define java_awt_event_KeyEvent_VK_HOME 36L
00187 #undef java_awt_event_KeyEvent_VK_LEFT
00188 #define java_awt_event_KeyEvent_VK_LEFT 37L
00189 #undef java_awt_event_KeyEvent_VK_UP
00190 #define java_awt_event_KeyEvent_VK_UP 38L
00191 #undef java_awt_event_KeyEvent_VK_RIGHT
00192 #define java_awt_event_KeyEvent_VK_RIGHT 39L
00193 #undef java_awt_event_KeyEvent_VK_DOWN
00194 #define java_awt_event_KeyEvent_VK_DOWN 40L
00195 #undef java_awt_event_KeyEvent_VK_COMMA
00196 #define java_awt_event_KeyEvent_VK_COMMA 44L
00197 #undef java_awt_event_KeyEvent_VK_PERIOD
00198 #define java_awt_event_KeyEvent_VK_PERIOD 46L
00199 #undef java_awt_event_KeyEvent_VK_MINUS
00200 #define java_awt_event_KeyEvent_VK_MINUS 0x2D
00201 #undef java_awt_event_KeyEvent_VK_SLASH
00202 #define java_awt_event_KeyEvent_VK_SLASH 47L
00203 #undef java_awt_event_KeyEvent_VK_0
00204 #define java_awt_event_KeyEvent_VK_0 48L
00205 #undef java_awt_event_KeyEvent_VK_1
00206 #define java_awt_event_KeyEvent_VK_1 49L
00207 #undef java_awt_event_KeyEvent_VK_2
00208 #define java_awt_event_KeyEvent_VK_2 50L
00209 #undef java_awt_event_KeyEvent_VK_3
00210 #define java_awt_event_KeyEvent_VK_3 51L
00211 #undef java_awt_event_KeyEvent_VK_4
00212 #define java_awt_event_KeyEvent_VK_4 52L
00213 #undef java_awt_event_KeyEvent_VK_5
00214 #define java_awt_event_KeyEvent_VK_5 53L
00215 #undef java_awt_event_KeyEvent_VK_6
00216 #define java_awt_event_KeyEvent_VK_6 54L
00217 #undef java_awt_event_KeyEvent_VK_7
00218 #define java_awt_event_KeyEvent_VK_7 55L
00219 #undef java_awt_event_KeyEvent_VK_8
00220 #define java_awt_event_KeyEvent_VK_8 56L
00221 #undef java_awt_event_KeyEvent_VK_9
00222 #define java_awt_event_KeyEvent_VK_9 57L
00223 #undef java_awt_event_KeyEvent_VK_SEMICOLON
00224 #define java_awt_event_KeyEvent_VK_SEMICOLON 59L
00225 #undef java_awt_event_KeyEvent_VK_EQUALS
00226 #define java_awt_event_KeyEvent_VK_EQUALS 61L
00227 #undef java_awt_event_KeyEvent_VK_A
00228 #define java_awt_event_KeyEvent_VK_A 65L
00229 #undef java_awt_event_KeyEvent_VK_B
00230 #define java_awt_event_KeyEvent_VK_B 66L
00231 #undef java_awt_event_KeyEvent_VK_C
00232 #define java_awt_event_KeyEvent_VK_C 67L
00233 #undef java_awt_event_KeyEvent_VK_D
00234 #define java_awt_event_KeyEvent_VK_D 68L
00235 #undef java_awt_event_KeyEvent_VK_E
00236 #define java_awt_event_KeyEvent_VK_E 69L
00237 #undef java_awt_event_KeyEvent_VK_F
00238 #define java_awt_event_KeyEvent_VK_F 70L
00239 #undef java_awt_event_KeyEvent_VK_G
00240 #define java_awt_event_KeyEvent_VK_G 71L
00241 #undef java_awt_event_KeyEvent_VK_H
00242 #define java_awt_event_KeyEvent_VK_H 72L
00243 #undef java_awt_event_KeyEvent_VK_I
00244 #define java_awt_event_KeyEvent_VK_I 73L
00245 #undef java_awt_event_KeyEvent_VK_J
00246 #define java_awt_event_KeyEvent_VK_J 74L
00247 #undef java_awt_event_KeyEvent_VK_K
00248 #define java_awt_event_KeyEvent_VK_K 75L
00249 #undef java_awt_event_KeyEvent_VK_L
00250 #define java_awt_event_KeyEvent_VK_L 76L
00251 #undef java_awt_event_KeyEvent_VK_M
00252 #define java_awt_event_KeyEvent_VK_M 77L
00253 #undef java_awt_event_KeyEvent_VK_N
00254 #define java_awt_event_KeyEvent_VK_N 78L
00255 #undef java_awt_event_KeyEvent_VK_O
00256 #define java_awt_event_KeyEvent_VK_O 79L
00257 #undef java_awt_event_KeyEvent_VK_P
00258 #define java_awt_event_KeyEvent_VK_P 80L
00259 #undef java_awt_event_KeyEvent_VK_Q
00260 #define java_awt_event_KeyEvent_VK_Q 81L
00261 #undef java_awt_event_KeyEvent_VK_R
00262 #define java_awt_event_KeyEvent_VK_R 82L
00263 #undef java_awt_event_KeyEvent_VK_S
00264 #define java_awt_event_KeyEvent_VK_S 83L
00265 #undef java_awt_event_KeyEvent_VK_T
00266 #define java_awt_event_KeyEvent_VK_T 84L
00267 #undef java_awt_event_KeyEvent_VK_U
00268 #define java_awt_event_KeyEvent_VK_U 85L
00269 #undef java_awt_event_KeyEvent_VK_V
00270 #define java_awt_event_KeyEvent_VK_V 86L
00271 #undef java_awt_event_KeyEvent_VK_W
00272 #define java_awt_event_KeyEvent_VK_W 87L
00273 #undef java_awt_event_KeyEvent_VK_X
00274 #define java_awt_event_KeyEvent_VK_X 88L
00275 #undef java_awt_event_KeyEvent_VK_Y
00276 #define java_awt_event_KeyEvent_VK_Y 89L
00277 #undef java_awt_event_KeyEvent_VK_Z
00278 #define java_awt_event_KeyEvent_VK_Z 90L
00279 #undef java_awt_event_KeyEvent_VK_OPEN_BRACKET
00280 #define java_awt_event_KeyEvent_VK_OPEN_BRACKET 91L
00281 #undef java_awt_event_KeyEvent_VK_BACK_SLASH
00282 #define java_awt_event_KeyEvent_VK_BACK_SLASH 92L
00283 #undef java_awt_event_KeyEvent_VK_CLOSE_BRACKET
00284 #define java_awt_event_KeyEvent_VK_CLOSE_BRACKET 93L
00285 #undef java_awt_event_KeyEvent_VK_NUMPAD0
00286 #define java_awt_event_KeyEvent_VK_NUMPAD0 96L
00287 #undef java_awt_event_KeyEvent_VK_NUMPAD1
00288 #define java_awt_event_KeyEvent_VK_NUMPAD1 97L
00289 #undef java_awt_event_KeyEvent_VK_NUMPAD2
00290 #define java_awt_event_KeyEvent_VK_NUMPAD2 98L
00291 #undef java_awt_event_KeyEvent_VK_NUMPAD3
00292 #define java_awt_event_KeyEvent_VK_NUMPAD3 99L
00293 #undef java_awt_event_KeyEvent_VK_NUMPAD4
00294 #define java_awt_event_KeyEvent_VK_NUMPAD4 100L
00295 #undef java_awt_event_KeyEvent_VK_NUMPAD5
00296 #define java_awt_event_KeyEvent_VK_NUMPAD5 101L
00297 #undef java_awt_event_KeyEvent_VK_NUMPAD6
00298 #define java_awt_event_KeyEvent_VK_NUMPAD6 102L
00299 #undef java_awt_event_KeyEvent_VK_NUMPAD7
00300 #define java_awt_event_KeyEvent_VK_NUMPAD7 103L
00301 #undef java_awt_event_KeyEvent_VK_NUMPAD8
00302 #define java_awt_event_KeyEvent_VK_NUMPAD8 104L
00303 #undef java_awt_event_KeyEvent_VK_NUMPAD9
00304 #define java_awt_event_KeyEvent_VK_NUMPAD9 105L
00305 #undef java_awt_event_KeyEvent_VK_MULTIPLY
00306 #define java_awt_event_KeyEvent_VK_MULTIPLY 106L
00307 #undef java_awt_event_KeyEvent_VK_ADD
00308 #define java_awt_event_KeyEvent_VK_ADD 107L
00309 #undef java_awt_event_KeyEvent_VK_SEPARATER
00310 #define java_awt_event_KeyEvent_VK_SEPARATER 108L
00311 #undef java_awt_event_KeyEvent_VK_SUBTRACT
00312 #define java_awt_event_KeyEvent_VK_SUBTRACT 109L
00313 #undef java_awt_event_KeyEvent_VK_DECIMAL
00314 #define java_awt_event_KeyEvent_VK_DECIMAL 110L
00315 #undef java_awt_event_KeyEvent_VK_DIVIDE
00316 #define java_awt_event_KeyEvent_VK_DIVIDE 111L
00317 #undef java_awt_event_KeyEvent_VK_F1
00318 #define java_awt_event_KeyEvent_VK_F1 112L
00319 #undef java_awt_event_KeyEvent_VK_F2
00320 #define java_awt_event_KeyEvent_VK_F2 113L
00321 #undef java_awt_event_KeyEvent_VK_F3
00322 #define java_awt_event_KeyEvent_VK_F3 114L
00323 #undef java_awt_event_KeyEvent_VK_F4
00324 #define java_awt_event_KeyEvent_VK_F4 115L
00325 #undef java_awt_event_KeyEvent_VK_F5
00326 #define java_awt_event_KeyEvent_VK_F5 116L
00327 #undef java_awt_event_KeyEvent_VK_F6
00328 #define java_awt_event_KeyEvent_VK_F6 117L
00329 #undef java_awt_event_KeyEvent_VK_F7
00330 #define java_awt_event_KeyEvent_VK_F7 118L
00331 #undef java_awt_event_KeyEvent_VK_F8
00332 #define java_awt_event_KeyEvent_VK_F8 119L
00333 #undef java_awt_event_KeyEvent_VK_F9
00334 #define java_awt_event_KeyEvent_VK_F9 120L
00335 #undef java_awt_event_KeyEvent_VK_F10
00336 #define java_awt_event_KeyEvent_VK_F10 121L
00337 #undef java_awt_event_KeyEvent_VK_F11
00338 #define java_awt_event_KeyEvent_VK_F11 122L
00339 #undef java_awt_event_KeyEvent_VK_F12
00340 #define java_awt_event_KeyEvent_VK_F12 123L
00341 #undef java_awt_event_KeyEvent_VK_DELETE
00342 #define java_awt_event_KeyEvent_VK_DELETE 127L
00343 #undef java_awt_event_KeyEvent_VK_NUM_LOCK
00344 #define java_awt_event_KeyEvent_VK_NUM_LOCK 144L
00345 #undef java_awt_event_KeyEvent_VK_SCROLL_LOCK
00346 #define java_awt_event_KeyEvent_VK_SCROLL_LOCK 145L
00347 #undef java_awt_event_KeyEvent_VK_PRINTSCREEN
00348 #define java_awt_event_KeyEvent_VK_PRINTSCREEN 154L
00349 #undef java_awt_event_KeyEvent_VK_INSERT
00350 #define java_awt_event_KeyEvent_VK_INSERT 155L
00351 #undef java_awt_event_KeyEvent_VK_HELP
00352 #define java_awt_event_KeyEvent_VK_HELP 156L
00353 #undef java_awt_event_KeyEvent_VK_META
00354 #define java_awt_event_KeyEvent_VK_META 157L
00355 #undef java_awt_event_KeyEvent_VK_BACK_QUOTE
00356 #define java_awt_event_KeyEvent_VK_BACK_QUOTE 192L
00357 #undef java_awt_event_KeyEvent_VK_QUOTE
00358 #define java_awt_event_KeyEvent_VK_QUOTE 222L
00359 #undef java_awt_event_KeyEvent_VK_FINAL
00360 #define java_awt_event_KeyEvent_VK_FINAL 24L
00361 #undef java_awt_event_KeyEvent_VK_CONVERT
00362 #define java_awt_event_KeyEvent_VK_CONVERT 28L
00363 #undef java_awt_event_KeyEvent_VK_NONCONVERT
00364 #define java_awt_event_KeyEvent_VK_NONCONVERT 29L
00365 #undef java_awt_event_KeyEvent_VK_ACCEPT
00366 #define java_awt_event_KeyEvent_VK_ACCEPT 30L
00367 #undef java_awt_event_KeyEvent_VK_MODECHANGE
00368 #define java_awt_event_KeyEvent_VK_MODECHANGE 31L
00369 #undef java_awt_event_KeyEvent_VK_KANA
00370 #define java_awt_event_KeyEvent_VK_KANA 21L
00371 #undef java_awt_event_KeyEvent_VK_KANJI
00372 #define java_awt_event_KeyEvent_VK_KANJI 25L
00373 #undef java_awt_event_KeyEvent_VK_UNDEFINED
00374 #define java_awt_event_KeyEvent_VK_UNDEFINED 0L
00375 #undef java_awt_event_KeyEvent_CHAR_UNDEFINED
00376 #define java_awt_event_KeyEvent_CHAR_UNDEFINED 0L
00377 
00378 #undef java_awt_event_KeyEvent_VK_CUT
00379 #define java_awt_event_KeyEvent_VK_CUT                      0xFFD1
00380 #undef java_awt_event_KeyEvent_VK_COPY
00381 #define java_awt_event_KeyEvent_VK_COPY                     0xFFCD
00382 #undef java_awt_event_KeyEvent_VK_PASTE
00383 #define java_awt_event_KeyEvent_VK_PASTE                    0xFFCF
00384 #undef java_awt_event_KeyEvent_VK_UNDO
00385 #define java_awt_event_KeyEvent_VK_UNDO                     0xFFCB
00386 #undef java_awt_event_KeyEvent_VK_AGAIN
00387 #define java_awt_event_KeyEvent_VK_AGAIN                    0xFFC9
00388 #undef java_awt_event_KeyEvent_VK_FIND
00389 #define java_awt_event_KeyEvent_VK_FIND                     0xFFD0
00390 #undef java_awt_event_KeyEvent_VK_PROPS
00391 #define java_awt_event_KeyEvent_VK_PROPS                    0xFFCA
00392 #undef java_awt_event_KeyEvent_VK_STOP
00393 #define java_awt_event_KeyEvent_VK_STOP                     0xFFC8
00394 
00395 #undef java_awt_event_KeyEvent_VK_AT
00396 #define java_awt_event_KeyEvent_VK_AT                       0x0200
00397 
00398 #undef java_awt_event_InputEvent_SHIFT_MASK
00399 #define java_awt_event_InputEvent_SHIFT_MASK 1L
00400 #undef java_awt_event_InputEvent_CTRL_MASK
00401 #define java_awt_event_InputEvent_CTRL_MASK 2L
00402 #undef java_awt_event_InputEvent_META_MASK
00403 #define java_awt_event_InputEvent_META_MASK 4L
00404 #undef java_awt_event_InputEvent_ALT_MASK
00405 #define java_awt_event_InputEvent_ALT_MASK 8L
00406 #undef java_awt_event_InputEvent_BUTTON1_MASK
00407 #define java_awt_event_InputEvent_BUTTON1_MASK 16L
00408 #undef java_awt_event_InputEvent_BUTTON2_MASK
00409 #define java_awt_event_InputEvent_BUTTON2_MASK 8L
00410 #undef java_awt_event_InputEvent_BUTTON3_MASK
00411 #define java_awt_event_InputEvent_BUTTON3_MASK 4L
00412 
00413 typedef       enum {
00414     FALSE = 0,
00415     TRUE = 1
00416 } bool_t;
00417 
00418 typedef unsigned short unicode;
00419 
00420 #if kana_table
00421 static KeymapEntry2 kana_normal_keymapTable[] = {
00422     { java_awt_event_KeyEvent_VK_1, XK_kana_NU, XK_1, 0xff87, TRUE, 0 },
00423     { java_awt_event_KeyEvent_VK_2, XK_kana_FU, XK_2, 0xff8c, TRUE, 0 },
00424     { java_awt_event_KeyEvent_VK_3, XK_kana_A, XK_3, 0xff71, TRUE, 0 },
00425     { java_awt_event_KeyEvent_VK_4, XK_kana_U, XK_4, 0xff73, TRUE, 0 },
00426     { java_awt_event_KeyEvent_VK_5, XK_kana_E, XK_5, 0xff74, TRUE, 0 },
00427     { java_awt_event_KeyEvent_VK_6, XK_kana_O, XK_6, 0xff75, TRUE, 0 },
00428     { java_awt_event_KeyEvent_VK_7, XK_kana_YA, XK_7, 0xff94, TRUE, 0 },
00429     { java_awt_event_KeyEvent_VK_8, XK_kana_YU, XK_8, 0xff95, TRUE, 0 },
00430     { java_awt_event_KeyEvent_VK_9, XK_kana_YO, XK_9, 0xff96, TRUE, 0 },
00431     { java_awt_event_KeyEvent_VK_0, XK_kana_WA, XK_0, 0xff9c, TRUE, 0 },
00432     { '-',                      XK_kana_HO, XK_minus, 0xff8e, TRUE, 0 },
00433     { '~',                      XK_kana_HE, XK_asciicircum, 0xff8d, TRUE, 0 },
00434     { java_awt_event_KeyEvent_VK_Q, XK_kana_TA, XK_q, 0xff80, TRUE, 0 },
00435     { java_awt_event_KeyEvent_VK_W, XK_kana_TE, XK_w, 0xff83, TRUE, 0 },
00436     { java_awt_event_KeyEvent_VK_E, XK_kana_I, XK_e, 0xff72, TRUE, 0 },
00437     { java_awt_event_KeyEvent_VK_R, XK_kana_SU, XK_r, 0xff7d, TRUE, 0 },
00438     { java_awt_event_KeyEvent_VK_T, XK_kana_KA, XK_t, 0xff76, TRUE, 0 },
00439     { java_awt_event_KeyEvent_VK_Y, XK_kana_N, XK_y, 0xff9d, TRUE, 0 },
00440     { java_awt_event_KeyEvent_VK_U, XK_kana_NA, XK_u, 0xff85, TRUE, 0 },
00441     { java_awt_event_KeyEvent_VK_I, XK_kana_NI, XK_i, 0xff86, TRUE, 0 },
00442     { java_awt_event_KeyEvent_VK_O, XK_kana_RA, XK_o, 0xff97, TRUE, 0 },
00443     { java_awt_event_KeyEvent_VK_P, XK_kana_SE, XK_p, 0xff7e, TRUE, 0 },
00444     { java_awt_event_KeyEvent_VK_AT, XK_voicedsound, XK_at, 0xff9e, TRUE, 0 },
00445     { java_awt_event_KeyEvent_VK_OPEN_BRACKET, XK_semivoicedsound, XK_bracketleft, 0xff9f, TRUE, 0 },
00446     { java_awt_event_KeyEvent_VK_A, XK_kana_CHI, XK_a, 0xff81, TRUE, 0 },
00447     { java_awt_event_KeyEvent_VK_S, XK_kana_TO, XK_s, 0xff84, TRUE, 0 },
00448     { java_awt_event_KeyEvent_VK_D, XK_kana_SHI, XK_d, 0xff7c, TRUE, 0 },
00449     { java_awt_event_KeyEvent_VK_F, XK_kana_HA, XK_f, 0xff8a, TRUE, 0 },
00450     { java_awt_event_KeyEvent_VK_G, XK_kana_KI, XK_g, 0xff77, TRUE, 0 },
00451     { java_awt_event_KeyEvent_VK_H, XK_kana_KU, XK_h, 0xff78, TRUE, 0 },
00452     { java_awt_event_KeyEvent_VK_J, XK_kana_MA, XK_j, 0xff8f, TRUE, 0 },
00453     { java_awt_event_KeyEvent_VK_K, XK_kana_NO, XK_k, 0xff89, TRUE, 0 },
00454     { java_awt_event_KeyEvent_VK_L, XK_kana_RI, XK_l, 0xff98, TRUE, 0 },
00455     { java_awt_event_KeyEvent_VK_SEMICOLON, XK_kana_RE, XK_semicolon, 0xff9a, TRUE, 0 },
00456     { ':',                             XK_kana_KE, XK_colon, 0xff79, TRUE, 0 },
00457     { java_awt_event_KeyEvent_VK_CLOSE_BRACKET, XK_kana_MU, XK_bracketright, 0xff91, TRUE, 0 },
00458     { java_awt_event_KeyEvent_VK_Z, XK_kana_TSU, XK_z, 0xff82, TRUE, 0 },
00459     { java_awt_event_KeyEvent_VK_X, XK_kana_SA, XK_x, 0xff7b, TRUE, 0 },
00460     { java_awt_event_KeyEvent_VK_C, XK_kana_SO, XK_c, 0xff7f, TRUE, 0 },
00461     { java_awt_event_KeyEvent_VK_V, XK_kana_HI, XK_v, 0xff8b, TRUE, 0 },
00462     { java_awt_event_KeyEvent_VK_B, XK_kana_KO, XK_b, 0xff7a, TRUE, 0 },
00463     { java_awt_event_KeyEvent_VK_N, XK_kana_MI, XK_n, 0xff90, TRUE, 0 },
00464     { java_awt_event_KeyEvent_VK_M, XK_kana_MO, XK_m, 0xff93, TRUE, 0 },
00465     { java_awt_event_KeyEvent_VK_COMMA, XK_kana_NE, XK_comma, 0xff88, TRUE, 0 },
00466     { java_awt_event_KeyEvent_VK_PERIOD, XK_kana_RU, XK_period, 0xff99, TRUE , 0},
00467     { java_awt_event_KeyEvent_VK_SLASH, XK_kana_ME, XK_slash, 0xff92, TRUE, 0 },
00468     /* hack to japanese keyboard */
00469     /* backslash is duplicate for RO and prolongedsound */
00470     { java_awt_event_KeyEvent_VK_BACK_SLASH, XK_kana_RO, XK_underscore, 0xff9b, TRUE, 0 },
00471     { java_awt_event_KeyEvent_VK_BACK_SLASH, XK_prolongedsound, XK_bar, 0xff70, TRUE, 0 },
00472     { 0, 0, 0 }
00473 };
00474 
00475 static KeymapEntry2 kana_shift_keymapTable[] = {
00476     { java_awt_event_KeyEvent_VK_3, XK_kana_a, XK_numbersign, 0xff67, TRUE, 0 },
00477     { java_awt_event_KeyEvent_VK_4, XK_kana_u, XK_dollar, 0xff69, TRUE, 0 },
00478     { java_awt_event_KeyEvent_VK_5, XK_kana_e, XK_percent, 0xff6a, TRUE, 0 },
00479     { java_awt_event_KeyEvent_VK_6, XK_kana_o, XK_ampersand, 0xff6b, TRUE, 0 },
00480     { java_awt_event_KeyEvent_VK_7, XK_kana_ya, XK_apostrophe, 0xff6c, TRUE, 0 },
00481     { java_awt_event_KeyEvent_VK_8, XK_kana_yu, XK_parenleft, 0xff6d, TRUE, 0 },
00482     { java_awt_event_KeyEvent_VK_9, XK_kana_yo, XK_parenright, 0xff6e, TRUE, 0 },
00483     { java_awt_event_KeyEvent_VK_0, XK_kana_WO, XK_asciitilde, 0xff66, TRUE, 0 },
00484     { java_awt_event_KeyEvent_VK_E, XK_kana_i, XK_E, 0xff68, TRUE, 0 },
00485     { java_awt_event_KeyEvent_VK_OPEN_BRACKET, XK_kana_openingbracket, XK_braceleft, 0xff62, TRUE, 0 },
00486     { java_awt_event_KeyEvent_VK_CLOSE_BRACKET, XK_kana_closingbracket, XK_braceright, 0xff63, TRUE, 0 },
00487     { java_awt_event_KeyEvent_VK_Z, XK_kana_tsu, XK_Z, 0xff6f, TRUE, 0 },
00488     /* XK_less does not return correct keycode on VineLinux 1.1 */
00489     { java_awt_event_KeyEvent_VK_COMMA, XK_kana_comma, XK_comma, 0xff64, TRUE, 0 },
00490     { java_awt_event_KeyEvent_VK_PERIOD, XK_kana_fullstop, XK_greater, 0xff61, TRUE,0 },
00491     { java_awt_event_KeyEvent_VK_SLASH, XK_kana_conjunctive, XK_question, 0xff65, TRUE,0 },
00492     { 0, 0, 0 }
00493 };
00494 #endif
00495 
00496 static KeymapEntry keymapTable[] = {
00497     { java_awt_event_KeyEvent_VK_A, XK_a, TRUE },
00498     { java_awt_event_KeyEvent_VK_B, XK_b, TRUE },
00499     { java_awt_event_KeyEvent_VK_C, XK_c, TRUE },
00500     { java_awt_event_KeyEvent_VK_D, XK_d, TRUE },
00501     { java_awt_event_KeyEvent_VK_E, XK_e, TRUE },
00502     { java_awt_event_KeyEvent_VK_F, XK_f, TRUE },
00503     { java_awt_event_KeyEvent_VK_G, XK_g, TRUE },
00504     { java_awt_event_KeyEvent_VK_H, XK_h, TRUE },
00505     { java_awt_event_KeyEvent_VK_I, XK_i, TRUE },
00506     { java_awt_event_KeyEvent_VK_J, XK_j, TRUE },
00507     { java_awt_event_KeyEvent_VK_K, XK_k, TRUE },
00508     { java_awt_event_KeyEvent_VK_L, XK_l, TRUE },
00509     { java_awt_event_KeyEvent_VK_M, XK_m, TRUE },
00510     { java_awt_event_KeyEvent_VK_N, XK_n, TRUE },
00511     { java_awt_event_KeyEvent_VK_O, XK_o, TRUE },
00512     { java_awt_event_KeyEvent_VK_P, XK_p, TRUE },
00513     { java_awt_event_KeyEvent_VK_Q, XK_q, TRUE },
00514     { java_awt_event_KeyEvent_VK_R, XK_r, TRUE },
00515     { java_awt_event_KeyEvent_VK_S, XK_s, TRUE },
00516     { java_awt_event_KeyEvent_VK_T, XK_t, TRUE },
00517     { java_awt_event_KeyEvent_VK_U, XK_u, TRUE },
00518     { java_awt_event_KeyEvent_VK_V, XK_v, TRUE },
00519     { java_awt_event_KeyEvent_VK_W, XK_w, TRUE },
00520     { java_awt_event_KeyEvent_VK_X, XK_x, TRUE },
00521     { java_awt_event_KeyEvent_VK_Y, XK_y, TRUE },
00522     { java_awt_event_KeyEvent_VK_Z, XK_z, TRUE },
00523 
00524     { java_awt_event_KeyEvent_VK_ENTER, XK_Return, TRUE },
00525     { java_awt_event_KeyEvent_VK_ENTER, XK_KP_Enter, TRUE },
00526     { java_awt_event_KeyEvent_VK_ENTER, XK_Linefeed, TRUE },
00527 
00528     { java_awt_event_KeyEvent_VK_BACK_SPACE, XK_BackSpace, TRUE },
00529     { java_awt_event_KeyEvent_VK_TAB, XK_Tab, TRUE },
00530     { java_awt_event_KeyEvent_VK_TAB, XK_ISO_Left_Tab, TRUE },
00531     { java_awt_event_KeyEvent_VK_CANCEL, XK_Cancel, FALSE },
00532     { java_awt_event_KeyEvent_VK_CLEAR, XK_Clear, FALSE },
00533     { java_awt_event_KeyEvent_VK_SHIFT, XK_Shift_L, FALSE },
00534     { java_awt_event_KeyEvent_VK_SHIFT, XK_Shift_R, FALSE }, 
00535     { java_awt_event_KeyEvent_VK_CONTROL, XK_Control_L, FALSE },
00536     { java_awt_event_KeyEvent_VK_CONTROL, XK_Control_R, FALSE }, 
00537     { java_awt_event_KeyEvent_VK_ALT, XK_Alt_L, FALSE },
00538     { java_awt_event_KeyEvent_VK_ALT, XK_Alt_R, FALSE },
00539     { java_awt_event_KeyEvent_VK_META, XK_Meta_L, FALSE },
00540     { java_awt_event_KeyEvent_VK_META, XK_Meta_R, FALSE }, 
00541     { java_awt_event_KeyEvent_VK_PAUSE, XK_Pause, FALSE },
00542     { java_awt_event_KeyEvent_VK_CAPS_LOCK, XK_Caps_Lock, FALSE },
00543     { java_awt_event_KeyEvent_VK_ESCAPE, XK_Escape, TRUE },
00544     { java_awt_event_KeyEvent_VK_SPACE, XK_space, TRUE },
00545 
00546     { java_awt_event_KeyEvent_VK_PAGE_UP, XK_Page_Up, FALSE },
00547     { java_awt_event_KeyEvent_VK_PAGE_UP, XK_R9, FALSE },
00548     { java_awt_event_KeyEvent_VK_PAGE_UP, XK_Prior, FALSE },
00549     { java_awt_event_KeyEvent_VK_PAGE_UP, XK_F29, FALSE },
00550     { java_awt_event_KeyEvent_VK_PAGE_DOWN, XK_Page_Down, FALSE },
00551     { java_awt_event_KeyEvent_VK_PAGE_DOWN, XK_R15, FALSE },
00552     { java_awt_event_KeyEvent_VK_PAGE_DOWN, XK_Next, FALSE },
00553     { java_awt_event_KeyEvent_VK_PAGE_DOWN, XK_F35, FALSE },
00554     { java_awt_event_KeyEvent_VK_END, XK_End, FALSE },
00555     { java_awt_event_KeyEvent_VK_END, XK_R13, FALSE },
00556     { java_awt_event_KeyEvent_VK_HOME, XK_Home, FALSE },
00557     { java_awt_event_KeyEvent_VK_HOME, XK_R7, FALSE },
00558     { java_awt_event_KeyEvent_VK_HOME, XK_F27, FALSE },
00559 
00560     { java_awt_event_KeyEvent_VK_LEFT, XK_Left, FALSE },
00561     { java_awt_event_KeyEvent_VK_UP, XK_Up, FALSE },
00562     { java_awt_event_KeyEvent_VK_RIGHT, XK_Right, FALSE },
00563     { java_awt_event_KeyEvent_VK_DOWN, XK_Down, FALSE },
00564     { java_awt_event_KeyEvent_VK_INSERT, XK_Insert, FALSE },
00565     { java_awt_event_KeyEvent_VK_HELP, XK_Help, FALSE },
00566 
00567     { java_awt_event_KeyEvent_VK_0, XK_0, TRUE },
00568     { java_awt_event_KeyEvent_VK_1, XK_1, TRUE },
00569     { java_awt_event_KeyEvent_VK_2, XK_2, TRUE },
00570     { java_awt_event_KeyEvent_VK_3, XK_3, TRUE },
00571     { java_awt_event_KeyEvent_VK_4, XK_4, TRUE },
00572     { java_awt_event_KeyEvent_VK_5, XK_5, TRUE },
00573     { java_awt_event_KeyEvent_VK_6, XK_6, TRUE },
00574     { java_awt_event_KeyEvent_VK_7, XK_7, TRUE },
00575     { java_awt_event_KeyEvent_VK_8, XK_8, TRUE },
00576     { java_awt_event_KeyEvent_VK_9, XK_9, TRUE },
00577 
00578     { java_awt_event_KeyEvent_VK_EQUALS, XK_equal, TRUE },
00579     { java_awt_event_KeyEvent_VK_BACK_SLASH, XK_backslash, TRUE },
00580     { java_awt_event_KeyEvent_VK_BACK_QUOTE, XK_grave, TRUE },
00581     { java_awt_event_KeyEvent_VK_OPEN_BRACKET, XK_bracketleft, TRUE },
00582     { java_awt_event_KeyEvent_VK_CLOSE_BRACKET, XK_bracketright, TRUE },
00583     { java_awt_event_KeyEvent_VK_SEMICOLON, XK_semicolon, TRUE },
00584     { java_awt_event_KeyEvent_VK_QUOTE, XK_apostrophe, TRUE },
00585     { java_awt_event_KeyEvent_VK_MINUS, XK_minus, TRUE },
00586     { java_awt_event_KeyEvent_VK_COMMA, XK_comma, TRUE },
00587     { java_awt_event_KeyEvent_VK_PERIOD, XK_period, TRUE },
00588     { java_awt_event_KeyEvent_VK_SLASH, XK_slash, TRUE },
00589 
00590     { java_awt_event_KeyEvent_VK_NUMPAD0, XK_KP_0, TRUE },
00591     { java_awt_event_KeyEvent_VK_NUMPAD1, XK_KP_1, TRUE },
00592     { java_awt_event_KeyEvent_VK_NUMPAD2, XK_KP_2, TRUE },
00593     { java_awt_event_KeyEvent_VK_NUMPAD3, XK_KP_3, TRUE },
00594     { java_awt_event_KeyEvent_VK_NUMPAD4, XK_KP_4, TRUE },
00595     { java_awt_event_KeyEvent_VK_NUMPAD5, XK_KP_5, TRUE },
00596     { java_awt_event_KeyEvent_VK_NUMPAD6, XK_KP_6, TRUE },
00597     { java_awt_event_KeyEvent_VK_NUMPAD7, XK_KP_7, TRUE },
00598     { java_awt_event_KeyEvent_VK_NUMPAD8, XK_KP_8, TRUE },
00599     { java_awt_event_KeyEvent_VK_NUMPAD9, XK_KP_9, TRUE },
00600     { java_awt_event_KeyEvent_VK_MULTIPLY, XK_KP_Multiply, TRUE },
00601     { java_awt_event_KeyEvent_VK_ADD, XK_KP_Add, TRUE },
00602     { java_awt_event_KeyEvent_VK_SUBTRACT, XK_KP_Subtract, TRUE },
00603     { java_awt_event_KeyEvent_VK_DECIMAL, XK_KP_Decimal, TRUE },
00604     { java_awt_event_KeyEvent_VK_DIVIDE, XK_KP_Divide, TRUE },
00605     { java_awt_event_KeyEvent_VK_EQUALS, XK_KP_Equal, TRUE },
00606     { java_awt_event_KeyEvent_VK_INSERT, XK_KP_Insert, FALSE },
00607     { java_awt_event_KeyEvent_VK_ENTER, XK_KP_Enter, FALSE },
00608 
00609     { java_awt_event_KeyEvent_VK_F1, XK_F1, FALSE },
00610     { java_awt_event_KeyEvent_VK_F2, XK_F2, FALSE },
00611     { java_awt_event_KeyEvent_VK_F3, XK_F3, FALSE },
00612     { java_awt_event_KeyEvent_VK_F4, XK_F4, FALSE },
00613     { java_awt_event_KeyEvent_VK_F5, XK_F5, FALSE },
00614     { java_awt_event_KeyEvent_VK_F6, XK_F6, FALSE },
00615     { java_awt_event_KeyEvent_VK_F7, XK_F7, FALSE },
00616     { java_awt_event_KeyEvent_VK_F8, XK_F8, FALSE },
00617     { java_awt_event_KeyEvent_VK_F9, XK_F9, FALSE },
00618     { java_awt_event_KeyEvent_VK_F10, XK_F10, FALSE },
00619     /* next two entries for for 4173902 */
00620     { java_awt_event_KeyEvent_VK_F11, SunXK_F36, FALSE },
00621     { java_awt_event_KeyEvent_VK_F12, SunXK_F37, FALSE },
00622     { java_awt_event_KeyEvent_VK_F11, XK_F11, FALSE },
00623     { java_awt_event_KeyEvent_VK_F12, XK_F12, FALSE },
00624 
00625     { java_awt_event_KeyEvent_VK_DELETE, XK_Delete, TRUE },
00626     { java_awt_event_KeyEvent_VK_DELETE, XK_KP_Delete, TRUE },
00627 
00628     { java_awt_event_KeyEvent_VK_NUM_LOCK, XK_Num_Lock, FALSE },
00629     { java_awt_event_KeyEvent_VK_SCROLL_LOCK, XK_Scroll_Lock, FALSE },
00630     { java_awt_event_KeyEvent_VK_PRINTSCREEN, XK_Print, FALSE },
00631 
00632     { java_awt_event_KeyEvent_VK_ACCEPT, XK_Execute, FALSE },
00633 
00634 #ifdef JAVA_12_BUG
00635     /* bugs in Java2 4124396
00636 
00637        - Convert key (right of Space key): generates VK_KANJI,
00638               should generate VK_CONVERT.
00639        - Nihongo On-Off key (right of Convert key): generates VK_CONVERT,
00640               should generate VK_KANJI.
00641 
00642     */
00643 
00644     { java_awt_event_KeyEvent_VK_CONVERT, XK_Henkan_Mode, FALSE },
00645     { java_awt_event_KeyEvent_VK_KANJI, XK_Kanji, FALSE },
00646 #else
00647     { java_awt_event_KeyEvent_VK_KANJI, XK_Henkan_Mode, FALSE },
00648     { java_awt_event_KeyEvent_VK_CONVERT, XK_Kanji, FALSE },
00649 #endif
00650 
00651     { java_awt_event_KeyEvent_VK_NONCONVERT, XK_Muhenkan, FALSE },
00652 
00653     { java_awt_event_KeyEvent_VK_KANA, XK_Katakana, FALSE },
00654     { java_awt_event_KeyEvent_VK_KANA, XK_kana_switch, FALSE },
00655 
00656     { java_awt_event_KeyEvent_VK_CUT, XK_F20, FALSE },
00657     { java_awt_event_KeyEvent_VK_COPY, XK_F16, FALSE },
00658     { java_awt_event_KeyEvent_VK_PASTE, XK_F18, FALSE },
00659     { java_awt_event_KeyEvent_VK_UNDO, XK_F14, FALSE },
00660     { java_awt_event_KeyEvent_VK_FIND, XK_F19, FALSE },
00661     { java_awt_event_KeyEvent_VK_PROPS, XK_F13, FALSE },
00662 
00663     { 0, 0, 0 }
00664 };
00665 
00666 static KeySym getX11KeySym(long awtKey) 
00667 {
00668     int i;
00669     for (i = 0; keymapTable[i].awtKey != 0; i++) {
00670         if (keymapTable[i].awtKey == awtKey) {
00671          /* stop checking printable or not, otherwise
00672             arrow keys won't work
00673            if (keymapTable[i].printable == FALSE) return 0;
00674            */
00675          return keymapTable[i].x11Key;
00676         }
00677     }
00678     return 0;
00679 }
00680 
00681 static long getAWTKeyCode(long keysym) 
00682 {
00683     int i;
00684     for (i = 0; keymapTable[i].awtKey != 0; i++) {
00685         if (keymapTable[i].x11Key == keysym) {
00686          return keymapTable[i].awtKey;
00687         }
00688     }
00689     return 0;
00690 }
00691 
00692 /* for kana */
00693 #if kana_table
00694 static void getAWTKeyCode2(long keysym, int *keycode, int *keychar) 
00695 {
00696     int i;
00697          *keycode = 0;
00698          *keychar = 0;
00699 
00700     for (i = 0; kana_normal_keymapTable[i].awtKey != 0; i++) {
00701         if (kana_normal_keymapTable[i].x11Key == keysym) {
00702          *keycode = kana_normal_keymapTable[i].awtKey;
00703          *keychar = kana_normal_keymapTable[i].keychar;
00704          return;
00705         }
00706     }
00707     for (i = 0; kana_shift_keymapTable[i].awtKey != 0; i++) {
00708         if (kana_shift_keymapTable[i].x11Key == keysym) {
00709          *keycode = kana_shift_keymapTable[i].awtKey;
00710          *keychar = kana_shift_keymapTable[i].keychar;
00711          return;
00712         }
00713     }
00714     return;
00715 }
00716 #endif
00717 
00718 static void
00719 set_mod_mask(int modnum, int *mask) {
00720     switch(modnum) {
00721       case 1: 
00722        *mask = Mod1Mask;
00723        break;               
00724       case 2: 
00725        *mask = Mod2Mask;
00726        break;        
00727       case 3: 
00728        *mask = Mod3Mask;
00729        break;               
00730       case 4: 
00731        *mask = Mod4Mask;
00732        break; 
00733       case 5:
00734        *mask = Mod5Mask;
00735        break;
00736       default:
00737        *mask = 0;
00738     }
00739 }
00740 
00741 static void
00742 setup_modifier_map(Display *disp)
00743 {
00744     XModifierKeymap *modmap; 
00745     int i, k, nkeys;
00746     KeyCode keycode, metaL, metaR, altL, altR, numLock, Mode_switch;
00747 
00748     metaL = XKeysymToKeycode(disp, XK_Meta_L);
00749     metaR = XKeysymToKeycode(disp, XK_Meta_R);
00750     altR = XKeysymToKeycode(disp, XK_Alt_R);
00751     altL = XKeysymToKeycode(disp, XK_Alt_L);
00752     numLock = XKeysymToKeycode(disp, XK_Num_Lock);
00753     Mode_switch = XKeysymToKeycode(disp, XK_Mode_switch);
00754 
00755     modmap = XGetModifierMapping(disp);
00756     nkeys = modmap->max_keypermod;
00757     for(i = 3*nkeys; 
00758        i < (nkeys*8) && (awt_MetaMask == 0 || awt_AltMask == 0 || awt_NumLockMask == 0 || awt_KanaLockMask ==0);
00759             i++) {
00760        keycode = modmap->modifiermap[i];
00761        k = (i/nkeys) - 2;
00762        if (awt_MetaMask == 0 && (keycode == metaL || keycode == metaR)) {
00763            set_mod_mask(k, &awt_MetaMask);
00764        } else if (awt_AltMask == 0 && (keycode == altL || keycode == altR)) {
00765            set_mod_mask(k, &awt_AltMask);
00766        } else if (awt_NumLockMask == 0 && keycode == numLock) {
00767             set_mod_mask(k, &awt_NumLockMask);
00768        } else if (awt_KanaLockMask == 0 && keycode == Mode_switch) {
00769             set_mod_mask(k, &awt_KanaLockMask);
00770         }
00771     }
00772     XFreeModifiermap(modmap);
00773 
00774 #ifdef linux
00775     /* hack for Linux XFree86 */
00776     if (getenv("HTT_USES_LINUX_XKEYSYM")){
00777            for (i = 0; keymapTable[i].awtKey != 0; i++) {
00778               if (keymapTable[i].x11Key == XK_Henkan_Mode) {
00779                 keymapTable[i].x11Key = XK_Zenkaku_Hankaku;
00780                 break;
00781               }
00782            }
00783            for (i = 0; keymapTable[i].awtKey != 0; i++) {
00784               if (keymapTable[i].x11Key == XK_Kanji) {
00785                 keymapTable[i].x11Key = XK_Henkan_Mode;
00786                 break;
00787               }
00788            }
00789            for (i = 0; keymapTable[i].awtKey != 0; i++) {
00790               if (keymapTable[i].x11Key == XK_Execute) {
00791                 keymapTable[i].x11Key = XK_Muhenkan;
00792                 break;
00793               }
00794            }
00795     }
00796 
00797     /* hack for Linux XFree86 */
00798     if (getenv("HTT_GENERATES_KANAKEY")){
00799        KanaMode = 0;
00800     } else {
00801        return;
00802     }
00803 
00804     /* Get Keycodes for Kana keys */
00805     for (i = 0; kana_normal_keymapTable[i].awtKey != 0; i++) {
00806        kana_normal_keymapTable[i].keycode = XKeysymToKeycode(disp,
00807                                           kana_normal_keymapTable[i].x11Key);
00808        if (kana_normal_keymapTable[i].keycode == 0) {
00809               kana_normal_keymapTable[i].keycode = XKeysymToKeycode(disp,
00810                                           kana_normal_keymapTable[i].alt_x11Key);
00811        }
00812 #ifdef DEBUG
00813        printf("xkey=%x(%x) -> %x\n", kana_normal_keymapTable[i].x11Key,
00814                                    kana_normal_keymapTable[i].keychar,
00815                                    kana_normal_keymapTable[i].keycode);
00816 #endif
00817     }
00818     for (i = 0; kana_shift_keymapTable[i].awtKey != 0; i++) {
00819        kana_shift_keymapTable[i].keycode = XKeysymToKeycode(disp,
00820                                           kana_shift_keymapTable[i].x11Key);
00821        if (kana_shift_keymapTable[i].keycode == 0) {
00822               kana_shift_keymapTable[i].keycode = XKeysymToKeycode(disp,
00823                                           kana_shift_keymapTable[i].alt_x11Key);
00824        }
00825 #ifdef DEBUG
00826        printf("xkey=%x(%x) -> %x\n", kana_shift_keymapTable[i].x11Key,
00827                                    kana_shift_keymapTable[i].keychar,
00828                                    kana_shift_keymapTable[i].keycode);
00829 #endif
00830     }
00831 
00832     if (!kanawin_atom) {
00833        kanawin_atom = XInternAtom(disp, "HTT_KANA_WIN", False);
00834        kanaflag_atom = XInternAtom(disp, "HTT_KANA_FLAG", False);
00835     }
00836 
00837     kana_w = XGetSelectionOwner(disp, kanawin_atom);
00838 
00839     if (kana_w == None) {
00840        kana_w = XCreateSimpleWindow(disp, RootWindow(disp, 0),
00841                      0, 0, 1, 1, 0, 0, 0);
00842 
00843        XSetSelectionOwner(disp, kanawin_atom, kana_w, CurrentTime);
00844 
00845        XChangeProperty(disp, kana_w, kanaflag_atom, XA_WINDOW, 32,
00846                             PropModeReplace,
00847                             &KanaMode, sizeof(KanaMode));
00848     }
00849 
00850     GetKanaFlag(disp);
00851 #endif /* linux */
00852 }
00853 
00854 #ifdef linux
00855 GetKanaFlag(Display *disp)
00856 {
00857     Atom            ret_type;
00858     int             ret_format;
00859     unsigned long   nitems, bytes_left;
00860     unsigned long  *tmp;
00861 
00862     XGetWindowProperty(disp, kana_w,
00863                      kanaflag_atom, 0, 4, False, XA_WINDOW,
00864                      &ret_type, &ret_format,
00865                      &nitems, &bytes_left, &tmp);
00866 
00867     if (ret_type == XA_WINDOW) {
00868        KanaMode = *tmp;
00869     }
00870 }
00871 #endif /* linux */
00872 
00873 /*
00874        XKeysymToKeycode() does not return correct keycode for XK_Delete.
00875        So we store and keep the value of KeyCode at the first key typed,
00876        then use in modify_Event()
00877 */
00878 
00879 static long keyCode_XK_Delete = 0;
00880 
00881 static void
00882 modify_Event(XEvent *xevent, long keyCode, unicode keyChar, long modifiers)
00883 {
00884     KeySym keysym = 0;
00885 
00886     if (xevent->type != KeyPress && xevent->type != KeyRelease)
00887         return;
00888 
00889     switch(keyCode) {
00890       case java_awt_event_KeyEvent_VK_ENTER:
00891       case java_awt_event_KeyEvent_VK_BACK_SPACE:
00892       case java_awt_event_KeyEvent_VK_TAB:
00893       case java_awt_event_KeyEvent_VK_ESCAPE:
00894       case java_awt_event_KeyEvent_VK_MULTIPLY:
00895       case java_awt_event_KeyEvent_VK_ADD:
00896       case java_awt_event_KeyEvent_VK_SUBTRACT:
00897       case java_awt_event_KeyEvent_VK_DIVIDE:
00898       case java_awt_event_KeyEvent_VK_EQUALS:
00899       case java_awt_event_KeyEvent_VK_DECIMAL:
00900           keysym = getX11KeySym(keyCode);
00901           break;
00902       default:
00903           if ((keyChar != 0 && keyChar < 256)
00904              || (keyChar >= 0xff61 && keyChar <= 0xff9f)) {
00905               keysym = keyChar;
00906           } else {
00907               keysym = getX11KeySym(keyCode);
00908           }
00909           break;
00910     }
00911 
00912     if (keysym != 0) {
00913        if (modifiers & java_awt_event_InputEvent_CTRL_MASK) {
00914            switch (keysym + 64) {
00915              case '[':
00916              case ']':
00917              case '\\':
00918              case '_':
00919               keysym += 64;
00920               break;
00921              default:
00922               if (keysym < 254) {
00923                 if (modifiers & java_awt_event_InputEvent_SHIFT_MASK) {
00924                   if (isalpha(keysym + 'A' - 1)) {
00925                     keysym += ('A' - 1);
00926                   }
00927                 } else {
00928                   if (isalpha(keysym + 'a' - 1)) {
00929                     keysym += ('a' - 1);
00930                   }
00931                 }
00932               }
00933               break;
00934            }
00935        }
00936 
00937        /*
00938         * 0xff61 is Unicode value of first XK_kana_fullstop.
00939         * We need X Keysym to Unicode map in post1.1 release
00940         * to support more intenational keyboard.
00941         */
00942        /*
00943         * 0xff63 is duplicate with INSERT
00944         */
00945        if (keyCode != java_awt_event_KeyEvent_VK_INSERT &&
00946            keyCode != java_awt_event_KeyEvent_VK_ACCEPT &&
00947            keyCode != java_awt_event_KeyEvent_VK_ENTER &&
00948            (keysym >= 0xff61 && keysym <= 0xff9f)) {
00949            keysym = keysym - 0xff61 + XK_kana_fullstop;
00950 
00951            /*
00952             * modifier needs to be set
00953             */
00954            xevent->xkey.state |= awt_KanaLockMask;
00955        }
00956 
00957        /* workaround, do we have to set NumLock mask for
00958           all KP_ keysym??? */
00959        if(keysym == XK_KP_Decimal){
00960            xevent->xkey.state |= awt_NumLockMask;
00961         }
00962 
00963        if (xevent->xany.display)
00964            xevent->xkey.keycode = XKeysymToKeycode(xevent->xany.display,
00965                                               keysym);
00966        else
00967            xevent->xkey.keycode = keysym; /* hack */
00968 
00969        /* workaround for XKeysymToKeycode() */
00970        if (keyCode == java_awt_event_KeyEvent_VK_DELETE){
00971            xevent->xkey.keycode = keyCode_XK_Delete;
00972        }
00973     }
00974 
00975     if (keysym >= 'A' && keysym <= 'Z') {
00976        xevent->xkey.state |= ShiftMask;
00977     }
00978     if (modifiers & java_awt_event_InputEvent_SHIFT_MASK) {
00979        xevent->xkey.state |= ShiftMask;
00980     }
00981     if (modifiers & java_awt_event_InputEvent_CTRL_MASK) {
00982        xevent->xkey.state |= ControlMask;
00983     }
00984     if (modifiers & java_awt_event_InputEvent_META_MASK) {
00985        xevent->xkey.state |= awt_MetaMask;
00986     }
00987     if (modifiers & java_awt_event_InputEvent_ALT_MASK) {
00988        xevent->xkey.state |= awt_AltMask;
00989     }
00990     if (modifiers & java_awt_event_InputEvent_BUTTON1_MASK) {
00991         xevent->xkey.state |= Button1Mask;
00992     }
00993     if (modifiers & java_awt_event_InputEvent_BUTTON2_MASK) {
00994         xevent->xkey.state |= Button2Mask;
00995     }
00996     if (modifiers & java_awt_event_InputEvent_BUTTON3_MASK) {
00997         xevent->xkey.state |= Button3Mask;
00998     }
00999 }
01000 
01001 static first_call = True;
01002 
01003 void
01004 VirtualKeyToXKeyEvent(CARD32 keyCode, CARD32 keyChar,
01005                     CARD32 state, XKeyEvent *kev) {
01006 
01007     if (first_call && kev->display != (Display*)0) {
01008        setup_modifier_map(kev->display);
01009     }
01010     first_call = False;
01011     modify_Event((XEvent*)kev, keyCode, keyChar, state);
01012     return;
01013 }
01014 
01015 /*
01016   KeyEventToVirtualKey() :
01017      Convert X KeyEvent to IIIMP keyCode, keyChar, state values
01018  */
01019 Bool
01020 KeyEventToVirtualKey(XKeyEvent *ev, int *keycode_ret,
01021                    int *keychar_ret, int *state_ret) {
01022   KeySym keysym;
01023   char buf[64];
01024   int len = sizeof(buf);
01025   int state;
01026   int i;
01027 
01028   *keychar_ret = 0;
01029   *keycode_ret = 0;
01030 
01031   if (first_call && ev->display != (Display*)0) {
01032      setup_modifier_map(ev->display);
01033   }
01034   first_call = False;
01035 
01036   state = ev->state;
01037 
01038   /* LockMask, NumLockMask, KanaLockMask should be ignored for
01039      Java Client compatibility */
01040   if(state & LockMask){
01041     state -= LockMask;
01042   }
01043   if(state & awt_NumLockMask){
01044     state -= awt_NumLockMask;
01045   }
01046   if(state & awt_KanaLockMask){
01047     state -= awt_KanaLockMask;
01048   }
01049 
01050   /* IIIMP's control_mask(1<<1) and X's control_mask(1<<2)is
01051        different, so it should be changed */
01052   if (state & ControlMask) {
01053     state -= (1<<2);
01054     state |= (1<<1);
01055   }
01056 
01057   *state_ret = state;
01058 
01059   len = XLookupString(ev, buf, len - 1, &keysym, NULL);
01060 
01061 #ifdef  linux
01062    /* Linux generates XK_Mode_switch at Shift + Henkan_Mode */
01063    if (getenv("HTT_USES_LINUX_XKEYSYM")&&
01064         ((state & ShiftMask) && keysym == XK_Mode_switch)){
01065         keysym = XK_Henkan_Mode;
01066    } else
01067 #endif /* linux */
01068   if (IsModifierKey(keysym)) {
01069        return False;
01070   }
01071 
01072 #ifdef linux
01073   if (KanaMode != -1){
01074        if (keysym == XK_Hiragana_Katakana){
01075 #ifdef DEBUG
01076               printf("Kanakey is pressed\n");
01077 #endif
01078               if (KanaMode == 1){
01079                      KanaMode = 0;
01080 #ifdef DEBUG
01081               printf("      off\n");
01082 #endif
01083               } else {
01084                      KanaMode = 1;
01085 #ifdef DEBUG
01086               printf("      on\n");
01087 #endif
01088               }
01089               XChangeProperty(ev->display, kana_w, kanaflag_atom,
01090                             XA_WINDOW, 32,
01091                             PropModeReplace,
01092                             &KanaMode, sizeof(KanaMode));
01093               return False;
01094        }
01095   }
01096 
01097   if (KanaMode != -1){
01098        GetKanaFlag(ev->display);
01099   }     
01100 
01101   if (KanaMode == 1) {
01102        if (ev->state & ShiftMask) {
01103               /* check kana_shift_keymapTable first is ShiftMask */
01104               for (i = 0; kana_shift_keymapTable[i].awtKey != 0; i++) {
01105                      if (kana_shift_keymapTable[i].keycode == ev->keycode) {
01106                             getAWTKeyCode2(kana_shift_keymapTable[i].x11Key, keycode_ret, keychar_ret);
01107                             if (*keycode_ret) {
01108                                    return True;
01109                             }
01110                             break;
01111                      }
01112               }
01113        }
01114 
01115        for (i = 0; kana_normal_keymapTable[i].awtKey != 0; i++) {
01116               if (kana_normal_keymapTable[i].keycode == ev->keycode) {
01117                      getAWTKeyCode2(kana_normal_keymapTable[i].x11Key, keycode_ret, keychar_ret);
01118                      if (*keycode_ret) {
01119                             return True;
01120                      }
01121                      break;
01122               }
01123        }
01124 
01125        for (i = 0; kana_shift_keymapTable[i].awtKey != 0; i++) {
01126               if (kana_shift_keymapTable[i].keycode == ev->keycode) {
01127                      getAWTKeyCode2(kana_shift_keymapTable[i].x11Key, keycode_ret, keychar_ret);
01128                      if (*keycode_ret) {
01129                             return True;
01130                      }
01131                      break;
01132               }
01133        }
01134    }
01135 #endif /* linux */
01136 
01137   /* store keycode for XK_Delete */
01138   if(keysym == XK_Delete && keyCode_XK_Delete == 0){
01139        keyCode_XK_Delete = ev->keycode;
01140   }
01141 
01142   if (keysym < 256) {
01143     if ((ev->state & ControlMask)) {
01144        if (isalpha(keysym)) {
01145          keysym = toupper(keysym);
01146        }
01147     }
01148     *keycode_ret = getAWTKeyCode(keysym);
01149     if (*keycode_ret == 0 && (ev->state & ShiftMask)) {
01150        /* when Shift key is pressed, need to get the normal keysym,
01151           then get the AWT keycode */
01152        if (ev->display != (Display*)0) {
01153           *keycode_ret = getAWTKeyCode(XKeycodeToKeysym(ev->display,
01154                                                  ev->keycode, 0));
01155        }
01156     }
01157     if (*keycode_ret == 0) {
01158         *keycode_ret = keysym;
01159     }
01160     *keychar_ret = keysym;
01161     return True;
01162   } else {
01163     *keycode_ret = getAWTKeyCode(keysym);
01164     switch (keysym) {
01165     case XK_KP_Decimal:
01166       *keychar_ret = '.';
01167       break;
01168     case XK_KP_Add:
01169       *keychar_ret = '+';
01170       break;
01171     case XK_KP_Subtract:
01172       *keychar_ret = '-';
01173       break;
01174     case XK_KP_Divide:
01175       *keychar_ret = '/';
01176       break;
01177     case XK_KP_Multiply:
01178       *keychar_ret = '*';
01179       break;
01180     case XK_KP_0:
01181       *keychar_ret = '0';
01182       break;
01183     case XK_KP_1:
01184       *keychar_ret = '1';
01185       break;
01186     case XK_KP_2:
01187       *keychar_ret = '2';
01188       break;
01189     case XK_KP_3:
01190       *keychar_ret = '3';
01191       break;
01192     case XK_KP_4:
01193       *keychar_ret = '4';
01194       break;
01195     case XK_KP_5:
01196       *keychar_ret = '5';
01197       break;
01198     case XK_KP_6:
01199       *keychar_ret = '6';
01200       break;
01201     case XK_KP_7:
01202       *keychar_ret = '7';
01203       break;
01204     case XK_KP_8:
01205       *keychar_ret = '8';
01206       break;
01207     case XK_KP_9:
01208       *keychar_ret = '9';
01209       break;
01210     }
01211     if(*keycode_ret) {
01212         return True;
01213     }
01214 
01215     /* get Kana code */
01216     getAWTKeyCode2(keysym, keycode_ret, keychar_ret);
01217 
01218     if (*keycode_ret) {
01219         return True;
01220     }
01221 
01222     if (*keycode_ret == 0 && (ev->state & ShiftMask)) {
01223         /* when Shift key is pressed, need to get the normal keysym,
01224           then get the AWT keycode */
01225        *keycode_ret = getAWTKeyCode(XKeycodeToKeysym(ev->display,
01226                                                  ev->keycode, 0));
01227     }
01228 
01229     if (*keycode_ret) {
01230         return True;
01231     }
01232   }
01233   return False;
01234 }