summaryrefslogtreecommitdiff
path: root/apps/plugins/SUBDIRS
diff options
context:
space:
mode:
authorRafaël Carré <rafael.carre@gmail.com>2010-05-17 18:16:45 +0000
committerRafaël Carré <rafael.carre@gmail.com>2010-05-17 18:16:45 +0000
commitec6476c14adc83869862eef82fa3d4a25b971865 (patch)
tree9d2635f8076c7b7fe1d9393646fa7a0da3df9e8f /apps/plugins/SUBDIRS
parentc4c7069a8a0b4ffc5de8758c2aa154118449aa62 (diff)
downloadrockbox-ec6476c14adc83869862eef82fa3d4a25b971865.zip
rockbox-ec6476c14adc83869862eef82fa3d4a25b971865.tar.gz
rockbox-ec6476c14adc83869862eef82fa3d4a25b971865.tar.bz2
rockbox-ec6476c14adc83869862eef82fa3d4a25b971865.tar.xz
plugins: reorder SOURCES conditions to be more readable
change a lot of conditions to be more understandable add some spacing remove ifp conditions as disabling plugins can be done in configure SUBDIRS: concatenate some conditions and add comments No changes expected (no plugins added / removed) for working targets git-svn-id: svn://svn.rockbox.org/rockbox/trunk@26114 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/plugins/SUBDIRS')
-rw-r--r--apps/plugins/SUBDIRS30
1 files changed, 16 insertions, 14 deletions
diff --git a/apps/plugins/SUBDIRS b/apps/plugins/SUBDIRS
index 1c7f969..2a88e7d 100644
--- a/apps/plugins/SUBDIRS
+++ b/apps/plugins/SUBDIRS
@@ -1,5 +1,3 @@
-#if !defined(IRIVER_IFP7XX_SERIES)
-
/* For all targets */
shortcuts
@@ -10,32 +8,38 @@ clock
#endif
#if (CONFIG_KEYPAD == RECORDER_PAD) || defined(HAVE_LCD_COLOR) \
- || defined(IRIVER_H100_SERIES) || defined(IAUDIO_M5)
+ || defined(IRIVER_H100_SERIES) || defined(IAUDIO_M5) /* FIXME */
rockboy
#endif
/* For all targets with a bitmap display */
#ifdef HAVE_LCD_BITMAP
+
#ifdef HAVE_TAGCACHE
pictureflow
#endif
+
#if (CONFIG_CODEC == SWCODEC)
fft
#endif
+
chessbox
fractals
imageviewer
sudoku
reversi
goban
+
/* setjmp/longjmp are not implemented on sh */
#if (CONFIG_CPU != SH7034)
frotz
#endif
+
#ifndef OLYMPUS_MROBE_500
zxbox
#endif
-#endif
+
+#endif /* HAVE_LCD_BITMAP */
/* For all big enough colour screens, iriver H1x0 and iAudio M5 */
#if defined(HAVE_LCD_COLOR) && LCD_HEIGHT > 96\
@@ -43,32 +47,30 @@ zxbox
pacbox
#endif
-/* For all the color targets */
#if (defined(HAVE_LCD_COLOR) || defined(MROBE_100) || \
- (LCD_DEPTH == 2) && !defined(ARCHOS_AV300)) && (MEMORYSIZE > 2)
-#ifndef RB_PROFILE
+ (LCD_DEPTH == 2) && !defined(ARCHOS_AV300)) && (MEMORYSIZE > 2) && \
+ !defined(RB_PROFILE)
doom
#endif
-#endif
/* For all the swcodec targets */
#if CONFIG_CODEC == SWCODEC
+
midi
+
/* beatbox */
#if defined(IRIVER_H300_SERIES) || defined(IRIVER_H100_SERIES)
/* PDBox is confirmed to run on these player models. */
pdbox
#endif
-#ifndef RB_PROFILE
-#if MEMORYSIZE > 2 /* mpegplayer allocates at least 2MB of RAM */
+
+#if !defined(RB_PROFILE) && MEMORYSIZE > 2 /* mpegplayer allocates at least 2MB of RAM */
mpegplayer
#endif
-#endif
-#endif
+
+#endif /* CONFIG_CODEC == SWCODEC */
/* Lua needs at least 160 KB to work in */
#if (PLUGIN_BUFFER_SIZE >= 0x80000)
lua
#endif
-
-#endif /* IRIVER_IFP7XX_SERIES */
76' href='#n276'>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 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962
/***************************************************************************
*             __________               __   ___.
*   Open      \______   \ ____   ____ |  | _\_ |__   _______  ___
*   Source     |       _//  _ \_/ ___\|  |/ /| __ \ /  _ \  \/  /
*   Jukebox    |    |   (  <_> )  \___|    < | \_\ (  <_> > <  <
*   Firmware   |____|_  /\____/ \___  >__|_ \|___  /\____/__/\_ \
*                     \/            \/     \/    \/            \/
* $Id$
*
* Copyright (C) 2002 Damien Teney
* modified to use int instead of float math by Andreas Zwirtes
* heavily extended by Jens Arnold
*
* 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 "fixedpoint.h"
#include "lib/playergfx.h"
#include "lib/pluginlib_exit.h"
#if LCD_DEPTH > 1
#include "lib/mylcd.h" /* MYLCD_CFG_RB_XLCD or MYLCD_CFG_PGFX */
#include "lib/grey.h"
#else
#include "lib/grey.h"
#include "lib/mylcd.h" /* MYLCD_CFG_GREYLIB or MYLCD_CFG_PGFX */
#endif
#include "lib/xlcd.h"

