Disable rombox on ondio SP. It can be reenabled if the binsize goes down again.
[kugel-rb.git] / uisimulator / sdl / button.c
blob52646220e776a26042224a0d2021dcda40849abd
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
10 * Copyright (C) 2002 by Felix Arends
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
20 ****************************************************************************/
22 #include "uisdl.h"
23 #include "lcd-charcells.h"
24 #include "lcd-remote.h"
25 #include "config.h"
26 #include "button.h"
27 #include "kernel.h"
28 #include "backlight.h"
29 #include "misc.h"
30 #include "sim_tasks.h"
31 #include "button-sdl.h"
32 #include "backlight.h"
34 #include "debug.h"
36 #ifdef HAVE_TOUCHSCREEN
37 #include "touchscreen.h"
38 static int mouse_coords = 0;
39 #endif
40 /* how long until repeat kicks in */
41 #define REPEAT_START 6
43 /* the speed repeat starts at */
44 #define REPEAT_INTERVAL_START 4
46 /* speed repeat finishes at */
47 #define REPEAT_INTERVAL_FINISH 2
49 #ifdef HAVE_TOUCHSCREEN
50 #define USB_KEY SDLK_c /* SDLK_u is taken by BUTTON_MIDLEFT */
51 #else
52 #define USB_KEY SDLK_u
53 #endif
55 #if defined(IRIVER_H100_SERIES) || defined (IRIVER_H300_SERIES)
56 int _remote_type=REMOTETYPE_H100_LCD;
58 int remote_type(void)
60 return _remote_type;
62 #endif
64 struct event_queue button_queue;
66 static int btn = 0; /* Hopefully keeps track of currently pressed keys... */
68 #ifdef HAS_BUTTON_HOLD
69 bool hold_button_state = false;
70 bool button_hold(void) {
71 return hold_button_state;
73 #endif
75 #ifdef HAS_REMOTE_BUTTON_HOLD
76 bool remote_hold_button_state = false;
77 bool remote_button_hold(void) {
78 return remote_hold_button_state;
80 #endif
82 void button_event(int key, bool pressed)
84 int new_btn = 0;
85 static bool usb_connected = false;
86 if (usb_connected && key != USB_KEY)
87 return;
88 switch (key)
91 #ifdef HAVE_TOUCHSCREEN
92 case BUTTON_TOUCHSCREEN:
93 switch (touchscreen_get_mode())
95 case TOUCHSCREEN_POINT:
96 new_btn = BUTTON_TOUCHSCREEN;
97 break;
98 case TOUCHSCREEN_BUTTON:
100 static int touchscreen_buttons[3][3] = {
101 {BUTTON_TOPLEFT, BUTTON_TOPMIDDLE, BUTTON_TOPRIGHT},
102 {BUTTON_MIDLEFT, BUTTON_CENTER, BUTTON_MIDRIGHT},
103 {BUTTON_BOTTOMLEFT, BUTTON_BOTTOMMIDDLE, BUTTON_BOTTOMRIGHT},
105 int px_x = ((mouse_coords&0xffff0000)>>16);
106 int px_y = ((mouse_coords&0x0000ffff));
107 new_btn = touchscreen_buttons[px_y/(LCD_HEIGHT/3)][px_x/(LCD_WIDTH/3)];
108 break;
111 break;
112 case SDLK_KP7:
113 case SDLK_7:
114 new_btn = BUTTON_TOPLEFT;
115 break;
116 case SDLK_KP8:
117 case SDLK_8:
118 case SDLK_UP:
119 new_btn = BUTTON_TOPMIDDLE;
120 break;
121 case SDLK_KP9:
122 case SDLK_9:
123 new_btn = BUTTON_TOPRIGHT;
124 break;
125 case SDLK_KP4:
126 case SDLK_u:
127 case SDLK_LEFT:
128 new_btn = BUTTON_MIDLEFT;
129 break;
130 case SDLK_KP5:
131 case SDLK_i:
132 new_btn = BUTTON_CENTER;
133 break;
134 case SDLK_KP6:
135 case SDLK_o:
136 case SDLK_RIGHT:
137 new_btn = BUTTON_MIDRIGHT;
138 break;
139 case SDLK_KP1:
140 case SDLK_j:
141 new_btn = BUTTON_BOTTOMLEFT;
142 break;
143 case SDLK_KP2:
144 case SDLK_k:
145 case SDLK_DOWN:
146 new_btn = BUTTON_BOTTOMMIDDLE;
147 break;
148 case SDLK_KP3:
149 case SDLK_l:
150 new_btn = BUTTON_BOTTOMRIGHT;
151 break;
152 case SDLK_F4:
153 if(pressed)
155 touchscreen_set_mode(touchscreen_get_mode() == TOUCHSCREEN_POINT ? TOUCHSCREEN_BUTTON : TOUCHSCREEN_POINT);
156 printf("Touchscreen mode: %s\n", touchscreen_get_mode() == TOUCHSCREEN_POINT ? "TOUCHSCREEN_POINT" : "TOUCHSCREEN_BUTTON");
158 break;
160 #endif
161 case USB_KEY:
162 if (!pressed)
164 usb_connected = !usb_connected;
165 if (usb_connected)
166 queue_post(&button_queue, SYS_USB_CONNECTED, 0);
167 else
168 queue_post(&button_queue, SYS_USB_DISCONNECTED, 0);
170 return;
172 #ifdef HAS_BUTTON_HOLD
173 case SDLK_h:
174 if(pressed)
176 hold_button_state = !hold_button_state;
177 DEBUGF("Hold button is %s\n", hold_button_state?"ON":"OFF");
179 return;
180 #endif
182 #ifdef HAS_REMOTE_BUTTON_HOLD
183 case SDLK_j:
184 if(pressed)
186 remote_hold_button_state = !remote_hold_button_state;
187 DEBUGF("Remote hold button is %s\n",
188 remote_hold_button_state?"ON":"OFF");
190 return;
191 #endif
193 #if CONFIG_KEYPAD == GIGABEAT_PAD
194 case SDLK_KP4:
195 case SDLK_LEFT:
196 new_btn = BUTTON_LEFT;
197 break;
198 case SDLK_KP6:
199 case SDLK_RIGHT:
200 new_btn = BUTTON_RIGHT;
201 break;
202 case SDLK_KP8:
203 case SDLK_UP:
204 new_btn = BUTTON_UP;
205 break;
206 case SDLK_KP2:
207 case SDLK_DOWN:
208 new_btn = BUTTON_DOWN;
209 break;
210 case SDLK_KP_PLUS:
211 case SDLK_F8:
212 new_btn = BUTTON_POWER;
213 break;
214 case SDLK_ESCAPE:
215 new_btn = BUTTON_POWER;
216 break;
217 case SDLK_KP_ENTER:
218 case SDLK_RETURN:
219 case SDLK_a:
220 new_btn = BUTTON_A;
221 break;
222 case SDLK_KP5:
223 case SDLK_SPACE:
224 new_btn = BUTTON_SELECT;
225 break;
226 case SDLK_KP_PERIOD:
227 case SDLK_INSERT:
228 new_btn = BUTTON_MENU;
229 break;
230 case SDLK_KP9:
231 new_btn = BUTTON_VOL_UP;
232 break;
233 case SDLK_KP3:
234 new_btn = BUTTON_VOL_DOWN;
235 break;
237 #elif CONFIG_KEYPAD == GIGABEAT_S_PAD
238 case SDLK_KP4:
239 case SDLK_LEFT:
240 new_btn = BUTTON_LEFT;
241 break;
242 case SDLK_KP6:
243 case SDLK_RIGHT:
244 new_btn = BUTTON_RIGHT;
245 break;
246 case SDLK_KP8:
247 case SDLK_UP:
248 new_btn = BUTTON_UP;
249 break;
250 case SDLK_KP2:
251 case SDLK_DOWN:
252 new_btn = BUTTON_DOWN;
253 break;
254 case SDLK_F8:
255 case SDLK_ESCAPE:
256 new_btn = BUTTON_POWER;
257 break;
258 case SDLK_KP_PLUS:
259 case SDLK_KP_ENTER:
260 case SDLK_RETURN:
261 new_btn = BUTTON_PLAY;
262 break;
263 case SDLK_KP7:
264 new_btn = BUTTON_BACK;
265 break;
266 case SDLK_KP5:
267 case SDLK_SPACE:
268 new_btn = BUTTON_SELECT;
269 break;
270 case SDLK_KP9:
271 case SDLK_KP_PERIOD:
272 case SDLK_INSERT:
273 new_btn = BUTTON_MENU;
274 break;
276 #elif CONFIG_KEYPAD == IAUDIO_X5M5_PAD
277 case SDLK_KP4:
278 case SDLK_LEFT:
279 new_btn = BUTTON_LEFT;
280 break;
281 case SDLK_KP6:
282 case SDLK_RIGHT:
283 new_btn = BUTTON_RIGHT;
284 break;
285 case SDLK_KP8:
286 case SDLK_UP:
287 new_btn = BUTTON_UP;
288 break;
289 case SDLK_KP2:
290 case SDLK_DOWN:
291 new_btn = BUTTON_DOWN;
292 break;
293 case SDLK_KP_PLUS:
294 case SDLK_F8:
295 new_btn = BUTTON_PLAY;
296 break;
297 case SDLK_ESCAPE:
298 new_btn = BUTTON_POWER;
299 break;
300 case SDLK_KP_ENTER:
301 case SDLK_RETURN:
302 case SDLK_a:
303 new_btn = BUTTON_POWER;
304 break;
305 case SDLK_KP_DIVIDE:
306 case SDLK_F1:
307 new_btn = BUTTON_REC;
308 break;
309 case SDLK_KP5:
310 case SDLK_SPACE:
311 new_btn = BUTTON_SELECT;
312 break;
314 #elif CONFIG_KEYPAD == IAUDIO_M3_PAD
315 case SDLK_KP4:
316 case SDLK_LEFT:
317 new_btn = BUTTON_LEFT;
318 break;
319 case SDLK_KP6:
320 case SDLK_RIGHT:
321 new_btn = BUTTON_RIGHT;
322 break;
323 case SDLK_KP8:
324 case SDLK_UP:
325 new_btn = BUTTON_VOL_UP;
326 break;
327 case SDLK_KP2:
328 case SDLK_DOWN:
329 new_btn = BUTTON_VOL_DOWN;
330 break;
331 case SDLK_KP_PERIOD:
332 case SDLK_INSERT:
333 new_btn = BUTTON_MODE;
334 break;
335 case SDLK_KP_DIVIDE:
336 case SDLK_F1:
337 new_btn = BUTTON_REC;
338 break;
339 case SDLK_KP5:
340 case SDLK_SPACE:
341 new_btn = BUTTON_PLAY;
342 break;
344 #elif (CONFIG_KEYPAD == IPOD_1G2G_PAD) || (CONFIG_KEYPAD == IPOD_3G_PAD) \
345 || (CONFIG_KEYPAD == IPOD_4G_PAD)
346 case SDLK_KP4:
347 case SDLK_LEFT:
348 new_btn = BUTTON_LEFT;
349 break;
350 case SDLK_KP6:
351 case SDLK_RIGHT:
352 new_btn = BUTTON_RIGHT;
353 break;
354 case SDLK_KP8:
355 case SDLK_UP:
356 new_btn = BUTTON_SCROLL_BACK;
357 break;
358 case SDLK_KP2:
359 case SDLK_DOWN:
360 new_btn = BUTTON_SCROLL_FWD;
361 break;
362 case SDLK_KP_PLUS:
363 case SDLK_F8:
364 new_btn = BUTTON_PLAY;
365 break;
366 case SDLK_KP5:
367 case SDLK_SPACE:
368 new_btn = BUTTON_SELECT;
369 break;
370 case SDLK_KP_PERIOD:
371 case SDLK_INSERT:
372 new_btn = BUTTON_MENU;
373 break;
375 #elif CONFIG_KEYPAD == IRIVER_H10_PAD
376 case SDLK_KP4:
377 case SDLK_LEFT:
378 new_btn = BUTTON_LEFT;
379 break;
380 case SDLK_KP6:
381 case SDLK_RIGHT:
382 new_btn = BUTTON_RIGHT;
383 break;
384 case SDLK_KP8:
385 case SDLK_UP:
386 new_btn = BUTTON_SCROLL_UP;
387 break;
388 case SDLK_KP2:
389 case SDLK_DOWN:
390 new_btn = BUTTON_SCROLL_DOWN;
391 break;
392 case SDLK_KP_PLUS:
393 case SDLK_F8:
394 new_btn = BUTTON_POWER;
395 break;
396 case SDLK_ESCAPE:
397 new_btn = BUTTON_POWER;
398 break;
399 case SDLK_KP_DIVIDE:
400 case SDLK_F1:
401 new_btn = BUTTON_REW;
402 break;
403 case SDLK_KP_MULTIPLY:
404 case SDLK_F2:
405 new_btn = BUTTON_FF;
406 break;
407 case SDLK_KP5:
408 case SDLK_SPACE:
409 new_btn = BUTTON_PLAY;
410 break;
412 #elif (CONFIG_KEYPAD == IRIVER_H100_PAD) || (CONFIG_KEYPAD == IRIVER_H300_PAD)
413 case SDLK_t:
414 if(pressed)
415 switch(_remote_type)
417 case REMOTETYPE_UNPLUGGED:
418 _remote_type=REMOTETYPE_H100_LCD;
419 DEBUGF("Changed remote type to H100\n");
420 break;
421 case REMOTETYPE_H100_LCD:
422 _remote_type=REMOTETYPE_H300_LCD;
423 DEBUGF("Changed remote type to H300\n");
424 break;
425 case REMOTETYPE_H300_LCD:
426 _remote_type=REMOTETYPE_H300_NONLCD;
427 DEBUGF("Changed remote type to H300 NON-LCD\n");
428 break;
429 case REMOTETYPE_H300_NONLCD:
430 _remote_type=REMOTETYPE_UNPLUGGED;
431 DEBUGF("Changed remote type to none\n");
432 break;
434 break;
435 case SDLK_KP4:
436 case SDLK_LEFT:
437 new_btn = BUTTON_LEFT;
438 break;
439 case SDLK_KP6:
440 case SDLK_RIGHT:
441 new_btn = BUTTON_RIGHT;
442 break;
443 case SDLK_KP8:
444 case SDLK_UP:
445 new_btn = BUTTON_UP;
446 break;
447 case SDLK_KP2:
448 case SDLK_DOWN:
449 new_btn = BUTTON_DOWN;
450 break;
451 case SDLK_KP_PLUS:
452 case SDLK_F8:
453 new_btn = BUTTON_ON;
454 break;
455 case SDLK_KP_ENTER:
456 case SDLK_RETURN:
457 case SDLK_a:
458 new_btn = BUTTON_OFF;
459 break;
460 case SDLK_KP_DIVIDE:
461 case SDLK_F1:
462 new_btn = BUTTON_REC;
463 break;
464 case SDLK_KP5:
465 case SDLK_SPACE:
466 new_btn = BUTTON_SELECT;
467 break;
468 case SDLK_KP_PERIOD:
469 case SDLK_INSERT:
470 new_btn = BUTTON_MODE;
471 break;
473 #elif CONFIG_KEYPAD == IRIVER_IFP7XX_PAD
474 case SDLK_KP4:
475 case SDLK_LEFT:
476 new_btn = BUTTON_LEFT;
477 break;
478 case SDLK_KP6:
479 case SDLK_RIGHT:
480 new_btn = BUTTON_RIGHT;
481 break;
482 case SDLK_KP8:
483 case SDLK_UP:
484 new_btn = BUTTON_UP;
485 break;
486 case SDLK_KP2:
487 case SDLK_DOWN:
488 new_btn = BUTTON_DOWN;
489 break;
490 case SDLK_KP_PLUS:
491 case SDLK_F8:
492 new_btn = BUTTON_PLAY;
493 break;
494 case SDLK_KP_ENTER:
495 case SDLK_RETURN:
496 case SDLK_a:
497 new_btn = BUTTON_EQ;
498 break;
499 case SDLK_KP5:
500 case SDLK_SPACE:
501 new_btn = BUTTON_SELECT;
502 break;
503 case SDLK_KP_PERIOD:
504 case SDLK_INSERT:
505 new_btn = BUTTON_MODE;
506 break;
508 #elif CONFIG_KEYPAD == ONDIO_PAD
509 case SDLK_KP4:
510 case SDLK_LEFT:
511 new_btn = BUTTON_LEFT;
512 break;
513 case SDLK_KP6:
514 case SDLK_RIGHT:
515 new_btn = BUTTON_RIGHT;
516 break;
517 case SDLK_KP8:
518 case SDLK_UP:
519 new_btn = BUTTON_UP;
520 break;
521 case SDLK_KP2:
522 case SDLK_DOWN:
523 new_btn = BUTTON_DOWN;
524 break;
525 case SDLK_KP_ENTER:
526 case SDLK_RETURN:
527 case SDLK_a:
528 new_btn = BUTTON_OFF;
529 break;
530 case SDLK_KP_PERIOD:
531 case SDLK_INSERT:
532 new_btn = BUTTON_MENU;
533 break;
535 #elif CONFIG_KEYPAD == PLAYER_PAD
536 case SDLK_KP4:
537 case SDLK_LEFT:
538 new_btn = BUTTON_LEFT;
539 break;
540 case SDLK_KP6:
541 case SDLK_RIGHT:
542 new_btn = BUTTON_RIGHT;
543 break;
544 case SDLK_KP8:
545 case SDLK_UP:
546 new_btn = BUTTON_PLAY;
547 break;
548 case SDLK_KP2:
549 case SDLK_DOWN:
550 new_btn = BUTTON_STOP;
551 break;
552 case SDLK_KP_PLUS:
553 case SDLK_F8:
554 new_btn = BUTTON_ON;
555 break;
556 case SDLK_KP_PERIOD:
557 case SDLK_INSERT:
558 new_btn = BUTTON_MENU;
559 break;
561 #elif CONFIG_KEYPAD == RECORDER_PAD
562 case SDLK_KP4:
563 case SDLK_LEFT:
564 new_btn = BUTTON_LEFT;
565 break;
566 case SDLK_KP6:
567 case SDLK_RIGHT:
568 new_btn = BUTTON_RIGHT;
569 break;
570 case SDLK_KP8:
571 case SDLK_UP:
572 new_btn = BUTTON_UP;
573 break;
574 case SDLK_KP2:
575 case SDLK_DOWN:
576 new_btn = BUTTON_DOWN;
577 break;
578 case SDLK_KP_PLUS:
579 case SDLK_F8:
580 new_btn = BUTTON_ON;
581 break;
582 case SDLK_KP_ENTER:
583 case SDLK_RETURN:
584 case SDLK_a:
585 new_btn = BUTTON_OFF;
586 break;
587 case SDLK_KP_DIVIDE:
588 case SDLK_F1:
589 new_btn = BUTTON_F1;
590 break;
591 case SDLK_KP_MULTIPLY:
592 case SDLK_F2:
593 new_btn = BUTTON_F2;
594 break;
595 case SDLK_KP_MINUS:
596 case SDLK_F3:
597 new_btn = BUTTON_F3;
598 break;
599 case SDLK_KP5:
600 case SDLK_SPACE:
601 new_btn = BUTTON_PLAY;
602 break;
604 #elif CONFIG_KEYPAD == ARCHOS_AV300_PAD
605 case SDLK_KP4:
606 case SDLK_LEFT:
607 new_btn = BUTTON_LEFT;
608 break;
609 case SDLK_KP6:
610 case SDLK_RIGHT:
611 new_btn = BUTTON_RIGHT;
612 break;
613 case SDLK_KP8:
614 case SDLK_UP:
615 new_btn = BUTTON_UP;
616 break;
617 case SDLK_KP2:
618 case SDLK_DOWN:
619 new_btn = BUTTON_DOWN;
620 break;
621 case SDLK_KP_PLUS:
622 case SDLK_F8:
623 new_btn = BUTTON_ON;
624 break;
625 case SDLK_KP_ENTER:
626 case SDLK_RETURN:
627 case SDLK_a:
628 new_btn = BUTTON_OFF;
629 break;
630 case SDLK_KP_DIVIDE:
631 case SDLK_F1:
632 new_btn = BUTTON_F1;
633 break;
634 case SDLK_KP_MULTIPLY:
635 case SDLK_F2:
636 new_btn = BUTTON_F2;
637 break;
638 case SDLK_KP_MINUS:
639 case SDLK_F3:
640 new_btn = BUTTON_F3;
641 break;
642 case SDLK_KP5:
643 case SDLK_SPACE:
644 new_btn = BUTTON_SELECT;
645 break;
647 #elif CONFIG_KEYPAD == SANSA_E200_PAD
648 case SDLK_KP4:
649 case SDLK_LEFT:
650 new_btn = BUTTON_LEFT;
651 break;
652 case SDLK_KP6:
653 case SDLK_RIGHT:
654 new_btn = BUTTON_RIGHT;
655 break;
656 case SDLK_KP8:
657 case SDLK_UP:
658 new_btn = BUTTON_SCROLL_BACK;
659 break;
660 case SDLK_KP2:
661 case SDLK_DOWN:
662 new_btn = BUTTON_SCROLL_FWD;
663 break;
664 case SDLK_KP9:
665 case SDLK_PAGEUP:
666 new_btn = BUTTON_UP;
667 break;
668 case SDLK_KP3:
669 case SDLK_PAGEDOWN:
670 new_btn = BUTTON_DOWN;
671 break;
672 case SDLK_KP1:
673 case SDLK_HOME:
674 new_btn = BUTTON_POWER;
675 break;
676 case SDLK_KP7:
677 case SDLK_END:
678 new_btn = BUTTON_REC;
679 break;
680 case SDLK_KP5:
681 case SDLK_SPACE:
682 new_btn = BUTTON_SELECT;
683 break;
685 #elif CONFIG_KEYPAD == SANSA_C200_PAD
686 case SDLK_KP4:
687 case SDLK_LEFT:
688 new_btn = BUTTON_LEFT;
689 break;
690 case SDLK_KP6:
691 case SDLK_RIGHT:
692 new_btn = BUTTON_RIGHT;
693 break;
694 case SDLK_KP8:
695 case SDLK_UP:
696 new_btn = BUTTON_UP;
697 break;
698 case SDLK_KP2:
699 case SDLK_DOWN:
700 new_btn = BUTTON_DOWN;
701 break;
702 case SDLK_KP3:
703 new_btn = BUTTON_POWER;
704 break;
705 case SDLK_KP1:
706 new_btn = BUTTON_REC;
707 break;
708 case SDLK_KP5:
709 case SDLK_KP_ENTER:
710 case SDLK_RETURN:
711 new_btn = BUTTON_SELECT;
712 break;
713 case SDLK_KP7:
714 new_btn = BUTTON_VOL_DOWN;
715 break;
716 case SDLK_KP9:
717 new_btn = BUTTON_VOL_UP;
718 break;
720 #elif CONFIG_KEYPAD == MROBE500_PAD
721 case SDLK_F9:
722 new_btn = BUTTON_RC_HEART;
723 break;
724 case SDLK_F10:
725 new_btn = BUTTON_RC_MODE;
726 break;
727 case SDLK_F11:
728 new_btn = BUTTON_RC_VOL_DOWN;
729 break;
730 case SDLK_F12:
731 new_btn = BUTTON_RC_VOL_UP;
732 break;
733 case SDLK_MINUS:
734 case SDLK_LESS:
735 case SDLK_LEFTBRACKET:
736 case SDLK_KP_DIVIDE:
737 new_btn = BUTTON_LEFT;
738 break;
739 case SDLK_PLUS:
740 case SDLK_GREATER:
741 case SDLK_RIGHTBRACKET:
742 case SDLK_KP_MULTIPLY:
743 new_btn = BUTTON_RIGHT;
744 break;
745 case SDLK_PAGEUP:
746 new_btn = BUTTON_RC_PLAY;
747 break;
748 case SDLK_PAGEDOWN:
749 new_btn = BUTTON_RC_DOWN;
750 break;
751 case SDLK_F8:
752 case SDLK_ESCAPE:
753 new_btn = BUTTON_POWER;
754 break;
755 #elif CONFIG_KEYPAD == MROBE100_PAD
756 case SDLK_F9:
757 new_btn = BUTTON_RC_HEART;
758 break;
759 case SDLK_F10:
760 new_btn = BUTTON_RC_MODE;
761 break;
762 case SDLK_F11:
763 new_btn = BUTTON_RC_VOL_DOWN;
764 break;
765 case SDLK_F12:
766 new_btn = BUTTON_RC_VOL_UP;
767 break;
768 case SDLK_LEFT:
769 new_btn = BUTTON_RC_FF;
770 break;
771 case SDLK_RIGHT:
772 new_btn = BUTTON_RC_REW;
773 break;
774 case SDLK_UP:
775 new_btn = BUTTON_RC_PLAY;
776 break;
777 case SDLK_DOWN:
778 new_btn = BUTTON_RC_DOWN;
779 break;
780 case SDLK_KP1:
781 new_btn = BUTTON_DISPLAY;
782 break;
783 case SDLK_KP7:
784 new_btn = BUTTON_MENU;
785 break;
786 case SDLK_KP9:
787 new_btn = BUTTON_PLAY;
788 break;
789 case SDLK_KP4:
790 new_btn = BUTTON_LEFT;
791 break;
792 case SDLK_KP6:
793 new_btn = BUTTON_RIGHT;
794 break;
795 case SDLK_KP8:
796 new_btn = BUTTON_UP;
797 break;
798 case SDLK_KP2:
799 new_btn = BUTTON_DOWN;
800 break;
801 case SDLK_KP5:
802 case SDLK_SPACE:
803 new_btn = BUTTON_SELECT;
804 break;
805 case SDLK_KP_MULTIPLY:
806 case SDLK_F8:
807 case SDLK_ESCAPE:
808 new_btn = BUTTON_POWER;
809 break;
811 #elif CONFIG_KEYPAD == COWON_D2_PAD
812 case SDLK_KP_MULTIPLY:
813 case SDLK_F8:
814 case SDLK_ESCAPE:
815 case SDLK_BACKSPACE:
816 case SDLK_DELETE:
817 new_btn = BUTTON_POWER;
818 break;
819 case SDLK_KP_PLUS:
820 case SDLK_EQUALS:
821 new_btn = BUTTON_PLUS;
822 break;
823 case SDLK_KP_MINUS:
824 case SDLK_MINUS:
825 new_btn = BUTTON_MINUS;
826 break;
827 case SDLK_KP_ENTER:
828 case SDLK_RETURN:
829 case SDLK_SPACE:
830 case SDLK_INSERT:
831 new_btn = BUTTON_MENU;
832 break;
833 #elif CONFIG_KEYPAD == IAUDIO67_PAD
834 case SDLK_UP:
835 new_btn = BUTTON_RIGHT;
836 break;
837 case SDLK_DOWN:
838 new_btn = BUTTON_LEFT;
839 break;
840 case SDLK_LEFT:
841 new_btn = BUTTON_STOP;
842 break;
843 case SDLK_RETURN:
844 case SDLK_KP_ENTER:
845 case SDLK_RIGHT:
846 new_btn = BUTTON_PLAY;
847 break;
848 case SDLK_PLUS:
849 new_btn = BUTTON_VOLUP;
850 break;
851 case SDLK_MINUS:
852 new_btn = BUTTON_VOLDOWN;
853 break;
854 case SDLK_SPACE:
855 new_btn = BUTTON_MENU;
856 break;
857 case SDLK_BACKSPACE:
858 new_btn = BUTTON_POWER;
859 break;
860 #elif CONFIG_KEYPAD == CREATIVEZVM_PAD
861 case SDLK_KP1:
862 new_btn = BUTTON_BACK;
863 break;
864 case SDLK_KP3:
865 new_btn = BUTTON_MENU;
866 break;
867 case SDLK_KP7:
868 new_btn = BUTTON_CUSTOM;
869 break;
870 case SDLK_KP9:
871 new_btn = BUTTON_PLAY;
872 break;
873 case SDLK_KP4:
874 case SDLK_LEFT:
875 new_btn = BUTTON_LEFT;
876 break;
877 case SDLK_KP6:
878 case SDLK_RIGHT:
879 new_btn = BUTTON_RIGHT;
880 break;
881 case SDLK_KP8:
882 case SDLK_UP:
883 new_btn = BUTTON_UP;
884 break;
885 case SDLK_KP2:
886 case SDLK_DOWN:
887 new_btn = BUTTON_DOWN;
888 break;
889 case SDLK_KP5:
890 case SDLK_SPACE:
891 new_btn = BUTTON_SELECT;
892 break;
893 case SDLK_KP_MULTIPLY:
894 case SDLK_F8:
895 case SDLK_ESCAPE:
896 new_btn = BUTTON_POWER;
897 break;
898 #elif CONFIG_KEYPAD == CREATIVEZV_PAD
899 case SDLK_KP1:
900 new_btn = BUTTON_PREV;
901 break;
902 case SDLK_KP3:
903 new_btn = BUTTON_NEXT;
904 break;
905 case SDLK_KP7:
906 new_btn = BUTTON_BACK;
907 break;
908 case SDLK_p:
909 new_btn = BUTTON_PLAY;
910 break;
911 case SDLK_KP9:
912 new_btn = BUTTON_MENU;
913 break;
914 case SDLK_KP4:
915 case SDLK_LEFT:
916 new_btn = BUTTON_LEFT;
917 break;
918 case SDLK_KP6:
919 case SDLK_RIGHT:
920 new_btn = BUTTON_RIGHT;
921 break;
922 case SDLK_KP8:
923 case SDLK_UP:
924 new_btn = BUTTON_UP;
925 break;
926 case SDLK_KP2:
927 case SDLK_DOWN:
928 new_btn = BUTTON_DOWN;
929 break;
930 case SDLK_KP5:
931 case SDLK_SPACE:
932 new_btn = BUTTON_SELECT;
933 break;
934 case SDLK_KP_MULTIPLY:
935 case SDLK_F8:
936 case SDLK_ESCAPE:
937 new_btn = BUTTON_POWER;
938 break;
939 case SDLK_z:
940 new_btn = BUTTON_VOL_DOWN;
941 break;
942 case SDLK_s:
943 new_btn = BUTTON_VOL_UP;
945 #elif CONFIG_KEYPAD == MEIZU_M6SL_PAD
946 case SDLK_KP1:
947 new_btn = BUTTON_PREV;
948 break;
949 case SDLK_KP3:
950 new_btn = BUTTON_NEXT;
951 break;
952 case SDLK_KP_ENTER:
953 case SDLK_RETURN:
954 case SDLK_a:
955 new_btn = BUTTON_PLAY;
956 break;
957 case SDLK_KP_PERIOD:
958 case SDLK_INSERT:
959 new_btn = BUTTON_MENU;
960 break;
961 case SDLK_KP8:
962 case SDLK_UP:
963 new_btn = BUTTON_UP;
964 break;
965 case SDLK_KP2:
966 case SDLK_DOWN:
967 new_btn = BUTTON_DOWN;
968 break;
969 case SDLK_KP5:
970 case SDLK_SPACE:
971 new_btn = BUTTON_SELECT;
972 break;
973 #elif CONFIG_KEYPAD == SANSA_FUZE_PAD
974 case SDLK_KP4:
975 case SDLK_LEFT:
976 new_btn = BUTTON_LEFT;
977 break;
978 case SDLK_KP6:
979 case SDLK_RIGHT:
980 new_btn = BUTTON_RIGHT;
981 break;
982 case SDLK_KP8:
983 case SDLK_UP:
984 new_btn = BUTTON_SCROLL_BACK;
985 break;
986 case SDLK_KP2:
987 case SDLK_DOWN:
988 new_btn = BUTTON_SCROLL_FWD;
989 break;
990 case SDLK_PAGEUP:
991 case SDLK_KP9:
992 new_btn = BUTTON_UP;
993 break;
994 case SDLK_PAGEDOWN:
995 case SDLK_KP3:
996 new_btn = BUTTON_DOWN;
997 break;
998 case SDLK_KP_MINUS:
999 case SDLK_KP1:
1000 new_btn = BUTTON_POWER;
1001 break;
1002 case SDLK_KP_MULTIPLY:
1003 new_btn = BUTTON_HOME;
1004 break;
1005 case SDLK_KP5:
1006 case SDLK_SPACE:
1007 case SDLK_KP_ENTER:
1008 case SDLK_RETURN:
1009 new_btn = BUTTON_SELECT;
1010 break;
1011 #elif CONFIG_KEYPAD == SANSA_CLIP_PAD
1012 case SDLK_KP4:
1013 case SDLK_LEFT:
1014 new_btn = BUTTON_LEFT;
1015 break;
1016 case SDLK_KP6:
1017 case SDLK_RIGHT:
1018 new_btn = BUTTON_RIGHT;
1019 break;
1020 case SDLK_KP8:
1021 case SDLK_UP:
1022 new_btn = BUTTON_UP;
1023 break;
1024 case SDLK_KP2:
1025 case SDLK_DOWN:
1026 new_btn = BUTTON_DOWN;
1027 break;
1029 case SDLK_INSERT:
1030 case SDLK_KP_MULTIPLY:
1031 new_btn = BUTTON_HOME;
1032 break;
1033 case SDLK_SPACE:
1034 case SDLK_KP5:
1035 new_btn = BUTTON_SELECT;
1036 break;
1037 case SDLK_PAGEDOWN:
1038 case SDLK_KP3:
1039 new_btn = BUTTON_VOL_DOWN;
1040 break;
1041 case SDLK_PAGEUP:
1042 case SDLK_KP9:
1043 new_btn = BUTTON_VOL_UP;
1044 break;
1045 case SDLK_ESCAPE:
1046 case SDLK_KP1:
1047 new_btn = BUTTON_POWER;
1048 break;
1049 #elif CONFIG_KEYPAD == SANSA_M200_PAD
1050 case SDLK_KP4:
1051 case SDLK_LEFT:
1052 new_btn = BUTTON_LEFT;
1053 break;
1054 case SDLK_KP6:
1055 case SDLK_RIGHT:
1056 new_btn = BUTTON_RIGHT;
1057 break;
1058 case SDLK_KP8:
1059 case SDLK_UP:
1060 new_btn = BUTTON_UP;
1061 break;
1062 case SDLK_KP2:
1063 case SDLK_DOWN:
1064 new_btn = BUTTON_DOWN;
1065 break;
1066 case SDLK_PLUS:
1067 new_btn = BUTTON_POWER;
1068 break;
1069 case SDLK_KP5:
1070 new_btn = BUTTON_SELECT;
1071 break;
1072 case SDLK_KP7:
1073 new_btn = BUTTON_VOL_DOWN;
1074 break;
1075 case SDLK_KP9:
1076 new_btn = BUTTON_VOL_UP;
1077 break;
1078 #elif CONFIG_KEYPAD == PHILIPS_SA9200_PAD
1079 case SDLK_KP4:
1080 case SDLK_LEFT:
1081 new_btn = BUTTON_LEFT;
1082 break;
1083 case SDLK_KP6:
1084 case SDLK_RIGHT:
1085 new_btn = BUTTON_RIGHT;
1086 break;
1087 case SDLK_KP8:
1088 case SDLK_UP:
1089 new_btn = BUTTON_UP;
1090 break;
1091 case SDLK_KP2:
1092 case SDLK_DOWN:
1093 new_btn = BUTTON_DOWN;
1094 break;
1095 case SDLK_KP1:
1096 new_btn = BUTTON_MENU;
1097 break;
1098 case SDLK_KP5:
1099 case SDLK_SPACE:
1100 new_btn = BUTTON_PLAY;
1101 break;
1102 case SDLK_KP7:
1103 new_btn = BUTTON_PREV;
1104 break;
1105 case SDLK_KP9:
1106 new_btn = BUTTON_NEXT;
1107 break;
1108 case SDLK_KP_ENTER:
1109 case SDLK_RETURN:
1110 new_btn = BUTTON_POWER;
1111 break;
1112 case SDLK_PAGEUP:
1113 new_btn = BUTTON_VOL_UP;
1114 break;
1115 case SDLK_PAGEDOWN:
1116 new_btn = BUTTON_VOL_DOWN;
1117 break;
1118 #elif CONFIG_KEYPAD == PHILIPS_HDD1630_PAD
1119 case SDLK_KP4:
1120 case SDLK_LEFT:
1121 new_btn = BUTTON_LEFT;
1122 break;
1123 case SDLK_KP6:
1124 case SDLK_RIGHT:
1125 new_btn = BUTTON_RIGHT;
1126 break;
1127 case SDLK_KP8:
1128 case SDLK_UP:
1129 new_btn = BUTTON_UP;
1130 break;
1131 case SDLK_KP2:
1132 case SDLK_DOWN:
1133 new_btn = BUTTON_DOWN;
1134 break;
1135 case SDLK_KP5:
1136 case SDLK_SPACE:
1137 new_btn = BUTTON_SELECT;
1138 break;
1139 case SDLK_KP7:
1140 case SDLK_ESCAPE:
1141 new_btn = BUTTON_POWER;
1142 break;
1143 case SDLK_KP1:
1144 new_btn = BUTTON_PLAYLIST;
1145 break;
1146 case SDLK_KP9:
1147 new_btn = BUTTON_VOL_UP;
1148 break;
1149 case SDLK_KP3:
1150 new_btn = BUTTON_VOL_DOWN;
1151 break;
1152 case SDLK_KP_MINUS:
1153 new_btn = BUTTON_MENU;
1154 break;
1155 case SDLK_KP_PLUS:
1156 new_btn = BUTTON_VIEW;
1157 break;
1158 #elif CONFIG_KEYPAD == ONDAVX747_PAD
1159 case SDLK_ESCAPE:
1160 new_btn = BUTTON_POWER;
1161 break;
1162 case SDLK_KP_PLUS:
1163 case SDLK_PLUS:
1164 case SDLK_GREATER:
1165 case SDLK_RIGHTBRACKET:
1166 case SDLK_KP_MULTIPLY:
1167 new_btn = BUTTON_VOL_UP;
1168 break;
1169 case SDLK_KP_MINUS:
1170 case SDLK_MINUS:
1171 case SDLK_LESS:
1172 case SDLK_LEFTBRACKET:
1173 case SDLK_KP_DIVIDE:
1174 new_btn = BUTTON_VOL_DOWN;
1175 break;
1176 case SDLK_KP_ENTER:
1177 case SDLK_RETURN:
1178 new_btn = BUTTON_MENU;
1179 break;
1180 #elif CONFIG_KEYPAD == ONDAVX777_PAD
1181 case SDLK_ESCAPE:
1182 new_btn = BUTTON_POWER;
1183 break;
1184 #elif CONFIG_KEYPAD == SAMSUNG_YH_PAD
1185 case SDLK_KP4:
1186 case SDLK_LEFT:
1187 new_btn = BUTTON_LEFT;
1188 break;
1189 case SDLK_KP6:
1190 case SDLK_RIGHT:
1191 new_btn = BUTTON_RIGHT;
1192 break;
1193 case SDLK_KP8:
1194 case SDLK_UP:
1195 new_btn = BUTTON_UP;
1196 break;
1197 case SDLK_KP2:
1198 case SDLK_DOWN:
1199 new_btn = BUTTON_DOWN;
1200 break;
1201 case SDLK_KP5:
1202 case SDLK_KP_ENTER:
1203 new_btn = BUTTON_PLAY;
1204 break;
1205 case SDLK_KP9:
1206 case SDLK_PAGEUP:
1207 new_btn = BUTTON_FFWD;
1208 break;
1209 #ifdef SAMSUNG_YH820
1210 case SDLK_KP7:
1211 #else
1212 case SDLK_KP3:
1213 #endif
1214 case SDLK_PAGEDOWN:
1215 new_btn = BUTTON_REW;
1216 break;
1217 case SDLK_KP_PLUS:
1218 new_btn = BUTTON_REC;
1219 break;
1220 #elif CONFIG_KEYPAD == MINI2440_PAD
1221 case SDLK_LEFT:
1222 new_btn = BUTTON_LEFT;
1223 break;
1224 case SDLK_RIGHT:
1225 new_btn = BUTTON_RIGHT;
1226 break;
1227 case SDLK_UP:
1228 new_btn = BUTTON_UP;
1229 break;
1230 case SDLK_DOWN:
1231 new_btn = BUTTON_DOWN;
1232 break;
1233 case SDLK_F8:
1234 case SDLK_ESCAPE:
1235 new_btn = BUTTON_POWER;
1236 break;
1237 case SDLK_KP_ENTER:
1238 case SDLK_RETURN:
1239 case SDLK_a:
1240 new_btn = BUTTON_A;
1241 break;
1242 case SDLK_SPACE:
1243 new_btn = BUTTON_SELECT;
1244 break;
1245 case SDLK_KP_PERIOD:
1246 case SDLK_INSERT:
1247 new_btn = BUTTON_MENU;
1248 break;
1249 case SDLK_KP_PLUS:
1250 new_btn = BUTTON_VOL_UP;
1251 break;
1252 case SDLK_KP_MINUS:
1253 new_btn = BUTTON_VOL_DOWN;
1254 break;
1255 #elif CONFIG_KEYPAD == PBELL_VIBE500_PAD
1256 case SDLK_KP4:
1257 case SDLK_LEFT:
1258 new_btn = BUTTON_PREV;
1259 break;
1260 case SDLK_KP6:
1261 case SDLK_RIGHT:
1262 new_btn = BUTTON_NEXT;
1263 break;
1264 case SDLK_KP8:
1265 case SDLK_UP:
1266 new_btn = BUTTON_UP;
1267 break;
1268 case SDLK_KP2:
1269 case SDLK_DOWN:
1270 new_btn = BUTTON_DOWN;
1271 break;
1272 case SDLK_KP7:
1273 new_btn = BUTTON_MENU;
1274 break;
1275 case SDLK_KP9:
1276 new_btn = BUTTON_PLAY;
1277 break;
1278 case SDLK_KP5:
1279 new_btn = BUTTON_OK;
1280 break;
1281 case SDLK_KP_DIVIDE:
1282 new_btn = BUTTON_CANCEL;
1283 break;
1284 case SDLK_KP_PLUS:
1285 new_btn = BUTTON_POWER;
1286 break;
1287 case SDLK_KP_MULTIPLY:
1288 new_btn = BUTTON_REC;
1289 break;
1290 #else
1291 #error No keymap defined!
1292 #endif /* CONFIG_KEYPAD */
1293 case SDLK_KP0:
1294 case SDLK_F5:
1295 if(pressed)
1297 sim_trigger_screendump();
1298 return;
1300 break;
1303 /* Call to make up for scrollwheel target implementation. This is
1304 * not handled in the main button.c driver, but on the target
1305 * implementation (look at button-e200.c for example if you are trying to
1306 * figure out why using button_get_data needed a hack before).
1308 #if defined(BUTTON_SCROLL_FWD) && defined(BUTTON_SCROLL_BACK)
1309 if((new_btn == BUTTON_SCROLL_FWD || new_btn == BUTTON_SCROLL_BACK) &&
1310 pressed)
1312 /* Clear these buttons from the data - adding them to the queue is
1313 * handled in the scrollwheel drivers for the targets. They do not
1314 * store the scroll forward/back buttons in their button data for
1315 * the button_read call.
1317 #ifdef HAVE_BACKLIGHT
1318 backlight_on();
1319 #endif
1320 #ifdef HAVE_BUTTON_LIGHT
1321 buttonlight_on();
1322 #endif
1323 queue_post(&button_queue, new_btn, 1<<24);
1324 new_btn &= ~(BUTTON_SCROLL_FWD | BUTTON_SCROLL_BACK);
1326 #endif
1328 if (pressed)
1329 btn |= new_btn;
1330 else
1331 btn &= ~new_btn;
1333 #if defined(HAVE_BUTTON_DATA) && defined(HAVE_TOUCHSCREEN)
1334 int button_read_device(int* data)
1336 *data = mouse_coords;
1337 #else
1338 int button_read_device(void)
1340 #endif
1342 #ifdef HAS_BUTTON_HOLD
1343 int hold_button = button_hold();
1345 #ifdef HAVE_BACKLIGHT
1346 /* light handling */
1347 static int hold_button_old = false;
1348 if (hold_button != hold_button_old)
1350 hold_button_old = hold_button;
1351 backlight_hold_changed(hold_button);
1353 #endif
1355 if (hold_button)
1356 return BUTTON_NONE;
1357 #endif
1359 return btn;
1363 #ifdef HAVE_TOUCHSCREEN
1364 extern bool debug_wps;
1365 void mouse_tick_task(void)
1367 static int last_check = 0;
1368 int x,y;
1369 if (TIME_BEFORE(current_tick, last_check+(HZ/10)))
1370 return;
1371 last_check = current_tick;
1372 if (SDL_GetMouseState(&x, &y) & SDL_BUTTON(SDL_BUTTON_LEFT))
1374 if(background)
1376 x -= UI_LCD_POSX;
1377 y -= UI_LCD_POSY;
1379 if(x<0 || y<0 || x>SIM_LCD_WIDTH || y>SIM_LCD_HEIGHT)
1380 return;
1383 mouse_coords = (x<<16)|y;
1384 button_event(BUTTON_TOUCHSCREEN, true);
1385 if (debug_wps)
1386 printf("Mouse at: (%d, %d)\n", x, y);
1389 #endif
1391 void button_init_sdl(void)
1393 #ifdef HAVE_TOUCHSCREEN
1394 tick_add_task(mouse_tick_task);
1395 #endif
1398 /* Button maps: simulated key, x, y, radius, name */
1399 /* Run sim with --mapping to get coordinates */
1400 /* or --debugbuttons to check */
1401 /* The First matching button is returned */
1403 #ifdef SANSA_FUZE
1404 struct button_map bm[] = {
1405 { SDLK_KP8, 70, 265, 35, "Scroll Back" },
1406 { SDLK_KP9, 141, 255, 31, "Play" },
1407 { SDLK_KP_MULTIPLY, 228, 267, 18, "Home" },
1408 { SDLK_LEFT, 69, 329, 31, "Left" },
1409 { SDLK_SPACE, 141, 330, 20, "Select" },
1410 { SDLK_RIGHT, 214, 331, 23, "Right" },
1411 { SDLK_KP3, 142, 406, 30, "Menu" },
1412 { SDLK_DOWN, 221, 384, 24, "Scroll Fwd" },
1413 { SDLK_KP_MINUS, 270, 299, 25, "Power" },
1414 { SDLK_h, 269, 358, 26, "Hold" },
1415 { 0, 0, 0, 0, "None" }
1417 #elif defined (SANSA_CLIP)
1418 struct button_map bm[] = {
1419 { SDLK_KP_MULTIPLY, 165, 158, 17, "Home" },
1420 { SDLK_KP5, 102, 230, 29, "Select" },
1421 { SDLK_KP8, 100, 179, 25, "Play" },
1422 { SDLK_KP4, 53, 231, 21, "Left" },
1423 { SDLK_KP6, 147, 232, 19, "Right" },
1424 { SDLK_KP2, 105, 275, 22, "Menu" },
1425 { 0, 0, 0, 0, "None" }
1427 #elif defined (SANSA_C200) || defined(SANSA_C200V2)
1428 struct button_map bm[] = {
1430 { SDLK_KP7, 84, 7, 21, "Vol Down" },
1431 { SDLK_KP9, 158, 7, 20, "Vol Up" },
1432 { SDLK_KP1, 173, 130, 27, "Record" },
1433 { SDLK_KP5, 277, 75, 21, "Select" },
1434 { SDLK_KP4, 233, 75, 24, "Left" },
1435 { SDLK_KP6, 313, 74, 18, "Right" },
1436 { SDLK_KP8, 276, 34, 15, "Play" },
1437 { SDLK_KP2, 277, 119, 17, "Down" },
1438 { SDLK_KP3, 314, 113, 19, "Menu" },
1439 { 0, 0, 0, 0, "None" }
1441 #elif defined (SANSA_E200V2) || defined(SANSA_E200)
1442 struct button_map bm[] = {
1443 { SDLK_KP7, 5, 92, 18, "Record" },
1444 { SDLK_KP9, 128, 295, 43, "Play" },
1445 { SDLK_KP4, 42, 380, 33, "Left" },
1446 { SDLK_KP5, 129, 378, 36, "Select" },
1447 { SDLK_KP6, 218, 383, 30, "Right" },
1448 { SDLK_KP3, 129, 461, 29, "Down" },
1449 { SDLK_KP1, 55, 464, 20, "Menu" },
1450 { SDLK_KP8, 92, 338, 17, "Scroll Back" },
1451 { SDLK_KP2, 167, 342, 17, "Scroll Fwd" },
1452 { 0, 0, 0, 0, "None" }
1454 #elif defined (SANSA_M200V4)
1455 struct button_map bm[] = {
1456 { SDLK_KP_PLUS, 54, 14, 16, "Power" },
1457 { SDLK_KP7, 96, 13, 12, "Vol Down" },
1458 { SDLK_KP9, 139, 14, 14, "Vol Up" },
1459 { SDLK_KP5, 260, 82, 20, "Select" },
1460 { SDLK_KP8, 258, 35, 30, "Play" },
1461 { SDLK_KP4, 214, 84, 25, "Left" },
1462 { SDLK_KP6, 300, 83, 24, "Right" },
1463 { SDLK_KP2, 262, 125, 28, "Repeat" },
1464 { SDLK_h, 113, 151, 21, "Hold" },
1465 { 0, 0, 0, 0, "None" }
1467 #elif defined (IPOD_VIDEO)
1468 struct button_map bm[] = {
1469 { SDLK_KP_PERIOD, 174, 350, 35, "Menu" },
1470 { SDLK_KP8, 110, 380, 33, "Scroll Back" },
1471 { SDLK_KP2, 234, 377, 34, "Scroll Fwd" },
1472 { SDLK_KP4, 78, 438, 47, "Left" },
1473 { SDLK_KP5, 172, 435, 43, "Select" },
1474 { SDLK_KP6, 262, 438, 52, "Right" },
1475 { SDLK_KP_PLUS, 172, 519, 43, "Play" },
1476 { 0, 0, 0 , 0, "None" }
1478 #elif defined (IPOD_MINI) || defined(IPOD_MINI2G)
1479 struct button_map bm[] = {
1480 { SDLK_KP5, 92, 267, 29, "Select" },
1481 { SDLK_KP4, 31, 263, 37, "Left" },
1482 { SDLK_KP6, 150, 268, 33, "Right" },
1483 { SDLK_KP_PERIOD, 93, 209, 30, "Menu" },
1484 { SDLK_KP_PLUS, 93, 324, 25, "Play" },
1485 { SDLK_KP8, 53, 220, 29, "Scroll Back" },
1486 { SDLK_KP2, 134, 219, 31, "Scroll Fwd" },
1487 { 0, 0, 0 , 0, "None" }
1489 #elif defined (IPOD_3G)
1490 struct button_map bm[] = {
1491 { SDLK_KP5, 108, 296, 26, "Select" },
1492 { SDLK_KP8, 70, 255, 26, "Scroll Back" },
1493 { SDLK_KP2, 149, 256, 28, "Scroll Fwd" },
1494 { SDLK_KP4, 27, 186, 22, "Left" },
1495 { SDLK_KP_PERIOD, 82, 185, 22, "Menu" },
1496 { SDLK_KP_PERIOD, 133, 185, 21, "Play" },
1497 { SDLK_KP6, 189, 188, 21, "Right" },
1498 { 0, 0, 0 , 0, "None" }
1500 #elif defined (IPOD_4G)
1501 struct button_map bm[] = {
1502 { SDLK_KP5, 96, 269, 27, "Select" },
1503 { SDLK_KP4, 39, 267, 30, "Left" },
1504 { SDLK_KP6, 153, 270, 27, "Right" },
1505 { SDLK_KP_PERIOD, 96, 219, 30, "Menu" },
1506 { SDLK_KP_PLUS, 95, 326, 27, "Play" },
1507 { SDLK_KP8, 57, 233, 29, "Scroll Back" },
1508 { SDLK_KP2, 132, 226, 29, "Scroll Fwd" },
1509 { 0, 0, 0 , 0, "None" }
1511 #elif defined (IPOD_COLOR)
1512 struct button_map bm[] = {
1513 { SDLK_KP5, 128, 362, 35, "Select" },
1514 { SDLK_KP4, 55, 358, 38, "Left" },
1515 { SDLK_KP6, 203, 359, 39, "Right" },
1516 { SDLK_KP_PERIOD, 128, 282, 34, "Menu" },
1517 { SDLK_KP_PLUS, 129, 439, 41, "Play" },
1518 { SDLK_KP8, 76, 309, 34, "Scroll Back" },
1519 { SDLK_KP2, 182, 311, 45, "Scroll Fwd" },
1520 { 0, 0, 0 , 0, "None" }
1522 #elif defined (IPOD_1G2G)
1523 struct button_map bm[] = {
1524 { SDLK_KP5, 112, 265, 31, "Select" },
1525 { SDLK_KP8, 74, 224, 28, "Scroll Back" },
1526 { SDLK_KP2, 146, 228, 28, "Scroll Fwd" },
1527 /* Dummy button to make crescent shape */
1528 { SDLK_y, 112, 265, 76, "None" },
1529 { SDLK_KP8, 74, 224, 28, "Scroll Back" },
1530 { SDLK_KP2, 146, 228, 28, "Scroll Fwd" },
1531 { SDLK_KP6, 159, 268, 64, "Right" },
1532 { SDLK_KP4, 62, 266, 62, "Left" },
1533 { SDLK_KP_PERIOD, 111, 216, 64, "Menu" },
1534 { SDLK_KP_PLUS, 111, 326, 55, "Down" },
1535 { 0, 0, 0 , 0, "None" }
1537 #elif defined (IPOD_NANO)
1538 struct button_map bm[] = {
1539 { SDLK_KP5, 98, 316, 37, "Select" },
1540 { SDLK_KP4, 37, 312, 28, "Left" },
1541 { SDLK_KP6, 160, 313, 25, "Right" },
1542 { SDLK_KP_PERIOD,102, 256, 23, "Menu" },
1543 { SDLK_KP_PLUS, 99, 378, 28, "Play" },
1544 { SDLK_KP8, 58, 272, 24, "Scroll Back" },
1545 { SDLK_KP2, 141, 274, 22, "Scroll Fwd" },
1546 { 0, 0, 0 , 0, "None" }
1548 #elif defined (IPOD_NANO2G)
1549 struct button_map bm[] = {
1550 { SDLK_KP5, 118, 346, 37, "Select" },
1551 { SDLK_KP4, 51, 345, 28, "Left" },
1552 { SDLK_KP6, 180, 346, 26, "Right" },
1553 { SDLK_KP_PERIOD, 114, 286, 23, "Menu" },
1554 { SDLK_KP_PLUS, 115, 412, 27, "Down" },
1555 { SDLK_KP8, 67, 303, 28, "Scroll Back" },
1556 { SDLK_KP2, 163, 303, 27, "Scroll Fwd" },
1557 { 0, 0, 0 , 0, "None" }
1559 #elif defined (COWON_D2)
1560 struct button_map bm[] = {
1561 { SDLK_DELETE, 51, 14, 17, "Power" },
1562 { SDLK_h, 138, 14, 16, "Hold" },
1563 { SDLK_MINUS, 320, 14, 10, "Minus" },
1564 { SDLK_INSERT, 347, 13, 13, "Menu" },
1565 { SDLK_KP_PLUS, 374, 14, 12, "Plus" },
1566 { 0, 0, 0, 0, "None" }
1568 #elif defined (IAUDIO_M3)
1569 struct button_map bm[] = {
1570 { SDLK_KP5, 256, 72, 29, "Play" },
1571 { SDLK_KP6, 255, 137, 28, "Right" },
1572 { SDLK_KP4, 257, 201, 26, "Left" },
1573 { SDLK_KP8, 338, 31, 27, "Up" },
1574 { SDLK_KP2, 339, 92, 23, "Down" },
1575 { SDLK_KP_DIVIDE, 336, 147, 23, "Rec" },
1576 { SDLK_h, 336, 212, 30, "Hold" },
1577 { 0, 0, 0, 0, "None" }
1579 #elif defined (IAUDIO_M5)
1580 struct button_map bm[] = {
1581 { SDLK_KP_ENTER, 333, 41, 17, "Enter" },
1582 { SDLK_h, 334, 74, 21, "Hold" },
1583 { SDLK_KP_DIVIDE, 333, 142, 24, "Record" },
1584 { SDLK_KP_PLUS, 332, 213, 20, "Play" },
1585 { SDLK_KP5, 250, 291, 19, "Select" },
1586 { SDLK_KP8, 249, 236, 32, "Up" },
1587 { SDLK_KP4, 194, 292, 29, "Left" },
1588 { SDLK_KP6, 297, 290, 27, "Right" },
1589 { SDLK_KP2, 252, 335, 28, "Down" },
1590 { 0, 0, 0, 0, "None" }
1592 #elif defined (IAUDIO_7)
1593 struct button_map bm[] = {
1594 { 0, 0, 0, 0, "None" }
1596 #elif defined (IAUDIO_X5)
1597 struct button_map bm[] = {
1598 { SDLK_KP_ENTER, 275, 38, 17, "Power" },
1599 { SDLK_h, 274, 83, 16, "Hold" },
1600 { SDLK_KP_DIVIDE, 276, 128, 22, "Record" },
1601 { SDLK_KP_PLUS, 274, 186, 22, "Play" },
1602 { SDLK_KP5, 200, 247, 16, "Select" },
1603 { SDLK_KP8, 200, 206, 16, "Up" },
1604 { SDLK_KP4, 163, 248, 19, "Left" },
1605 { SDLK_KP6, 225, 247, 24, "Right" },
1606 { SDLK_KP2, 199, 279, 20, "Down" },
1607 { 0, 0, 0, 0, "None" }
1609 #elif defined (ARCHOS_PLAYER)
1610 struct button_map bm[] = {
1611 { SDLK_KP_PLUS, 79, 252, 23, "On" },
1612 { SDLK_KP_PERIOD, 81, 310, 20, "Menu" },
1613 { SDLK_KP8, 154, 237, 28, "Play" },
1614 { SDLK_KP4, 121, 282, 23, "Left" },
1615 { SDLK_KP6, 187, 282, 22, "Right" },
1616 { SDLK_KP2, 157, 312, 20, "Down" },
1617 { 0, 0, 0, 0, "None" }
1619 #elif defined (ARCHOS_RECORDER)
1620 struct button_map bm[] = {
1621 { SDLK_F1, 94, 205, 22, "F1" },
1622 { SDLK_F2, 136, 204, 21, "F2" },
1623 { SDLK_F3, 174, 204, 24, "F3" },
1624 { SDLK_KP_PLUS, 75, 258, 19, "On" },
1625 { SDLK_KP_ENTER, 76, 307, 15, "Off" },
1626 { SDLK_KP5, 151, 290, 20, "Select" },
1627 { SDLK_KP8, 152, 251, 23, "Up" },
1628 { SDLK_KP4, 113, 288, 26, "Left" },
1629 { SDLK_KP6, 189, 291, 23, "Right" },
1630 { SDLK_KP2, 150, 327, 27, "Down" },
1631 { 0, 0, 0, 0, "None" }
1633 #elif defined (ARCHOS_FMRECORDER) || defined (ARCHOS_RECORDERV2)
1634 struct button_map bm[] = {
1635 { SDLK_F1, 88, 210, 28, "F1" },
1636 { SDLK_F2, 144, 212, 28, "F2" },
1637 { SDLK_F3, 197, 212, 28, "F3" },
1638 { SDLK_KP5, 144, 287, 21, "Select" },
1639 { SDLK_KP_PLUS, 86, 320, 13, "Menu" },
1640 { SDLK_KP_ENTER, 114, 347, 13, "Stop" },
1641 { SDLK_y, 144, 288, 31, "None" },
1642 { SDLK_KP8, 144, 259, 25, "Up" },
1643 { SDLK_KP2, 144, 316, 31, "Down" },
1644 { SDLK_KP6, 171, 287, 32, "Right" },
1645 { SDLK_KP4, 117, 287, 31, "Left" },
1646 { 0, 0, 0, 0, "None" }
1648 #elif defined (ARCHOS_ONDIOSP) || defined (ARCHOS_ONDIOFM)
1649 struct button_map bm[] = {
1650 { SDLK_KP_ENTER, 75, 23, 30, "Enter" },
1651 { SDLK_KP8, 75, 174, 33, "KP8" },
1652 { SDLK_KP4, 26, 186, 48, "KP4" },
1653 { SDLK_KP6, 118, 196, 32, "KP6" },
1654 { SDLK_KP2, 75, 234, 16, "KP2" },
1655 { SDLK_KP_PERIOD, 54, 250, 24, "Period" },
1656 { 0, 0, 0, 0, "None" }
1658 #elif defined (IRIVER_H10)
1659 struct button_map bm[] = {
1660 { SDLK_KP_PLUS, 38, 70, 37, "Power" },
1661 { SDLK_KP4, 123, 194, 26, "Cancel" },
1662 { SDLK_KP6, 257, 195, 34, "Select" },
1663 { SDLK_KP8, 190, 221, 28, "Up" },
1664 { SDLK_KP2, 192, 320, 27, "Down" },
1665 { SDLK_KP_DIVIDE, 349, 49, 20, "Rew" },
1666 { SDLK_KP5, 349, 96, 20, "Play" },
1667 { SDLK_KP_MULTIPLY, 350, 141, 23, "FF" },
1668 { 0, 0, 0, 0, "None" }
1670 #elif defined (IRIVER_H10_5GB)
1671 struct button_map bm[] = {
1672 { SDLK_KP_PLUS, 34, 76, 23, "Power" },
1673 { SDLK_KP4, 106, 222, 28, "Cancel" },
1674 { SDLK_KP6, 243, 220, 31, "Select" },
1675 { SDLK_KP8, 176, 254, 34, "Up" },
1676 { SDLK_KP2, 175, 371, 35, "Down" },
1677 { SDLK_KP_DIVIDE, 319, 63, 26, "Rew" },
1678 { SDLK_KP5, 320, 124, 26, "Play" },
1679 { SDLK_KP_MULTIPLY, 320, 181, 32, "FF" },
1680 { 0, 0, 0, 0, "None" }
1682 #elif defined (IRIVER_H120) || defined (IRIVER_H100)
1683 struct button_map bm[] = {
1684 { SDLK_KP_DIVIDE, 46, 162, 13, "Record" },
1685 { SDLK_KP_PLUS, 327, 36, 16, "Play" },
1686 { SDLK_KP_ENTER, 330, 99, 18, "Stop" },
1687 { SDLK_KP_PERIOD, 330, 163, 18, "AB" },
1688 { SDLK_KP5, 186, 227, 27, "5" },
1689 { SDLK_KP8, 187, 185, 19, "8" },
1690 { SDLK_KP4, 142, 229, 23, "4" },
1691 { SDLK_KP6, 231, 229, 22, "6" },
1692 { SDLK_KP2, 189, 272, 28, "2" },
1693 /* Remote Buttons */
1694 { SDLK_KP_ENTER, 250, 404, 20, "Stop" },
1695 { SDLK_SPACE, 285, 439, 29, "Space" },
1696 { SDLK_h, 336, 291, 24, "Hold" },
1697 { 0, 0, 0, 0, "None" }
1699 #elif defined (IRIVER_H300)
1700 struct button_map bm[] = {
1701 { SDLK_KP_PLUS, 56, 335, 20, "Play" },
1702 { SDLK_KP8, 140, 304, 29, "Up" },
1703 { SDLK_KP_DIVIDE, 233, 331, 23, "Record" },
1704 { SDLK_KP_ENTER, 54, 381, 24, "Stop" },
1705 { SDLK_KP4, 100, 353, 17, "Left" },
1706 { SDLK_KP5, 140, 351, 19, "Navi" },
1707 { SDLK_KP6, 185, 356, 19, "Right" },
1708 { SDLK_KP_PERIOD, 230, 380, 20, "AB" },
1709 { SDLK_KP2, 142, 402, 24, "Down" },
1710 { SDLK_KP_ENTER, 211, 479, 21, "Stop" },
1711 { SDLK_KP_PLUS, 248, 513, 29, "Play" },
1712 { 0, 0, 0, 0, "None" }
1714 #elif defined (MROBE_500)
1715 struct button_map bm[] = {
1716 { SDLK_KP9, 171, 609, 9, "Play" },
1717 { SDLK_KP4, 158, 623, 9, "Left" },
1718 { SDLK_KP6, 184, 622, 9, "Right" },
1719 { SDLK_KP7, 171, 638, 11, "Menu" },
1720 { 0, 0, 0, 0, "None" }
1722 #elif defined (MROBE_100)
1723 struct button_map bm[] = {
1724 { SDLK_KP7, 80, 233, 30, "Menu" },
1725 { SDLK_KP8, 138, 250, 19, "Up" },
1726 { SDLK_KP9, 201, 230, 27, "Play" },
1727 { SDLK_KP4, 63, 305, 25, "Left" },
1728 { SDLK_KP5, 125, 309, 28, "Select" },
1729 { SDLK_KP6, 200, 307, 35, "Right" },
1730 { SDLK_KP1, 52, 380, 32, "Display" },
1731 { SDLK_KP2, 125, 363, 30, "Down" },
1732 { SDLK_KP9, 168, 425, 10, "Play" },
1733 { SDLK_KP4, 156, 440, 11, "Left" },
1734 { SDLK_KP6, 180, 440, 13, "Right" },
1735 { SDLK_KP7, 169, 452, 10, "Menu" },
1736 { SDLK_KP_MULTIPLY, 222, 15, 16, "Power" },
1737 { 0, 0, 0, 0, "None" }
1739 #elif defined (GIGABEAT_F)
1740 struct button_map bm[] = {
1741 { SDLK_KP_PLUS, 361, 187, 22, "Power" },
1742 { SDLK_KP_PERIOD, 361, 270, 17, "Menu" },
1743 { SDLK_KP9, 365, 345, 26, "Vol Up" },
1744 { SDLK_KP3, 363, 433, 25, "Vol Down" },
1745 { SDLK_KP_ENTER, 365, 520, 19, "A" },
1746 { SDLK_KP8, 167, 458, 35, "Up" },
1747 { SDLK_KP4, 86, 537, 29, "Left" },
1748 { SDLK_KP5, 166, 536, 30, "Select" },
1749 { SDLK_KP6, 248, 536, 30, "Right" },
1750 { SDLK_KP2, 169, 617, 28, "Down" },
1751 { 0, 0, 0, 0, "None" }
1753 #elif defined (GIGABEAT_S)
1754 struct button_map bm[] = {
1755 { SDLK_KP_PLUS, 416, 383, 23, "Play" },
1756 { SDLK_KP7, 135, 442, 46, "Back" },
1757 { SDLK_KP9, 288, 447, 35, "Menu" },
1758 { SDLK_KP8, 214, 480, 32, "Up" },
1759 { SDLK_KP4, 128, 558, 33, "Left" },
1760 { SDLK_KP5, 214, 556, 34, "Select" },
1761 { SDLK_KP6, 293, 558, 35, "Right" },
1762 { SDLK_KP2, 214, 637, 38, "Down" },
1763 { 0, 0, 0, 0, "None" }
1765 #elif defined (SAMSUNG_YH820)
1766 struct button_map bm[] = {
1767 { SDLK_KP_PLUS, 330, 53, 23, "Record" },
1768 { SDLK_KP7, 132, 208, 21, "Left" },
1769 { SDLK_KP5, 182, 210, 18, "Play" },
1770 { SDLK_KP9, 234, 211, 22, "Right" },
1771 { SDLK_KP8, 182, 260, 15, "Up" },
1772 { SDLK_KP4, 122, 277, 29, "Menu" },
1773 { SDLK_KP6, 238, 276, 25, "Select" },
1774 { SDLK_KP2, 183, 321, 24, "Down" },
1775 { 0, 0, 0, 0, "None" }
1777 #elif defined (SAMSUNG_YH920) || defined (SAMSUNG_YH925)
1778 struct button_map bm[] = {
1779 { SDLK_KP9, 370, 32, 15, "FF" },
1780 { SDLK_KP5, 369, 84, 25, "Play" },
1781 { SDLK_KP5, 367, 125, 27, "Play" },
1782 { SDLK_KP3, 369, 188, 17, "Rew" },
1783 { SDLK_KP_PLUS, 370, 330, 30, "Record" },
1784 { SDLK_KP4, 146, 252, 32, "Menu" },
1785 { SDLK_KP8, 204, 226, 27, "Up" },
1786 { SDLK_KP6, 257, 250, 34, "Select" },
1787 { SDLK_KP2, 205, 294, 35, "Down" },
1788 { 0, 0, 0, 0, "None" }
1790 #elif defined (ONDA_VX747) || defined (ONDA_VX747P)
1791 struct button_map bm[] = {
1792 { SDLK_MINUS, 113, 583, 28, "Minus" },
1793 { SDLK_PLUS, 227, 580, 28, "Plus" },
1794 { SDLK_RETURN, 171, 583, 34, "Menu" },
1795 { 0, 0, 0, 0, "None" }
1797 #elif defined (PHILIPS_SA9200)
1798 struct button_map bm[] = {
1799 { SDLK_KP_ENTER, 25, 155, 33, "Power" },
1800 { SDLK_PAGEUP, 210, 98, 31, "Vol Up" },
1801 { SDLK_PAGEDOWN, 210, 168, 34, "Vol Down" },
1802 { SDLK_KP7, 40, 249, 26, "Prev" },
1803 { SDLK_KP8, 110, 247, 22, "Up" },
1804 { SDLK_KP9, 183, 249, 31, "Next" },
1805 { SDLK_KP4, 45, 305, 25, "Left" },
1806 { SDLK_KP5, 111, 304, 24, "Play" },
1807 { SDLK_KP6, 183, 304, 21, "Right" },
1808 { SDLK_KP1, 43, 377, 21, "Menu" },
1809 { SDLK_KP2, 112, 371, 24, "Down" },
1810 { 0, 0, 0, 0, "None" }
1812 #elif defined (CREATIVE_ZVM) || defined (CREATIVE_ZVM60GB) || \
1813 defined (CREATIVE_ZV)
1814 struct button_map bm[] = {
1815 { SDLK_KP7, 52, 414, 35, "Custom" },
1816 { SDLK_KP8, 185, 406, 55, "Up" },
1817 { SDLK_KP9, 315, 421, 46, "Play" },
1818 { SDLK_KP4, 122, 500, 41, "Left" },
1819 { SDLK_KP6, 247, 493, 49, "Right" },
1820 { SDLK_KP1, 58, 577, 49, "Back" },
1821 { SDLK_KP2, 186, 585, 46, "Down" },
1822 { SDLK_KP3, 311, 569, 47, "Menu" },
1823 { 0, 0, 0, 0, "None" }
1825 #else
1826 struct button_map bm[] = {
1827 { 0, 0, 0, 0, ""}
1829 #endif
1831 int xy2button( int x, int y) {
1832 int i;
1833 extern bool debug_buttons;
1835 for ( i = 0; bm[i].button; i++ )
1836 /* check distance from center of button < radius */
1837 if ( ( (x-bm[i].x)*(x-bm[i].x) ) + ( ( y-bm[i].y)*(y-bm[i].y) ) < bm[i].radius*bm[i].radius ) {
1838 if (debug_buttons)
1839 printf("Button: %s\n", bm[i].description );
1840 return bm[i].button;
1842 return 0;