Debian Codegraph @

unikey/inputproc.h

raw
1 // -*- coding:unix; mode:c++; tab-width:4; c-basic-offset:4; indent-tabs-mode:nil -*-
2 /* Unikey Vietnamese Input Method
3 * Copyright (C) 2000-2005 Pham Kim Long
4 * Contact:
5 * [email protected]
6 * UniKey project: http://unikey.org
7 *
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2 of the License, or (at your option) any later version.
12 *
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
17 *
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the
20 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor
21 * Boston, MA 02110-1301, USA.
22 */
23 #ifndef __UK_INPUT_PROCESSOR_H
24 #define __UK_INPUT_PROCESSOR_H
25
26 #include "keycons.h"
27 #include "vnlexi.h"
28
29 #if defined(_WIN32)
30 #define DllExport __declspec( dllexport )
31 #define DllImport __declspec( dllimport )
32 #if defined(UNIKEYHOOK)
33 #define DllInterface __declspec( dllexport )
34 #else
35 #define DllInterface __declspec( dllimport )
36 #endif
37 #else
38 #define DllInterface //not used
39 #define DllExport
40 #define DllImport
41 #endif
42
43 enum UkKeyEvName {
44 vneRoofAll, vneRoof_a, vneRoof_e, vneRoof_o,
45 vneHookAll, vneHook_uo, vneHook_u, vneHook_o, vneBowl,
46 vneDd,
47 vneTone0, vneTone1, vneTone2, vneTone3, vneTone4, vneTone5,
48 vne_telex_w, //special for telex
49 vneMapChar, //e.g. [ -> u+ , ] -> o+
50 vneEscChar,
51 vneNormal, //does not belong to any of the above categories
52 vneCount //just to count how many event types there are
53 };
54
55 enum UkCharType {
56 ukcVn,
57 ukcWordBreak,
58 ukcNonVn,
59 ukcReset
60 };
61
62 struct UkKeyEvent {
63 int evType;
64 UkCharType chType;
65 VnLexiName vnSym; //meaningful only when chType==ukcVn
66 unsigned int keyCode;
67 int tone; //meaningful only when this is a vowel
68 };
69
70 struct UkKeyMapping {
71 unsigned char key;
72 int action;
73 };
74
75 ///////////////////////////////////////////
76 class UkInputProcessor {
77
78 public:
79 //don't do anything with constructor, because
80 //this object can be allocated in shared memory
81 //Use init method instead
82 //UkInputProcessor();
83
84 void init();
85
86 UkInputMethod getIM()
87 {
88 return m_im;
89 }
90
91 void keyCodeToEvent(unsigned int keyCode, UkKeyEvent & ev);
92 void keyCodeToSymbol(unsigned int keyCode, UkKeyEvent & ev);
93 int setIM(UkInputMethod im);
94 int setIM(int map[256]);
95 void getKeyMap(int map[256]);
96
97 UkCharType getCharType(unsigned int keyCode);
98
99 protected:
100 static bool m_classInit;
101
102 UkInputMethod m_im;
103 int m_keyMap[256];
104
105 void useBuiltIn(UkKeyMapping *map);
106
107 };
108
109 void UkResetKeyMap(int keyMap[256]);
110 void SetupInputClassifierTable();
111
112 DllInterface extern UkKeyMapping TelexMethodMapping[];
113 DllInterface extern UkKeyMapping SimpleTelexMethodMapping[];
114 DllInterface extern UkKeyMapping VniMethodMapping[];
115 DllInterface extern UkKeyMapping VIQRMethodMapping[];
116 DllInterface extern UkKeyMapping MsViMethodMapping[];
117
118 extern VnLexiName IsoVnLexiMap[];
119 inline VnLexiName IsoToVnLexi(unsigned int keyCode)
120 {
121 return (keyCode >= 256)? vnl_nonVnChar : IsoVnLexiMap[keyCode];
122 }
123
124 #endif