/* Loops that the values are displayed */
#define DISP_TIME 30

/* variable button definitions */
#if CONFIG_KEYPAD == RECORDER_PAD
#define CUBE_QUIT          BUTTON_OFF
#define CUBE_NEXT          BUTTON_RIGHT
#define CUBE_PREV          BUTTON_LEFT
#define CUBE_INC           BUTTON_UP
#define CUBE_DEC           BUTTON_DOWN
#define CUBE_MODE          BUTTON_F1
#define CUBE_PAUSE         BUTTON_PLAY
#define CUBE_HIGHSPEED     BUTTON_ON

#elif CONFIG_KEYPAD == ARCHOS_AV300_PAD
#define CUBE_QUIT          BUTTON_OFF
#define CUBE_NEXT          BUTTON_RIGHT
#define CUBE_PREV          BUTTON_LEFT
#define CUBE_INC           BUTTON_UP
#define CUBE_DEC           BUTTON_DOWN
#define CUBE_MODE          BUTTON_F1
#define CUBE_PAUSE         BUTTON_SELECT
#define CUBE_HIGHSPEED     BUTTON_ON

#elif CONFIG_KEYPAD == PLAYER_PAD
#define CUBE_QUIT          BUTTON_STOP
#define CUBE_INC           BUTTON_RIGHT
#define CUBE_DEC           BUTTON_LEFT
#define CUBE_NEXT          (BUTTON_ON | BUTTON_RIGHT)
#define CUBE_PREV          (BUTTON_ON | BUTTON_LEFT)
#define CUBE_MODE          BUTTON_MENU
#define CUBE_PAUSE         BUTTON_PLAY
#define CUBE_HIGHSPEED_PRE BUTTON_ON
#define CUBE_HIGHSPEED     (BUTTON_ON | BUTTON_REL)

#elif CONFIG_KEYPAD == ONDIO_PAD
#define CUBE_QUIT          BUTTON_OFF
#define CUBE_NEXT          BUTTON_RIGHT
#define CUBE_PREV          BUTTON_LEFT
#define CUBE_INC           BUTTON_UP
#define CUBE_DEC           BUTTON_DOWN
#define CUBE_MODE_PRE      BUTTON_MENU
#define CUBE_MODE          (BUTTON_MENU | BUTTON_REL)
#define CUBE_PAUSE         (BUTTON_MENU | BUTTON_LEFT)
#define CUBE_HIGHSPEED     (BUTTON_MENU | BUTTON_RIGHT)

#elif (CONFIG_KEYPAD == IRIVER_H100_PAD) || \
      (CONFIG_KEYPAD == IRIVER_H300_PAD)
#define CUBE_QUIT          BUTTON_OFF
#define CUBE_NEXT          BUTTON_RIGHT
#define CUBE_PREV          BUTTON_LEFT
#define CUBE_INC           BUTTON_UP
#define CUBE_DEC           BUTTON_DOWN
#define CUBE_MODE          BUTTON_MODE
#define CUBE_PAUSE         BUTTON_ON
#define CUBE_HIGHSPEED     BUTTON_SELECT

#define CUBE_RC_QUIT       BUTTON_RC_STOP

#elif (CONFIG_KEYPAD == IPOD_4G_PAD) || \
      (CONFIG_KEYPAD == IPOD_3G_PAD) || \
      (CONFIG_KEYPAD == IPOD_1G2G_PAD)
#define CUBE_QUIT          (BUTTON_SELECT | BUTTON_MENU)
#define CUBE_NEXT          BUTTON_RIGHT
#define CUBE_PREV          BUTTON_LEFT
#define CUBE_INC           BUTTON_SCROLL_FWD
#define CUBE_DEC           BUTTON_SCROLL_BACK
#define CUBE_MODE          BUTTON_MENU
#define CUBE_PAUSE         BUTTON_PLAY
#define CUBE_HIGHSPEED_PRE BUTTON_SELECT
#define CUBE_HIGHSPEED     (BUTTON_SELECT | BUTTON_REL)

#elif CONFIG_KEYPAD == IRIVER_IFP7XX_PAD
#define CUBE_QUIT          BUTTON_PLAY
#define CUBE_NEXT          BUTTON_RIGHT
#define CUBE_PREV          BUTTON_LEFT
#define CUBE_INC           BUTTON_UP
#define CUBE_DEC           BUTTON_DOWN
#define CUBE_MODE          BUTTON_MODE
#define CUBE_PAUSE         BUTTON_SELECT
#define CUBE_HIGHSPEED     BUTTON_EQ

