summaryrefslogtreecommitdiff
path: root/apps/plugins/lib/pluginlib_actions.c
blob: bd910ac6328a93691bd3b82a7afeab5a382ceffc (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
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
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
/***************************************************************************
*             __________               __   ___.
*   Open      \______   \ ____   ____ |  | _\_ |__   _______  ___
*   Source     |       _//  _ \_/ ___\|  |/ /| __ \ /  _ \  \/  /
*   Jukebox    |    |   (  <_> )  \___|    < | \_\ (  <_> > <  <
*   Firmware   |____|_  /\____/ \___  >__|_ \|___  /\____/__/\_ \
*                     \/            \/     \/    \/            \/
* $Id$
*
* Copyright (C) 2006 Jonathan Gordon
*
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
****************************************************************************/

#include "plugin.h"
#include "action.h"
#include "pluginlib_actions.h"

#if defined(HAVE_REMOTE_LCD)
/* remote directions */
const struct button_mapping pla_remote_ctx[] =
{
#if (CONFIG_KEYPAD == IRIVER_H100_PAD) || \
    (CONFIG_KEYPAD == IRIVER_H300_PAD)
    { PLA_UP,                BUTTON_RC_BITRATE,                BUTTON_NONE},
    { PLA_DOWN,              BUTTON_RC_SOURCE,                 BUTTON_NONE},
    { PLA_LEFT,              BUTTON_RC_VOL_DOWN,               BUTTON_NONE},
    { PLA_RIGHT,             BUTTON_RC_VOL_UP,                 BUTTON_NONE},
    { PLA_UP_REPEAT,         BUTTON_RC_BITRATE|BUTTON_REPEAT,  BUTTON_NONE},
    { PLA_DOWN_REPEAT,       BUTTON_RC_SOURCE|BUTTON_REPEAT,   BUTTON_NONE},
    { PLA_LEFT_REPEAT,       BUTTON_RC_VOL_DOWN|BUTTON_REPEAT, BUTTON_NONE},
    { PLA_RIGHT_REPEAT,      BUTTON_RC_VOL_UP|BUTTON_REPEAT,   BUTTON_NONE},
#elif (CONFIG_KEYPAD == IAUDIO_X5M5_PAD) || \
      (CONFIG_KEYPAD == IRIVER_H10_PAD) || \
      (CONFIG_KEYPAD == GIGABEAT_PAD) || \
      (CONFIG_KEYPAD == IAUDIO_M3_PAD) || \
      (CONFIG_KEYPAD == GIGABEAT_S_PAD)
    { PLA_UP,                BUTTON_RC_FF,                     BUTTON_NONE},
    { PLA_DOWN,              BUTTON_RC_REW,                    BUTTON_NONE},
    { PLA_LEFT,              BUTTON_RC_VOL_DOWN,               BUTTON_NONE},
    { PLA_RIGHT,             BUTTON_RC_VOL_UP,                 BUTTON_NONE},
    { PLA_UP_REPEAT,         BUTTON_RC_FF|BUTTON_REPEAT,       BUTTON_NONE},
    { PLA_DOWN_REPEAT,       BUTTON_RC_REW|BUTTON_REPEAT,      BUTTON_NONE},
    { PLA_LEFT_REPEAT,       BUTTON_RC_VOL_DOWN|BUTTON_REPEAT, BUTTON_NONE},
    { PLA_RIGHT_REPEAT,      BUTTON_RC_VOL_UP|BUTTON_REPEAT,   BUTTON_NONE},
#elif (CONFIG_KEYPAD == PLAYER_PAD) || \
      (CONFIG_KEYPAD == RECORDER_PAD)
    { PLA_UP,                BUTTON_RC_VOL_UP,                 BUTTON_NONE},
    { PLA_DOWN,              BUTTON_RC_VOL_DOWN,               BUTTON_NONE},
    { PLA_LEFT,              BUTTON_RC_LEFT,                   BUTTON_NONE},
    { PLA_RIGHT,             BUTTON_RC_RIGHT,                  BUTTON_NONE},
    { PLA_UP_REPEAT,         BUTTON_RC_VOL_UP|BUTTON_REPEAT,   BUTTON_NONE},
    { PLA_DOWN_REPEAT,       BUTTON_RC_VOL_DOWN|BUTTON_REPEAT, BUTTON_NONE},
    { PLA_LEFT_REPEAT,       BUTTON_RC_LEFT|BUTTON_REPEAT,     BUTTON_NONE},
    { PLA_RIGHT_REPEAT,      BUTTON_RC_RIGHT|BUTTON_REPEAT,    BUTTON_NONE},
#elif (CONFIG_REMOTE_KEYPAD == MROBE_REMOTE)
    { PLA_UP,                BUTTON_RC_PLAY,                   BUTTON_NONE},
    { PLA_DOWN,              BUTTON_RC_DOWN,                   BUTTON_NONE},
    { PLA_LEFT,              BUTTON_RC_REW,                    BUTTON_NONE},
    { PLA_RIGHT,             BUTTON_RC_FF,                     BUTTON_NONE},
    { PLA_UP_REPEAT,         BUTTON_RC_PLAY|BUTTON_REPEAT,     BUTTON_NONE},
    { PLA_DOWN_REPEAT,       BUTTON_RC_DOWN|BUTTON_REPEAT,     BUTTON_NONE},
    { PLA_LEFT_REPEAT,       BUTTON_RC_REW|BUTTON_REPEAT,      BUTTON_NONE},
    { PLA_RIGHT_REPEAT,      BUTTON_RC_FF|BUTTON_REPEAT,       BUTTON_NONE},
#else
    #error pluginlib_actions: No remote directions
#endif
    LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_PLUGIN),
};
#endif /* HAVE_REMOTE_LCD */

