-
Notifications
You must be signed in to change notification settings - Fork 1
/
imlayouts.h
executable file
·180 lines (170 loc) · 5.6 KB
/
imlayouts.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
/**
@file imlayout.h
Copyright (C) 2011 Jonathan Wilson
@author Jonathan wilson <[email protected]>
This library is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License version 2.1 as
published by the Free Software Foundation.
This library is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this library; if not, write to the Free Software Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
typedef struct _vkb_key vkb_key;
struct _vkb_key
{
unsigned char gtk_state;
unsigned char unk1;
unsigned short key_flags;
unsigned char current_slide_key;
unsigned int width;
unsigned char byte_count;
char *label;
unsigned int special_font;
unsigned char key_type;
unsigned int left;
unsigned int top;
unsigned int right;
unsigned int bottom;
unsigned int unk9;
unsigned char offset;
unsigned char scancode_length;
unsigned char unk12;
unsigned char unk13;
unsigned char *scancode;
unsigned char num_sub_keys;
vkb_key *sub_keys;
unsigned char key_size;
};
#define KEY_TYPE_NORMAL 0
#define KEY_TYPE_SLIDING 1
#define KEY_TYPE_MODIFIER 2
#define KEY_TYPE_MULTIPLE 4
#define KEY_TYPE_ALPHA 0x01
#define KEY_TYPE_NUMERIC 0x02
#define KEY_TYPE_HEXA 0x04
#define KEY_TYPE_TELE 0x08
#define KEY_TYPE_SPECIAL 0x10
#define KEY_TYPE_DEAD 0x20
#define KEY_TYPE_WHITESPACE 0x40
#define KEY_TYPE_EXTRA_BYTE 0x80
#define KEY_TYPE_RAW ((0x01<<8) | KEY_TYPE_EXTRA_BYTE)
#define KEY_TYPE_TONE ((0x02<<8) | KEY_TYPE_EXTRA_BYTE)
#define KEY_TYPE_TAB ((0x04<<8) | KEY_TYPE_EXTRA_BYTE)
#define KEY_TYPE_BACKSPACE ((0x08<<8) | KEY_TYPE_EXTRA_BYTE)
#define KEY_TYPE_SHIFT ((0x10<<8) | KEY_TYPE_EXTRA_BYTE)
typedef struct _vkb_key_section
{
unsigned int num_keys;
unsigned char num_rows;
unsigned char *num_keys_in_rows;
vkb_key *keys;
unsigned char margin_left;
unsigned char margin_top;
unsigned char margin_bottom;
unsigned char margin_right;
unsigned int width;
unsigned int unk0;
} vkb_key_section;
typedef struct _vkb_sub_layout
{
unsigned int type;
unsigned char variance_index;
unsigned char num_key_sections;
vkb_key_section *key_sections;
char *label;
unsigned int hash;
unsigned int width;
unsigned int height;
} vkb_sub_layout;
#define SUBLAYOUT_TYPE_LOWERCASE 0
#define SUBLAYOUT_TYPE_UPPERCASE 1
#define SUBLAYOUT_TYPE_SPECIAL 2
typedef struct _vkb_layout
{
unsigned int type;
unsigned int numeric;
unsigned char num_sub_layouts;
vkb_sub_layout *sub_layouts;
unsigned char default_key_size;
} vkb_layout;
#define LAYOUT_TYPE_NORMAL 0
#define LAYOUT_TYPE_SPECIAL 1
#define LAYOUT_TYPE_LARGE 3
#define LAYOUT_TYPE_THUMB 4
#define LAYOUT_TYPE_PINYIN 5
#define LAYOUT_TYPE_ZHUYIN 6
#define LAYOUT_TYPE_CANGJIE 7
#define LAYOUT_TYPE_STROKE 8
typedef struct _vkb_key_size
{
unsigned char width;
unsigned char height;
unsigned char baseline;
unsigned char margin_left;
unsigned char margin_top;
} vkb_key_size;
typedef struct _vkb_layout_collection
{
char version;
unsigned char num_layouts;
char *name;
char *lang;
char *wc;
char *filename;
int *layout_types;
int special_font;
unsigned short *offsets;
unsigned char num_key_sizes;
vkb_key_size *key_sizes;
unsigned char num_screen_modes;
unsigned char *screen_modes;
} vkb_layout_collection;
#define SCREEN_TYPE_NORMAL 0
#define SCREEN_TYPE_THUMB 1
#define SCREEN_TYPE_ROTATED 2
typedef struct _vkb_keyboard_layout {
int header_fd;
int body_fd;
vkb_layout_collection layout;
vkb_layout *layouts;
char *file;
char *header_file;
char *body_file;
int is_key;
int is_slide_key;
int is_multiple_key;
int parsing_multiple;
} vkb_keyboard_layout;
void imlayout_vkb_free_layout(vkb_layout *layout);
void imlayout_vkb_free_layout_collection(vkb_layout_collection *collection);
void imlayout_vkb_free_layout_list(GSList *list);
vkb_layout *imlayout_vkb_get_layout(vkb_layout_collection *collection, int layout_type);
GSList *imlayout_vkb_get_layout_list();
GSList *imlayout_vkb_get_layout_list_from_prefix(const gchar *path);
int imlayout_vkb_init_buttons(vkb_layout_collection *collection, vkb_layout *section, int width, int height);
int vkb_init_buttons(vkb_layout_collection *collection, vkb_layout *section);
vkb_layout_collection *imlayout_vkb_load_file(const char *fname);
void print_info(vkb_layout_collection *collection);
void print_layout_info(vkb_layout *layout);
void print_sublayout_info(vkb_sub_layout *layout);
void add_key(vkb_keyboard_layout *layout);
void add_keysection(vkb_keyboard_layout *layout_name);
void add_keysize(vkb_keyboard_layout *layout);
void add_layout(vkb_keyboard_layout *layout);
void add_rows(vkb_keyboard_layout *layout);
void add_screen(vkb_keyboard_layout *layout);
void add_slide(vkb_keyboard_layout *layout, const char *src, int len);
void add_sublayout(vkb_keyboard_layout *layout);
vkb_key *get_key(vkb_keyboard_layout *layout);
vkb_key *get_key0(vkb_keyboard_layout *layout, int no_subkey);
vkb_key_section *get_keysection(vkb_keyboard_layout *layout);
vkb_key_size *get_keysize(vkb_keyboard_layout *layout);
vkb_layout *get_layout(vkb_keyboard_layout *layout);
unsigned char *get_num_keys_in_row(vkb_keyboard_layout *layout);
unsigned char *get_screen(vkb_keyboard_layout *layout);
vkb_sub_layout *get_sublayout(vkb_keyboard_layout *layout);
void increase_num_keys_in_row(vkb_keyboard_layout *layout);