1 /*****************************************************************************
2 * This file is part of gfxprim library. *
4 * Gfxprim is free software; you can redistribute it and/or *
5 * modify it under the terms of the GNU Lesser General Public *
6 * License as published by the Free Software Foundation; either *
7 * version 2.1 of the License, or (at your option) any later version. *
9 * Gfxprim is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
12 * Lesser General Public License for more details. *
14 * You should have received a copy of the GNU Lesser General Public *
15 * License along with gfxprim; if not, write to the Free Software *
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, *
17 * Boston, MA 02110-1301 USA *
19 * Copyright (C) 2009-2013 Cyril Hrubis <metan@ucw.cz> *
21 *****************************************************************************/
23 #include "core/GP_Common.h"
24 #include "core/GP_Debug.h"
26 #include "input/GP_EventQueue.h"
27 #include "input/GP_InputDriverKBD.h"
29 /* KBD raw mode keycodes */
30 static uint16_t keycode_table
[] = {
31 GP_KEY_ESC
, GP_KEY_1
, GP_KEY_2
, GP_KEY_3
,
32 GP_KEY_4
, GP_KEY_5
, GP_KEY_6
, GP_KEY_7
,
33 GP_KEY_8
, GP_KEY_9
, GP_KEY_0
, GP_KEY_MINUS
,
34 GP_KEY_EQUAL
, GP_KEY_BACKSPACE
, GP_KEY_TAB
, GP_KEY_Q
,
35 GP_KEY_W
, GP_KEY_E
, GP_KEY_R
, GP_KEY_T
,
36 GP_KEY_Y
, GP_KEY_U
, GP_KEY_I
, GP_KEY_O
,
37 GP_KEY_P
, GP_KEY_LEFT_BRACE
, GP_KEY_RIGHT_BRACE
, GP_KEY_ENTER
,
38 GP_KEY_LEFT_CTRL
, GP_KEY_A
, GP_KEY_S
, GP_KEY_D
,
39 GP_KEY_F
, GP_KEY_G
, GP_KEY_H
, GP_KEY_J
,
40 GP_KEY_K
, GP_KEY_L
, GP_KEY_SEMICOLON
, GP_KEY_APOSTROPHE
,
41 GP_KEY_GRAVE
, GP_KEY_LEFT_SHIFT
, GP_KEY_BACKSLASH
, GP_KEY_Z
,
42 GP_KEY_X
, GP_KEY_C
, GP_KEY_V
, GP_KEY_B
,
43 GP_KEY_N
, GP_KEY_M
, GP_KEY_COMMA
, 0,
44 GP_KEY_SLASH
, GP_KEY_RIGHT_SHIFT
, GP_KEY_KP_ASTERISK
, GP_KEY_LEFT_ALT
,
45 GP_KEY_SPACE
, GP_KEY_CAPS_LOCK
, GP_KEY_F1
, GP_KEY_F2
,
46 GP_KEY_F3
, GP_KEY_F4
, GP_KEY_F5
, GP_KEY_F6
,
47 GP_KEY_F7
, GP_KEY_F8
, GP_KEY_F9
, GP_KEY_F10
,
48 GP_KEY_NUM_LOCK
, GP_KEY_SCROLL_LOCK
, GP_KEY_KP_7
, GP_KEY_KP_8
,
49 GP_KEY_KP_MINUS
, GP_KEY_KP_9
, GP_KEY_KP_4
, GP_KEY_KP_5
,
50 GP_KEY_KP_6
, GP_KEY_KP_PLUS
, GP_KEY_KP_1
, GP_KEY_KP_2
,
51 GP_KEY_KP_3
, GP_KEY_KP_0
, GP_KEY_KP_COMMA
, 0,
52 0, 0, GP_KEY_F11
, GP_KEY_F12
,
54 0, 0, 0, GP_KEY_KP_ENTER
,
55 GP_KEY_RIGHT_CTRL
, GP_KEY_KP_ASTERISK
, GP_KEY_SYSRQ
, GP_KEY_RIGHT_ALT
,
56 0, GP_KEY_HOME
, GP_KEY_UP
, GP_KEY_PAGE_UP
,
57 GP_KEY_LEFT
, GP_KEY_RIGHT
, GP_KEY_END
, GP_KEY_DOWN
,
58 GP_KEY_PAGE_DOWN
, GP_KEY_INSERT
, GP_KEY_DELETE
, 0,
65 void GP_InputDriverKBDEventPut(struct GP_EventQueue
*event_queue
,
68 unsigned int keycode
= ev
& 0x7f;
69 int press
= !(ev
& 0x80);
72 GP_DEBUG(2, "Press %i keycode %i", press
, keycode
);
74 if (keycode
> 0 && keycode
<= GP_ARRAY_SIZE(keycode_table
)) {
75 key
= keycode_table
[keycode
- 1];
78 GP_EventQueuePushKey(event_queue
, key
, press
, NULL
);
83 GP_WARN("Unmapped key %i", keycode
);