/* these were taken from the bubbles plugin, so may need tweaking */
const struct button_mapping pla_main_ctx[] = 
{
    /* Touchscreens */
#ifdef HAVE_TOUCHSCREEN
    { PLA_CANCEL,           BUTTON_BOTTOMRIGHT,                 BUTTON_NONE},
    { PLA_SELECT,           BUTTON_CENTER,                      BUTTON_NONE},
    { PLA_SELECT_REL,       BUTTON_CENTER|BUTTON_REL,           BUTTON_NONE},
    { PLA_SELECT_REPEAT,    BUTTON_CENTER|BUTTON_REPEAT,        BUTTON_NONE},
    { PLA_UP,               BUTTON_TOPMIDDLE,                   BUTTON_NONE},
    { PLA_DOWN,             BUTTON_BOTTOMMIDDLE,                BUTTON_NONE},
    { PLA_LEFT,             BUTTON_MIDLEFT,                     BUTTON_NONE},
    { PLA_RIGHT,            BUTTON_MIDRIGHT,                    BUTTON_NONE},
    { PLA_UP_REPEAT,        BUTTON_TOPMIDDLE|BUTTON_REPEAT,     BUTTON_NONE},
    { PLA_DOWN_REPEAT,      BUTTON_BOTTOMMIDDLE|BUTTON_REPEAT,  BUTTON_NONE},
    { PLA_LEFT_REPEAT,      BUTTON_MIDLEFT|BUTTON_REPEAT,       BUTTON_NONE},
    { PLA_RIGHT_REPEAT,     BUTTON_MIDRIGHT|BUTTON_REPEAT,      BUTTON_NONE},
#endif

    /* Directions */
#if   ((CONFIG_KEYPAD == IRIVER_H100_PAD)   \
    || (CONFIG_KEYPAD == IRIVER_H300_PAD)   \
    || (CONFIG_KEYPAD == IAUDIO_X5M5_PAD)     \
    || (CONFIG_KEYPAD == GIGABEAT_PAD)      \
    || (CONFIG_KEYPAD == RECORDER_PAD)      \
    || (CONFIG_KEYPAD == ARCHOS_AV300_PAD)  \
    || (CONFIG_KEYPAD == IRIVER_IFP7XX_PAD) \
    || (CONFIG_KEYPAD == ONDIO_PAD) \
    || (CONFIG_KEYPAD == SANSA_C200_PAD) \
    || (CONFIG_KEYPAD == GIGABEAT_S_PAD) \
    || (CONFIG_KEYPAD == MROBE100_PAD) \
    || (CONFIG_KEYPAD == PHILIPS_HDD1630_PAD) \
    || (CONFIG_KEYPAD == SANSA_CLIP_PAD) \
    || (CONFIG_KEYPAD == CREATIVEZVM_PAD) \
    || (CONFIG_KEYPAD == SANSA_M200_PAD)\
    || (CONFIG_KEYPAD == SANSA_E200_PAD) \
    || (CONFIG_KEYPAD == SANSA_FUZE_PAD) \
    || (CONFIG_KEYPAD == SAMSUNG_YH820_PAD) \
    || (CONFIG_KEYPAD == SAMSUNG_YH920_PAD) \
    || (CONFIG_KEYPAD == SANSA_FUZEPLUS_PAD) \
    || (CONFIG_KEYPAD == SANSA_CONNECT_PAD) \
    || (CONFIG_KEYPAD == SAMSUNG_YPR0_PAD) \
    || (CONFIG_KEYPAD == CREATIVE_ZENXFI3_PAD) \
    || (CONFIG_KEYPAD == HM60X_PAD) \
    || (CONFIG_KEYPAD == HM801_PAD) \
    || (CONFIG_KEYPAD == SONY_NWZ_PAD) \
    || (CONFIG_KEYPAD == CREATIVE_ZEN_PAD))
    { PLA_UP,               BUTTON_UP,                          BUTTON_NONE },
    { PLA_DOWN,             BUTTON_DOWN,                        BUTTON_NONE },
    { PLA_LEFT,             BUTTON_LEFT,                        BUTTON_NONE },
    { PLA_RIGHT,            BUTTON_RIGHT,                       BUTTON_NONE },
    { PLA_UP_REPEAT,        BUTTON_UP|BUTTON_REPEAT,            BUTTON_NONE },
    { PLA_DOWN_REPEAT,      BUTTON_DOWN|BUTTON_REPEAT,          BUTTON_NONE },
    { PLA_LEFT_REPEAT,      BUTTON_LEFT|BUTTON_REPEAT,          BUTTON_NONE },
    { PLA_RIGHT_REPEAT,     BUTTON_RIGHT|BUTTON_REPEAT,         BUTTON_NONE },
    /* now the bad ones that don't have standard names for the directional
     * buttons */