#elif (CONFIG_KEYPAD == IAUDIO_X5M5_PAD)
#define CUBE_QUIT          BUTTON_POWER
#define CUBE_NEXT          BUTTON_RIGHT
#define CUBE_PREV          BUTTON_LEFT
#define CUBE_INC           BUTTON_UP
#define CUBE_DEC           BUTTON_DOWN
#define CUBE_MODE          BUTTON_REC
#define CUBE_PAUSE         BUTTON_PLAY
#define CUBE_HIGHSPEED     BUTTON_SELECT

#elif (CONFIG_KEYPAD == GIGABEAT_PAD)
#define CUBE_QUIT          BUTTON_POWER
#define CUBE_NEXT          BUTTON_RIGHT
#define CUBE_PREV          BUTTON_LEFT
#define CUBE_INC           BUTTON_UP
#define CUBE_DEC           BUTTON_DOWN
#define CUBE_MODE          BUTTON_MENU
#define CUBE_PAUSE         BUTTON_SELECT
#define CUBE_HIGHSPEED     BUTTON_A

#elif (CONFIG_KEYPAD == SANSA_E200_PAD)
#define CUBE_QUIT          BUTTON_POWER
#define CUBE_NEXT          BUTTON_RIGHT
#define CUBE_PREV          BUTTON_LEFT
#define CUBE_INC           BUTTON_SCROLL_FWD
#define CUBE_DEC           BUTTON_SCROLL_BACK
#define CUBE_MODE          BUTTON_DOWN
#define CUBE_PAUSE         BUTTON_UP
#define CUBE_HIGHSPEED     BUTTON_SELECT

#elif (CONFIG_KEYPAD == SANSA_FUZE_PAD)
#define CUBE_QUIT          (BUTTON_HOME|BUTTON_REPEAT)
#define CUBE_NEXT          BUTTON_RIGHT
#define CUBE_PREV          BUTTON_LEFT
#define CUBE_INC           BUTTON_SCROLL_FWD
#define CUBE_DEC           BUTTON_SCROLL_BACK
#define CUBE_MODE          BUTTON_DOWN
#define CUBE_PAUSE         BUTTON_UP
#define CUBE_HIGHSPEED     BUTTON_SELECT

#elif (CONFIG_KEYPAD == SANSA_C200_PAD) || \
(CONFIG_KEYPAD == SANSA_CLIP_PAD) || \
(CONFIG_KEYPAD == SANSA_M200_PAD)
#define CUBE_QUIT          BUTTON_POWER
#define CUBE_NEXT          BUTTON_RIGHT
#define CUBE_PREV          BUTTON_LEFT
#define CUBE_INC           BUTTON_VOL_UP
#define CUBE_DEC           BUTTON_VOL_DOWN
#define CUBE_MODE          BUTTON_DOWN
#define CUBE_PAUSE         BUTTON_UP
#define CUBE_HIGHSPEED     BUTTON_SELECT


#elif (CONFIG_KEYPAD == IRIVER_H10_PAD)
#define CUBE_QUIT          BUTTON_POWER
#define CUBE_NEXT          BUTTON_RIGHT
#define CUBE_PREV          BUTTON_LEFT
#define CUBE_INC           BUTTON_SCROLL_UP
#define CUBE_DEC           BUTTON_SCROLL_DOWN
#define CUBE_MODE          BUTTON_REW
#define CUBE_PAUSE         BUTTON_PLAY
#define CUBE_HIGHSPEED     BUTTON_FF

#elif CONFIG_KEYPAD == MROBE500_PAD
#define CUBE_QUIT          BUTTON_POWER

#elif CONFIG_KEYPAD == GIGABEAT_S_PAD
#define CUBE_QUIT          BUTTON_BACK
#define CUBE_NEXT          BUTTON_RIGHT
#define CUBE_PREV          BUTTON_LEFT
#define CUBE_INC           BUTTON_UP
#define CUBE_DEC           BUTTON_DOWN
#define CUBE_MODE          BUTTON_MENU
#define CUBE_PAUSE         BUTTON_PLAY
#define CUBE_HIGHSPEED     BUTTON_SELECT

#elif (CONFIG_KEYPAD == MROBE100_PAD)
#define CUBE_QUIT          BUTTON_POWER
#define CUBE_NEXT          BUTTON_RIGHT
#define CUBE_PREV          BUTTON_LEFT
#define CUBE_INC           BUTTON_UP
#define CUBE_DEC           BUTTON_DOWN
#define CUBE_MODE          BUTTON_MENU
#define CUBE_PAUSE         BUTTON_PLAY
#define CUBE_HIGHSPEED     BUTTON_SELECT

