Debian Codegraph @

unikey/inputproc.h

raw
1 /*
2 * SPDX-FileCopyrightText: 2000-2005 Pham Kim Long <[email protected]>
3 *
4 * SPDX-License-Identifier: LGPL-2.0-or-later
5 */
6 #ifndef __UK_INPUT_PROCESSOR_H
7 #define __UK_INPUT_PROCESSOR_H
8
9 #include "keycons.h"
10 #include "vnlexi.h"
11 #include <unordered_set>
12
13 #if defined(_WIN32)
14 #define DllExport __declspec(dllexport)
15 #define DllImport __declspec(dllimport)
16 #if defined(UNIKEYHOOK)
17 #define DllInterface __declspec(dllexport)
18 #else
19 #define DllInterface __declspec(dllimport)
20 #endif
21 #else
22 #define DllInterface // not used
23 #define DllExport
24 #define DllImport
25 #endif
26
27 enum UkKeyEvName {
28 vneRoofAll,
29 vneRoof_a,
30 vneRoof_e,
31 vneRoof_o,
32 vneHookAll,
33 vneHook_uo,
34 vneHook_u,
35 vneHook_o,
36 vneBowl,
37 vneDd,
38 vneTone0,
39 vneTone1,
40 vneTone2,
41 vneTone3,
42 vneTone4,
43 vneTone5,
44 vne_telex_w, // special for telex
45 vneMapChar, // e.g. [ -> u+ , ] -> o+
46 vneEscChar,
47 vneNormal, // does not belong to any of the above categories
48 vneCount // just to count how many event types there are
49 };
50
51 enum UkCharType { ukcVn, ukcWordBreak, ukcNonVn, ukcReset };
52
53 struct UkKeyEvent {
54 int evType;
55 UkCharType chType;
56 VnLexiName vnSym; // meaningful only when chType==ukcVn
57 unsigned int keyCode;
58 int tone; // meaningful only when this is a vowel
59 };
60
61 struct UkKeyMapping {
62 unsigned char key;
63 int action;
64 };
65
66 ///////////////////////////////////////////
67 class UkInputProcessor {
68
69 public:
70 // don't do anything with constructor, because
71 // this object can be allocated in shared memory
72 // Use init method instead
73 // UkInputProcessor();
74
75 void init();
76
77 UkInputMethod getIM() const { return m_im; }
78
79 void keyCodeToEvent(unsigned int keyCode, UkKeyEvent &ev);
80 void keyCodeToSymbol(unsigned int keyCode, UkKeyEvent &ev);
81 int setIM(UkInputMethod im);
82 int setIM(int map[256]);
83 void getKeyMap(int map[256]) const;
84
85 UkCharType getCharType(unsigned int keyCode) const;
86
87 protected:
88 static bool m_classInit;
89
90 UkInputMethod m_im;
91 int m_keyMap[256];
92
93 void useBuiltIn(UkKeyMapping *map);
94 };
95
96 void UkResetKeyMap(int keyMap[256]);
97 void SetupInputClassifierTable();
98
99 DllInterface extern UkKeyMapping TelexMethodMapping[];
100 DllInterface extern UkKeyMapping SimpleTelexMethodMapping[];
101 DllInterface extern UkKeyMapping SimpleTelex2MethodMapping[];
102 DllInterface extern UkKeyMapping VniMethodMapping[];
103 DllInterface extern UkKeyMapping VIQRMethodMapping[];
104 DllInterface extern UkKeyMapping MsViMethodMapping[];
105
106 extern VnLexiName IsoVnLexiMap[];
107 inline VnLexiName IsoToVnLexi(unsigned int keyCode) {
108 return (keyCode >= 256) ? vnl_nonVnChar : IsoVnLexiMap[keyCode];
109 }
110
111 extern const std::unordered_set<unsigned char> WordBreakSyms;
112
113 #endif