#elif (CONFIG_KEYPAD == IPOD_1G2G_PAD) \
    || (CONFIG_KEYPAD == IPOD_3G_PAD) \
    || (CONFIG_KEYPAD == IPOD_4G_PAD)
    { PLA_UP,               BUTTON_MENU,                        BUTTON_NONE },
    { PLA_DOWN,             BUTTON_PLAY,                        BUTTON_NONE },
    { PLA_LEFT,             BUTTON_LEFT,                        BUTTON_NONE },
    { PLA_RIGHT,            BUTTON_RIGHT,                       BUTTON_NONE },
    { PLA_UP_REPEAT,        BUTTON_MENU|BUTTON_REPEAT,          BUTTON_NONE },
    { PLA_DOWN_REPEAT,      BUTTON_PLAY|BUTTON_REPEAT,          BUTTON_NONE },
    { PLA_LEFT_REPEAT,      BUTTON_LEFT|BUTTON_REPEAT,          BUTTON_NONE },
    { PLA_RIGHT_REPEAT,     BUTTON_RIGHT|BUTTON_REPEAT,         BUTTON_NONE },
#elif (CONFIG_KEYPAD == PLAYER_PAD)
    { PLA_UP,               BUTTON_PLAY,                        BUTTON_NONE },
    { PLA_DOWN,             BUTTON_STOP,                        BUTTON_NONE },
    { PLA_LEFT,             BUTTON_LEFT,                        BUTTON_NONE },
    { PLA_RIGHT,            BUTTON_RIGHT,                       BUTTON_NONE },
    { PLA_UP_REPEAT,        BUTTON_PLAY|BUTTON_REPEAT,          BUTTON_NONE },
    { PLA_DOWN_REPEAT,      BUTTON_STOP|BUTTON_REPEAT,          BUTTON_NONE },
    { PLA_LEFT_REPEAT,      BUTTON_LEFT|BUTTON_REPEAT,          BUTTON_NONE },
    { PLA_RIGHT_REPEAT,     BUTTON_RIGHT|BUTTON_REPEAT,         BUTTON_NONE },
#elif (CONFIG_KEYPAD == IRIVER_H10_PAD)
    { PLA_UP,               BUTTON_SCROLL_UP,                   BUTTON_NONE },
    { PLA_DOWN,             BUTTON_SCROLL_DOWN,                 BUTTON_NONE },
    { PLA_LEFT,             BUTTON_LEFT,                        BUTTON_NONE },
    { PLA_RIGHT,            BUTTON_RIGHT,                       BUTTON_NONE },
    { PLA_UP_REPEAT,        BUTTON_SCROLL_UP|BUTTON_REPEAT,     BUTTON_NONE },
    { PLA_DOWN_REPEAT,      BUTTON_SCROLL_DOWN|BUTTON_REPEAT,   BUTTON_NONE },
    { PLA_LEFT_REPEAT,      BUTTON_LEFT|BUTTON_REPEAT,          BUTTON_NONE },
    { PLA_RIGHT_REPEAT,     BUTTON_RIGHT|BUTTON_REPEAT,         BUTTON_NONE },
#elif (CONFIG_KEYPAD == IAUDIO_M3_PAD)
    { PLA_UP,               BUTTON_VOL_UP,                      BUTTON_NONE },
    { PLA_DOWN,             BUTTON_VOL_DOWN,                    BUTTON_NONE },
    { PLA_LEFT,             BUTTON_LEFT,                        BUTTON_NONE },
    { PLA_RIGHT,            BUTTON_RIGHT,                       BUTTON_NONE },
    { PLA_UP_REPEAT,        BUTTON_VOL_UP|BUTTON_REPEAT,        BUTTON_NONE },
    { PLA_DOWN_REPEAT,      BUTTON_VOL_DOWN|BUTTON_REPEAT,      BUTTON_NONE },
    { PLA_LEFT_REPEAT,      BUTTON_LEFT|BUTTON_REPEAT,          BUTTON_NONE },
    { PLA_RIGHT_REPEAT,     BUTTON_RIGHT|BUTTON_REPEAT,         BUTTON_NONE },
#elif (CONFIG_KEYPAD == PHILIPS_HDD6330_PAD) \
    || (CONFIG_KEYPAD == PHILIPS_SA9200_PAD)
    { PLA_UP,               BUTTON_UP,                          BUTTON_NONE },
    { PLA_DOWN,             BUTTON_DOWN,                        BUTTON_NONE },
    { PLA_LEFT,             BUTTON_PREV,                        BUTTON_NONE },
    { PLA_RIGHT,            BUTTON_NEXT,                        BUTTON_NONE },
    { PLA_UP_REPEAT,        BUTTON_UP|BUTTON_REPEAT,            BUTTON_NONE },
    { PLA_DOWN_REPEAT,      BUTTON_DOWN|BUTTON_REPEAT,          BUTTON_NONE },
    { PLA_LEFT_REPEAT,      BUTTON_PREV|BUTTON_REPEAT,          BUTTON_NONE },
    { PLA_RIGHT_REPEAT,     BUTTON_NEXT|BUTTON_REPEAT,          BUTTON_NONE },