#elif (CONFIG_KEYPAD == IAUDIO_M3_PAD)
#define CUBE_QUIT          BUTTON_RC_REC
#define CUBE_NEXT          BUTTON_RC_FF
#define CUBE_PREV          BUTTON_RC_REW
#define CUBE_INC           BUTTON_RC_VOL_UP
#define CUBE_DEC           BUTTON_RC_VOL_DOWN
#define CUBE_MODE          BUTTON_RC_MODE
#define CUBE_PAUSE         BUTTON_RC_PLAY
#define CUBE_HIGHSPEED     BUTTON_RC_MENU

#elif CONFIG_KEYPAD == COWON_D2_PAD
#define CUBE_QUIT          BUTTON_POWER

#elif (CONFIG_KEYPAD == IAUDIO67_PAD)
#define CUBE_QUIT          BUTTON_POWER
#define CUBE_NEXT          BUTTON_RIGHT
#define CUBE_PREV          BUTTON_LEFT
#define CUBE_INC           BUTTON_VOLUP
#define CUBE_DEC           BUTTON_VOLDOWN
#define CUBE_MODE          BUTTON_MENU
#define CUBE_PAUSE         BUTTON_PLAY
#define CUBE_HIGHSPEED     BUTTON_STOP

#elif CONFIG_KEYPAD == CREATIVEZVM_PAD
#define CUBE_QUIT          BUTTON_BACK
#define CUBE_NEXT          BUTTON_RIGHT
#define CUBE_PREV          BUTTON_LEFT
#define CUBE_INC           BUTTON_UP
#define CUBE_DEC           BUTTON_DOWN
#define CUBE_MODE          BUTTON_MENU
#define CUBE_PAUSE         BUTTON_PLAY
#define CUBE_HIGHSPEED     BUTTON_SELECT

#elif CONFIG_KEYPAD == CREATIVE_ZENXFI3_PAD
#define CUBE_QUIT          BUTTON_POWER
#define CUBE_NEXT          BUTTON_UP
#define CUBE_PREV          BUTTON_DOWN
#define CUBE_INC           BUTTON_VOL_UP
#define CUBE_DEC           BUTTON_VOL_DOWN
#define CUBE_MODE          BUTTON_MENU
#define CUBE_PAUSE         (BUTTON_PLAY|BUTTON_REL)
#define CUBE_HIGHSPEED     BUTTON_BACK

#elif CONFIG_KEYPAD == PHILIPS_HDD1630_PAD
#define CUBE_QUIT          BUTTON_POWER
#define CUBE_NEXT          BUTTON_RIGHT
#define CUBE_PREV          BUTTON_LEFT
#define CUBE_INC           BUTTON_UP
#define CUBE_DEC           BUTTON_DOWN
#define CUBE_MODE          BUTTON_MENU
#define CUBE_PAUSE         BUTTON_SELECT
#define CUBE_HIGHSPEED     BUTTON_VIEW

#elif CONFIG_KEYPAD == PHILIPS_HDD6330_PAD
#define CUBE_QUIT          BUTTON_POWER
#define CUBE_NEXT          BUTTON_NEXT
#define CUBE_PREV          BUTTON_PREV
#define CUBE_INC           BUTTON_UP
#define CUBE_DEC           BUTTON_DOWN
#define CUBE_MODE          BUTTON_MENU
#define CUBE_PAUSE         BUTTON_PLAY
#define CUBE_HIGHSPEED     BUTTON_RIGHT

#elif CONFIG_KEYPAD == PHILIPS_SA9200_PAD
#define CUBE_QUIT          BUTTON_POWER
#define CUBE_NEXT          BUTTON_NEXT
#define CUBE_PREV          BUTTON_PREV
#define CUBE_INC           BUTTON_UP
#define CUBE_DEC           BUTTON_DOWN
#define CUBE_MODE          BUTTON_MENU
#define CUBE_PAUSE         BUTTON_PLAY
#define CUBE_HIGHSPEED     BUTTON_RIGHT

#elif CONFIG_KEYPAD == ONDAVX747_PAD
#define CUBE_QUIT          BUTTON_POWER
#elif CONFIG_KEYPAD == ONDAVX777_PAD
#define CUBE_QUIT          BUTTON_POWER

#elif (CONFIG_KEYPAD == SAMSUNG_YH820_PAD) || \
      (CONFIG_KEYPAD == SAMSUNG_YH920_PAD)
#define CUBE_QUIT          BUTTON_REC
#define CUBE_NEXT          BUTTON_RIGHT
#define CUBE_PREV          BUTTON_LEFT
#define CUBE_INC           BUTTON_UP
#define CUBE_DEC           BUTTON_DOWN
#define CUBE_MODE          BUTTON_REW
#define CUBE_PAUSE         BUTTON_PLAY
#define CUBE_HIGHSPEED     BUTTON_FFWD

