comparison lib/Xatoklib/key.c @ 0:92745d501b9a

initial import from kinput2-v3.1
author Yoshiki Yazawa <yaz@honeyplanet.jp>
date Mon, 08 Mar 2010 04:44:30 +0900
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:92745d501b9a
1 /*
2 * Copyright 1999 Justsystem Corporation, Japan.
3 *
4 * Permission to use, copy, modify, and distribute this software and its
5 * documentation for any purpose and without fee is hereby granted,
6 * provided that the above copyright notice appear in all copies and that
7 * both that copyright notice and this permission notice appear in
8 * supporting documentation, and that the name of Justsystem Corporation
9 * not be used in advertising or publicity pertaining to distribution
10 * of the software without specific, written prior permission. Justsystem
11 * Corporation makes no representations about the suitability of this
12 * software for any purpose. It is provided "as is" without express
13 * or implied warranty.
14 *
15 * Author: Atsushi Irisawa
16 */
17
18 #ifndef lint
19 static char rcsid[] = "$Id: key.c,v 1.3 1999/08/24 09:01:09 ishisone Exp $" ;
20 #endif /* !lint */
21
22
23 #include <X11/IntrinsicP.h>
24 #include <X11/StringDefs.h>
25 #include <X11/Xmu/Atoms.h>
26 #include <X11/keysym.h>
27
28 #include <Xatoklib.h>
29 #include <key_def.h>
30
31 const WORD XkeyAAJtable[]={
32 /* 0,8 ,1,9 ,2,a ,3,b ,4,c ,5,d ,6,e ,7,f */
33 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, /* 00-07 */
34 0x0108,0x0109,0x0000,0x0000,0x0000,0x010d,0x0000,0x0000, /* 08-0f */
35 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, /* 10-17 */
36 0x0000,0x0000,0x0000,0x011b,0x0000,0x0000,0x0000,0x0000, /* 18-1f */
37 /* ! " # $ % & ' */
38 /* XK_Kanji XK_Muhenkan XK_ */
39 0x0000,XFER,NFER,XFER,EIJI,HIRAGANA,KATAKANA,HIRAGANA, /* 20-27 */
40 /* ( ) * + , - */
41 ZORH, ZORH, ZORH,0x0341,0x033a,0x0015,0x0000,0x0000, /* 28-2f */
42 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, /* 30-37 */
43 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, /* 38-3f */
44 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, /* 40-47 */
45 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, /* 48-4f */
46 /* P Q R S T U V W */
47 /* XK_Home XK_Left XK_Up XK_Right XK_PageUP XK_PageDown XK_End */
48 HOME, LEFT, UP, RIGHT, DOWN, PGUP, PGDN, EEND, /* 50-57 */
49 /* X Y Z [ \ ] ^ _ */
50 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, /* 58-5f */
51 /* ` a b c d e f g */
52 0x0000,0x0000, NFER, INS,0x0000,0x0000,0x0000,0x0000, /* 60-67 */
53 /* h i j k l m n o */
54 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, /* 68-6f */
55 /* p q r s t u v w */
56 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, /* 70-77 */
57 /* x y z { | } ~ del */
58 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, /* 78-7f */
59 0x0020,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, /* 80-87 */
60 0x0000, TAB,0x0000,0x0000,0x0000, CR,0x0000,0x0000, /* 88-8f */
61 0x0000, F1, F2, F3, F4, HOME, LEFT, UP, /* 90-97 */
62 RIGHT, DOWN, PGUP, PGDN, EEND,0x0000, INS, DEL, /* 98-9f */
63 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, /* a0-a7 */
64 0x0000,0x0000,0x022a,0x022b,0x0000,0x022d,0x0000,0x022f, /* a8-af */
65 0x0230,0x0231,0x0232,0x0233,0x0234,0x0235,0x0236,0x0237, /* b0-b7 */
66 /* XK_F1 XK_F2 */
67 0x0238,0x0239,0x0000,0x0000,0x0000,0x0000, F1, F2, /* b8-bf */
68 /* XK_F3 XK_F4 XK_F5 XK_F6 XK_F7 XK_F8 XK_F9 XK_F10 */
69 F3, F4, F5, F6, F7, F8, F9, F10, /* c0-c7 */
70 /* XK_F11 XK_F12 XK_F13 XK_F14 XK_F15 XK_F16 XK_F17 XK_F18 */
71 F11, F12, F13, F14, F15, F16, F17, F18, /* c8-cf */
72 /* XK_F19 XK_F20 */
73 F19, F20,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, /* d0-d7 */
74 /* XK_F33 */
75 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, HELP,0x0000, /* d8-df */
76 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, /* e0-e7 */
77 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, /* e8-ef */
78 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, /* f0-f7 */
79 /* XK_Delete */
80 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, DEL /* f8-ff */
81 };
82
83 /* Page */
84 /*
85 * [$B4X?tL>(B]
86 * getAAJCode( )
87 * [$BI=Bj(B]
88 * AAJCODE $B$N<hF@(B
89 * [$B8F=P7A<0(B]
90 * WORD getAAJCode( XKeyEvent *event, KeySym xkeysym,
91 * unsigned char *kbuf )
92 *
93 * [$B0z?t(B]
94 * $B7?(B : $BL>(B $B>N(B : I O : $B@b(B $BL@(B
95 * XKeyEvent : *event : i : X $B$N%$%Y%s%H%3!<%I(B
96 * KeySym : xkeysym : i : X$B$N%-!<%7%s%\%k(B
97 * unsigned char : *kbuf : i : $BF~NO$5$l$?J8;z%3!<%I(B
98 *
99 * [$BJV$jCM(B]
100 * AAJCODE : $BJQ49$5$l$?(BAAJCODE
101 *
102 * [$B;HMQ4X?t(B]
103 * $B$J$7(B
104 * [$B5!G=(B]
105 * X$B$N%-!<%$%Y%s%H$h$j!"(B AAJCODE$B$KJQ49$9$k!#(B
106 *
107 */
108 WORD getAAJCode(event, xkeysym, kbuf)
109 /* Fix Length */
110 XKeyEvent *event;
111 KeySym xkeysym;
112 unsigned char *kbuf;
113 {
114
115 WORD aajcode = 0 ;
116 unsigned char ch ;
117
118 ch = kbuf[0] ;
119
120 #ifdef ATOK_DEBUG
121 printf( "KEY CODE CH = 0x%02x\n", ch ) ;
122 printf( "KEY SYM ORG 0x%x, FF00 4 = 0x%04x\n", xkeysym, xkeysym & 0xff00 ) ;
123 printf( "KEY SYM CODE 4 = 0x%04x\n", xkeysym ) ;
124 printf( "SHIFT STAT %d\n", event->state & ShiftMask ) ;
125 printf( "CTRL STAT %d\n", event->state & ControlMask ) ;
126
127 #endif /* ATOK_DEBUG */
128
129 /*
130 * X $B$N5!G=%-!<$@$C$?>l9g(B,AAJTABLE $B$KDj5A$7$F$"$k%3!<%I$KJQ49(B
131 */
132 if (( xkeysym & 0xFF00 ) == 0xFF00 ) {
133 int index ;
134 index = xkeysym & 0xff ;
135 #ifdef ATOK_DEBUG
136 printf( "FUNCTIONAL KEY INDEX = 0x%02x\n", index ) ;
137 #endif /* ATOK_DEBUG */
138 aajcode = XkeyAAJtable[index] ;
139 if ( !aajcode ) {
140 return 0 ;
141 }
142 }
143 /*
144 * $BF~NO$5$l$?J8;z$H%-!<%3!<%I$,F1$8>l9g$K$O(B
145 * $B$=$N%3!<%I$r(BAAJ$B%3!<%I$H$9$k!#(B
146 * $BF~NOJ8;z$,%3%s%H%m!<%k%3!<%I$N>l9g$OF~NOJ8;z$r(B
147 * AAJ$B%3!<%I$H$9$k!#(B
148 */
149 else if ( ch == 0x8e ) {
150 aajcode = ( WORD )kbuf[1] ;
151 }
152 else if ( ch == xkeysym & 0xff ) {
153 aajcode = ( WORD )xkeysym ;
154 }
155 else if ( ch > 0 && ch < 0x20 ) {
156 aajcode = ch ;
157 }
158 /* 990614 */
159 else if ( ch == 0 && xkeysym & 0xff ) {
160 aajcode = xkeysym & 0xff ;
161 if (( xkeysym & 0xff ) == '@' && ( event->state & ControlMask )) {
162 aajcode = 0x1000 ;
163 return aajcode ;
164 }
165 }
166 /* 990614 */
167 else {
168 /* printf( "unknonw key\n" ) ; */
169 return 0 ;
170 }
171
172 if ( event->state & ShiftMask ) {
173 aajcode |= SHIFT ;
174 }
175 if ( event->state & ControlMask ) {
176 aajcode |= CTRL ;
177 }
178 if( event->state & 0x08 ) { /* ALT Mask */
179 aajcode |= ALT ;
180 }
181 switch( aajcode ) {
182 case 0x101b : /* CTR + 3 */
183 case 0x101c : /* CTR + 4 */
184 case 0x101d : /* CTR + 5 */
185 case 0x101e : /* CTR + 6 */
186 case 0x101f : /* CTR + 7 */
187 aajcode = 0x1033 + aajcode - 0x101b ;
188 break ;
189 }
190
191
192 return aajcode ;
193 }
194 /* End of key.c */
195
196
197
198