#elif (CONFIG_KEYPAD == IAUDIO67_PAD)
    { PLA_UP,               BUTTON_STOP,                        BUTTON_NONE },
    { PLA_DOWN,             BUTTON_PLAY,                        BUTTON_NONE },
    { PLA_LEFT,             BUTTON_LEFT,                        BUTTON_NONE },
    { PLA_RIGHT,            BUTTON_RIGHT,                       BUTTON_NONE },
    { PLA_UP_REPEAT,        BUTTON_STOP|BUTTON_REPEAT,          BUTTON_NONE },
    { PLA_DOWN_REPEAT,      BUTTON_PLAY|BUTTON_REPEAT,          BUTTON_NONE },
    { PLA_LEFT_REPEAT,      BUTTON_LEFT|BUTTON_REPEAT,          BUTTON_NONE },
    { PLA_RIGHT_REPEAT,     BUTTON_RIGHT|BUTTON_REPEAT,         BUTTON_NONE },
#elif (CONFIG_KEYPAD == PBELL_VIBE500_PAD)
    { PLA_UP,                BUTTON_UP,                         BUTTON_NONE},
    { PLA_DOWN,              BUTTON_DOWN,                       BUTTON_NONE},
    { PLA_LEFT,              BUTTON_PREV,                       BUTTON_NONE},
    { PLA_RIGHT,             BUTTON_NEXT,                       BUTTON_NONE},
    { PLA_UP_REPEAT,         BUTTON_UP|BUTTON_REPEAT,           BUTTON_NONE},
    { PLA_DOWN_REPEAT,       BUTTON_DOWN|BUTTON_REPEAT,         BUTTON_NONE},
    { PLA_LEFT_REPEAT,       BUTTON_PREV|BUTTON_REPEAT,         BUTTON_NONE},
    { PLA_RIGHT_REPEAT,      BUTTON_NEXT|BUTTON_REPEAT,         BUTTON_NONE},
#elif (CONFIG_KEYPAD == MPIO_HD200_PAD)
    { PLA_UP,                BUTTON_REW,                        BUTTON_NONE},
    { PLA_DOWN,              BUTTON_FF,                         BUTTON_NONE},
    { PLA_LEFT,              BUTTON_VOL_DOWN,                   BUTTON_NONE},
    { PLA_RIGHT,             BUTTON_VOL_UP,                     BUTTON_NONE},
    { PLA_UP_REPEAT,         BUTTON_REW|BUTTON_REPEAT,          BUTTON_NONE},
    { PLA_DOWN_REPEAT,       BUTTON_FF|BUTTON_REPEAT,           BUTTON_NONE},
    { PLA_LEFT_REPEAT,       BUTTON_VOL_DOWN|BUTTON_REPEAT,     BUTTON_NONE},
    { PLA_RIGHT_REPEAT,      BUTTON_VOL_UP|BUTTON_REPEAT,       BUTTON_NONE},
#elif (CONFIG_KEYPAD == MPIO_HD300_PAD)
    { PLA_UP,                BUTTON_UP,                         BUTTON_NONE},
    { PLA_DOWN,              BUTTON_DOWN,                       BUTTON_NONE},
    { PLA_LEFT,              BUTTON_REW,                        BUTTON_NONE},
    { PLA_RIGHT,             BUTTON_FF,                         BUTTON_NONE},
    { PLA_UP_REPEAT,         BUTTON_UP|BUTTON_REPEAT,           BUTTON_NONE},
    { PLA_DOWN_REPEAT,       BUTTON_DOWN|BUTTON_REPEAT,         BUTTON_NONE},
    { PLA_LEFT_REPEAT,       BUTTON_REW|BUTTON_REPEAT,          BUTTON_NONE},
    { PLA_RIGHT_REPEAT,      BUTTON_FF|BUTTON_REPEAT,           BUTTON_NONE},
#elif (CONFIG_KEYPAD == RK27XX_GENERIC_PAD)
    { PLA_UP,                BUTTON_REW,                        BUTTON_NONE},
    { PLA_DOWN,              BUTTON_FF,                         BUTTON_NONE},
    { PLA_LEFT,              BUTTON_REW|BUTTON_M,               BUTTON_NONE},
    { PLA_RIGHT,             BUTTON_FF|BUTTON_M,                BUTTON_NONE},
    { PLA_UP_REPEAT,         BUTTON_REW|BUTTON_REPEAT,          BUTTON_NONE},
    { PLA_DOWN_REPEAT,       BUTTON_FF|BUTTON_REPEAT,           BUTTON_NONE},
    { PLA_LEFT_REPEAT,       BUTTON_REW|BUTTON_M|BUTTON_REPEAT, BUTTON_NONE},
    { PLA_RIGHT_REPEAT,      BUTTON_FF|BUTTON_M|BUTTON_REPEAT,  BUTTON_NONE},
#else
#   ifndef HAVE_TOUCHSCREEN
#       error pluginlib_actions: No directions defined
#   endif
#endif

    /* Scrollwheels */
#ifdef HAVE_SCROLLWHEEL
    { PLA_SCROLL_BACK,       BUTTON_SCROLL_BACK,                BUTTON_NONE },
    { PLA_SCROLL_FWD,        BUTTON_SCROLL_FWD,                 BUTTON_NONE },
    { PLA_SCROLL_BACK_REPEAT,BUTTON_SCROLL_BACK|BUTTON_REPEAT,  BUTTON_NONE },
    { PLA_SCROLL_FWD_REPEAT, BUTTON_SCROLL_FWD|BUTTON_REPEAT,   BUTTON_NONE },
#endif

    /* Actions */