#elif CONFIG_KEYPAD == PBELL_VIBE500_PAD
#define CUBE_QUIT          BUTTON_REC
#define CUBE_NEXT          BUTTON_NEXT
#define CUBE_PREV          BUTTON_PREV
#define CUBE_INC           BUTTON_UP
#define CUBE_DEC           BUTTON_DOWN
#define CUBE_MODE          BUTTON_MENU
#define CUBE_PAUSE         BUTTON_PLAY
#define CUBE_HIGHSPEED     BUTTON_OK

#elif CONFIG_KEYPAD == MPIO_HD200_PAD
#define CUBE_QUIT          (BUTTON_REC | BUTTON_PLAY)
#define CUBE_NEXT          BUTTON_FF
#define CUBE_PREV          BUTTON_REW
#define CUBE_INC           BUTTON_VOL_UP
#define CUBE_DEC           BUTTON_VOL_DOWN
#define CUBE_MODE          BUTTON_REC
#define CUBE_PAUSE         BUTTON_PLAY
#define CUBE_HIGHSPEED     BUTTON_FUNC

#elif CONFIG_KEYPAD == MPIO_HD300_PAD
#define CUBE_QUIT          (BUTTON_MENU | BUTTON_REPEAT)
#define CUBE_NEXT          BUTTON_FF
#define CUBE_PREV          BUTTON_REW
#define CUBE_INC           BUTTON_UP
#define CUBE_DEC           BUTTON_DOWN
#define CUBE_MODE          BUTTON_MENU
#define CUBE_PAUSE         BUTTON_PLAY
#define CUBE_HIGHSPEED     BUTTON_ENTER

#elif CONFIG_KEYPAD == SANSA_FUZEPLUS_PAD
#define CUBE_QUIT          BUTTON_POWER
#define CUBE_NEXT          BUTTON_RIGHT
#define CUBE_PREV          BUTTON_LEFT
#define CUBE_INC           BUTTON_UP
#define CUBE_DEC           BUTTON_DOWN
#define CUBE_MODE          BUTTON_SELECT
#define CUBE_PAUSE         BUTTON_PLAYPAUSE
#define CUBE_HIGHSPEED     BUTTON_BACK

#elif CONFIG_KEYPAD == SANSA_CONNECT_PAD
#define CUBE_QUIT          BUTTON_POWER
#define CUBE_NEXT          BUTTON_NEXT
#define CUBE_PREV          BUTTON_PREV
#define CUBE_INC           BUTTON_VOL_UP
#define CUBE_DEC           BUTTON_VOL_DOWN
#define CUBE_MODE          BUTTON_SELECT
#define CUBE_PAUSE         BUTTON_DOWN
#define CUBE_HIGHSPEED     BUTTON_LEFT

#elif (CONFIG_KEYPAD == SAMSUNG_YPR0_PAD)
#define CUBE_QUIT          BUTTON_BACK
#define CUBE_NEXT          BUTTON_RIGHT
#define CUBE_PREV          BUTTON_LEFT
#define CUBE_INC           BUTTON_UP
#define CUBE_DEC           BUTTON_DOWN
#define CUBE_MODE          BUTTON_MENU
#define CUBE_PAUSE         BUTTON_USER
#define CUBE_HIGHSPEED     BUTTON_SELECT

#elif (CONFIG_KEYPAD == HM60X_PAD)
#define CUBE_QUIT          BUTTON_POWER
#define CUBE_NEXT          BUTTON_RIGHT
#define CUBE_PREV          BUTTON_LEFT
#define CUBE_INC           BUTTON_UP
#define CUBE_DEC           BUTTON_DOWN
#define CUBE_MODE          (BUTTON_SELECT|BUTTON_POWER)
#define CUBE_PAUSE         BUTTON_SELECT
#define CUBE_HIGHSPEED     (BUTTON_UP|BUTTON_POWER)

#elif (CONFIG_KEYPAD == HM801_PAD)
#define CUBE_QUIT          BUTTON_POWER
#define CUBE_NEXT          BUTTON_RIGHT
#define CUBE_PREV          BUTTON_LEFT
#define CUBE_INC           BUTTON_UP
#define CUBE_DEC           BUTTON_DOWN
#define CUBE_MODE          BUTTON_PREV
#define CUBE_PAUSE         BUTTON_SELECT
#define CUBE_HIGHSPEED     BUTTON_NEXT

#elif (CONFIG_KEYPAD == SONY_NWZ_PAD)
#define CUBE_QUIT        BUTTON_BACK
#define CUBE_NEXT        BUTTON_RIGHT
#define CUBE_PREV        BUTTON_LEFT
#define CUBE_INC         BUTTON_UP
#define CUBE_DEC         BUTTON_DOWN
#define CUBE_MODE        (BUTTON_POWER|BUTTON_UP)
#define CUBE_PAUSE       BUTTON_PLAY
#define CUBE_HIGHSPEED   (BUTTON_POWER|BUTTON_DOWN)

