summaryrefslogtreecommitdiff
path: root/firmware/target/coldfire/iaudio/m3/button-m3.c
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/target/coldfire/iaudio/m3/button-m3.c')
-rw-r--r--firmware/target/coldfire/iaudio/m3/button-m3.c49
1 files changed, 39 insertions, 10 deletions
diff --git a/firmware/target/coldfire/iaudio/m3/button-m3.c b/firmware/target/coldfire/iaudio/m3/button-m3.c
index b5b09807c0..c7c5b2e90f 100644
--- a/firmware/target/coldfire/iaudio/m3/button-m3.c
+++ b/firmware/target/coldfire/iaudio/m3/button-m3.c
@@ -48,7 +48,7 @@ int button_read_device(void)
48 int btn = BUTTON_NONE; 48 int btn = BUTTON_NONE;
49 bool hold_button_old; 49 bool hold_button_old;
50 bool remote_hold_button_old; 50 bool remote_hold_button_old;
51 int data = 0xff; /* FIXME */ 51 int data;
52 52
53 /* normal buttons */ 53 /* normal buttons */
54 hold_button_old = hold_button; 54 hold_button_old = hold_button;
@@ -56,24 +56,36 @@ int button_read_device(void)
56 56
57 if (!hold_button) 57 if (!hold_button)
58 { 58 {
59#if 0 /* TODO: implement ADC */
60 data = adc_scan(ADC_BUTTONS); 59 data = adc_scan(ADC_BUTTONS);
61 60
62 if (data < 0xf0) 61 if (data < 0xc0)
63 { 62 {
63 if (data < 0x67)
64 if (data < 0x37)
65 btn = BUTTON_VOL_DOWN;
66 else
67 if (data < 0x51)
68 btn = BUTTON_MODE;
69 else
70 btn = BUTTON_VOL_UP;
71 else
72 if (data < 0x7f)
73 btn = BUTTON_REC;
74 else
75 if (data < 0x98)
76 btn = BUTTON_LEFT;
77 else
78 btn = BUTTON_RIGHT;
64 } 79 }
65#endif
66 if (!(GPIO1_READ & 0x00000002)) 80 if (!(GPIO1_READ & 0x00000002))
67 btn |= BUTTON_PLAY; 81 btn |= BUTTON_PLAY;
68 } 82 }
69 83
70 /* remote buttons */ 84 /* remote buttons */
71#if 0 /* TODO: implement ADC */
72 data = remote_detect() ? adc_scan(ADC_REMOTE) : 0xff; 85 data = remote_detect() ? adc_scan(ADC_REMOTE) : 0xff;
73#endif
74 86
75 remote_hold_button_old = remote_hold_button; 87 remote_hold_button_old = remote_hold_button;
76 remote_hold_button = data < 0x17; 88 remote_hold_button = data < 0x14;
77 89
78#ifndef BOOTLOADER 90#ifndef BOOTLOADER
79 if (remote_hold_button != remote_hold_button_old) 91 if (remote_hold_button != remote_hold_button_old)
@@ -82,11 +94,28 @@ int button_read_device(void)
82 94
83 if (!remote_hold_button) 95 if (!remote_hold_button)
84 { 96 {
85#if 0 /* TODO: implement ADC */ 97 if (data < 0xd0)
86 if (data < 0xee)
87 { 98 {
99 if (data < 0x67)
100 if (data < 0x37)
101 btn |= BUTTON_RC_FF;
102 else
103 if (data < 0x51)
104 btn |= BUTTON_RC_REW;
105 else
106 btn |= BUTTON_RC_MODE;
107 else
108 if (data < 0x98)
109 if (data < 0x7f)
110 btn |= BUTTON_RC_REC;
111 else
112 btn |= BUTTON_RC_MENU;
113 else
114 if (data < 0xb0)
115 btn |= BUTTON_RC_VOL_UP;
116 else
117 btn |= BUTTON_RC_VOL_DOWN;
88 } 118 }
89#endif
90 if ((GPIO_READ & 0x80000000) == 0) 119 if ((GPIO_READ & 0x80000000) == 0)
91 btn |= BUTTON_RC_PLAY; 120 btn |= BUTTON_RC_PLAY;
92 } 121 }