#if (CONFIG_KEYPAD == IRIVER_H100_PAD) || (CONFIG_KEYPAD == IRIVER_H300_PAD)
    {PLA_CANCEL,            BUTTON_OFF,                         BUTTON_NONE },
    {PLA_CANCEL,            BUTTON_RC_STOP,                     BUTTON_NONE },
    {PLA_EXIT,              BUTTON_ON,                          BUTTON_NONE },
    {PLA_EXIT,              BUTTON_RC_MENU,                     BUTTON_NONE },
    {PLA_SELECT,            BUTTON_SELECT,                      BUTTON_NONE },
    {PLA_SELECT,            BUTTON_RC_ON,                       BUTTON_NONE },
    {PLA_SELECT_REL,        BUTTON_SELECT|BUTTON_REL,           BUTTON_SELECT },
    {PLA_SELECT_REL,        BUTTON_RC_ON|BUTTON_REL,            BUTTON_RC_ON },
    {PLA_SELECT_REPEAT,     BUTTON_SELECT|BUTTON_REPEAT,        BUTTON_NONE },
    {PLA_SELECT_REPEAT,     BUTTON_RC_ON|BUTTON_REPEAT,         BUTTON_NONE },
#elif (CONFIG_KEYPAD == IPOD_1G2G_PAD) \
   || (CONFIG_KEYPAD == IPOD_3G_PAD) \
   || (CONFIG_KEYPAD == IPOD_4G_PAD)
    {PLA_CANCEL,            BUTTON_MENU|BUTTON_SELECT,          BUTTON_NONE },
    {PLA_EXIT,              BUTTON_PLAY|BUTTON_SELECT,          BUTTON_NONE },
    {PLA_SELECT,            BUTTON_SELECT,                      BUTTON_NONE },
    {PLA_SELECT_REL,        BUTTON_SELECT|BUTTON_REL,           BUTTON_SELECT },
    {PLA_SELECT_REPEAT,     BUTTON_SELECT|BUTTON_REPEAT,        BUTTON_NONE },
#elif (CONFIG_KEYPAD == IAUDIO_X5M5_PAD)
    {PLA_CANCEL,            BUTTON_REC,                         BUTTON_NONE },
    {PLA_CANCEL,            BUTTON_RC_REC|BUTTON_REL,           BUTTON_RC_REC},
    {PLA_EXIT,              BUTTON_POWER,                       BUTTON_NONE },
    {PLA_EXIT,              BUTTON_RC_REC|BUTTON_REPEAT,        BUTTON_NONE },
    {PLA_SELECT,            BUTTON_SELECT,                      BUTTON_NONE },
    {PLA_SELECT,            BUTTON_RC_MODE,                     BUTTON_NONE },
    {PLA_SELECT_REL,        BUTTON_SELECT|BUTTON_REL,           BUTTON_SELECT },
    {PLA_SELECT_REL,        BUTTON_RC_MODE|BUTTON_REL,          BUTTON_RC_MODE },
    {PLA_SELECT_REPEAT,     BUTTON_SELECT|BUTTON_REPEAT,        BUTTON_NONE },
    {PLA_SELECT_REPEAT,     BUTTON_RC_MODE|BUTTON_REPEAT,       BUTTON_NONE },
#elif (CONFIG_KEYPAD == GIGABEAT_PAD \
    || CONFIG_KEYPAD == SANSA_E200_PAD \
    || CONFIG_KEYPAD == SANSA_C200_PAD \
    || CONFIG_KEYPAD == SANSA_CLIP_PAD \
    || CONFIG_KEYPAD == SANSA_M200_PAD \
    || CONFIG_KEYPAD == MROBE100_PAD \
    || CONFIG_KEYPAD == PHILIPS_HDD1630_PAD \
    || CONFIG_KEYPAD == SANSA_CONNECT_PAD \
    || CONFIG_KEYPAD == HM60X_PAD \
    || CONFIG_KEYPAD == HM801_PAD)
    {PLA_CANCEL,            BUTTON_POWER|BUTTON_REL,            BUTTON_POWER},
    {PLA_EXIT,              BUTTON_POWER|BUTTON_REPEAT,         BUTTON_NONE},
    {PLA_SELECT,            BUTTON_SELECT,                      BUTTON_NONE},
    {PLA_SELECT_REL,        BUTTON_SELECT|BUTTON_REL,           BUTTON_SELECT},
    {PLA_SELECT_REPEAT,     BUTTON_SELECT|BUTTON_REPEAT,        BUTTON_NONE},
#elif  (CONFIG_KEYPAD == GIGABEAT_S_PAD) \
    || (CONFIG_KEYPAD == SAMSUNG_YPR0_PAD)
    {PLA_CANCEL,            BUTTON_BACK,                        BUTTON_NONE},
    {PLA_EXIT,              BUTTON_MENU,                        BUTTON_NONE},
    {PLA_SELECT,            BUTTON_SELECT,                      BUTTON_NONE},
    {PLA_SELECT_REL,        BUTTON_SELECT|BUTTON_REL,           BUTTON_SELECT},
    {PLA_SELECT_REPEAT,     BUTTON_SELECT|BUTTON_REPEAT,        BUTTON_NONE},