#elif (CONFIG_KEYPAD == CREATIVE_ZEN_PAD)
#define CUBE_QUIT        BUTTON_BACK
#define CUBE_NEXT        BUTTON_RIGHT
#define CUBE_PREV        BUTTON_LEFT
#define CUBE_INC         BUTTON_UP
#define CUBE_DEC         BUTTON_DOWN
#define CUBE_MODE        BUTTON_MENU
#define CUBE_PAUSE       BUTTON_PLAYPAUSE
#define CUBE_HIGHSPEED   BUTTON_SHORTCUT

#elif (CONFIG_KEYPAD == DX50_PAD)
#define CUBE_QUIT          (BUTTON_POWER|BUTTON_REL)
#define CUBE_NEXT          BUTTON_RIGHT
#define CUBE_PREV          BUTTON_LEFT
#define CUBE_INC           BUTTON_VOL_UP
#define CUBE_DEC           BUTTON_VOL_DOWN
#define CUBE_MODE          BUTTON_PLAY

#else
#error No keymap defined!
#endif

#ifdef HAVE_TOUCHSCREEN
#ifndef CUBE_QUIT
#define CUBE_QUIT          BUTTON_TOPLEFT
#endif
#ifndef CUBE_NEXT
#define CUBE_NEXT          BUTTON_MIDRIGHT
#endif
#ifndef CUBE_PREV
#define CUBE_PREV          BUTTON_MIDLEFT
#endif
#ifndef CUBE_INC
#define CUBE_INC           BUTTON_TOPMIDDLE
#endif
#ifndef CUBE_DEC
#define CUBE_DEC           BUTTON_BOTTOMMIDDLE
#endif
#ifndef CUBE_MODE
#define CUBE_MODE          BUTTON_TOPRIGHT
#endif
#ifndef CUBE_PAUSE
#define CUBE_PAUSE         BUTTON_CENTER
#endif
#ifndef CUBE_HIGHSPEED
#define CUBE_HIGHSPEED     BUTTON_BOTTOMRIGHT
#endif
#endif


#ifdef HAVE_LCD_BITMAP

#define DIST (10 * MIN(LCD_HEIGHT, LCD_WIDTH) / 16)
static int x_off = LCD_WIDTH/2;
static int y_off = LCD_HEIGHT/2;

#if LCD_DEPTH == 1
#define USEGSLIB
GREY_INFO_STRUCT
struct my_lcd {
    void (*update)(void);
    void (*clear_display)(void);
    void (*drawline)(int x1, int y1, int x2, int y2);
    void (*putsxy)(int x, int y, const unsigned char *string);
};

static struct my_lcd greyfuncs = {
    grey_update, grey_clear_display, grey_drawline, grey_putsxy
};
static struct my_lcd lcdfuncs; /* initialised at runtime */
static struct my_lcd *mylcd = &greyfuncs;

#define MYLCD(fn) mylcd->fn

#else
#define MYLCD(fn) rb->lcd_ ## fn
#endif

#if CONFIG_LCD == LCD_SSD1815
#define ASPECT 320 /* = 1.25 (fixed point 24.8) */
#else
#define ASPECT 256 /* = 1.00 */
#endif

#else /* !LCD_BITMAP */

#define MYLCD(fn) pgfx_ ## fn
#define DIST 9
static int x_off = 10;
static int y_off = 7;
#define ASPECT 300 /* = 1.175 */

#endif /* !LCD_BITMAP */

struct point_3D {
    long x, y, z;
};

struct point_2D {
    long x, y;
};

struct line {
    int start, end;
};

struct face {
    int corner[4];
    int line[4];
};

/* initial, unrotated cube corners */
static const struct point_3D sommet[8] =
{
    {-DIST, -DIST, -DIST},
    { DIST, -DIST, -DIST},
    { DIST,  DIST, -DIST},
    {-DIST,  DIST, -DIST},
    {-DIST, -DIST,  DIST},
    { DIST, -DIST,  DIST},
    { DIST,  DIST,  DIST},
    {-DIST,  DIST,  DIST}
};

/* The 12 lines forming the edges */
static const struct line lines[12] =
{
    {0, 1}, {1, 2}, {2, 3}, {3, 0},
    {4, 7}, {7, 6}, {6, 5}, {5, 4},
    {0, 4}, {1, 5}, {2, 6}, {3, 7}
};

static bool lines_drawn[12];

/* The 6 faces of the cube; points are in clockwise order when viewed
   from the outside */
static const struct face faces[6] =
{
    {{0, 1, 2, 3}, {0, 1, 2, 3}},
    {{4, 7, 6, 5}, {4, 5, 6, 7}},
    {{0, 4, 5, 1}, {8, 7, 9, 0}},
    {{2, 6, 7, 3}, {10, 5, 11, 2}},
    {{0, 3, 7, 4}, {3, 11, 4, 8}},
    {{1, 5, 6, 2}, {9, 6, 10, 1}}
};

