File: keycodeconvert.c

package info (click to toggle)
freshplayerplugin 0.3.5-1
  • links: PTS, VCS
  • area: contrib
  • in suites: stretch
  • size: 5,324 kB
  • ctags: 13,257
  • sloc: ansic: 45,542; cpp: 26,176; yacc: 1,707; lex: 910; python: 176; sh: 87; makefile: 21
file content (418 lines) | stat: -rw-r--r-- 9,359 bytes parent folder | download | duplicates (2)
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
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
/*
 * Copyright © 2013-2015  Rinat Ibragimov
 *
 * This file is part of FreshPlayerPlugin.
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in all
 * copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 */

#include "keycodeconvert.h"
#include "keycodepp.h"
#define XK_3270
#include <X11/keysym.h>
#include <X11/XF86keysym.h>
#include <ppapi/c/ppb_input_event.h>

int
xkeycode_to_pp_keycode(int xkeycode)
{
    switch (xkeycode) {
    case XK_Break:
        return VK_CANCEL;
    case XK_BackSpace:
        return VK_BACK;
    case XK_Tab:
    case XK_ISO_Left_Tab:
        return VK_TAB;
    case XK_Clear:
        return VK_CLEAR;
    case XK_Return:
    case XK_KP_Enter:
    case XK_ISO_Enter:
    case XK_3270_Enter:
        return VK_RETURN;
    case XK_Pause:
        return VK_PAUSE;
    case XK_Caps_Lock:
        return VK_CAPITAL;
    case XK_Kana_Lock:
    case XK_Kana_Shift:
        return VK_KANA;
    case XK_Hangul:
        return VK_HANGUL;
    case XK_Hangul_Hanja:
        return VK_HANJA;
    case XK_Kanji:
        return VK_KANJI;
    case XK_Escape:
        return VK_ESCAPE;
    case XK_space:
        return VK_SPACE;
    case XK_Page_Up:
        return VK_PRIOR;
    case XK_Page_Down:
        return VK_NEXT;
    case XK_End:
        return VK_END;
    case XK_Home:
        return VK_HOME;
    case XK_Left:
        return VK_LEFT;
    case XK_Up:
        return VK_UP;
    case XK_Right:
        return VK_RIGHT;
    case XK_Down:
        return VK_DOWN;
    case XK_Select:
        return VK_SELECT;
    case XK_Print:
        return VK_PRINT;
    case XK_Execute:
        return VK_EXECUTE;
    case XK_Sys_Req:
        return VK_SNAPSHOT;
    case XK_Insert:
        return VK_INSERT;
    case XK_Delete:
        return VK_DELETE;
    case XK_Help:
        return VK_HELP;
    // digits
    case XK_1:
    case XK_exclam:
        return '1';
    case XK_2:
    case XK_at:
        return '2';
    case XK_3:
    case XK_numbersign:
        return '3';
    case XK_4:
    case XK_dollar:
        return '4';
    case XK_5:
    case XK_percent:
        return '5';
    case XK_6:
    case XK_asciicircum:
        return '6';
    case XK_7:
    case XK_ampersand:
        return '7';
    case XK_8:
    case XK_asterisk:
        return '8';
    case XK_9:
    case XK_parenleft:
        return '9';
    case XK_0:
    case XK_parenright:
        return '0';
    // letters
    case XK_a:
    case XK_A:
        return 'A';
    case XK_b:
    case XK_B:
        return 'B';
    case XK_c:
    case XK_C:
        return 'C';
    case XK_d:
    case XK_D:
        return 'D';
    case XK_e:
    case XK_E:
        return 'E';
    case XK_f:
    case XK_F:
        return 'F';
    case XK_g:
    case XK_G:
        return 'G';
    case XK_h:
    case XK_H:
        return 'H';
    case XK_i:
    case XK_I:
        return 'I';
    case XK_j:
    case XK_J:
        return 'J';
    case XK_k:
    case XK_K:
        return 'K';
    case XK_l:
    case XK_L:
        return 'L';
    case XK_m:
    case XK_M:
        return 'M';
    case XK_n:
    case XK_N:
        return 'N';
    case XK_o:
    case XK_O:
        return 'O';
    case XK_p:
    case XK_P:
        return 'P';
    case XK_q:
    case XK_Q:
        return 'Q';
    case XK_r:
    case XK_R:
        return 'R';
    case XK_s:
    case XK_S:
        return 'S';
    case XK_t:
    case XK_T:
        return 'T';
    case XK_u:
    case XK_U:
        return 'U';
    case XK_v:
    case XK_V:
        return 'V';
    case XK_w:
    case XK_W:
        return 'W';
    case XK_x:
    case XK_X:
        return 'X';
    case XK_y:
    case XK_Y:
        return 'Y';
    case XK_z:
    case XK_Z:
        return 'Z';

    case XK_Super_L:
        return VK_LWIN;
    case XK_Super_R:
        return VK_RWIN;
    case XK_Menu:
        return VK_APPS;
    case XK_KP_0:
        return VK_NUMPAD0;
    case XK_KP_1:
        return VK_NUMPAD1;
    case XK_KP_2:
        return VK_NUMPAD2;
    case XK_KP_3:
        return VK_NUMPAD3;
    case XK_KP_4:
        return VK_NUMPAD4;
    case XK_KP_5:
        return VK_NUMPAD5;
    case XK_KP_6:
        return VK_NUMPAD6;
    case XK_KP_7:
        return VK_NUMPAD7;
    case XK_KP_8:
        return VK_NUMPAD8;
    case XK_KP_9:
        return VK_NUMPAD9;
    case XK_KP_Multiply:
        return VK_MULTIPLY;
    case XK_KP_Add:
        return VK_ADD;
    case XK_KP_Separator:
        return VK_SEPARATOR;
    case XK_KP_Subtract:
        return VK_SUBTRACT;
    case XK_KP_Decimal:
        return VK_DECIMAL;
    case XK_KP_Divide:
        return VK_DIVIDE;

    case XK_F1:
        return VK_F1;
    case XK_F2:
        return VK_F2;
    case XK_F3:
        return VK_F3;
    case XK_F4:
        return VK_F4;
    case XK_F5:
        return VK_F5;
    case XK_F6:
        return VK_F6;
    case XK_F7:
        return VK_F7;
    case XK_F8:
        return VK_F8;
    case XK_F9:
        return VK_F9;
    case XK_F10:
        return VK_F10;
    case XK_F11:
        return VK_F11;
    case XK_F12:
        return VK_F12;
    case XK_F13:
        return VK_F13;
    case XK_F14:
        return VK_F14;
    case XK_F15:
        return VK_F15;
    case XK_F16:
        return VK_F16;
    case XK_F17:
        return VK_F17;
    case XK_F18:
        return VK_F18;
    case XK_F19:
        return VK_F19;
    case XK_F20:
        return VK_F20;
    case XK_F21:
        return VK_F21;
    case XK_F22:
        return VK_F22;
    case XK_F23:
        return VK_F23;
    case XK_F24:
        return VK_F24;
    case XK_Num_Lock:
        return VK_NUMLOCK;
    case XK_Scroll_Lock:
        return VK_SCROLL;
    case XK_Shift_L:
    case XK_Shift_R:
        return VK_SHIFT;
    case XK_Control_L:
    case XK_Control_R:
        return VK_CONTROL;
    case XK_Meta_L:
    case XK_Meta_R:
    case XK_Alt_L:
    case XK_Alt_R:
        return VK_MENU;
    case XF86XK_Back:
        return VK_BROWSER_BACK;
    case XF86XK_Forward:
        return VK_BROWSER_FORWARD;
    case XF86XK_Refresh:
        return VK_BROWSER_REFRESH;
    case XF86XK_Stop:
        return VK_BROWSER_STOP;
    case XF86XK_Search:
        return VK_BROWSER_SEARCH;
    case XF86XK_Favorites:
        return VK_BROWSER_FAVORITES;
    case XF86XK_HomePage:
        return VK_BROWSER_HOME;
    case XF86XK_AudioMute:
        return VK_VOLUME_MUTE;
    case XF86XK_AudioLowerVolume:
        return VK_VOLUME_DOWN;
    case XF86XK_AudioRaiseVolume:
        return VK_VOLUME_UP;
    case XF86XK_AudioNext:
        return VK_MEDIA_NEXT_TRACK;
    case XF86XK_AudioPrev:
        return VK_MEDIA_PREV_TRACK;
    case XF86XK_AudioStop:
        return VK_MEDIA_STOP;
    case XF86XK_AudioPlay:
        return VK_MEDIA_PLAY_PAUSE;
    case XF86XK_Mail:
        return VK_LAUNCH_MAIL;
    case XF86XK_LaunchA:
        return VK_LAUNCH_APP1;
    case XF86XK_LaunchB:
        return VK_LAUNCH_APP2;

    case XK_semicolon:
    case XK_colon:
        return VK_OEM_1;
    case XK_plus:
    case XK_equal:
        return VK_OEM_PLUS;
    case XK_comma:
    case XK_less:
        return VK_OEM_COMMA;
    case XK_minus:
    case XK_underscore:
        return VK_OEM_MINUS;
    case XK_period:
    case XK_greater:
        return VK_OEM_PERIOD;
    case XK_slash:
    case XK_question:
        return VK_OEM_2;
    case XK_quoteleft:
    case XK_asciitilde:
        return VK_OEM_3;
    case XK_bracketleft:
    case XK_braceleft:
        return VK_OEM_4;
    case XK_backslash:
    case XK_bar:
        return VK_OEM_5;
    case XK_bracketright:
    case XK_braceright:
        return VK_OEM_6;
    case XK_quoteright:
    case XK_quotedbl:
        return VK_OEM_7;
    case XK_3270_Attn:
        return VK_ATTN;
    case XK_3270_CursorSelect:
        return VK_CRSEL;
    case XK_3270_ExSelect:
        return VK_EXSEL;
    case XK_3270_EraseEOF:
        return VK_EREOF;
    case XK_3270_Play:
        return VK_PLAY;
    case XK_3270_PA1:
        return VK_PA1;
    default:
        return 0;
    }

}

int
get_left_right_pp_flag(int xkeycode)
{
    switch (xkeycode) {

    case XK_Shift_L:
    case XK_Control_L:
    case XK_Meta_L:
    case XK_Alt_L:
    case XK_Super_L:
        return PP_INPUTEVENT_MODIFIER_ISLEFT;

    case XK_Shift_R:
    case XK_Control_R:
    case XK_Meta_R:
    case XK_Alt_R:
    case XK_Super_R:
        return PP_INPUTEVENT_MODIFIER_ISRIGHT;

    default:
        return 0;
    }
}