AiCPlayer
Interface of aic vm - for rendering aspect, sensors, video records
Quick intro
AiC player usage
Data Structures
Files
File List
Globals
src
sdl_translate.c
Go to the documentation of this file.
1
5
#include <
sdl_translate.h
>
6
#include <linux/input.h>
7
8
#include "
logger.h
"
9
#define LOG_TAG "sdl_translate"
10
11
// clang-format off
12
/* Keep it consistent with linux/input.h */
13
typedef
enum
{
14
kKeyCodeEscape
= KEY_ESC,
15
kKeyCodeHome
= KEY_HOME,
16
kKeyCodeBack
= KEY_BACK,
17
kKeyCodeCall
= KEY_SEND,
18
kKeyCodeEndCall
= KEY_END,
19
kKeyCode0
= KEY_0,
20
kKeyCode1
= KEY_1,
21
kKeyCode2
= KEY_2,
22
kKeyCode3
= KEY_3,
23
kKeyCode4
= KEY_4,
24
kKeyCode5
= KEY_5,
25
kKeyCode6
= KEY_6,
26
kKeyCode7
= KEY_7,
27
kKeyCode8
= KEY_8,
28
kKeyCode9
= KEY_9,
29
kKeyCodeStar
= KEY_KPASTERISK,
30
kKeyCodeDpadUp
= KEY_UP,
31
kKeyCodeDpadDown
= KEY_DOWN,
32
kKeyCodeDpadLeft
= KEY_LEFT,
33
kKeyCodeDpadRight
= KEY_RIGHT,
34
kKeyCodeVolumeUp
= KEY_VOLUMEUP,
35
kKeyCodeVolumeDown
= KEY_VOLUMEDOWN,
36
kKeyCodePower
= KEY_POWER,
37
kKeyCodeCamera
= KEY_CAMERA,
38
kKeyCodeClear
= KEY_CLEAR,
39
kKeyCodePageUp
= KEY_PAGEUP,
40
kKeyCodePageDown
= KEY_PAGEDOWN,
41
kKeyCodeA
= KEY_A,
42
kKeyCodeB
= KEY_B,
43
kKeyCodeC
= KEY_C,
44
kKeyCodeD
= KEY_D,
45
kKeyCodeE
= KEY_E,
46
kKeyCodeF
= KEY_F,
47
kKeyCodeG
= KEY_G,
48
kKeyCodeH
= KEY_H,
49
kKeyCodeI
= KEY_I,
50
kKeyCodeJ
= KEY_J,
51
kKeyCodeK
= KEY_K,
52
kKeyCodeL
= KEY_L,
53
kKeyCodeM
= KEY_M,
54
kKeyCodeN
= KEY_N,
55
kKeyCodeO
= KEY_O,
56
kKeyCodeP
= KEY_P,
57
kKeyCodeQ
= KEY_Q,
58
kKeyCodeR
= KEY_R,
59
kKeyCodeS
= KEY_S,
60
kKeyCodeT
= KEY_T,
61
kKeyCodeU
= KEY_U,
62
kKeyCodeV
= KEY_V,
63
kKeyCodeW
= KEY_W,
64
kKeyCodeX
= KEY_X,
65
kKeyCodeY
= KEY_Y,
66
kKeyCodeZ
= KEY_Z,
67
68
kKeyCodeComma
= KEY_COMMA,
69
kKeyCodePeriod
= KEY_DOT,
70
kKeyCodeAltLeft
= KEY_LEFTALT,
71
kKeyCodeAltRight
= KEY_RIGHTALT,
72
kKeyCodeCapLeft
= KEY_LEFTSHIFT,
73
kKeyCodeCapRight
= KEY_RIGHTSHIFT,
74
kKeyCodeTab
= KEY_TAB,
75
kKeyCodeSpace
= KEY_SPACE,
76
kKeyCodeSym
= KEY_COMPOSE,
77
kKeyCodeExplorer
= KEY_WWW,
78
kKeyCodeEnvelope
= KEY_MAIL,
79
kKeyCodeNewline
= KEY_ENTER,
80
kKeyCodeDel
= KEY_BACKSPACE,
81
kKeyCodeGrave
= 399,
82
kKeyCodeMinus
= KEY_MINUS,
83
kKeyCodeEquals
= KEY_EQUAL,
84
kKeyCodeLeftBracket
= KEY_LEFTBRACE,
85
kKeyCodeRightBracket
= KEY_RIGHTBRACE,
86
kKeyCodeBackslash
= KEY_BACKSLASH,
87
kKeyCodeSemicolon
= KEY_SEMICOLON,
88
kKeyCodeApostrophe
= KEY_APOSTROPHE,
89
kKeyCodeSlash
= KEY_SLASH,
90
kKeyCodeAt
= KEY_EMAIL,
91
kKeyCodeSearch
= KEY_SEARCH,
92
kKeyCodePrevious
= KEY_PREVIOUS,
93
kKeyCodeNext
= KEY_NEXT,
94
kKeyCodePlay
= KEY_PLAY,
95
kKeyCodePause
= KEY_PAUSE,
96
kKeyCodeStop
= KEY_STOP,
97
kKeyCodeRewind
= KEY_REWIND,
98
kKeyCodeFastForward
= KEY_FASTFORWARD,
99
kKeyCodeBookmarks
= KEY_BOOKMARKS,
100
kKeyCodeCycleWindows
= KEY_CYCLEWINDOWS,
101
102
}
AndroidKeyCode
;
103
104
105
int
sdl_translate_event
(SDL_Scancode scancode, SDL_Keycode keysym)
106
{
107
(void) keysym;
108
switch
(scancode) {
109
case
SDL_SCANCODE_ESCAPE:
return
kKeyCodeEscape
;
110
case
SDL_SCANCODE_1:
return
kKeyCode1
;
111
case
SDL_SCANCODE_2:
return
kKeyCode2
;
112
case
SDL_SCANCODE_3:
return
kKeyCode3
;
113
case
SDL_SCANCODE_4:
return
kKeyCode4
;
114
case
SDL_SCANCODE_5:
return
kKeyCode5
;
115
case
SDL_SCANCODE_6:
return
kKeyCode6
;
116
case
SDL_SCANCODE_7:
return
kKeyCode7
;
117
case
SDL_SCANCODE_8:
return
kKeyCode8
;
118
case
SDL_SCANCODE_9:
return
kKeyCode9
;
119
case
SDL_SCANCODE_0:
return
kKeyCode0
;
120
121
case
SDL_SCANCODE_Q:
return
kKeyCodeQ
;
122
case
SDL_SCANCODE_W:
return
kKeyCodeW
;
123
case
SDL_SCANCODE_E:
return
kKeyCodeE
;
124
case
SDL_SCANCODE_R:
return
kKeyCodeR
;
125
case
SDL_SCANCODE_T:
return
kKeyCodeT
;
126
case
SDL_SCANCODE_Y:
return
kKeyCodeY
;
127
case
SDL_SCANCODE_U:
return
kKeyCodeU
;
128
case
SDL_SCANCODE_I:
return
kKeyCodeI
;
129
case
SDL_SCANCODE_O:
return
kKeyCodeO
;
130
case
SDL_SCANCODE_P:
return
kKeyCodeP
;
131
case
SDL_SCANCODE_A:
return
kKeyCodeA
;
132
case
SDL_SCANCODE_S:
return
kKeyCodeS
;
133
case
SDL_SCANCODE_D:
return
kKeyCodeD
;
134
case
SDL_SCANCODE_F:
return
kKeyCodeF
;
135
case
SDL_SCANCODE_G:
return
kKeyCodeG
;
136
case
SDL_SCANCODE_H:
return
kKeyCodeH
;
137
case
SDL_SCANCODE_J:
return
kKeyCodeJ
;
138
case
SDL_SCANCODE_K:
return
kKeyCodeK
;
139
case
SDL_SCANCODE_L:
return
kKeyCodeL
;
140
case
SDL_SCANCODE_Z:
return
kKeyCodeZ
;
141
case
SDL_SCANCODE_X:
return
kKeyCodeX
;
142
case
SDL_SCANCODE_C:
return
kKeyCodeC
;
143
case
SDL_SCANCODE_V:
return
kKeyCodeV
;
144
case
SDL_SCANCODE_B:
return
kKeyCodeB
;
145
case
SDL_SCANCODE_N:
return
kKeyCodeN
;
146
case
SDL_SCANCODE_M:
return
kKeyCodeM
;
147
case
SDL_SCANCODE_COMMA:
return
kKeyCodeComma
;
148
case
SDL_SCANCODE_PERIOD:
return
kKeyCodePeriod
;
149
case
SDL_SCANCODE_SPACE:
return
kKeyCodeSpace
;
150
case
SDL_SCANCODE_SLASH:
return
kKeyCodeSlash
;
151
case
SDL_SCANCODE_RETURN:
return
kKeyCodeNewline
;
152
case
SDL_SCANCODE_BACKSPACE:
return
kKeyCodeDel
;
153
154
/* these are qwerty keys not on a device keyboard */
155
case
SDL_SCANCODE_TAB:
return
kKeyCodeTab
;
156
case
SDL_SCANCODE_GRAVE :
return
kKeyCodeGrave
;
157
case
SDL_SCANCODE_MINUS:
return
kKeyCodeMinus
;
158
case
SDL_SCANCODE_EQUALS:
return
kKeyCodeEquals
;
159
case
SDL_SCANCODE_LEFTBRACKET:
return
kKeyCodeLeftBracket
;
160
case
SDL_SCANCODE_RIGHTBRACKET:
return
kKeyCodeRightBracket
;
161
case
SDL_SCANCODE_BACKSLASH:
return
kKeyCodeBackslash
;
162
case
SDL_SCANCODE_SEMICOLON:
return
kKeyCodeSemicolon
;
163
case
SDL_SCANCODE_APOSTROPHE:
return
kKeyCodeApostrophe
;
164
165
case
SDL_SCANCODE_UP:
return
kKeyCodeDpadUp
;
166
case
SDL_SCANCODE_DOWN:
return
kKeyCodeDpadDown
;
167
case
SDL_SCANCODE_LEFT:
return
kKeyCodeDpadLeft
;
168
case
SDL_SCANCODE_RIGHT:
return
kKeyCodeDpadRight
;
169
case
SDL_SCANCODE_PAGEUP:
return
kKeyCodePageUp
;
170
case
SDL_SCANCODE_PAGEDOWN:
return
kKeyCodePageDown
;
171
172
case
SDL_SCANCODE_RSHIFT:
return
kKeyCodeCapRight
;
173
case
SDL_SCANCODE_LSHIFT:
return
kKeyCodeCapLeft
;
174
case
SDL_SCANCODE_RALT:
return
kKeyCodeAltRight
;
175
case
SDL_SCANCODE_LALT:
return
kKeyCodeAltLeft
;
176
case
SDL_SCANCODE_RCTRL:
return
kKeyCodeSym
;
177
case
SDL_SCANCODE_LCTRL:
return
kKeyCodeSym
;
178
179
default
:
180
LOGW
(
"unknown sdl scancode %d"
, scancode);
181
return
-1;
182
}
183
}
184
// clang-format on
kKeyCodeU
Definition:
sdl_translate.c:61
AndroidKeyCode
AndroidKeyCode
Definition:
sdl_translate.c:13
kKeyCode5
Definition:
sdl_translate.c:24
kKeyCodeT
Definition:
sdl_translate.c:60
kKeyCodeA
Definition:
sdl_translate.c:41
kKeyCodeX
Definition:
sdl_translate.c:64
kKeyCode8
Definition:
sdl_translate.c:27
kKeyCodeTab
Definition:
sdl_translate.c:74
kKeyCodeAltRight
Definition:
sdl_translate.c:71
kKeyCodeEscape
Definition:
sdl_translate.c:14
kKeyCodePageDown
Definition:
sdl_translate.c:40
kKeyCodeNewline
Definition:
sdl_translate.c:79
kKeyCodeDpadLeft
Definition:
sdl_translate.c:32
kKeyCodeStar
Definition:
sdl_translate.c:29
kKeyCodeCycleWindows
Definition:
sdl_translate.c:100
kKeyCodeBack
Definition:
sdl_translate.c:16
kKeyCodeJ
Definition:
sdl_translate.c:50
kKeyCodeSemicolon
Definition:
sdl_translate.c:87
kKeyCodeSym
Definition:
sdl_translate.c:76
kKeyCodePeriod
Definition:
sdl_translate.c:69
kKeyCodeRightBracket
Definition:
sdl_translate.c:85
kKeyCodePower
Definition:
sdl_translate.c:36
kKeyCodeI
Definition:
sdl_translate.c:49
kKeyCodeCapLeft
Definition:
sdl_translate.c:72
kKeyCodePause
Definition:
sdl_translate.c:95
kKeyCodeHome
Definition:
sdl_translate.c:15
kKeyCodeZ
Definition:
sdl_translate.c:66
kKeyCodeSpace
Definition:
sdl_translate.c:75
kKeyCodeEndCall
Definition:
sdl_translate.c:18
kKeyCodeQ
Definition:
sdl_translate.c:57
kKeyCodeK
Definition:
sdl_translate.c:51
kKeyCodeAltLeft
Definition:
sdl_translate.c:70
kKeyCodeM
Definition:
sdl_translate.c:53
kKeyCodeFastForward
Definition:
sdl_translate.c:98
kKeyCodeClear
Definition:
sdl_translate.c:38
kKeyCodeB
Definition:
sdl_translate.c:42
kKeyCodeR
Definition:
sdl_translate.c:58
kKeyCode0
Definition:
sdl_translate.c:19
kKeyCodeSlash
Definition:
sdl_translate.c:89
kKeyCodeS
Definition:
sdl_translate.c:59
kKeyCodeCapRight
Definition:
sdl_translate.c:73
kKeyCodeDpadDown
Definition:
sdl_translate.c:31
kKeyCode9
Definition:
sdl_translate.c:28
kKeyCodeGrave
Definition:
sdl_translate.c:81
kKeyCodeRewind
Definition:
sdl_translate.c:97
kKeyCodeApostrophe
Definition:
sdl_translate.c:88
kKeyCodeDpadUp
Definition:
sdl_translate.c:30
kKeyCodeVolumeDown
Definition:
sdl_translate.c:35
sdl_translate_event
int sdl_translate_event(SDL_Scancode scancode, SDL_Keycode keysym)
Convert an SDL scancode to a value read by the virtual input daemon.
Definition:
sdl_translate.c:105
kKeyCodeCamera
Definition:
sdl_translate.c:37
kKeyCodeY
Definition:
sdl_translate.c:65
kKeyCodeE
Definition:
sdl_translate.c:45
kKeyCodeCall
Definition:
sdl_translate.c:17
kKeyCodeBookmarks
Definition:
sdl_translate.c:99
kKeyCodeExplorer
Definition:
sdl_translate.c:77
kKeyCodeV
Definition:
sdl_translate.c:62
kKeyCodeVolumeUp
Definition:
sdl_translate.c:34
kKeyCodeDel
Definition:
sdl_translate.c:80
kKeyCode4
Definition:
sdl_translate.c:23
kKeyCodeBackslash
Definition:
sdl_translate.c:86
kKeyCodePrevious
Definition:
sdl_translate.c:92
kKeyCodeC
Definition:
sdl_translate.c:43
kKeyCodeF
Definition:
sdl_translate.c:46
kKeyCodeAt
Definition:
sdl_translate.c:90
logger.h
Logging macros.
sdl_translate.h
Convert sdl events to uinput codes.
kKeyCodeMinus
Definition:
sdl_translate.c:82
kKeyCodeLeftBracket
Definition:
sdl_translate.c:84
kKeyCode1
Definition:
sdl_translate.c:20
kKeyCodeDpadRight
Definition:
sdl_translate.c:33
LOGW
#define LOGW(...)
Log at WARNING level.
Definition:
logger.h:27
kKeyCodeComma
Definition:
sdl_translate.c:68
kKeyCodeO
Definition:
sdl_translate.c:55
kKeyCodeP
Definition:
sdl_translate.c:56
kKeyCodePlay
Definition:
sdl_translate.c:94
kKeyCode7
Definition:
sdl_translate.c:26
kKeyCodeW
Definition:
sdl_translate.c:63
kKeyCodeL
Definition:
sdl_translate.c:52
kKeyCode6
Definition:
sdl_translate.c:25
kKeyCodeN
Definition:
sdl_translate.c:54
kKeyCode2
Definition:
sdl_translate.c:21
kKeyCodeNext
Definition:
sdl_translate.c:93
kKeyCodeG
Definition:
sdl_translate.c:47
kKeyCodeSearch
Definition:
sdl_translate.c:91
kKeyCodePageUp
Definition:
sdl_translate.c:39
kKeyCode3
Definition:
sdl_translate.c:22
kKeyCodeEquals
Definition:
sdl_translate.c:83
kKeyCodeEnvelope
Definition:
sdl_translate.c:78
kKeyCodeStop
Definition:
sdl_translate.c:96
kKeyCodeH
Definition:
sdl_translate.c:48
kKeyCodeD
Definition:
sdl_translate.c:44
Generated on Thu Feb 16 2017 15:02:04 for AiCPlayer by
1.8.6