summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHristo Kovachev <bger@rockbox.org>2006-02-20 20:08:27 +0000
committerHristo Kovachev <bger@rockbox.org>2006-02-20 20:08:27 +0000
commit7f6fe6aa35cdbac9ef2d684af299b9695f22fccd (patch)
tree23846280cf07c5e238e3b6f1e7e4e1a0ef2285ee
parente48e60b3e072d9c6974343db07ebda24e1bcb123 (diff)
downloadrockbox-7f6fe6aa35cdbac9ef2d684af299b9695f22fccd.tar.gz
rockbox-7f6fe6aa35cdbac9ef2d684af299b9695f22fccd.zip
Multiple remote support for iriver Hxxx stage 2: now button_read() returns correct buttons for each remote type.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@8752 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--firmware/drivers/button.c212
1 files changed, 110 insertions, 102 deletions
diff --git a/firmware/drivers/button.c b/firmware/drivers/button.c
index c4c22641ca..3d14eb147c 100644
--- a/firmware/drivers/button.c
+++ b/firmware/drivers/button.c
@@ -40,6 +40,11 @@
40#include "system.h" 40#include "system.h"
41#include "powermgmt.h" 41#include "powermgmt.h"
42 42
43#if (CONFIG_KEYPAD == IRIVER_H100_PAD) \
44 || (CONFIG_KEYPAD == IRIVER_H300_PAD)
45#include "lcd-remote.h"
46#endif
47
43struct event_queue button_queue; 48struct event_queue button_queue;
44 49
45static long lastbtn; /* Last valid button status */ 50static long lastbtn; /* Last valid button status */
@@ -703,7 +708,8 @@ static int button_read(void)
703 708
704 int data; 709 int data;
705 710
706#if CONFIG_KEYPAD == IRIVER_H100_PAD 711#if (CONFIG_KEYPAD == IRIVER_H100_PAD)\
712 || (CONFIG_KEYPAD == IRIVER_H300_PAD)
707 713
708 static bool hold_button = false; 714 static bool hold_button = false;
709 static bool remote_hold_button = false; 715 static bool remote_hold_button = false;
@@ -725,7 +731,7 @@ static int button_read(void)
725 if (!hold_button) 731 if (!hold_button)
726 { 732 {
727 data = adc_scan(ADC_BUTTONS); 733 data = adc_scan(ADC_BUTTONS);
728 734#if CONFIG_KEYPAD == IRIVER_H100_PAD
729 if (data < 0x80) 735 if (data < 0x80)
730 if (data < 0x30) 736 if (data < 0x30)
731 if (data < 0x18) 737 if (data < 0x18)
@@ -749,74 +755,7 @@ static int button_read(void)
749 else 755 else
750 if (data < 0xf0) 756 if (data < 0xf0)
751 btn = BUTTON_REC; 757 btn = BUTTON_REC;
752 } 758#else /* H300 */
753
754 /* remote buttons */
755 if (!remote_hold_button)
756 {
757 data = adc_scan(ADC_REMOTE);
758
759 if (data < 0x74)
760 if (data < 0x40)
761 if (data < 0x20)
762 if(data < 0x10)
763 btn = BUTTON_RC_STOP;
764 else
765 btn = BUTTON_RC_VOL_DOWN;
766 else
767 btn = BUTTON_RC_MODE;
768 else
769 if (data < 0x58)
770 btn = BUTTON_RC_VOL_UP;
771 else
772 btn = BUTTON_RC_BITRATE;
773 else
774 if (data < 0xb0)
775 if (data < 0x88)
776 btn = BUTTON_RC_REC;
777 else
778 btn = BUTTON_RC_SOURCE;
779 else
780 if (data < 0xd8)
781 if(data < 0xc0)
782 btn = BUTTON_RC_FF;
783 else
784 btn = BUTTON_RC_MENU;
785 else
786 if (data < 0xf0)
787 btn = BUTTON_RC_REW;
788 }
789
790 /* special buttons */
791 data = GPIO1_READ;
792 if (!hold_button && ((data & 0x20) == 0))
793 btn |= BUTTON_ON;
794 if (!remote_hold_button && ((data & 0x40) == 0))
795 btn |= BUTTON_RC_ON;
796
797#elif CONFIG_KEYPAD == IRIVER_H300_PAD
798
799 static bool hold_button = false;
800 static bool remote_hold_button = false;
801
802 /* light handling */
803 if (hold_button && !button_hold())
804 {
805 backlight_on();
806 }
807 if (remote_hold_button && !remote_button_hold_only())
808 {
809 remote_backlight_on();
810 }
811
812 hold_button = button_hold();
813 remote_hold_button = remote_button_hold_only();
814
815 /* normal buttons */
816 if (!hold_button)
817 {
818 data = adc_scan(ADC_BUTTONS);
819
820 if (data < 0x54) 759 if (data < 0x54)
821 if (data < 0x30) 760 if (data < 0x30)
822 if (data < 0x10) 761 if (data < 0x10)
@@ -834,45 +773,96 @@ static int button_read(void)
834 else 773 else
835 if(data < 0xba) 774 if(data < 0xba)
836 btn = BUTTON_OFF; 775 btn = BUTTON_OFF;
776
777#endif
837 } 778 }
838 779
839 /* remote buttons */ 780 /* remote buttons */
840 if (!remote_hold_button) 781 if (!remote_hold_button)
841 { 782 {
842 data = adc_scan(ADC_REMOTE); 783 data = adc_scan(ADC_REMOTE);
843 784 switch(remote_type())
844 if (data < 0x74) 785 {
845 if (data < 0x40) 786 case REMOTETYPE_H100_LCD:
846 if (data < 0x20) 787 if (data < 0x73)
847 if(data < 0x10) 788 if (data < 0x3f)
848 btn = BUTTON_RC_STOP; 789 if (data < 0x25)
790 if(data < 0x0c)
791 btn = BUTTON_RC_STOP;
792 else
793 btn = BUTTON_RC_VOL_DOWN;
794 else
795 btn = BUTTON_RC_MODE;
849 else 796 else
850 btn = BUTTON_RC_VOL_DOWN; 797 if (data < 0x5a)
851 else 798 btn = BUTTON_RC_VOL_UP;
852 btn = BUTTON_RC_MODE; 799 else
853 else 800 btn = BUTTON_RC_BITRATE;
854 if (data < 0x58)
855 btn = BUTTON_RC_VOL_UP;
856 else 801 else
857 btn = BUTTON_RC_BITRATE; 802 if (data < 0xa8)
858 else 803 if (data < 0x8c)
859 if (data < 0xb0) 804 btn = BUTTON_RC_REC;
860 if (data < 0x88) 805 else
861 btn = BUTTON_RC_REC; 806 btn = BUTTON_RC_SOURCE;
807 else
808 if (data < 0xdf)
809 if(data < 0xc5)
810 btn = BUTTON_RC_FF;
811 else
812 btn = BUTTON_RC_MENU;
813 else
814 if (data < 0xf5)
815 btn = BUTTON_RC_REW;
816 break;
817 case REMOTETYPE_H300_LCD:
818 if (data < 0x73)
819 if (data < 0x42)
820 if (data < 0x27)
821 if(data < 0x0c)
822 btn = BUTTON_RC_VOL_DOWN;
823 else
824 btn = BUTTON_RC_FF;
825 else
826 btn = BUTTON_RC_STOP;
827 else
828 if (data < 0x5b)
829 btn = BUTTON_RC_MODE;
830 else
831 btn = BUTTON_RC_REC;
862 else 832 else
863 btn = BUTTON_RC_SOURCE; 833 if (data < 0xab)
864 else 834 if (data < 0x8e)
865 if (data < 0xd8) 835 btn = BUTTON_RC_ON;
866 if(data < 0xc0) 836 else
837 btn = BUTTON_RC_BITRATE;
838 else
839 if (data < 0xde)
840 if(data < 0xc5)
841 btn = BUTTON_RC_SOURCE;
842 else
843 btn = BUTTON_RC_VOL_UP;
844 else
845 if (data < 0xf5)
846 btn = BUTTON_RC_REW;
847 break;
848 case REMOTETYPE_H300_NONLCD:
849 if(data<0x7d)
850 if(data<0x25)
867 btn = BUTTON_RC_FF; 851 btn = BUTTON_RC_FF;
868 else 852 else
869 btn = BUTTON_RC_MENU;
870 else
871 if (data < 0xf0)
872 btn = BUTTON_RC_REW; 853 btn = BUTTON_RC_REW;
854 else
855 if(data<0xd5)
856 btn = BUTTON_RC_VOL_DOWN;
857 else
858 if(data<0xf1) /* 0xff no button pressed */
859 btn = BUTTON_RC_VOL_UP;
860 break;
861 }
873 } 862 }
874 863
875 /* special buttons */ 864 /* special buttons */
865#if CONFIG_KEYPAD == IRIVER_H300_PAD
876 if (!hold_button) 866 if (!hold_button)
877 { 867 {
878 data = GPIO_READ; 868 data = GPIO_READ;
@@ -881,13 +871,23 @@ static int button_read(void)
881 if ((data & 0x8000) == 0) 871 if ((data & 0x8000) == 0)
882 btn |= BUTTON_REC; 872 btn |= BUTTON_REC;
883 } 873 }
884 874#endif
875
885 data = GPIO1_READ; 876 data = GPIO1_READ;
886 if (!hold_button && ((data & 0x20) == 0)) 877 if (!hold_button && ((data & 0x20) == 0))
887 btn |= BUTTON_ON; 878 btn |= BUTTON_ON;
888 if (!remote_hold_button && ((data & 0x40) == 0)) 879 if (!remote_hold_button && ((data & 0x40) == 0))
889 btn |= BUTTON_RC_ON; 880 switch(remote_type())
890 881 {
882 case REMOTETYPE_H100_LCD:
883 case REMOTETYPE_H300_NONLCD:
884 btn |= BUTTON_RC_ON;
885 break;
886 case REMOTETYPE_H300_LCD:
887 btn |= BUTTON_RC_MENU;
888 break;
889 }
890
891#elif CONFIG_KEYPAD == IRIVER_IFP7XX_PAD 891#elif CONFIG_KEYPAD == IRIVER_IFP7XX_PAD
892 892
893 static bool hold_button = false; 893 static bool hold_button = false;
@@ -1072,13 +1072,21 @@ bool button_hold(void)
1072} 1072}
1073 1073
1074static bool remote_button_hold_only(void) 1074static bool remote_button_hold_only(void)
1075{ 1075{
1076 return (GPIO1_READ & 0x00100000)?true:false; 1076 if(remote_type() == REMOTETYPE_H300_NONLCD)
1077 return adc_scan(ADC_REMOTE)<0x0d; /* hold should be 0x00 */
1078 else
1079 return (GPIO1_READ & 0x00100000)?true:false;
1077} 1080}
1078 1081
1082/* returns true only if there is remote present */
1079bool remote_button_hold(void) 1083bool remote_button_hold(void)
1080{ 1084{
1081 return ((GPIO_READ & 0x40000000) == 0)?remote_button_hold_only():false; 1085 /* H300's NON-LCD remote doesn't set the "remote present" bit */
1086 if(remote_type() == REMOTETYPE_H300_NONLCD)
1087 return remote_button_hold_only();
1088 else
1089 return ((GPIO_READ & 0x40000000) == 0)?remote_button_hold_only():false;
1082} 1090}
1083#endif 1091#endif
1084 1092