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 #ifndef XK_KATAKANA
00043 #define XK_KATAKANA
00044 #endif
00045 
00046 #include <ctype.h>
00047 #include <stdlib.h>
00048 #include <string.h>
00049 #include <X11/Xlib.h>
00050 #include <X11/Xutil.h>
00051 #include <X11/keysym.h>
00052 #include <X11/Sunkeysym.h>
00053 #include <X11/Xmd.h>
00054 
00055 #include "KeyMap.h"
00056 
00057 #define kana_table 1 /* for japanese kana support */
00058 
00059 typedef struct KEYMAP_ENTRY {
00060     long awtKey;
00061     KeySym x11Key;
00062     Bool printable;
00063 } KeymapEntry;
00064 
00065 #if kana_table
00066 typedef struct KEYMAP_ENTRY2 {
00067     long awtKey;
00068     KeySym x11Key;
00069     KeySym alt_x11Key;
00070     int keychar;
00071     Bool printable;
00072     KeyCode keycode;
00073 } KeymapEntry2;
00074 #endif
00075 
00076 static int awt_MetaMask = 0;
00077 static int awt_AltMask = 0;
00078 static int awt_NumLockMask = 0;
00079 static int awt_KanaLockMask = 0;
00080 
00081 #ifdef linux
00082 #include <X11/Xatom.h>
00083 static int KanaMode = -1;
00084 static Atom kanawin_atom = 0;
00085 static Atom kanaflag_atom = 0;
00086 #endif /* linux */
00087 
00088 /* extract the definitions below from java header files */
00089 #undef java_awt_event_KeyEvent_COMPONENT_EVENT_MASK
00090 #define java_awt_event_KeyEvent_COMPONENT_EVENT_MASK 1LL
00091 #undef java_awt_event_KeyEvent_CONTAINER_EVENT_MASK
00092 #define java_awt_event_KeyEvent_CONTAINER_EVENT_MASK 2LL
00093 #undef java_awt_event_KeyEvent_FOCUS_EVENT_MASK
00094 #define java_awt_event_KeyEvent_FOCUS_EVENT_MASK 4LL
00095 #undef java_awt_event_KeyEvent_KEY_EVENT_MASK
00096 #define java_awt_event_KeyEvent_KEY_EVENT_MASK 8LL
00097 #undef java_awt_event_KeyEvent_MOUSE_EVENT_MASK
00098 #define java_awt_event_KeyEvent_MOUSE_EVENT_MASK 16LL
00099 #undef java_awt_event_KeyEvent_MOUSE_MOTION_EVENT_MASK
00100 #define java_awt_event_KeyEvent_MOUSE_MOTION_EVENT_MASK 32LL
00101 #undef java_awt_event_KeyEvent_WINDOW_EVENT_MASK
00102 #define java_awt_event_KeyEvent_WINDOW_EVENT_MASK 64LL
00103 #undef java_awt_event_KeyEvent_ACTION_EVENT_MASK
00104 #define java_awt_event_KeyEvent_ACTION_EVENT_MASK 128LL
00105 #undef java_awt_event_KeyEvent_ADJUSTMENT_EVENT_MASK
00106 #define java_awt_event_KeyEvent_ADJUSTMENT_EVENT_MASK 256LL
00107 #undef java_awt_event_KeyEvent_ITEM_EVENT_MASK
00108 #define java_awt_event_KeyEvent_ITEM_EVENT_MASK 512LL
00109 #undef java_awt_event_KeyEvent_TEXT_EVENT_MASK
00110 #define java_awt_event_KeyEvent_TEXT_EVENT_MASK 1024LL
00111 #undef java_awt_event_KeyEvent_RESERVED_ID_MAX
00112 #define java_awt_event_KeyEvent_RESERVED_ID_MAX 1999L
00113 #undef java_awt_event_KeyEvent_serialVersionUID
00114 #define java_awt_event_KeyEvent_serialVersionUID -1825314779160409405LL
00115 #undef java_awt_event_KeyEvent_COMPONENT_FIRST
00116 #define java_awt_event_KeyEvent_COMPONENT_FIRST 100L
00117 #undef java_awt_event_KeyEvent_COMPONENT_LAST
00118 #define java_awt_event_KeyEvent_COMPONENT_LAST 103L
00119 #undef java_awt_event_KeyEvent_COMPONENT_MOVED
00120 #define java_awt_event_KeyEvent_COMPONENT_MOVED 100L
00121 #undef java_awt_event_KeyEvent_COMPONENT_RESIZED
00122 #define java_awt_event_KeyEvent_COMPONENT_RESIZED 101L
00123 #undef java_awt_event_KeyEvent_COMPONENT_SHOWN
00124 #define java_awt_event_KeyEvent_COMPONENT_SHOWN 102L
00125 #undef java_awt_event_KeyEvent_COMPONENT_HIDDEN
00126 #define java_awt_event_KeyEvent_COMPONENT_HIDDEN 103L
00127 #undef java_awt_event_KeyEvent_serialVersionUID
00128 #define java_awt_event_KeyEvent_serialVersionUID 8101406823902992965LL
00129 #undef java_awt_event_KeyEvent_SHIFT_MASK
00130 #define java_awt_event_KeyEvent_SHIFT_MASK 1L
00131 #undef java_awt_event_KeyEvent_CTRL_MASK
00132 #define java_awt_event_KeyEvent_CTRL_MASK 2L
00133 #undef java_awt_event_KeyEvent_META_MASK
00134 #define java_awt_event_KeyEvent_META_MASK 4L
00135 #undef java_awt_event_KeyEvent_ALT_MASK
00136 #define java_awt_event_KeyEvent_ALT_MASK 8L
00137 #undef java_awt_event_KeyEvent_BUTTON1_MASK
00138 #define java_awt_event_KeyEvent_BUTTON1_MASK 16L
00139 #undef java_awt_event_KeyEvent_BUTTON2_MASK
00140 #define java_awt_event_KeyEvent_BUTTON2_MASK 8L
00141 #undef java_awt_event_KeyEvent_BUTTON3_MASK
00142 #define java_awt_event_KeyEvent_BUTTON3_MASK 4L
00143 #undef java_awt_event_KeyEvent_KEY_FIRST
00144 #define java_awt_event_KeyEvent_KEY_FIRST 400L
00145 #undef java_awt_event_KeyEvent_KEY_LAST
00146 #define java_awt_event_KeyEvent_KEY_LAST 402L
00147 #undef java_awt_event_KeyEvent_KEY_TYPED
00148 #define java_awt_event_KeyEvent_KEY_TYPED 400L
00149 #undef java_awt_event_KeyEvent_KEY_PRESSED
00150 #define java_awt_event_KeyEvent_KEY_PRESSED 401L
00151 #undef java_awt_event_KeyEvent_KEY_RELEASED
00152 #define java_awt_event_KeyEvent_KEY_RELEASED 402L
00153 #undef java_awt_event_KeyEvent_VK_ENTER
00154 #define java_awt_event_KeyEvent_VK_ENTER 10L
00155 #undef java_awt_event_KeyEvent_VK_BACK_SPACE
00156 #define java_awt_event_KeyEvent_VK_BACK_SPACE 8L
00157 #undef java_awt_event_KeyEvent_VK_TAB
00158 #define java_awt_event_KeyEvent_VK_TAB 9L
00159 #undef java_awt_event_KeyEvent_VK_CANCEL
00160 #define java_awt_event_KeyEvent_VK_CANCEL 3L
00161 #undef java_awt_event_KeyEvent_VK_CLEAR
00162 #define java_awt_event_KeyEvent_VK_CLEAR 12L
00163 #undef java_awt_event_KeyEvent_VK_SHIFT
00164 #define java_awt_event_KeyEvent_VK_SHIFT 16L
00165 #undef java_awt_event_KeyEvent_VK_CONTROL
00166 #define java_awt_event_KeyEvent_VK_CONTROL 17L
00167 #undef java_awt_event_KeyEvent_VK_ALT
00168 #define java_awt_event_KeyEvent_VK_ALT 18L
00169 #undef java_awt_event_KeyEvent_VK_PAUSE
00170 #define java_awt_event_KeyEvent_VK_PAUSE 19L
00171 #undef java_awt_event_KeyEvent_VK_CAPS_LOCK
00172 #define java_awt_event_KeyEvent_VK_CAPS_LOCK 20L
00173 #undef java_awt_event_KeyEvent_VK_ESCAPE
00174 #define java_awt_event_KeyEvent_VK_ESCAPE 27L
00175 #undef java_awt_event_KeyEvent_VK_SPACE
00176 #define java_awt_event_KeyEvent_VK_SPACE 32L
00177 #undef java_awt_event_KeyEvent_VK_PAGE_UP
00178 #define java_awt_event_KeyEvent_VK_PAGE_UP 33L
00179 #undef java_awt_event_KeyEvent_VK_PAGE_DOWN
00180 #define java_awt_event_KeyEvent_VK_PAGE_DOWN 34L
00181 #undef java_awt_event_KeyEvent_VK_END
00182 #define java_awt_event_KeyEvent_VK_END 35L
00183 #undef java_awt_event_KeyEvent_VK_HOME
00184 #define java_awt_event_KeyEvent_VK_HOME 36L
00185 #undef java_awt_event_KeyEvent_VK_LEFT
00186 #define java_awt_event_KeyEvent_VK_LEFT 37L
00187 #undef java_awt_event_KeyEvent_VK_UP
00188 #define java_awt_event_KeyEvent_VK_UP 38L
00189 #undef java_awt_event_KeyEvent_VK_RIGHT
00190 #define java_awt_event_KeyEvent_VK_RIGHT 39L
00191 #undef java_awt_event_KeyEvent_VK_DOWN
00192 #define java_awt_event_KeyEvent_VK_DOWN 40L
00193 #undef java_awt_event_KeyEvent_VK_COMMA
00194 #define java_awt_event_KeyEvent_VK_COMMA 44L
00195 #undef java_awt_event_KeyEvent_VK_PERIOD
00196 #define java_awt_event_KeyEvent_VK_PERIOD 46L
00197 #undef java_awt_event_KeyEvent_VK_MINUS
00198 #define java_awt_event_KeyEvent_VK_MINUS 0x2D
00199 #undef java_awt_event_KeyEvent_VK_SLASH
00200 #define java_awt_event_KeyEvent_VK_SLASH 47L
00201 #undef java_awt_event_KeyEvent_VK_0
00202 #define java_awt_event_KeyEvent_VK_0 48L
00203 #undef java_awt_event_KeyEvent_VK_1
00204 #define java_awt_event_KeyEvent_VK_1 49L
00205 #undef java_awt_event_KeyEvent_VK_2
00206 #define java_awt_event_KeyEvent_VK_2 50L
00207 #undef java_awt_event_KeyEvent_VK_3
00208 #define java_awt_event_KeyEvent_VK_3 51L
00209 #undef java_awt_event_KeyEvent_VK_4
00210 #define java_awt_event_KeyEvent_VK_4 52L
00211 #undef java_awt_event_KeyEvent_VK_5
00212 #define java_awt_event_KeyEvent_VK_5 53L
00213 #undef java_awt_event_KeyEvent_VK_6
00214 #define java_awt_event_KeyEvent_VK_6 54L
00215 #undef java_awt_event_KeyEvent_VK_7
00216 #define java_awt_event_KeyEvent_VK_7 55L
00217 #undef java_awt_event_KeyEvent_VK_8
00218 #define java_awt_event_KeyEvent_VK_8 56L
00219 #undef java_awt_event_KeyEvent_VK_9
00220 #define java_awt_event_KeyEvent_VK_9 57L
00221 #undef java_awt_event_KeyEvent_VK_SEMICOLON
00222 #define java_awt_event_KeyEvent_VK_SEMICOLON 59L
00223 #undef java_awt_event_KeyEvent_VK_EQUALS
00224 #define java_awt_event_KeyEvent_VK_EQUALS 61L
00225 #undef java_awt_event_KeyEvent_VK_A
00226 #define java_awt_event_KeyEvent_VK_A 65L
00227 #undef java_awt_event_KeyEvent_VK_B
00228 #define java_awt_event_KeyEvent_VK_B 66L
00229 #undef java_awt_event_KeyEvent_VK_C
00230 #define java_awt_event_KeyEvent_VK_C 67L
00231 #undef java_awt_event_KeyEvent_VK_D
00232 #define java_awt_event_KeyEvent_VK_D 68L
00233 #undef java_awt_event_KeyEvent_VK_E
00234 #define java_awt_event_KeyEvent_VK_E 69L
00235 #undef java_awt_event_KeyEvent_VK_F
00236 #define java_awt_event_KeyEvent_VK_F 70L
00237 #undef java_awt_event_KeyEvent_VK_G
00238 #define java_awt_event_KeyEvent_VK_G 71L
00239 #undef java_awt_event_KeyEvent_VK_H
00240 #define java_awt_event_KeyEvent_VK_H 72L
00241 #undef java_awt_event_KeyEvent_VK_I
00242 #define java_awt_event_KeyEvent_VK_I 73L
00243 #undef java_awt_event_KeyEvent_VK_J
00244 #define java_awt_event_KeyEvent_VK_J 74L
00245 #undef java_awt_event_KeyEvent_VK_K
00246 #define java_awt_event_KeyEvent_VK_K 75L
00247 #undef java_awt_event_KeyEvent_VK_L
00248 #define java_awt_event_KeyEvent_VK_L 76L
00249 #undef java_awt_event_KeyEvent_VK_M
00250 #define java_awt_event_KeyEvent_VK_M 77L
00251 #undef java_awt_event_KeyEvent_VK_N
00252 #define java_awt_event_KeyEvent_VK_N 78L
00253 #undef java_awt_event_KeyEvent_VK_O
00254 #define java_awt_event_KeyEvent_VK_O 79L
00255 #undef java_awt_event_KeyEvent_VK_P
00256 #define java_awt_event_KeyEvent_VK_P 80L
00257 #undef java_awt_event_KeyEvent_VK_Q
00258 #define java_awt_event_KeyEvent_VK_Q 81L
00259 #undef java_awt_event_KeyEvent_VK_R
00260 #define java_awt_event_KeyEvent_VK_R 82L
00261 #undef java_awt_event_KeyEvent_VK_S
00262 #define java_awt_event_KeyEvent_VK_S 83L
00263 #undef java_awt_event_KeyEvent_VK_T
00264 #define java_awt_event_KeyEvent_VK_T 84L
00265 #undef java_awt_event_KeyEvent_VK_U
00266 #define java_awt_event_KeyEvent_VK_U 85L
00267 #undef java_awt_event_KeyEvent_VK_V
00268 #define java_awt_event_KeyEvent_VK_V 86L
00269 #undef java_awt_event_KeyEvent_VK_W
00270 #define java_awt_event_KeyEvent_VK_W 87L
00271 #undef java_awt_event_KeyEvent_VK_X
00272 #define java_awt_event_KeyEvent_VK_X 88L
00273 #undef java_awt_event_KeyEvent_VK_Y
00274 #define java_awt_event_KeyEvent_VK_Y 89L
00275 #undef java_awt_event_KeyEvent_VK_Z
00276 #define java_awt_event_KeyEvent_VK_Z 90L
00277 #undef java_awt_event_KeyEvent_VK_OPEN_BRACKET
00278 #define java_awt_event_KeyEvent_VK_OPEN_BRACKET 91L
00279 #undef java_awt_event_KeyEvent_VK_BACK_SLASH
00280 #define java_awt_event_KeyEvent_VK_BACK_SLASH 92L
00281 #undef java_awt_event_KeyEvent_VK_CLOSE_BRACKET
00282 #define java_awt_event_KeyEvent_VK_CLOSE_BRACKET 93L
00283 #undef java_awt_event_KeyEvent_VK_NUMPAD0
00284 #define java_awt_event_KeyEvent_VK_NUMPAD0 96L
00285 #undef java_awt_event_KeyEvent_VK_NUMPAD1
00286 #define java_awt_event_KeyEvent_VK_NUMPAD1 97L
00287 #undef java_awt_event_KeyEvent_VK_NUMPAD2
00288 #define java_awt_event_KeyEvent_VK_NUMPAD2 98L
00289 #undef java_awt_event_KeyEvent_VK_NUMPAD3
00290 #define java_awt_event_KeyEvent_VK_NUMPAD3 99L
00291 #undef java_awt_event_KeyEvent_VK_NUMPAD4
00292 #define java_awt_event_KeyEvent_VK_NUMPAD4 100L
00293 #undef java_awt_event_KeyEvent_VK_NUMPAD5
00294 #define java_awt_event_KeyEvent_VK_NUMPAD5 101L
00295 #undef java_awt_event_KeyEvent_VK_NUMPAD6
00296 #define java_awt_event_KeyEvent_VK_NUMPAD6 102L
00297 #undef java_awt_event_KeyEvent_VK_NUMPAD7
00298 #define java_awt_event_KeyEvent_VK_NUMPAD7 103L
00299 #undef java_awt_event_KeyEvent_VK_NUMPAD8
00300 #define java_awt_event_KeyEvent_VK_NUMPAD8 104L
00301 #undef java_awt_event_KeyEvent_VK_NUMPAD9
00302 #define java_awt_event_KeyEvent_VK_NUMPAD9 105L
00303 #undef java_awt_event_KeyEvent_VK_MULTIPLY
00304 #define java_awt_event_KeyEvent_VK_MULTIPLY 106L
00305 #undef java_awt_event_KeyEvent_VK_ADD
00306 #define java_awt_event_KeyEvent_VK_ADD 107L
00307 #undef java_awt_event_KeyEvent_VK_SEPARATER
00308 #define java_awt_event_KeyEvent_VK_SEPARATER 108L
00309 #undef java_awt_event_KeyEvent_VK_SUBTRACT
00310 #define java_awt_event_KeyEvent_VK_SUBTRACT 109L
00311 #undef java_awt_event_KeyEvent_VK_DECIMAL
00312 #define java_awt_event_KeyEvent_VK_DECIMAL 110L
00313 #undef java_awt_event_KeyEvent_VK_DIVIDE
00314 #define java_awt_event_KeyEvent_VK_DIVIDE 111L
00315 #undef java_awt_event_KeyEvent_VK_F1
00316 #define java_awt_event_KeyEvent_VK_F1 112L
00317 #undef java_awt_event_KeyEvent_VK_F2
00318 #define java_awt_event_KeyEvent_VK_F2 113L
00319 #undef java_awt_event_KeyEvent_VK_F3
00320 #define java_awt_event_KeyEvent_VK_F3 114L
00321 #undef java_awt_event_KeyEvent_VK_F4
00322 #define java_awt_event_KeyEvent_VK_F4 115L
00323 #undef java_awt_event_KeyEvent_VK_F5
00324 #define java_awt_event_KeyEvent_VK_F5 116L
00325 #undef java_awt_event_KeyEvent_VK_F6
00326 #define java_awt_event_KeyEvent_VK_F6 117L
00327 #undef java_awt_event_KeyEvent_VK_F7
00328 #define java_awt_event_KeyEvent_VK_F7 118L
00329 #undef java_awt_event_KeyEvent_VK_F8
00330 #define java_awt_event_KeyEvent_VK_F8 119L
00331 #undef java_awt_event_KeyEvent_VK_F9
00332 #define java_awt_event_KeyEvent_VK_F9 120L
00333 #undef java_awt_event_KeyEvent_VK_F10
00334 #define java_awt_event_KeyEvent_VK_F10 121L
00335 #undef java_awt_event_KeyEvent_VK_F11
00336 #define java_awt_event_KeyEvent_VK_F11 122L
00337 #undef java_awt_event_KeyEvent_VK_F12
00338 #define java_awt_event_KeyEvent_VK_F12 123L
00339 #undef java_awt_event_KeyEvent_VK_DELETE
00340 #define java_awt_event_KeyEvent_VK_DELETE 127L
00341 #undef java_awt_event_KeyEvent_VK_NUM_LOCK
00342 #define java_awt_event_KeyEvent_VK_NUM_LOCK 144L
00343 #undef java_awt_event_KeyEvent_VK_SCROLL_LOCK
00344 #define java_awt_event_KeyEvent_VK_SCROLL_LOCK 145L
00345 #undef java_awt_event_KeyEvent_VK_PRINTSCREEN
00346 #define java_awt_event_KeyEvent_VK_PRINTSCREEN 154L
00347 #undef java_awt_event_KeyEvent_VK_INSERT
00348 #define java_awt_event_KeyEvent_VK_INSERT 155L
00349 #undef java_awt_event_KeyEvent_VK_HELP
00350 #define java_awt_event_KeyEvent_VK_HELP 156L
00351 #undef java_awt_event_KeyEvent_VK_META
00352 #define java_awt_event_KeyEvent_VK_META 157L
00353 #undef java_awt_event_KeyEvent_VK_BACK_QUOTE
00354 #define java_awt_event_KeyEvent_VK_BACK_QUOTE 192L
00355 #undef java_awt_event_KeyEvent_VK_QUOTE
00356 #define java_awt_event_KeyEvent_VK_QUOTE 222L
00357 #undef java_awt_event_KeyEvent_VK_FINAL
00358 #define java_awt_event_KeyEvent_VK_FINAL 24L
00359 #undef java_awt_event_KeyEvent_VK_CONVERT
00360 #define java_awt_event_KeyEvent_VK_CONVERT 28L
00361 #undef java_awt_event_KeyEvent_VK_NONCONVERT
00362 #define java_awt_event_KeyEvent_VK_NONCONVERT 29L
00363 #undef java_awt_event_KeyEvent_VK_ACCEPT
00364 #define java_awt_event_KeyEvent_VK_ACCEPT 30L
00365 #undef java_awt_event_KeyEvent_VK_MODECHANGE
00366 #define java_awt_event_KeyEvent_VK_MODECHANGE 31L
00367 #undef java_awt_event_KeyEvent_VK_KANA
00368 #define java_awt_event_KeyEvent_VK_KANA 21L
00369 #undef java_awt_event_KeyEvent_VK_KANJI
00370 #define java_awt_event_KeyEvent_VK_KANJI 25L
00371 #undef java_awt_event_KeyEvent_VK_UNDEFINED
00372 #define java_awt_event_KeyEvent_VK_UNDEFINED 0L
00373 #undef java_awt_event_KeyEvent_CHAR_UNDEFINED
00374 #define java_awt_event_KeyEvent_CHAR_UNDEFINED 0L
00375 
00376 #undef java_awt_event_KeyEvent_VK_CUT
00377 #define java_awt_event_KeyEvent_VK_CUT                      0xFFD1
00378 #undef java_awt_event_KeyEvent_VK_COPY
00379 #define java_awt_event_KeyEvent_VK_COPY                     0xFFCD
00380 #undef java_awt_event_KeyEvent_VK_PASTE
00381 #define java_awt_event_KeyEvent_VK_PASTE                    0xFFCF
00382 #undef java_awt_event_KeyEvent_VK_UNDO
00383 #define java_awt_event_KeyEvent_VK_UNDO                     0xFFCB
00384 #undef java_awt_event_KeyEvent_VK_AGAIN
00385 #define java_awt_event_KeyEvent_VK_AGAIN                    0xFFC9
00386 #undef java_awt_event_KeyEvent_VK_FIND
00387 #define java_awt_event_KeyEvent_VK_FIND                     0xFFD0
00388 #undef java_awt_event_KeyEvent_VK_PROPS
00389 #define java_awt_event_KeyEvent_VK_PROPS                    0xFFCA
00390 #undef java_awt_event_KeyEvent_VK_STOP
00391 #define java_awt_event_KeyEvent_VK_STOP                     0xFFC8
00392 
00393 #undef java_awt_event_KeyEvent_VK_AT
00394 #define java_awt_event_KeyEvent_VK_AT                       0x0200
00395 
00396 #undef java_awt_event_KeyEvent_VK_DEAD_GRAVE
00397 #define java_awt_event_KeyEvent_VK_DEAD_GRAVE 128L
00398 #undef java_awt_event_KeyEvent_VK_IM_VK_DEAD_ACUTE
00399 #define java_awt_event_KeyEvent_VK_IM_VK_DEAD_ACUTE 129L
00400 #undef java_awt_event_KeyEvent_VK_IM_VK_DEAD_CIRCUMFLEX
00401 #define java_awt_event_KeyEvent_VK_IM_VK_DEAD_CIRCUMFLEX 130L
00402 #undef java_awt_event_KeyEvent_VK_IM_VK_DEAD_TILDE
00403 #define java_awt_event_KeyEvent_VK_IM_VK_DEAD_TILDE 131L
00404 #undef java_awt_event_KeyEvent_VK_IM_VK_DEAD_MACRON
00405 #define java_awt_event_KeyEvent_VK_IM_VK_DEAD_MACRON 132L
00406 #undef java_awt_event_KeyEvent_VK_IM_VK_DEAD_BREVE
00407 #define java_awt_event_KeyEvent_VK_IM_VK_DEAD_BREVE 133L
00408 #undef java_awt_event_KeyEvent_VK_IM_VK_DEAD_ABOVEDOT
00409 #define java_awt_event_KeyEvent_VK_IM_VK_DEAD_ABOVEDOT 134L
00410 #undef java_awt_event_KeyEvent_VK_IM_VK_DEAD_DIAERESIS
00411 #define java_awt_event_KeyEvent_VK_IM_VK_DEAD_DIAERESIS 135L
00412 #undef java_awt_event_KeyEvent_VK_IM_VK_DEAD_ABOVERING
00413 #define java_awt_event_KeyEvent_VK_IM_VK_DEAD_ABOVERING 136L
00414 #undef java_awt_event_KeyEvent_VK_IM_VK_DEAD_DOUBLEACUTE
00415 #define java_awt_event_KeyEvent_VK_IM_VK_DEAD_DOUBLEACUTE 137L
00416 #undef java_awt_event_KeyEvent_VK_IM_VK_DEAD_CARON
00417 #define java_awt_event_KeyEvent_VK_IM_VK_DEAD_CARON 138L
00418 #undef java_awt_event_KeyEvent_VK_IM_VK_DEAD_CEDILLA
00419 #define java_awt_event_KeyEvent_VK_IM_VK_DEAD_CEDILLA 139L
00420 #undef java_awt_event_KeyEvent_VK_IM_VK_DEAD_OGONEK
00421 #define java_awt_event_KeyEvent_VK_IM_VK_DEAD_OGONEK 140L
00422 #undef java_awt_event_KeyEvent_VK_IM_VK_DEAD_IOTA
00423 #define java_awt_event_KeyEvent_VK_IM_VK_DEAD_IOTA 141L
00424 #undef java_awt_event_KeyEvent_VK_IM_VK_DEAD_VOICED_SOUND
00425 #define java_awt_event_KeyEvent_VK_IM_VK_DEAD_VOICED_SOUND 142L
00426 #undef java_awt_event_KeyEvent_VK_IM_VK_DEAD_SEMIVOICED_SOUND
00427 #define java_awt_event_KeyEvent_VK_IM_VK_DEAD_SEMIVOICED_SOUND 143L
00428 
00429 #undef java_awt_event_InputEvent_SHIFT_MASK
00430 #define java_awt_event_InputEvent_SHIFT_MASK 1L
00431 #undef java_awt_event_InputEvent_CTRL_MASK
00432 #define java_awt_event_InputEvent_CTRL_MASK 2L
00433 #undef java_awt_event_InputEvent_META_MASK
00434 #define java_awt_event_InputEvent_META_MASK 4L
00435 #undef java_awt_event_InputEvent_ALT_MASK
00436 #define java_awt_event_InputEvent_ALT_MASK 8L
00437 #undef java_awt_event_InputEvent_BUTTON1_MASK
00438 #define java_awt_event_InputEvent_BUTTON1_MASK 16L
00439 #undef java_awt_event_InputEvent_BUTTON2_MASK
00440 #define java_awt_event_InputEvent_BUTTON2_MASK 8L
00441 #undef java_awt_event_InputEvent_BUTTON3_MASK
00442 #define java_awt_event_InputEvent_BUTTON3_MASK 4L
00443 
00444 typedef       enum {
00445     FALSE = 0,
00446     TRUE = 1
00447 } bool_t;
00448 
00449 typedef unsigned short unicode;
00450 
00451 #if kana_table
00452 static KeymapEntry2 kana_normal_keymapTable[] = {
00453     { java_awt_event_KeyEvent_VK_1, XK_kana_NU, XK_1, 0xff87, TRUE, 0 },
00454     { java_awt_event_KeyEvent_VK_2, XK_kana_FU, XK_2, 0xff8c, TRUE, 0 },
00455     { java_awt_event_KeyEvent_VK_3, XK_kana_A, XK_3, 0xff71, TRUE, 0 },
00456     { java_awt_event_KeyEvent_VK_4, XK_kana_U, XK_4, 0xff73, TRUE, 0 },
00457     { java_awt_event_KeyEvent_VK_5, XK_kana_E, XK_5, 0xff74, TRUE, 0 },
00458     { java_awt_event_KeyEvent_VK_6, XK_kana_O, XK_6, 0xff75, TRUE, 0 },
00459     { java_awt_event_KeyEvent_VK_7, XK_kana_YA, XK_7, 0xff94, TRUE, 0 },
00460     { java_awt_event_KeyEvent_VK_8, XK_kana_YU, XK_8, 0xff95, TRUE, 0 },
00461     { java_awt_event_KeyEvent_VK_9, XK_kana_YO, XK_9, 0xff96, TRUE, 0 },
00462     { java_awt_event_KeyEvent_VK_0, XK_kana_WA, XK_0, 0xff9c, TRUE, 0 },
00463     { '-',                      XK_kana_HO, XK_minus, 0xff8e, TRUE, 0 },
00464     { '~',                      XK_kana_HE, XK_asciicircum, 0xff8d, TRUE, 0 },
00465     { java_awt_event_KeyEvent_VK_Q, XK_kana_TA, XK_q, 0xff80, TRUE, 0 },
00466     { java_awt_event_KeyEvent_VK_W, XK_kana_TE, XK_w, 0xff83, TRUE, 0 },
00467     { java_awt_event_KeyEvent_VK_E, XK_kana_I, XK_e, 0xff72, TRUE, 0 },
00468     { java_awt_event_KeyEvent_VK_R, XK_kana_SU, XK_r, 0xff7d, TRUE, 0 },
00469     { java_awt_event_KeyEvent_VK_T, XK_kana_KA, XK_t, 0xff76, TRUE, 0 },
00470     { java_awt_event_KeyEvent_VK_Y, XK_kana_N, XK_y, 0xff9d, TRUE, 0 },
00471     { java_awt_event_KeyEvent_VK_U, XK_kana_NA, XK_u, 0xff85, TRUE, 0 },
00472     { java_awt_event_KeyEvent_VK_I, XK_kana_NI, XK_i, 0xff86, TRUE, 0 },
00473     { java_awt_event_KeyEvent_VK_O, XK_kana_RA, XK_o, 0xff97, TRUE, 0 },
00474     { java_awt_event_KeyEvent_VK_P, XK_kana_SE, XK_p, 0xff7e, TRUE, 0 },
00475     { java_awt_event_KeyEvent_VK_AT, XK_voicedsound, XK_at, 0xff9e, TRUE, 0 },
00476     { java_awt_event_KeyEvent_VK_OPEN_BRACKET, XK_semivoicedsound, XK_bracketleft, 0xff9f, TRUE, 0 },
00477     { java_awt_event_KeyEvent_VK_A, XK_kana_CHI, XK_a, 0xff81, TRUE, 0 },
00478     { java_awt_event_KeyEvent_VK_S, XK_kana_TO, XK_s, 0xff84, TRUE, 0 },
00479     { java_awt_event_KeyEvent_VK_D, XK_kana_SHI, XK_d, 0xff7c, TRUE, 0 },
00480     { java_awt_event_KeyEvent_VK_F, XK_kana_HA, XK_f, 0xff8a, TRUE, 0 },
00481     { java_awt_event_KeyEvent_VK_G, XK_kana_KI, XK_g, 0xff77, TRUE, 0 },
00482     { java_awt_event_KeyEvent_VK_H, XK_kana_KU, XK_h, 0xff78, TRUE, 0 },
00483     { java_awt_event_KeyEvent_VK_J, XK_kana_MA, XK_j, 0xff8f, TRUE, 0 },
00484     { java_awt_event_KeyEvent_VK_K, XK_kana_NO, XK_k, 0xff89, TRUE, 0 },
00485     { java_awt_event_KeyEvent_VK_L, XK_kana_RI, XK_l, 0xff98, TRUE, 0 },
00486     { java_awt_event_KeyEvent_VK_SEMICOLON, XK_kana_RE, XK_semicolon, 0xff9a, TRUE, 0 },
00487     { ':',                             XK_kana_KE, XK_colon, 0xff79, TRUE, 0 },
00488     { java_awt_event_KeyEvent_VK_CLOSE_BRACKET, XK_kana_MU, XK_bracketright, 0xff91, TRUE, 0 },
00489     { java_awt_event_KeyEvent_VK_Z, XK_kana_TSU, XK_z, 0xff82, TRUE, 0 },
00490     { java_awt_event_KeyEvent_VK_X, XK_kana_SA, XK_x, 0xff7b, TRUE, 0 },
00491     { java_awt_event_KeyEvent_VK_C, XK_kana_SO, XK_c, 0xff7f, TRUE, 0 },
00492     { java_awt_event_KeyEvent_VK_V, XK_kana_HI, XK_v, 0xff8b, TRUE, 0 },
00493     { java_awt_event_KeyEvent_VK_B, XK_kana_KO, XK_b, 0xff7a, TRUE, 0 },
00494     { java_awt_event_KeyEvent_VK_N, XK_kana_MI, XK_n, 0xff90, TRUE, 0 },
00495     { java_awt_event_KeyEvent_VK_M, XK_kana_MO, XK_m, 0xff93, TRUE, 0 },
00496     { java_awt_event_KeyEvent_VK_COMMA, XK_kana_NE, XK_comma, 0xff88, TRUE, 0 },
00497     { java_awt_event_KeyEvent_VK_PERIOD, XK_kana_RU, XK_period, 0xff99, TRUE , 0},
00498     { java_awt_event_KeyEvent_VK_SLASH, XK_kana_ME, XK_slash, 0xff92, TRUE, 0 },
00499     /* hack to japanese keyboard */
00500     /* backslash is duplicate for RO and prolongedsound */
00501     { java_awt_event_KeyEvent_VK_BACK_SLASH, XK_kana_RO, XK_underscore, 0xff9b, TRUE, 0 },
00502     { java_awt_event_KeyEvent_VK_BACK_SLASH, XK_prolongedsound, XK_bar, 0xff70, TRUE, 0 },
00503     { 0, 0, 0 }
00504 };
00505 
00506 static KeymapEntry2 kana_shift_keymapTable[] = {
00507     { java_awt_event_KeyEvent_VK_3, XK_kana_a, XK_numbersign, 0xff67, TRUE, 0 },
00508     { java_awt_event_KeyEvent_VK_4, XK_kana_u, XK_dollar, 0xff69, TRUE, 0 },
00509     { java_awt_event_KeyEvent_VK_5, XK_kana_e, XK_percent, 0xff6a, TRUE, 0 },
00510     { java_awt_event_KeyEvent_VK_6, XK_kana_o, XK_ampersand, 0xff6b, TRUE, 0 },
00511     { java_awt_event_KeyEvent_VK_7, XK_kana_ya, XK_apostrophe, 0xff6c, TRUE, 0 },
00512     { java_awt_event_KeyEvent_VK_8, XK_kana_yu, XK_parenleft, 0xff6d, TRUE, 0 },
00513     { java_awt_event_KeyEvent_VK_9, XK_kana_yo, XK_parenright, 0xff6e, TRUE, 0 },
00514     { java_awt_event_KeyEvent_VK_0, XK_kana_WO, XK_asciitilde, 0xff66, TRUE, 0 },
00515     { java_awt_event_KeyEvent_VK_E, XK_kana_i, XK_E, 0xff68, TRUE, 0 },
00516     { java_awt_event_KeyEvent_VK_OPEN_BRACKET, XK_kana_openingbracket, XK_braceleft, 0xff62, TRUE, 0 },
00517     { java_awt_event_KeyEvent_VK_CLOSE_BRACKET, XK_kana_closingbracket, XK_braceright, 0xff63, TRUE, 0 },
00518     { java_awt_event_KeyEvent_VK_Z, XK_kana_tsu, XK_Z, 0xff6f, TRUE, 0 },
00519     /* XK_less does not return correct keycode on VineLinux 1.1 */
00520     { java_awt_event_KeyEvent_VK_COMMA, XK_kana_comma, XK_comma, 0xff64, TRUE, 0 },
00521     { java_awt_event_KeyEvent_VK_PERIOD, XK_kana_fullstop, XK_greater, 0xff61, TRUE,0 },
00522     { java_awt_event_KeyEvent_VK_SLASH, XK_kana_conjunctive, XK_question, 0xff65, TRUE,0 },
00523     { 0, 0, 0 }
00524 };
00525 #endif
00526 
00527 static KeymapEntry keymapTable[] = {
00528     { java_awt_event_KeyEvent_VK_A, XK_a, TRUE },
00529     { java_awt_event_KeyEvent_VK_B, XK_b, TRUE },
00530     { java_awt_event_KeyEvent_VK_C, XK_c, TRUE },
00531     { java_awt_event_KeyEvent_VK_D, XK_d, TRUE },
00532     { java_awt_event_KeyEvent_VK_E, XK_e, TRUE },
00533     { java_awt_event_KeyEvent_VK_F, XK_f, TRUE },
00534     { java_awt_event_KeyEvent_VK_G, XK_g, TRUE },
00535     { java_awt_event_KeyEvent_VK_H, XK_h, TRUE },
00536     { java_awt_event_KeyEvent_VK_I, XK_i, TRUE },
00537     { java_awt_event_KeyEvent_VK_J, XK_j, TRUE },
00538     { java_awt_event_KeyEvent_VK_K, XK_k, TRUE },
00539     { java_awt_event_KeyEvent_VK_L, XK_l, TRUE },
00540     { java_awt_event_KeyEvent_VK_M, XK_m, TRUE },
00541     { java_awt_event_KeyEvent_VK_N, XK_n, TRUE },
00542     { java_awt_event_KeyEvent_VK_O, XK_o, TRUE },
00543     { java_awt_event_KeyEvent_VK_P, XK_p, TRUE },
00544     { java_awt_event_KeyEvent_VK_Q, XK_q, TRUE },
00545     { java_awt_event_KeyEvent_VK_R, XK_r, TRUE },
00546     { java_awt_event_KeyEvent_VK_S, XK_s, TRUE },
00547     { java_awt_event_KeyEvent_VK_T, XK_t, TRUE },
00548     { java_awt_event_KeyEvent_VK_U, XK_u, TRUE },
00549     { java_awt_event_KeyEvent_VK_V, XK_v, TRUE },
00550     { java_awt_event_KeyEvent_VK_W, XK_w, TRUE },
00551     { java_awt_event_KeyEvent_VK_X, XK_x, TRUE },
00552     { java_awt_event_KeyEvent_VK_Y, XK_y, TRUE },
00553     { java_awt_event_KeyEvent_VK_Z, XK_z, TRUE },
00554 
00555     { java_awt_event_KeyEvent_VK_ENTER, XK_Return, TRUE },
00556     { java_awt_event_KeyEvent_VK_ENTER, XK_KP_Enter, TRUE },
00557     { java_awt_event_KeyEvent_VK_ENTER, XK_Linefeed, TRUE },
00558 
00559     { java_awt_event_KeyEvent_VK_BACK_SPACE, XK_BackSpace, TRUE },
00560     { java_awt_event_KeyEvent_VK_TAB, XK_Tab, TRUE },
00561     { java_awt_event_KeyEvent_VK_TAB, XK_ISO_Left_Tab, TRUE },
00562     { java_awt_event_KeyEvent_VK_CANCEL, XK_Cancel, FALSE },
00563     { java_awt_event_KeyEvent_VK_CLEAR, XK_Clear, FALSE },
00564     { java_awt_event_KeyEvent_VK_SHIFT, XK_Shift_L, FALSE },
00565     { java_awt_event_KeyEvent_VK_SHIFT, XK_Shift_R, FALSE }, 
00566     { java_awt_event_KeyEvent_VK_CONTROL, XK_Control_L, FALSE },
00567     { java_awt_event_KeyEvent_VK_CONTROL, XK_Control_R, FALSE }, 
00568     { java_awt_event_KeyEvent_VK_ALT, XK_Alt_L, FALSE },
00569     { java_awt_event_KeyEvent_VK_ALT, XK_Alt_R, FALSE },
00570     { java_awt_event_KeyEvent_VK_META, XK_Meta_L, FALSE },
00571     { java_awt_event_KeyEvent_VK_META, XK_Meta_R, FALSE }, 
00572     { java_awt_event_KeyEvent_VK_PAUSE, XK_Pause, FALSE },
00573     { java_awt_event_KeyEvent_VK_CAPS_LOCK, XK_Caps_Lock, FALSE },
00574     { java_awt_event_KeyEvent_VK_ESCAPE, XK_Escape, TRUE },
00575     { java_awt_event_KeyEvent_VK_SPACE, XK_space, TRUE },
00576 
00577     { java_awt_event_KeyEvent_VK_PAGE_UP, XK_Page_Up, FALSE },
00578     { java_awt_event_KeyEvent_VK_PAGE_UP, XK_R9, FALSE },
00579     { java_awt_event_KeyEvent_VK_PAGE_UP, XK_Prior, FALSE },
00580     { java_awt_event_KeyEvent_VK_PAGE_UP, XK_F29, FALSE },
00581     { java_awt_event_KeyEvent_VK_PAGE_DOWN, XK_Page_Down, FALSE },
00582     { java_awt_event_KeyEvent_VK_PAGE_DOWN, XK_R15, FALSE },
00583     { java_awt_event_KeyEvent_VK_PAGE_DOWN, XK_Next, FALSE },
00584     { java_awt_event_KeyEvent_VK_PAGE_DOWN, XK_F35, FALSE },
00585     { java_awt_event_KeyEvent_VK_END, XK_End, FALSE },
00586     { java_awt_event_KeyEvent_VK_END, XK_R13, FALSE },
00587     { java_awt_event_KeyEvent_VK_HOME, XK_Home, FALSE },
00588     { java_awt_event_KeyEvent_VK_HOME, XK_R7, FALSE },
00589     { java_awt_event_KeyEvent_VK_HOME, XK_F27, FALSE },
00590 
00591     { java_awt_event_KeyEvent_VK_LEFT, XK_Left, FALSE },
00592     { java_awt_event_KeyEvent_VK_UP, XK_Up, FALSE },
00593     { java_awt_event_KeyEvent_VK_RIGHT, XK_Right, FALSE },
00594     { java_awt_event_KeyEvent_VK_DOWN, XK_Down, FALSE },
00595     { java_awt_event_KeyEvent_VK_INSERT, XK_Insert, FALSE },
00596     { java_awt_event_KeyEvent_VK_HELP, XK_Help, FALSE },
00597 
00598     { java_awt_event_KeyEvent_VK_0, XK_0, TRUE },
00599     { java_awt_event_KeyEvent_VK_1, XK_1, TRUE },
00600     { java_awt_event_KeyEvent_VK_2, XK_2, TRUE },
00601     { java_awt_event_KeyEvent_VK_3, XK_3, TRUE },
00602     { java_awt_event_KeyEvent_VK_4, XK_4, TRUE },
00603     { java_awt_event_KeyEvent_VK_5, XK_5, TRUE },
00604     { java_awt_event_KeyEvent_VK_6, XK_6, TRUE },
00605     { java_awt_event_KeyEvent_VK_7, XK_7, TRUE },
00606     { java_awt_event_KeyEvent_VK_8, XK_8, TRUE },
00607     { java_awt_event_KeyEvent_VK_9, XK_9, TRUE },
00608 
00609     { java_awt_event_KeyEvent_VK_EQUALS, XK_equal, TRUE },
00610     { java_awt_event_KeyEvent_VK_BACK_SLASH, XK_backslash, TRUE },
00611     { java_awt_event_KeyEvent_VK_BACK_QUOTE, XK_grave, TRUE },
00612     { java_awt_event_KeyEvent_VK_OPEN_BRACKET, XK_bracketleft, TRUE },
00613     { java_awt_event_KeyEvent_VK_CLOSE_BRACKET, XK_bracketright, TRUE },
00614     { java_awt_event_KeyEvent_VK_SEMICOLON, XK_semicolon, TRUE },
00615     { java_awt_event_KeyEvent_VK_QUOTE, XK_apostrophe, TRUE },
00616     { java_awt_event_KeyEvent_VK_MINUS, XK_minus, TRUE },
00617     { java_awt_event_KeyEvent_VK_COMMA, XK_comma, TRUE },
00618     { java_awt_event_KeyEvent_VK_PERIOD, XK_period, TRUE },
00619     { java_awt_event_KeyEvent_VK_SLASH, XK_slash, TRUE },
00620 
00621     { java_awt_event_KeyEvent_VK_NUMPAD0, XK_KP_0, TRUE },
00622     { java_awt_event_KeyEvent_VK_NUMPAD1, XK_KP_1, TRUE },
00623     { java_awt_event_KeyEvent_VK_NUMPAD2, XK_KP_2, TRUE },
00624     { java_awt_event_KeyEvent_VK_NUMPAD3, XK_KP_3, TRUE },
00625     { java_awt_event_KeyEvent_VK_NUMPAD4, XK_KP_4, TRUE },
00626     { java_awt_event_KeyEvent_VK_NUMPAD5, XK_KP_5, TRUE },
00627     { java_awt_event_KeyEvent_VK_NUMPAD6, XK_KP_6, TRUE },
00628     { java_awt_event_KeyEvent_VK_NUMPAD7, XK_KP_7, TRUE },
00629     { java_awt_event_KeyEvent_VK_NUMPAD8, XK_KP_8, TRUE },
00630     { java_awt_event_KeyEvent_VK_NUMPAD9, XK_KP_9, TRUE },
00631     { java_awt_event_KeyEvent_VK_MULTIPLY, XK_KP_Multiply, TRUE },
00632     { java_awt_event_KeyEvent_VK_ADD, XK_KP_Add, TRUE },
00633     { java_awt_event_KeyEvent_VK_SUBTRACT, XK_KP_Subtract, TRUE },
00634     { java_awt_event_KeyEvent_VK_DECIMAL, XK_KP_Decimal, TRUE },
00635     { java_awt_event_KeyEvent_VK_DIVIDE, XK_KP_Divide, TRUE },
00636     { java_awt_event_KeyEvent_VK_EQUALS, XK_KP_Equal, TRUE },
00637     { java_awt_event_KeyEvent_VK_INSERT, XK_KP_Insert, FALSE },
00638     { java_awt_event_KeyEvent_VK_ENTER, XK_KP_Enter, FALSE },
00639 
00640     { java_awt_event_KeyEvent_VK_F1, XK_F1, FALSE },
00641     { java_awt_event_KeyEvent_VK_F2, XK_F2, FALSE },
00642     { java_awt_event_KeyEvent_VK_F3, XK_F3, FALSE },
00643     { java_awt_event_KeyEvent_VK_F4, XK_F4, FALSE },
00644     { java_awt_event_KeyEvent_VK_F5, XK_F5, FALSE },
00645     { java_awt_event_KeyEvent_VK_F6, XK_F6, FALSE },
00646     { java_awt_event_KeyEvent_VK_F7, XK_F7, FALSE },
00647     { java_awt_event_KeyEvent_VK_F8, XK_F8, FALSE },
00648     { java_awt_event_KeyEvent_VK_F9, XK_F9, FALSE },
00649     { java_awt_event_KeyEvent_VK_F10, XK_F10, FALSE },
00650     /* next two entries for for 4173902 */
00651 #if defined (sun)
00652     { java_awt_event_KeyEvent_VK_F11, SunXK_F36, FALSE },
00653     { java_awt_event_KeyEvent_VK_F12, SunXK_F37, FALSE },
00654 #else
00655     { java_awt_event_KeyEvent_VK_F11, XK_F11, FALSE },
00656     { java_awt_event_KeyEvent_VK_F12, XK_F12, FALSE },
00657 #endif
00658     { java_awt_event_KeyEvent_VK_DELETE, XK_Delete, TRUE },
00659     { java_awt_event_KeyEvent_VK_DELETE, XK_KP_Delete, TRUE },
00660 
00661     { java_awt_event_KeyEvent_VK_NUM_LOCK, XK_Num_Lock, FALSE },
00662     { java_awt_event_KeyEvent_VK_SCROLL_LOCK, XK_Scroll_Lock, FALSE },
00663     { java_awt_event_KeyEvent_VK_PRINTSCREEN, XK_Print, FALSE },
00664 
00665     { java_awt_event_KeyEvent_VK_ACCEPT, XK_Execute, FALSE },
00666 
00667     { java_awt_event_KeyEvent_VK_KANJI, XK_Henkan_Mode, FALSE },
00668     { java_awt_event_KeyEvent_VK_CONVERT, XK_Kanji, FALSE },
00669 
00670     { java_awt_event_KeyEvent_VK_NONCONVERT, XK_Muhenkan, FALSE },
00671 
00672     { java_awt_event_KeyEvent_VK_KANA, XK_Katakana, FALSE },
00673     { java_awt_event_KeyEvent_VK_KANA, XK_kana_switch, FALSE },
00674 
00675     { java_awt_event_KeyEvent_VK_CUT, XK_F20, FALSE },
00676     { java_awt_event_KeyEvent_VK_COPY, XK_F16, FALSE },
00677     { java_awt_event_KeyEvent_VK_PASTE, XK_F18, FALSE },
00678     { java_awt_event_KeyEvent_VK_UNDO, XK_F14, FALSE },
00679     { java_awt_event_KeyEvent_VK_FIND, XK_F19, FALSE },
00680     { java_awt_event_KeyEvent_VK_PROPS, XK_F13, FALSE },
00681 
00682     /* For supporting DEAD KEYS */
00683     { java_awt_event_KeyEvent_VK_DEAD_GRAVE, XK_dead_grave, FALSE },
00684     { java_awt_event_KeyEvent_VK_IM_VK_DEAD_ACUTE, XK_dead_acute, FALSE },
00685     { java_awt_event_KeyEvent_VK_IM_VK_DEAD_CIRCUMFLEX, XK_dead_circumflex, FALSE },
00686     { java_awt_event_KeyEvent_VK_IM_VK_DEAD_TILDE, XK_dead_tilde, FALSE },
00687     { java_awt_event_KeyEvent_VK_IM_VK_DEAD_MACRON, XK_dead_macron, FALSE },
00688     { java_awt_event_KeyEvent_VK_IM_VK_DEAD_BREVE, XK_dead_breve, FALSE },
00689     { java_awt_event_KeyEvent_VK_IM_VK_DEAD_ABOVEDOT, XK_dead_abovedot, FALSE },
00690     { java_awt_event_KeyEvent_VK_IM_VK_DEAD_DIAERESIS, XK_dead_diaeresis, FALSE },
00691     { java_awt_event_KeyEvent_VK_IM_VK_DEAD_ABOVERING, XK_dead_abovering, FALSE },
00692     { java_awt_event_KeyEvent_VK_IM_VK_DEAD_DOUBLEACUTE, XK_dead_doubleacute, FALSE },
00693     { java_awt_event_KeyEvent_VK_IM_VK_DEAD_CARON, XK_dead_caron, FALSE },
00694     { java_awt_event_KeyEvent_VK_IM_VK_DEAD_CEDILLA, XK_dead_cedilla, FALSE },
00695     { java_awt_event_KeyEvent_VK_IM_VK_DEAD_OGONEK, XK_dead_ogonek, FALSE },
00696     { java_awt_event_KeyEvent_VK_IM_VK_DEAD_IOTA, XK_dead_iota, FALSE },
00697     { java_awt_event_KeyEvent_VK_IM_VK_DEAD_VOICED_SOUND, XK_dead_voiced_sound, FALSE },
00698     { java_awt_event_KeyEvent_VK_IM_VK_DEAD_SEMIVOICED_SOUND, XK_dead_semivoiced_sound, FALSE },
00699 
00700     { 0, 0, 0 }
00701 };
00702 
00703 static KeySym getX11KeySym(long awtKey) 
00704 {
00705     int i;
00706     for (i = 0; keymapTable[i].awtKey != 0; i++) {
00707         if (keymapTable[i].awtKey == awtKey) {
00708          /* stop checking printable or not, otherwise
00709             arrow keys won't work
00710            if (keymapTable[i].printable == FALSE) return 0;
00711            */
00712          return keymapTable[i].x11Key;
00713         }
00714     }
00715     return 0;
00716 }
00717 
00718 static long getAWTKeyCode(long keysym) 
00719 {
00720     int i;
00721     for (i = 0; keymapTable[i].awtKey != 0; i++) {
00722         if (keymapTable[i].x11Key == keysym) {
00723          return keymapTable[i].awtKey;
00724         }
00725     }
00726     return 0;
00727 }
00728 
00729 /* for kana */
00730 #if kana_table
00731 static void getAWTKeyCode2(long keysym, int *keycode, int *keychar) 
00732 {
00733     int i;
00734          *keycode = 0;
00735          *keychar = 0;
00736 
00737     for (i = 0; kana_normal_keymapTable[i].awtKey != 0; i++) {
00738         if (kana_normal_keymapTable[i].x11Key == keysym) {
00739          *keycode = kana_normal_keymapTable[i].awtKey;
00740          *keychar = kana_normal_keymapTable[i].keychar;
00741          return;
00742         }
00743     }
00744     for (i = 0; kana_shift_keymapTable[i].awtKey != 0; i++) {
00745         if (kana_shift_keymapTable[i].x11Key == keysym) {
00746          *keycode = kana_shift_keymapTable[i].awtKey;
00747          *keychar = kana_shift_keymapTable[i].keychar;
00748          return;
00749         }
00750     }
00751     return;
00752 }
00753 #endif
00754 
00755 static void
00756 set_mod_mask(int modnum, int *mask) {
00757     switch(modnum) {
00758       case 1: 
00759        *mask = Mod1Mask;
00760        break;               
00761       case 2: 
00762        *mask = Mod2Mask;
00763        break;        
00764       case 3: 
00765        *mask = Mod3Mask;
00766        break;               
00767       case 4: 
00768        *mask = Mod4Mask;
00769        break; 
00770       case 5:
00771        *mask = Mod5Mask;
00772        break;
00773       default:
00774        *mask = 0;
00775     }
00776 }
00777 
00778 #ifdef linux
00779 static void GetKanaFlag(Display *disp);
00780 #endif
00781 
00782 static void
00783 setup_modifier_map(Display *disp)
00784 {
00785     XModifierKeymap *modmap; 
00786     int i, k, nkeys;
00787     KeyCode keycode, metaL, metaR, altL, altR, numLock, Mode_switch;
00788 
00789     metaL = XKeysymToKeycode(disp, XK_Meta_L);
00790     metaR = XKeysymToKeycode(disp, XK_Meta_R);
00791     altR = XKeysymToKeycode(disp, XK_Alt_R);
00792     altL = XKeysymToKeycode(disp, XK_Alt_L);
00793     numLock = XKeysymToKeycode(disp, XK_Num_Lock);
00794     Mode_switch = XKeysymToKeycode(disp, XK_Mode_switch);
00795 
00796     modmap = XGetModifierMapping(disp);
00797     nkeys = modmap->max_keypermod;
00798     for(i = 3*nkeys; 
00799        i < (nkeys*8) && (awt_MetaMask == 0 || awt_AltMask == 0 || awt_NumLockMask == 0 || awt_KanaLockMask ==0);
00800             i++) {
00801        keycode = modmap->modifiermap[i];
00802        k = (i/nkeys) - 2;
00803        if (awt_MetaMask == 0 && (keycode == metaL || keycode == metaR)) {
00804            set_mod_mask(k, &awt_MetaMask);
00805        } else if (awt_AltMask == 0 && (keycode == altL || keycode == altR)) {
00806            set_mod_mask(k, &awt_AltMask);
00807        } else if (awt_NumLockMask == 0 && keycode == numLock) {
00808             set_mod_mask(k, &awt_NumLockMask);
00809        } else if (awt_KanaLockMask == 0 && keycode == Mode_switch) {
00810             set_mod_mask(k, &awt_KanaLockMask);
00811         }
00812     }
00813     XFreeModifiermap(modmap);
00814 
00815 #ifdef linux
00816     /* hack for Linux XFree86 */
00817     for (i = 0; keymapTable[i].awtKey != 0; i++) {
00818       if (keymapTable[i].x11Key == XK_Henkan_Mode) {
00819        keymapTable[i].x11Key = XK_Zenkaku_Hankaku;
00820        break;
00821       }
00822     }
00823     for (i = 0; keymapTable[i].awtKey != 0; i++) {
00824       if (keymapTable[i].x11Key == XK_Kanji) {
00825        keymapTable[i].x11Key = XK_Henkan_Mode;
00826        break;
00827       }
00828     }
00829     for (i = 0; keymapTable[i].awtKey != 0; i++) {
00830       if (keymapTable[i].x11Key == XK_Execute) {
00831        keymapTable[i].x11Key = XK_Muhenkan;
00832        break;
00833       }
00834     }
00835 
00836     /* hack for Linux XFree86 */
00837     if (getenv("HTT_GENERATES_KANAKEY")){
00838        KanaMode = 0;
00839     } else {
00840        return;
00841     }
00842 
00843     /* Get Keycodes for Kana keys */
00844     for (i = 0; kana_normal_keymapTable[i].awtKey != 0; i++) {
00845        kana_normal_keymapTable[i].keycode = XKeysymToKeycode(disp,
00846                                           kana_normal_keymapTable[i].x11Key);
00847        if (kana_normal_keymapTable[i].keycode == 0) {
00848               kana_normal_keymapTable[i].keycode = XKeysymToKeycode(disp,
00849                                           kana_normal_keymapTable[i].alt_x11Key);
00850        }
00851 #ifdef DEBUG
00852        printf("xkey=%x(%x) -> %x\n", kana_normal_keymapTable[i].x11Key,
00853                                    kana_normal_keymapTable[i].keychar,
00854                                    kana_normal_keymapTable[i].keycode);
00855 #endif
00856     }
00857     for (i = 0; kana_shift_keymapTable[i].awtKey != 0; i++) {
00858        kana_shift_keymapTable[i].keycode = XKeysymToKeycode(disp,
00859                                           kana_shift_keymapTable[i].x11Key);
00860        if (kana_shift_keymapTable[i].keycode == 0) {
00861               kana_shift_keymapTable[i].keycode = XKeysymToKeycode(disp,
00862                                           kana_shift_keymapTable[i].alt_x11Key);
00863        }
00864 #ifdef DEBUG
00865        printf("xkey=%x(%x) -> %x\n", kana_shift_keymapTable[i].x11Key,
00866                                    kana_shift_keymapTable[i].keychar,
00867                                    kana_shift_keymapTable[i].keycode);
00868 #endif
00869     }
00870 #endif /* linux */
00871 }
00872 
00873 #ifdef linux
00874 void
00875 CreateKanaWindow(Display *disp)
00876 {
00877     Window kana_w;
00878 
00879     /* hack for Linux XFree86 */
00880     if (getenv("HTT_GENERATES_KANAKEY")){
00881        KanaMode = 0;
00882     } else {
00883        return;
00884     }
00885 
00886     if (!kanawin_atom) {
00887        kanawin_atom = XInternAtom(disp, "HTT_KANA_WIN", False);
00888        kanaflag_atom = XInternAtom(disp, "HTT_KANA_FLAG", False);
00889     }
00890 
00891     kana_w = XGetSelectionOwner(disp, kanawin_atom);
00892 
00893     if (kana_w == None) {
00894        kana_w = XCreateSimpleWindow(disp, RootWindow(disp, 0),
00895                      0, 0, 1, 1, 0, 0, 0);
00896 
00897        XSetSelectionOwner(disp, kanawin_atom, kana_w, CurrentTime);
00898        if (kana_w == XGetSelectionOwner(disp, kanawin_atom)) {
00899            XChangeProperty(disp, kana_w, kanaflag_atom, XA_WINDOW, 32,
00900                          PropModeReplace,
00901                          (unsigned char*) &KanaMode,
00902                          sizeof(KanaMode));
00903        }
00904     }
00905 }
00906 #endif /* linux */
00907 
00908 #ifdef linux
00909 static int
00910 IgnoreError(Display *disp, XErrorEvent *event)
00911 {
00912     return 0;
00913 }
00914 #endif /* linux */
00915 
00916 #ifdef linux
00917 static void
00918 GetKanaFlag(Display *disp)
00919 {
00920     int           (*oldhandler)(Display *, XErrorEvent *) = NULL;
00921     Window          kana_w;
00922     Atom            ret_type;
00923     int             ret_format;
00924     unsigned long   nitems, bytes_left;
00925     unsigned long  *tmp = NULL;
00926 
00927     if (!kanawin_atom) {
00928         return;
00929     }
00930 
00931     XSync(disp, False);
00932     oldhandler = XSetErrorHandler(IgnoreError);
00933 
00934     kana_w = XGetSelectionOwner(disp, kanawin_atom);
00935     if (!kana_w) {
00936         KanaMode = 0;
00937         XSync(disp, False);
00938         XSetErrorHandler(oldhandler);
00939         return;
00940     }
00941 
00942     XGetWindowProperty(disp, kana_w,
00943                      kanaflag_atom, 0, 4, False, XA_WINDOW,
00944                      &ret_type, &ret_format,
00945                      &nitems, &bytes_left, (void*) &tmp);
00946 
00947     XSync(disp, False);
00948     XSetErrorHandler(oldhandler);
00949 
00950     if ((tmp != NULL) && (ret_type == XA_WINDOW)) {
00951        KanaMode = *tmp;
00952     }
00953     if (tmp) {
00954        free((char*)tmp);
00955     }
00956 }
00957 #endif /* linux */
00958 
00959 /*
00960        XKeysymToKeycode() does not return correct keycode for XK_Delete.
00961        So we store and keep the value of KeyCode at the first key typed,
00962        then use in modify_Event()
00963 */
00964 
00965 static long keyCode_XK_Delete = 0;
00966 
00967 static void
00968 modify_Event(
00969     XEvent *xevent,
00970     long keyCode,
00971     unicode keyChar,
00972     long modifiers
00973 )
00974 {
00975     KeySym keysym = 0;
00976 
00977     if (xevent->type != KeyPress && xevent->type != KeyRelease)
00978         return;
00979 
00980     switch(keyCode) {
00981       case java_awt_event_KeyEvent_VK_ENTER:
00982       case java_awt_event_KeyEvent_VK_BACK_SPACE:
00983       case java_awt_event_KeyEvent_VK_TAB:
00984       case java_awt_event_KeyEvent_VK_ESCAPE:
00985       case java_awt_event_KeyEvent_VK_MULTIPLY:
00986       case java_awt_event_KeyEvent_VK_ADD:
00987       case java_awt_event_KeyEvent_VK_SUBTRACT:
00988       case java_awt_event_KeyEvent_VK_DIVIDE:
00989       case java_awt_event_KeyEvent_VK_EQUALS:
00990       case java_awt_event_KeyEvent_VK_DECIMAL:
00991           keysym = getX11KeySym(keyCode);
00992           break;
00993       default:
00994           if ((keyChar != 0 && keyChar < 256)
00995              || (keyChar >= 0xff61 && keyChar <= 0xff9f)) {
00996               keysym = keyChar;
00997           } else {
00998               keysym = getX11KeySym(keyCode);
00999           }
01000           break;
01001     }
01002 
01003     if (keysym != 0) {
01004        if (modifiers & java_awt_event_InputEvent_CTRL_MASK) {
01005            switch (keysym + 64) {
01006              case '[':
01007              case ']':
01008              case '\\':
01009              case '_':
01010               keysym += 64;
01011               break;
01012              default:
01013               if (keysym < 128) {
01014                 if (modifiers & java_awt_event_InputEvent_SHIFT_MASK) {
01015                   if (isupper(keysym + 'A' - 1)) {
01016                     keysym += ('A' - 1);
01017                   }
01018                 } else {
01019                   if (isalpha(keysym + 'a' - 1)) {
01020                     keysym += ('a' - 1);
01021                   }
01022                   if (isalpha(keysym))
01023                     keysym = tolower(keysym);    
01024                 }
01025               }
01026               break;
01027            }
01028        }
01029 
01030        /*
01031         * 0xff61 is Unicode value of first XK_kana_fullstop.
01032         * We need X Keysym to Unicode map in post1.1 release
01033         * to support more intenational keyboard.
01034         */
01035        /*
01036         * 0xff63 is duplicate with INSERT
01037         */
01038        if (keyCode != java_awt_event_KeyEvent_VK_INSERT &&
01039            keyCode != java_awt_event_KeyEvent_VK_ACCEPT &&
01040            keyCode != java_awt_event_KeyEvent_VK_ENTER &&
01041            (keysym >= 0xff61 && keysym <= 0xff9f)) {
01042            keysym = keysym - 0xff61 + XK_kana_fullstop;
01043 
01044            /*
01045             * modifier needs to be set
01046             */
01047            xevent->xkey.state |= awt_KanaLockMask;
01048        }
01049 
01050        /* workaround, do we have to set NumLock mask for
01051           all KP_ keysym??? */
01052        if(keysym == XK_KP_Decimal){
01053            xevent->xkey.state |= awt_NumLockMask;
01054         }
01055 
01056        if (xevent->xany.display)
01057            xevent->xkey.keycode = XKeysymToKeycode(xevent->xany.display,
01058                                               keysym);
01059        else
01060            xevent->xkey.keycode = keysym; /* hack */
01061 
01062        /* workaround for XKeysymToKeycode() */
01063        if (keyCode == java_awt_event_KeyEvent_VK_DELETE){
01064            xevent->xkey.keycode = keyCode_XK_Delete;
01065        }
01066     }
01067 
01068     if (keysym >= 'A' && keysym <= 'Z') {
01069        xevent->xkey.state |= ShiftMask;
01070     }
01071     if (modifiers & java_awt_event_InputEvent_SHIFT_MASK) {
01072        xevent->xkey.state |= ShiftMask;
01073     }
01074     if (modifiers & java_awt_event_InputEvent_CTRL_MASK) {
01075        xevent->xkey.state |= ControlMask;
01076     }
01077     if (modifiers & java_awt_event_InputEvent_META_MASK) {
01078        xevent->xkey.state |= awt_MetaMask;
01079     }
01080     if (modifiers & java_awt_event_InputEvent_ALT_MASK) {
01081        xevent->xkey.state |= awt_AltMask;
01082     }
01083     if (modifiers & java_awt_event_InputEvent_BUTTON1_MASK) {
01084         xevent->xkey.state |= Button1Mask;
01085     }
01086     if (modifiers & java_awt_event_InputEvent_BUTTON2_MASK) {
01087         xevent->xkey.state |= Button2Mask;
01088     }
01089     if (modifiers & java_awt_event_InputEvent_BUTTON3_MASK) {
01090         xevent->xkey.state |= Button3Mask;
01091     }
01092 }
01093 
01094 static int first_call = True;
01095 
01096 void
01097 IIIMCF_keyevent_To_XKeyEvent(
01098     IIIMCF_keyevent *pkev,
01099     Display *dpy,
01100     Window w,
01101     XKeyEvent *kev
01102 )
01103 {
01104     if (first_call && dpy != (Display*)0) {
01105        setup_modifier_map(dpy);
01106        first_call = False;
01107     }
01108 
01109     memset(kev, 0, sizeof(*kev));
01110     
01111     kev->type = KeyPress;
01112     kev->display = dpy;
01113     kev->window = w;
01114     kev->root = None;
01115     kev->subwindow = None;
01116     kev->same_screen = True;
01117     kev->time = pkev->time_stamp;
01118 
01119     modify_Event((XEvent*)kev, pkev->keycode,
01120                pkev->keychar, pkev->modifier);
01121 
01122     return;
01123 }
01124 
01125 /*
01126   XKeyEvent_To_IIIMCF_keyevent() :
01127      Convert X KeyEvent to IIIMP keyCode, keyChar, state values
01128  */
01129 Bool
01130 XKeyEvent_To_IIIMCF_keyevent(
01131     XKeyEvent *ev,
01132     IIIMCF_keyevent *pkev
01133 )
01134 {
01135     KeySym keysym;
01136     char buf[64];
01137     int len = sizeof(buf);
01138     int state;
01139     int i;
01140 
01141     pkev->keychar = 0;
01142     pkev->keycode = 0;
01143     pkev->time_stamp = ev->time;
01144 
01145     if (first_call && ev->display != (Display*)0) {
01146        setup_modifier_map(ev->display);
01147        first_call = False;
01148     }
01149 
01150     state = ev->state;
01151 
01152     if (getenv("HTT_IGNORES_LOCK_MASK")) {
01153       /* LockMask, NumLockMask, KanaLockMask should be ignored for
01154          Java Client compatibility */
01155       if(state & LockMask){
01156          state -= LockMask;
01157       }
01158       if(state & awt_NumLockMask){
01159          state -= awt_NumLockMask;
01160       }
01161       if(state & awt_KanaLockMask){
01162          state -= awt_KanaLockMask;
01163       }
01164     }
01165 
01166     /* IIIMP's control_mask(1<<1) and X's control_mask(1<<2)is
01167        different, so it should be changed */
01168     if (state & ControlMask) {
01169        state -= (1<<2);
01170        state |= (1<<1);
01171     }
01172 
01173     pkev->modifier = state;
01174     /* Set mask with 0x80000000 to indicate the event is key release event */
01175     if (ev->type == KeyRelease)
01176        pkev->modifier |= 0x80000000;
01177 
01178     len = XLookupString(ev, buf, len - 1, &keysym, NULL);
01179 
01180 #ifdef  linux
01181     /* Linux generates XK_Mode_switch at Shift + Henkan_Mode */
01182     if (state & ShiftMask && keysym == XK_Mode_switch)
01183       keysym = XK_Henkan_Mode;
01184 #endif /* linux */
01185 
01186 #ifdef linux
01187     if (KanaMode != -1){
01188        GetKanaFlag(ev->display);
01189     }   
01190 
01191     if (KanaMode != -1){
01192        if (keysym == XK_Hiragana_Katakana){
01193           int    (*oldhandler)(Display *, XErrorEvent *) = NULL;
01194           Window   kana_w;
01195 #ifdef DEBUG
01196            printf("Kanakey is pressed\n");
01197 #endif
01198            if (KanaMode == 1){
01199               KanaMode = 0;
01200 #ifdef DEBUG
01201               printf("      off\n");
01202 #endif
01203            } else {
01204               KanaMode = 1;
01205 #ifdef DEBUG
01206               printf("      on\n");
01207 #endif
01208            }
01209 
01210            XSync(ev->display, False);
01211            oldhandler = XSetErrorHandler(IgnoreError);
01212 
01213            kana_w = XGetSelectionOwner(ev->display, kanawin_atom);
01214            if (kana_w) {
01215               XChangeProperty(ev->display, kana_w, kanaflag_atom,
01216                             XA_WINDOW, 32,
01217                             PropModeReplace,
01218                             (unsigned char*) &KanaMode,
01219                             sizeof(KanaMode));
01220            }
01221 
01222            XSync(ev->display, False);
01223            XSetErrorHandler(oldhandler);
01224 
01225            return False;
01226        }
01227     }
01228 
01229     if (KanaMode == 1) {
01230        if (ev->state & ShiftMask) {
01231            /* check kana_shift_keymapTable first is ShiftMask */
01232            for (i = 0; kana_shift_keymapTable[i].awtKey != 0; i++) {
01233               if (kana_shift_keymapTable[i].keycode == ev->keycode) {
01234                   getAWTKeyCode2(kana_shift_keymapTable[i].x11Key,
01235                                &pkev->keycode, &pkev->keychar);
01236                   if (pkev->keycode) {
01237                      return True;
01238                   }
01239                   break;
01240               }
01241            }
01242        }
01243 
01244        for (i = 0; kana_normal_keymapTable[i].awtKey != 0; i++) {
01245            if (kana_normal_keymapTable[i].keycode == ev->keycode) {
01246               getAWTKeyCode2(kana_normal_keymapTable[i].x11Key,
01247                             &pkev->keycode, &pkev->keychar);
01248               if (pkev->keycode) {
01249                   return True;
01250               }
01251               break;
01252            }
01253        }
01254 
01255        for (i = 0; kana_shift_keymapTable[i].awtKey != 0; i++) {
01256            if (kana_shift_keymapTable[i].keycode == ev->keycode) {
01257               getAWTKeyCode2(kana_shift_keymapTable[i].x11Key,
01258                             &pkev->keycode, &pkev->keychar);
01259               if (pkev->keycode) {
01260                   return True;
01261               }
01262               break;
01263            }
01264        }
01265     }
01266 #endif /* linux */
01267 
01268     /* store keycode for XK_Delete */
01269     if(keysym == XK_Delete && keyCode_XK_Delete == 0){
01270        keyCode_XK_Delete = ev->keycode;
01271     }
01272 
01273     if (keysym < 256) {
01274        if ((ev->state & ControlMask)) {
01275            if (isalpha(keysym)) {
01276               keysym = toupper(keysym);
01277            }
01278        }
01279        pkev->keycode = getAWTKeyCode(keysym);
01280        if (pkev->keycode == 0 && (ev->state & ShiftMask)) {
01281            /* when Shift key is pressed, need to get the normal keysym,
01282               then get the AWT keycode */
01283            if (ev->display != (Display*)0) {
01284               pkev->keycode = getAWTKeyCode(XKeycodeToKeysym(ev->display,
01285                                                         ev->keycode, 0));
01286            }
01287        }
01288        if (pkev->keycode == 0) {
01289            pkev->keycode = keysym;
01290        }
01291        pkev->keychar = keysym;
01292        return True;
01293     } else {
01294        pkev->keycode = getAWTKeyCode(keysym);
01295        switch (keysym) {
01296          case XK_KP_Decimal:
01297           pkev->keychar = '.';
01298           break;
01299          case XK_KP_Add:
01300           pkev->keychar = '+';
01301           break;
01302          case XK_KP_Subtract:
01303           pkev->keychar = '-';
01304           break;
01305          case XK_KP_Divide:
01306           pkev->keychar = '/';
01307           break;
01308          case XK_KP_Multiply:
01309           pkev->keychar = '*';
01310           break;
01311          case XK_KP_0:
01312           pkev->keychar = '0';
01313           break;
01314          case XK_KP_1:
01315           pkev->keychar = '1';
01316           break;
01317          case XK_KP_2:
01318           pkev->keychar = '2';
01319           break;
01320          case XK_KP_3:
01321           pkev->keychar = '3';
01322           break;
01323          case XK_KP_4:
01324           pkev->keychar = '4';
01325           break;
01326          case XK_KP_5:
01327           pkev->keychar = '5';
01328           break;
01329          case XK_KP_6:
01330           pkev->keychar = '6';
01331           break;
01332          case XK_KP_7:
01333           pkev->keychar = '7';
01334           break;
01335          case XK_KP_8:
01336           pkev->keychar = '8';
01337           break;
01338          case XK_KP_9:
01339           pkev->keychar = '9';
01340           break;
01341        }
01342        if (pkev->keycode) {
01343            return True;
01344        }
01345 
01346        /* get Kana code */
01347        getAWTKeyCode2(keysym, &pkev->keycode, &pkev->keychar);
01348 
01349        if (pkev->keycode) {
01350            return True;
01351        }
01352 
01353        if (pkev->keycode == 0 && (ev->state & ShiftMask)) {
01354            /* when Shift key is pressed, need to get the normal keysym,
01355               then get the AWT keycode */
01356            pkev->keycode = getAWTKeyCode(XKeycodeToKeysym(ev->display,
01357                                                     ev->keycode, 0));
01358        }
01359 
01360        if (pkev->keycode) {
01361            return True;
01362        }
01363     }
01364     return False;
01365 }
01366 
01367 Bool
01368 XKeysym_To_IIIMCF_keyevent(
01369     int keysym,
01370     int state,
01371     IIIMCF_keyevent *pkev
01372 )
01373 {
01374     pkev->keychar = 0;
01375     pkev->keycode = 0;
01376     pkev->time_stamp = 0;
01377 
01378     /* LockMask, NumLockMask, KanaLockMask should be ignored for
01379        Java Client compatibility */
01380     if (state & LockMask) {
01381        state -= LockMask;
01382     }
01383     if (state & awt_NumLockMask) {
01384        state -= awt_NumLockMask;
01385     }
01386     if (state & awt_KanaLockMask) {
01387        state -= awt_KanaLockMask;
01388     }
01389 
01390     /* IIIMP's control_mask(1<<1) and X's control_mask(1<<2)is
01391        different, so it should be changed */
01392     if (state & ControlMask) {
01393        state -= (1<<2);
01394        state |= (1<<1);
01395     }
01396 
01397     pkev->modifier = state;
01398 
01399 #ifdef  linux
01400     /* Linux generates XK_Mode_switch at Shift + Henkan_Mode */
01401     if (state & ShiftMask && keysym == XK_Mode_switch)
01402       keysym = XK_Henkan_Mode;
01403 #endif /* linux */
01404 
01405     if (keysym < 256) {
01406        if ((state & ControlMask)) {
01407            if (isalpha(keysym)) {
01408               keysym = toupper(keysym);
01409            }
01410        }
01411        pkev->keycode = getAWTKeyCode(keysym);
01412        if (pkev->keycode == 0) {
01413            pkev->keycode = keysym;
01414        }
01415        pkev->keychar = keysym;
01416        return True;
01417     } else {
01418        pkev->keycode = getAWTKeyCode(keysym);
01419        switch (keysym) {
01420          case XK_KP_Decimal:
01421           pkev->keychar = '.';
01422           break;
01423          case XK_KP_Add:
01424           pkev->keychar = '+';
01425           break;
01426          case XK_KP_Subtract:
01427           pkev->keychar = '-';
01428           break;
01429          case XK_KP_Divide:
01430           pkev->keychar = '/';
01431           break;
01432          case XK_KP_Multiply:
01433           pkev->keychar = '*';
01434           break;
01435          case XK_KP_0:
01436           pkev->keychar = '0';
01437           break;
01438          case XK_KP_1:
01439           pkev->keychar = '1';
01440           break;
01441          case XK_KP_2:
01442           pkev->keychar = '2';
01443           break;
01444          case XK_KP_3:
01445           pkev->keychar = '3';
01446           break;
01447          case XK_KP_4:
01448           pkev->keychar = '4';
01449           break;
01450          case XK_KP_5:
01451           pkev->keychar = '5';
01452           break;
01453          case XK_KP_6:
01454           pkev->keychar = '6';
01455           break;
01456          case XK_KP_7:
01457           pkev->keychar = '7';
01458           break;
01459          case XK_KP_8:
01460           pkev->keychar = '8';
01461           break;
01462          case XK_KP_9:
01463           pkev->keychar = '9';
01464           break;
01465        }
01466        if (pkev->keycode) {
01467            return True;
01468        }
01469 
01470        /* get Kana code */
01471        getAWTKeyCode2(keysym, &pkev->keycode, &pkev->keychar);
01472        if (pkev->keycode) {
01473            return True;
01474        }
01475     }
01476 
01477     return False;
01478 }
01479 
01480 /* Local Variables: */
01481 /* c-file-style: "iiim-project" */
01482 /* End: */