blob: 15612d2a731527a2e944bb9dafd1cd7f170c8f50 (
plain)
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
|
#ifdef _WIN32_WCE
// Handle mapping of actions to hardware keys
#include "stdafx.h"
#include <assert.h>
#include <Winuser.h>
#include <sipapi.h>
#include <Aygshell.h>
#include <gx.h>
#include "gapi_keys.h"
#include "screen.h"
struct oneAction _actions[NUMBER_ACTIONS];
struct GXKeyList _keys;
pAction *_action_functions;
const char* ActionsText[] = {
"None",
"Pause",
"Save",
"Quit",
"Skip",
"Hide",
"Keyboard",
"Sound",
"Right click",
"Cursor on/off",
"Subtitles on/off"
};
bool _typeExists(int x) {
int i;
for (i=0; i<NUMBER_ACTIONS; i++)
if (_actions[i].action_type == x)
return true;
return false;
}
const char* getActionName(int action) {
return ActionsText[action];
}
void GAPIKeysInit(pAction *functions) {
int i;
GXOpenInput();
for (i=0; i<NUMBER_ACTIONS; i++) {
_actions[i].action_key = 0;
}
/* Default actions */
_actions[0].action_type = ACTION_PAUSE;
_actions[1].action_type = ACTION_SAVE;
_actions[2].action_type = ACTION_QUIT;
_actions[3].action_type = ACTION_SKIP;
_actions[4].action_type = ACTION_HIDE;
_action_functions = functions;
GAPIKeysGetReference();
}
void GAPIKeysGetReference() {
/*
if(GetScreenMode()) {
_keys = GXGetDefaultKeys(GX_LANDSCAPEKEYS);
} else {
_keys = GXGetDefaultKeys(GX_NORMALKEYS);
}
*/
_keys = GXGetDefaultKeys(GX_LANDSCAPEKEYS);
}
const unsigned char getGAPIKeyMapping(short key) {
// first the standard GAPI controls
if (key == _keys.vkA)
return GAPI_KEY_VKA;
if (key == _keys.vkB)
return GAPI_KEY_VKB;
if (key == _keys.vkC)
return GAPI_KEY_VKC;
if (key == _keys.vkStart)
return GAPI_KEY_VKSTART;
if (key == _keys.vkUp)
return GAPI_KEY_VKUP;
if (key == _keys.vkDown)
return GAPI_KEY_VKDOWN;
if (key == _keys.vkLeft)
return GAPI_KEY_VKLEFT;
if (key == _keys.vkRight)
return GAPI_KEY_VKRIGHT;
switch (key) {
// then the "unsupported" keys
case INTERNAL_KEY_CALENDAR:
return GAPI_KEY_CALENDAR;
case INTERNAL_KEY_CONTACTS:
return GAPI_KEY_CONTACTS;
case INTERNAL_KEY_INBOX:
return GAPI_KEY_INBOX;
case INTERNAL_KEY_ITASK:
return GAPI_KEY_ITASK;
default:
return 0;
}
}
const char* getGAPIKeyName(unsigned char key) {
switch(key) {
case GAPI_KEY_VKA:
return "Button A";
case GAPI_KEY_VKB:
return "Button B";
case GAPI_KEY_VKC:
return "Button C";
case GAPI_KEY_VKSTART:
return "Button Start";
case GAPI_KEY_CALENDAR:
return "Button Calendar";
case GAPI_KEY_CONTACTS:
return "Button Contacts";
case GAPI_KEY_INBOX:
return "Button Inbox";
case GAPI_KEY_ITASK:
return "Button ITask";
case GAPI_KEY_VKUP:
return "Pad Up";
case GAPI_KEY_VKDOWN:
return "Pad Down";
case GAPI_KEY_VKLEFT:
return "Pad Left";
case GAPI_KEY_VKRIGHT:
return "Pad Right";
default:
return "Not mapped";
}
}
struct oneAction* getAction(int action) {
return &_actions[action];
}
void processAction (short key) {
int i;
unsigned char GAPI_key;
GAPI_key = getGAPIKeyMapping(key);
if (!GAPI_key)
return;
for (i=0; i<NUMBER_ACTIONS; i++)
if (_actions[i].action_key == GAPI_key &&
_actions[i].action_type != ACTION_NONE &&
_action_functions[_actions[i].action_type - 1])
_action_functions[_actions[i].action_type - 1]();
}
void clearActionKey (unsigned char key) {
int i;
for (i=0; i<NUMBER_ACTIONS; i++)
if (_actions[i].action_key == key) {
_actions[i].action_key = 0;
}
}
const unsigned char* getActionKeys() {
int i;
static unsigned char actionKeys[NUMBER_ACTIONS];
for (i=0; i<NUMBER_ACTIONS; i++)
actionKeys[i] = _actions[i].action_key;
return actionKeys;
}
const unsigned char* getActionTypes() {
int i;
static unsigned char actionTypes[NUMBER_ACTIONS];
for (i=0; i<NUMBER_ACTIONS; i++)
actionTypes[i] = _actions[i].action_type;
return actionTypes;
}
void setNextType(int action) {
int start = _actions[action].action_type;
int current = start;
for (;;) {
current++;
if (current == start)
return;
if (current > TOTAL_ACTIONS)
current = 1;
if (!_typeExists(current)) {
_actions[action].action_type = current;
return;
}
}
}
void setPreviousType(int action) {
int start = _actions[action].action_type;
int current = start;
for (;;) {
current--;
if (current == start)
return;
if (current <= 0)
current = TOTAL_ACTIONS;
if (!_typeExists(current)) {
_actions[action].action_type = current;
return;
}
}
}
void setActionKeys(unsigned char *actionKeys) {
int i;
for (i=0; i<NUMBER_ACTIONS; i++)
_actions[i].action_key = actionKeys[i];
}
void setActionTypes(unsigned char *actionTypes) {
int i;
for (i=0; i<NUMBER_ACTIONS; i++)
_actions[i].action_type = (ActionType)actionTypes[i];
}
#endif
|