#elif (CONFIG_KEYPAD == RECORDER_PAD)
    {PLA_CANCEL,            BUTTON_ON,                          BUTTON_NONE},
    {PLA_EXIT,              BUTTON_OFF,                         BUTTON_NONE},
    {PLA_SELECT,            BUTTON_PLAY,                        BUTTON_NONE},
    {PLA_SELECT_REL,        BUTTON_PLAY|BUTTON_REL,             BUTTON_PLAY},
    {PLA_SELECT_REPEAT,     BUTTON_PLAY|BUTTON_REPEAT,          BUTTON_NONE},
#elif (CONFIG_KEYPAD == ARCHOS_AV300_PAD)
    {PLA_CANCEL,            BUTTON_OFF|BUTTON_REL,              BUTTON_OFF},
    {PLA_EXIT,              BUTTON_OFF|BUTTON_REPEAT,           BUTTON_NONE},
    {PLA_SELECT,            BUTTON_SELECT,                      BUTTON_NONE},
    {PLA_SELECT_REL,        BUTTON_SELECT|BUTTON_REL,           BUTTON_SELECT},
    {PLA_SELECT_REPEAT,     BUTTON_SELECT|BUTTON_REPEAT,        BUTTON_NONE},
#elif (CONFIG_KEYPAD == ONDIO_PAD)
    {PLA_CANCEL,            BUTTON_OFF|BUTTON_REL,              BUTTON_OFF},
    {PLA_EXIT,              BUTTON_OFF|BUTTON_REPEAT,           BUTTON_NONE},
    {PLA_SELECT,            BUTTON_MENU,                        BUTTON_NONE},
    {PLA_SELECT_REL,        BUTTON_MENU|BUTTON_REL,             BUTTON_MENU},
    {PLA_SELECT_REPEAT,     BUTTON_MENU|BUTTON_REPEAT,          BUTTON_NONE},
#elif (CONFIG_KEYPAD == PLAYER_PAD)
    {PLA_CANCEL,            BUTTON_MENU|BUTTON_REL,             BUTTON_MENU},
    {PLA_EXIT,              BUTTON_MENU|BUTTON_REPEAT,          BUTTON_NONE},
    {PLA_SELECT,            BUTTON_ON,                          BUTTON_NONE},
    {PLA_SELECT_REL,        BUTTON_ON|BUTTON_REL,               BUTTON_ON},
    {PLA_SELECT_REPEAT,     BUTTON_ON|BUTTON_REPEAT,            BUTTON_NONE},
#elif (CONFIG_KEYPAD == SANSA_FUZE_PAD)
    {PLA_CANCEL,            BUTTON_HOME|BUTTON_REL,             BUTTON_HOME},
    {PLA_EXIT,              BUTTON_HOME|BUTTON_REPEAT,          BUTTON_NONE},
    {PLA_SELECT,            BUTTON_SELECT,                      BUTTON_NONE},
    {PLA_SELECT_REL,        BUTTON_SELECT|BUTTON_REL,           BUTTON_SELECT},
    {PLA_SELECT_REPEAT,     BUTTON_SELECT|BUTTON_REPEAT,        BUTTON_NONE},
#elif (CONFIG_KEYPAD == IRIVER_H10_PAD)
    {PLA_CANCEL,            BUTTON_REW,                         BUTTON_NONE},
    {PLA_EXIT,              BUTTON_POWER,                       BUTTON_NONE},
    {PLA_SELECT,            BUTTON_PLAY,                        BUTTON_NONE},
    {PLA_SELECT_REL,        BUTTON_PLAY|BUTTON_REL,             BUTTON_PLAY},
    {PLA_SELECT_REPEAT,     BUTTON_PLAY|BUTTON_REPEAT,          BUTTON_NONE},
#elif (CONFIG_KEYPAD == IRIVER_IFP7XX_PAD)
    {PLA_CANCEL,            BUTTON_EQ|BUTTON_REL,               BUTTON_EQ},
    {PLA_EXIT,              BUTTON_EQ|BUTTON_REPEAT,            BUTTON_NONE},
    {PLA_SELECT,            BUTTON_SELECT,                      BUTTON_NONE},
    {PLA_SELECT_REL,        BUTTON_SELECT|BUTTON_REL,           BUTTON_SELECT},
    {PLA_SELECT_REPEAT,     BUTTON_SELECT|BUTTON_REPEAT,        BUTTON_NONE},
#elif (CONFIG_KEYPAD == MROBE500_PAD)
    {PLA_CANCEL,            BUTTON_POWER|BUTTON_REL,            BUTTON_POWER},
    {PLA_EXIT,              BUTTON_POWER|BUTTON_REPEAT,         BUTTON_NONE},
    {PLA_SELECT,            BUTTON_RC_HEART,                    BUTTON_NONE},
    {PLA_SELECT_REL,        BUTTON_RC_HEART|BUTTON_REL,         BUTTON_RC_HEART},
    {PLA_SELECT_REPEAT,     BUTTON_RC_HEART|BUTTON_REPEAT,      BUTTON_NONE},
#elif (CONFIG_KEYPAD == COWON_D2_PAD)
    {PLA_CANCEL,            BUTTON_POWER|BUTTON_REL,            BUTTON_POWER},
    {PLA_EXIT,              BUTTON_POWER|BUTTON_REPEAT,         BUTTON_NONE},
    {PLA_SELECT,            BUTTON_MINUS,                       BUTTON_NONE},
    {PLA_SELECT_REL,        BUTTON_MINUS|BUTTON_REL,            BUTTON_MINUS},
    {PLA_SELECT_REPEAT,     BUTTON_MINUS|BUTTON_REPEAT,         BUTTON_NONE},
