Back to index

im-sdk  12.3.91
Converter.c
Go to the documentation of this file.
00001 #ifdef HAVE_CONFIG_H
00002 #include <config.h>
00003 #endif
00004 
00005 #include <stdio.h>
00006 #include <stdlib.h>
00007 #include "kolelog.h"
00008 #include "Converter.h"
00009 
00010 #define False 0
00011 #define True 1
00012 
00013 typedef unsigned char *MString;
00014 typedef unsigned char *XPointer;
00015 
00016 static KeySym getX11KeySym(long awtKey)
00017 {
00018     int i;
00019     for (i = 0; keymapTable[i].awtKey != 0; i++) {
00020         if (keymapTable[i].awtKey == awtKey) {
00021             return keymapTable[i].x11Key;
00022         }
00023     }
00024     return 0;
00025 }
00026 
00027 modifyEvent(long *keyCode, unsigned short *keyChar, long *State)
00028 {
00029     KeySym keysym = 0;
00030     long state = 0;
00031 #ifndef NDEBUG
00032     KOLE_LOG (LOGDEST_STDOUT, "keycode:0x%x, keychar:0x%x, keystate:0x%x\n", *keyCode, *keyChar, *State);
00033 #endif
00034     switch(*keyCode) {
00035       case java_awt_event_KeyEvent_VK_ENTER:
00036       case java_awt_event_KeyEvent_VK_BACK_SPACE:
00037       case java_awt_event_KeyEvent_VK_TAB:
00038       case java_awt_event_KeyEvent_VK_ESCAPE:
00039       case java_awt_event_KeyEvent_VK_DELETE:
00040           keysym = getX11KeySym(*keyCode);
00041           break;
00042       default:
00043           if (*keyChar != 0 && *keyChar < 256) {
00044               keysym = *keyChar;
00045           } else {
00046               keysym = getX11KeySym(*keyCode);
00047           }
00048           break;
00049     }
00050     if (keysym >= 'A' && keysym <= 'Z') {
00051         state |= ShiftMask;
00052     }
00053     if (*State & java_awt_event_InputEvent_SHIFT_MASK) {
00054         state |= ShiftMask;
00055     }
00056     if (*State & java_awt_event_InputEvent_CTRL_MASK) {
00057         state |= ControlMask;
00058     }
00059     if (*State & java_awt_event_InputEvent_META_MASK) {
00060         state |= awt_MetaMask;
00061     }
00062     if (*State & java_awt_event_InputEvent_ALT_MASK) {
00063         state |= awt_AltMask;
00064     }
00065 
00066     *keyCode = keysym;
00067     if((*keyChar < 0x20) || (*keyChar > 0x7E))
00068        *keyChar = 0xFF;
00069     if(state != 0) *State = state;
00070 #ifndef NDEBUG
00071     KOLE_LOG (LOGDEST_STDOUT, "keycode:0x%x, keychar:0x%x, keystate:0x%x\n", *keyCode, *keyChar, *State);
00072 #endif
00073 }
00074