#if LCD_DEPTH > 1 || defined(USEGSLIB)
static const unsigned face_colors[6] =
{
#ifdef HAVE_LCD_COLOR
    LCD_RGBPACK(255, 0, 0), LCD_RGBPACK(255, 0, 0), LCD_RGBPACK(0, 255, 0),
    LCD_RGBPACK(0, 255, 0), LCD_RGBPACK(0, 0, 255), LCD_RGBPACK(0, 0, 255)
#elif defined(USEGSLIB)
#ifdef MROBE_100
    GREY_LIGHTGRAY, GREY_LIGHTGRAY, GREY_DARKGRAY,
    GREY_DARKGRAY,  GREY_WHITE,     GREY_WHITE
#else
    GREY_LIGHTGRAY, GREY_LIGHTGRAY, GREY_DARKGRAY,
    GREY_DARKGRAY,  GREY_BLACK,     GREY_BLACK
#endif
#else
    LCD_LIGHTGRAY, LCD_LIGHTGRAY, LCD_DARKGRAY,
    LCD_DARKGRAY,  LCD_BLACK,     LCD_BLACK
#endif
};
#endif

enum {
#if LCD_DEPTH > 1 || defined(USEGSLIB)
    SOLID,
#endif
    HIDDEN_LINES,
    WIREFRAME,
    NUM_MODES
};

static int mode = 0;

struct counter {
    const char *label;
    short speed;
    short angle;
};

static struct counter axes[] = {
    {"x-axis", 1, 0},
    {"y-axis", 3, 0},
    {"z-axis", 2, 0}
};

static struct point_3D point3D[8];
static struct point_2D point2D[8];
static long matrice[3][3];

static const int nb_points = 8;
static long z_off = 600;

static void cube_rotate(int xa, int ya, int za)
{
    int i;
    /* Just to prevent unnecessary lookups */
    long sxa, cxa, sya, cya, sza, cza;

    sxa = fp14_sin(xa);
    cxa = fp14_cos(xa);
    sya = fp14_sin(ya);
    cya = fp14_cos(ya);
    sza = fp14_sin(za);
    cza = fp14_cos(za);

    /* calculate overall translation matrix */
    matrice[0][0] = (cza * cya) >> 14;
    matrice[1][0] = (sza * cya) >> 14;
    matrice[2][0] = -sya;

    matrice[0][1] = (((cza * sya) >> 14) * sxa - sza * cxa) >> 14;
    matrice[1][1] = (((sza * sya) >> 14) * sxa + cxa * cza) >> 14;
    matrice[2][1] = (sxa * cya) >> 14;

    matrice[0][2] = (((cza * sya) >> 14) * cxa + sza * sxa) >> 14;
    matrice[1][2] = (((sza * sya) >> 14) * cxa - cza * sxa) >> 14;
    matrice[2][2] = (cxa * cya) >> 14;

    /* apply translation matrix to all points */
    for (i = 0; i < nb_points; i++)
    {
        point3D[i].x = matrice[0][0] * sommet[i].x + matrice[1][0] * sommet[i].y
                     + matrice[2][0] * sommet[i].z;

        point3D[i].y = matrice[0][1] * sommet[i].x + matrice[1][1] * sommet[i].y
                     + matrice[2][1] * sommet[i].z;

        point3D[i].z = matrice[0][2] * sommet[i].x + matrice[1][2] * sommet[i].y
                     + matrice[2][2] * sommet[i].z;
    }
}

static void cube_viewport(void)
{
    int i;

    /* Do viewport transformation for all points */
    for (i = 0; i < nb_points; i++)
    {
#if ASPECT != 256
        point2D[i].x = (point3D[i].x * ASPECT) / (point3D[i].z + (z_off << 14))
                     + x_off;
#else
        point2D[i].x = (point3D[i].x << 8) / (point3D[i].z + (z_off << 14))
                     + x_off;
#endif
        point2D[i].y = (point3D[i].y << 8) / (point3D[i].z + (z_off << 14))
                     + y_off;
    }
}