#elif (CONFIG_KEYPAD == ANDROID_PAD)
    {PLA_CANCEL,            BUTTON_BACK|BUTTON_REL,             BUTTON_BACK},
    {PLA_EXIT,              BUTTON_BACK|BUTTON_REPEAT,          BUTTON_NONE},
    {PLA_SELECT,            BUTTON_MENU,                        BUTTON_NONE},
    {PLA_SELECT_REL,        BUTTON_MENU|BUTTON_REL,             BUTTON_MENU},
    {PLA_SELECT_REPEAT,     BUTTON_MENU|BUTTON_REPEAT,          BUTTON_NONE},
#elif (CONFIG_KEYPAD == IAUDIO_M3_PAD)
    {PLA_CANCEL,            BUTTON_RC_REC|BUTTON_REL,           BUTTON_RC_REC},
    {PLA_EXIT,              BUTTON_RC_REC|BUTTON_REPEAT,        BUTTON_NONE},
    {PLA_SELECT,            BUTTON_RC_MODE,                     BUTTON_NONE},
    {PLA_SELECT_REL,        BUTTON_RC_MODE|BUTTON_REL,          BUTTON_RC_MODE},
    {PLA_SELECT_REPEAT,     BUTTON_RC_MODE|BUTTON_REPEAT,       BUTTON_NONE},
#elif (CONFIG_KEYPAD == PHILIPS_HDD6330_PAD) \
    || (CONFIG_KEYPAD == PHILIPS_SA9200_PAD)
    {PLA_EXIT,              BUTTON_POWER,                       BUTTON_NONE},
    {PLA_CANCEL,            BUTTON_MENU,                        BUTTON_NONE},
    {PLA_SELECT,            BUTTON_PLAY,                        BUTTON_NONE},
    {PLA_SELECT_REL,        BUTTON_PLAY|BUTTON_REL,             BUTTON_PLAY},
    {PLA_SELECT_REPEAT,     BUTTON_PLAY|BUTTON_REPEAT,          BUTTON_NONE},
#elif (CONFIG_KEYPAD == IAUDIO67_PAD)
    {PLA_CANCEL,            BUTTON_POWER|BUTTON_REL,            BUTTON_POWER},
    {PLA_EXIT,              BUTTON_POWER|BUTTON_REPEAT,         BUTTON_NONE},
    {PLA_SELECT,            BUTTON_PLAY,                        BUTTON_NONE},
    {PLA_SELECT_REL,        BUTTON_PLAY|BUTTON_REL,             BUTTON_PLAY},
    {PLA_SELECT_REPEAT,     BUTTON_PLAY|BUTTON_REPEAT           BUTTON_NONE},
#elif (CONFIG_KEYPAD == CREATIVEZVM_PAD)
    {PLA_CANCEL,            BUTTON_BACK|BUTTON_REL,             BUTTON_BACK},
    {PLA_EXIT,              BUTTON_BACK|BUTTON_REPEAT,          BUTTON_NONE},
    {PLA_SELECT,            BUTTON_SELECT,                      BUTTON_NONE},
    {PLA_SELECT_REL,        BUTTON_SELECT|BUTTON_REL,           BUTTON_SELECT},
    {PLA_SELECT_REPEAT,     BUTTON_SELECT|BUTTON_REPEAT,        BUTTON_NONE},
#elif (CONFIG_KEYPAD == ONDAVX747_PAD)
    {PLA_CANCEL,            BUTTON_POWER|BUTTON_REL,            BUTTON_POWER},
    {PLA_EXIT,              BUTTON_POWER|BUTTON_REPEAT,         BUTTON_NONE},
    {PLA_SELECT,            BUTTON_VOL_UP,                      BUTTON_NONE},
    {PLA_SELECT_REL,        BUTTON_VOL_UP|BUTTON_REL,           BUTTON_VOL_UP},
    {PLA_SELECT_REPEAT,     BUTTON_VOL_UP|BUTTON_REPEAT,        BUTTON_NONE},
#elif  (CONFIG_KEYPAD == SAMSUNG_YH820_PAD) \
    || (CONFIG_KEYPAD == SAMSUNG_YH920_PAD)
    {PLA_CANCEL,            BUTTON_REW|BUTTON_REL,              BUTTON_REW},
    {PLA_EXIT,              BUTTON_REW|BUTTON_REPEAT,           BUTTON_NONE},
    {PLA_SELECT,            BUTTON_PLAY,                        BUTTON_NONE},
    {PLA_SELECT_REL,        BUTTON_PLAY|BUTTON_REL,             BUTTON_PLAY},
    {PLA_SELECT_REPEAT,     BUTTON_PLAY|BUTTON_REPEAT,          BUTTON_NONE},
#elif (CONFIG_KEYPAD == PBELL_VIBE500_PAD)
    {PLA_CANCEL,            BUTTON_MENU,                        BUTTON_NONE},
    {PLA_EXIT,              BUTTON_REC,                         BUTTON_NONE},
    {PLA_SELECT,            BUTTON_OK,                          BUTTON_NONE},
    {PLA_SELECT_REL,        BUTTON_OK|BUTTON_REL,               BUTTON_OK  },
    {PLA_SELECT_REPEAT,     BUTTON_OK|BUTTON_REPEAT,            BUTTON_NONE},
