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 *****************************************************************************/
27 #include <core/GP_Debug.h>
28 #include <core/GP_Common.h>
30 #include <input/GP_EventQueue.h>
32 #include <input/GP_Event.h>
34 static char *key_names
[] = {
35 "Reserved", "Escape", "1", "2", "3",
36 "4", "5", "6", "7", "8",
37 "9", "0", "Minus", "Equal", "BackSpace",
38 "Tab", "Q", "W", "E", "R",
39 "T", "Y", "U", "I", "O",
40 "P", "LeftBrace", "RightBrace", "Enter", "LeftCtrl",
41 "A", "S", "D", "F", "G",
42 "H", "J", "K", "L", "Semicolon",
43 "Apostrophe", "Grave", "LeftShift", "BackSlash", "Z",
44 "X", "C", "V", "B", "N",
45 "M", "Comma", "Dot", "Slash", "RightShift",
46 "KP Asterisk", "LeftAlt", "Space", "CapsLock", "F1",
47 "F2", "F3", "F4", "F5", "F6",
48 "F7", "F8", "F9", "F10", "NumLock",
49 "ScrollLock", "KP 7", "KP 8", "KP 9", "KP Minus",
50 "KP 4", "KP 5", "KP 6", "KP Plus", "KP 1",
51 "KP 2", "KP 3", "KP 0", "KP Dot", "?",
52 "?", "?", "F11", "F12", "?",
53 "?", "?", "?", "?", "?",
54 "?", "KP Enter", "RightCtrl", "KP Slash", "SysRq",
55 "RightAlt", "?", "Home", "Up", "PageUp",
56 "Left", "Right", "End", "Down", "PageDown",
57 "Insert", "Delete", "?", "Mute", "VolumeDown",
58 "VolumeUp", "?", "KP Equal", "KP PlusMinus", "Pause",
59 "?", "KP Comma", "?", "?", "?",
60 "LeftMeta", "RightMeta", "Compose",
63 const char *GP_EventKeyName(enum GP_EventKeyValue key
)
65 if (key
< GP_ARRAY_SIZE(key_names
))
66 return key_names
[key
];
74 return "MiddleButton";
79 case GP_KEY_PREVIOUSSONG
:
80 return "PreviousSong";
81 case GP_KEY_PLAYPAUSE
:
88 static void dump_rel(struct GP_Event
*ev
)
94 printf("Position %u %u dx=%i dy=%i\n",
95 ev
->cursor_x
, ev
->cursor_y
,
96 ev
->val
.rel
.rx
, ev
->val
.rel
.ry
);
99 printf("Wheel %i\n", ev
->val
.val
);
104 static void dump_key(struct GP_Event
*ev
)
106 const char *name
= GP_EventKeyName(ev
->val
.key
.key
);
108 printf("Key %i (Key%s) %s\n",
109 ev
->val
.key
.key
, name
, ev
->code
? "down" : "up");
112 static void dump_abs(struct GP_Event
*ev
)
116 printf("Position %u %u %u\n",
117 ev
->cursor_x
, ev
->cursor_y
, ev
->val
.abs
.pressure
);
122 static void dump_sys(struct GP_Event
*ev
)
126 printf("Sys Quit\n");
128 case GP_EV_SYS_RESIZE
:
129 printf("Sys Resize %ux%u\n", ev
->val
.sys
.w
, ev
->val
.sys
.h
);
134 void GP_EventDump(struct GP_Event
*ev
)
136 printf("Event (%u) ", (unsigned int)ev
->time
.tv_sec
% 10000);
152 printf("Timer %s expired\n", ev
->val
.tmr
->id
);
155 printf("Unknown %u\n", ev
->type
);