static void cube_draw(void)
{
    int i, j, line;
#if LCD_DEPTH > 1 || defined(USEGSLIB)
    unsigned old_foreground;
#endif

    switch (mode)
    {
#if LCD_DEPTH > 1 || defined(USEGSLIB)
      case SOLID:
      
        old_foreground = mylcd_get_foreground();
        for (i = 0; i < 6; i++)
        {
            /* backface culling; if the shape winds counter-clockwise, we are
             * looking at the backface, and the (simplified) cross product
             * is < 0. Do not draw it. */
            if (0 >= (point2D[faces[i].corner[1]].x - point2D[faces[i].corner[0]].x)
                   * (point2D[faces[i].corner[2]].y - point2D[faces[i].corner[1]].y)
                   - (point2D[faces[i].corner[1]].y - point2D[faces[i].corner[0]].y)
                   * (point2D[faces[i].corner[2]].x - point2D[faces[i].corner[1]].x))
                continue;

            mylcd_set_foreground(face_colors[i]);
            mylcd_filltriangle(point2D[faces[i].corner[0]].x,
                               point2D[faces[i].corner[0]].y,
                               point2D[faces[i].corner[1]].x,
                               point2D[faces[i].corner[1]].y,
                               point2D[faces[i].corner[2]].x,
                               point2D[faces[i].corner[2]].y);
            mylcd_filltriangle(point2D[faces[i].corner[0]].x,
                               point2D[faces[i].corner[0]].y,
                               point2D[faces[i].corner[2]].x,
                               point2D[faces[i].corner[2]].y,
                               point2D[faces[i].corner[3]].x,
                               point2D[faces[i].corner[3]].y);

        }
        mylcd_set_foreground(old_foreground);
        break;
#endif /* (LCD_DEPTH > 1) || GSLIB */

      case HIDDEN_LINES:

        rb->memset(lines_drawn, 0, sizeof(lines_drawn));
        for (i = 0; i < 6; i++)
        {
            /* backface culling; if the shape winds counter-clockwise, we are
             * looking at the backface, and the (simplified) cross product
             * is < 0. Do not draw it. */
            if (0 >= (point2D[faces[i].corner[1]].x - point2D[faces[i].corner[0]].x)
                   * (point2D[faces[i].corner[2]].y - point2D[faces[i].corner[1]].y)
                   - (point2D[faces[i].corner[1]].y - point2D[faces[i].corner[0]].y)
                   * (point2D[faces[i].corner[2]].x - point2D[faces[i].corner[1]].x))
                continue;

            for (j = 0; j < 4; j++)
            {
                line = faces[i].line[j];
                if (!lines_drawn[line])
                {
                    lines_drawn[line] = true;
                    MYLCD(drawline)(point2D[lines[line].start].x,
                                    point2D[lines[line].start].y,
                                    point2D[lines[line].end].x,
                                    point2D[lines[line].end].y);
                }
            }
        }
        break;

      case WIREFRAME:

        for (i = 0; i < 12; i++)
            MYLCD(drawline)(point2D[lines[i].start].x,
                            point2D[lines[i].start].y,
                            point2D[lines[i].end].x,
                            point2D[lines[i].end].y);
        break;
    }
}

static void cleanup(void)
{
#ifdef USEGSLIB
    grey_release();
#elif defined HAVE_LCD_CHARCELLS
    pgfx_release();
#endif
}

enum plugin_status plugin_start(const void* parameter)
{
    int t_disp = 0;
#ifdef USEGSLIB
    unsigned char *gbuf;
    size_t gbuf_size = 0;
    bool mode_switch = true;
#endif

    int button;
#if defined(CUBE_MODE_PRE) || \
    defined(CUBE_PAUSE_PRE) || \
    defined(CUBE_HIGHSPEED_PRE)
    int lastbutton = BUTTON_NONE;
#endif
    int curr = 0;
    bool highspeed = false;
    bool paused = false;
    bool redraw = true;
    bool quit = false;

    (void)(parameter);

#ifdef HAVE_LCD_BITMAP
#if defined(USEGSLIB)
    gbuf = (unsigned char *)rb->plugin_get_buffer(&gbuf_size);
    if (!grey_init(gbuf, gbuf_size, GREY_BUFFERED,
                   LCD_WIDTH, LCD_HEIGHT, NULL))
    {
        rb->splash(HZ, "Couldn't init greyscale display");
        return PLUGIN_ERROR;
    }

    /* init lcd_ function pointers */
    lcdfuncs.update =        rb->lcd_update;
    lcdfuncs.clear_display = rb->lcd_clear_display;
    lcdfuncs.drawline =      rb->lcd_drawline;
    lcdfuncs.putsxy =        rb->lcd_putsxy;

#ifdef MROBE_100
    grey_set_background(GREY_BLACK);
#endif

    grey_setfont(FONT_SYSFIXED);
#endif
    rb->lcd_setfont(FONT_SYSFIXED);
#else /* LCD_CHARCELLS */
    if (!pgfx_init(4, 2))
    {
        rb->splash(HZ*2, "Old LCD :(");
        return PLUGIN_OK;
    }
    pgfx_display(0, 0);
#endif

    atexit(cleanup);
    while(!quit)
    {
        if (redraw)
        {
            MYLCD(clear_display)();
            cube_rotate(axes[0].angle, axes[1].angle, axes[2].angle);
            cube_viewport();
            cube_draw();
            redraw = false;
        }

#ifdef HAVE_LCD_BITMAP
        if (t_disp > 0)
        {
            char buffer[30];
            t_disp--;
            rb->snprintf(buffer, sizeof(buffer), "%s: %d %s",
                         axes[curr].label,
                         paused ? axes[curr].angle : axes[curr].speed,
                         highspeed ? "(hs)" : "");
            MYLCD(putsxy)(0, LCD_HEIGHT-8, buffer);
            if (t_disp == 0)
                redraw = true;
        }
#else
        if (t_disp > 0)
        {
            if (t_disp == DISP_TIME)
            {
                rb->lcd_puts(5, 0, axes[curr].label);
                rb->lcd_putsf(5, 1, "%d %c",