#elif (CONFIG_KEYPAD == MPIO_HD200_PAD)                                      
    {PLA_CANCEL,            BUTTON_REC,                         BUTTON_NONE},
    {PLA_EXIT,              (BUTTON_REC|BUTTON_PLAY),           BUTTON_NONE},
    {PLA_SELECT,            BUTTON_FUNC,                        BUTTON_NONE},
    {PLA_SELECT_REL,        BUTTON_FUNC|BUTTON_REL,             BUTTON_FUNC},
    {PLA_SELECT_REPEAT,     BUTTON_FUNC|BUTTON_REPEAT,          BUTTON_NONE},
#elif (CONFIG_KEYPAD == MPIO_HD300_PAD)                                      
    {PLA_CANCEL,            BUTTON_MENU,                        BUTTON_NONE},
    {PLA_EXIT,              BUTTON_MENU|BUTTON_REPEAT,          BUTTON_NONE},
    {PLA_SELECT,            BUTTON_ENTER,                       BUTTON_NONE},
    {PLA_SELECT_REL,        BUTTON_ENTER|BUTTON_REL,            BUTTON_ENTER},
    {PLA_SELECT_REPEAT,     BUTTON_ENTER|BUTTON_REPEAT,         BUTTON_NONE},
#elif (CONFIG_KEYPAD == RK27XX_GENERIC_PAD)                                      
    {PLA_CANCEL,            BUTTON_M,                           BUTTON_NONE},
    {PLA_EXIT,              BUTTON_M|BUTTON_REPEAT,             BUTTON_NONE},
    {PLA_SELECT,            BUTTON_PLAY,                        BUTTON_NONE},
    {PLA_SELECT_REL,        BUTTON_PLAY|BUTTON_REL,             BUTTON_PLAY},
    {PLA_SELECT_REPEAT,     BUTTON_PLAY|BUTTON_REPEAT,          BUTTON_NONE},
#elif (CONFIG_KEYPAD == SANSA_FUZEPLUS_PAD) || (CONFIG_KEYPAD == CREATIVE_ZEN_PAD)
    {PLA_CANCEL,            BUTTON_BACK,                        BUTTON_NONE},
    {PLA_EXIT,              BUTTON_POWER,                       BUTTON_NONE},
    {PLA_SELECT,            BUTTON_SELECT,                      BUTTON_NONE},
    {PLA_SELECT_REL,        BUTTON_SELECT|BUTTON_REL,           BUTTON_SELECT},
    {PLA_SELECT_REPEAT,     BUTTON_SELECT|BUTTON_REPEAT,        BUTTON_NONE},
#elif (CONFIG_KEYPAD == CREATIVE_ZENXFI3_PAD)
    {PLA_CANCEL,            BUTTON_POWER|BUTTON_REL,            BUTTON_NONE},
    {PLA_EXIT,              BUTTON_POWER|BUTTON_REPEAT,         BUTTON_NONE},
    {PLA_SELECT,            BUTTON_PLAY,                        BUTTON_NONE},
    {PLA_SELECT_REL,        BUTTON_PLAY|BUTTON_REL,             BUTTON_PLAY},
    {PLA_SELECT_REPEAT,     BUTTON_PLAY|BUTTON_REPEAT,          BUTTON_NONE},
#elif (CONFIG_KEYPAD == SONY_NWZ_PAD)
    {PLA_CANCEL,            BUTTON_BACK,                        BUTTON_NONE},
    {PLA_EXIT,              BUTTON_POWER,                       BUTTON_NONE},
    {PLA_SELECT,            BUTTON_PLAY,                        BUTTON_NONE},
    {PLA_SELECT_REL,        BUTTON_PLAY|BUTTON_REL,             BUTTON_PLAY},
    {PLA_SELECT_REPEAT,     BUTTON_PLAY|BUTTON_REPEAT,          BUTTON_NONE},
#elif (CONFIG_KEYPAD == DX50_PAD)
    {PLA_CANCEL,            BUTTON_LEFT|BUTTON_REL,             BUTTON_NONE},
    {PLA_EXIT,              BUTTON_POWER|BUTTON_REL,            BUTTON_NONE},
    {PLA_SELECT,            BUTTON_PLAY,                        BUTTON_NONE},
    {PLA_SELECT_REL,        BUTTON_PLAY|BUTTON_REL,             BUTTON_NONE},
    {PLA_SELECT_REPEAT,     BUTTON_PLAY|BUTTON_REPEAT,          BUTTON_NONE},

#else
#   ifndef HAVE_TOUCHSCREEN
#       error pluginlib_actions: No actions defined
#   endif
#endif
    LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_PLUGIN),
};

static struct button_mapping **plugin_context_order;
static int plugin_context_count = 0;
static int last_context = 0; /* index into plugin_context_order 
                                of the last context returned */

static const struct button_mapping* get_context_map(int context)
{
    (void)context;
    if (last_context<plugin_context_count)
        return plugin_context_order[last_context++];
    else return NULL;
}

int pluginlib_getaction(int timeout,
                        const struct button_mapping *plugin_contexts[],
                        int count)
{
    plugin_context_order = (struct button_mapping **)plugin_contexts;
    plugin_context_count = count;
    last_context = 0;
    return rb->get_custom_action(CONTEXT_PLUGIN,timeout,get_context_map);
}