diff options
-rw-r--r-- | firmware/target/arm/olympus/mrobe-500/button-mr500.c | 65 | ||||
-rw-r--r-- | firmware/target/arm/olympus/mrobe-500/button-target.h | 78 |
2 files changed, 71 insertions, 72 deletions
diff --git a/firmware/target/arm/olympus/mrobe-500/button-mr500.c b/firmware/target/arm/olympus/mrobe-500/button-mr500.c index 9cafab5c14..388dbf0689 100644 --- a/firmware/target/arm/olympus/mrobe-500/button-mr500.c +++ b/firmware/target/arm/olympus/mrobe-500/button-mr500.c | |||
@@ -27,22 +27,11 @@ | |||
27 | #include "system.h" | 27 | #include "system.h" |
28 | #include "backlight-target.h" | 28 | #include "backlight-target.h" |
29 | 29 | ||
30 | static int const remote_buttons[] = | 30 | #define BUTTON_TIMEOUT 50 |
31 | { | ||
32 | BUTTON_NONE, /* Headphones connected - remote disconnected */ | ||
33 | BUTTON_RC_PLAY, | ||
34 | BUTTON_RC_DSP, | ||
35 | BUTTON_RC_REW, | ||
36 | BUTTON_RC_FF, | ||
37 | BUTTON_RC_VOL_UP, | ||
38 | BUTTON_RC_VOL_DOWN, | ||
39 | BUTTON_NONE, /* Remote control attached - no buttons pressed */ | ||
40 | BUTTON_NONE, /* Nothing in the headphone socket */ | ||
41 | }; | ||
42 | |||
43 | void button_init_device(void) | 31 | void button_init_device(void) |
44 | { | 32 | { |
45 | /* Power, Remote Play & Hold switch */ | 33 | /* GIO is the power button, set as input */ |
34 | outw(inw(IO_GIO_DIR0)|0x01, IO_GIO_DIR0); | ||
46 | } | 35 | } |
47 | 36 | ||
48 | inline bool button_hold(void) | 37 | inline bool button_hold(void) |
@@ -52,5 +41,51 @@ inline bool button_hold(void) | |||
52 | 41 | ||
53 | int button_read_device(void) | 42 | int button_read_device(void) |
54 | { | 43 | { |
55 | return 0; | 44 | char data[5], c; |
45 | int i = 0; | ||
46 | int btn = BUTTON_NONE, timeout = BUTTON_TIMEOUT; | ||
47 | |||
48 | if ((inw(IO_GIO_BITSET0)&0x01) == 0) | ||
49 | btn |= BUTTON_POWER; | ||
50 | |||
51 | uartHeartbeat(); | ||
52 | while (timeout > 0) | ||
53 | { | ||
54 | c = uartPollch(BUTTON_TIMEOUT*100); | ||
55 | if (c > -1) | ||
56 | { | ||
57 | if (i && data[0] == 0xf4) | ||
58 | { | ||
59 | data[i++] = c; | ||
60 | } | ||
61 | else if (c == 0xf4) | ||
62 | { | ||
63 | data[0] = c; | ||
64 | i = 1; | ||
65 | } | ||
66 | |||
67 | if (i == 5) | ||
68 | { | ||
69 | if (data[1]& (1<<7)) | ||
70 | btn |= BUTTON_RC_HEART; | ||
71 | if (data[1]& (1<<6)) | ||
72 | btn |= BUTTON_RC_MODE; | ||
73 | if (data[1]& (1<<5)) | ||
74 | btn |= BUTTON_RC_VOL_DOWN; | ||
75 | if (data[1]& (1<<4)) | ||
76 | btn |= BUTTON_RC_VOL_UP; | ||
77 | if (data[1]& (1<<3)) | ||
78 | btn |= BUTTON_RC_REW; | ||
79 | if (data[1]& (1<<2)) | ||
80 | btn |= BUTTON_RC_FF; | ||
81 | if (data[1]& (1<<1)) | ||
82 | btn |= BUTTON_RC_DOWN; | ||
83 | if (data[1]& (1<<0)) | ||
84 | btn |= BUTTON_RC_PLAY; | ||
85 | break; | ||
86 | } | ||
87 | } | ||
88 | timeout--; | ||
89 | } | ||
90 | return btn; | ||
56 | } | 91 | } |
diff --git a/firmware/target/arm/olympus/mrobe-500/button-target.h b/firmware/target/arm/olympus/mrobe-500/button-target.h index 6637c5bf2b..80dd246744 100644 --- a/firmware/target/arm/olympus/mrobe-500/button-target.h +++ b/firmware/target/arm/olympus/mrobe-500/button-target.h | |||
@@ -7,7 +7,7 @@ | |||
7 | * \/ \/ \/ \/ \/ | 7 | * \/ \/ \/ \/ \/ |
8 | * $Id: $ | 8 | * $Id: $ |
9 | * | 9 | * |
10 | * Copyright (C) 2007 by Karl Kurbjun | 10 | * Copyright (C) 2007 by Jonathan Gordon |
11 | * | 11 | * |
12 | * All files in this archive are subject to the GNU General Public License. | 12 | * All files in this archive are subject to the GNU General Public License. |
13 | * See the file COPYING in the source tree root for full license agreement. | 13 | * See the file COPYING in the source tree root for full license agreement. |
@@ -29,71 +29,35 @@ bool button_hold(void); | |||
29 | void button_init_device(void); | 29 | void button_init_device(void); |
30 | int button_read_device(void); | 30 | int button_read_device(void); |
31 | 31 | ||
32 | /* Toshiba Gigabeat specific button codes */ | 32 | /* m:robe 500 specific button codes */ |
33 | 33 | ||
34 | #define BUTTON_POWER 0x00000001 | 34 | #define BUTTON_POWER 0x00000001 |
35 | #define BUTTON_MENU 0x00000002 | ||
36 | |||
37 | #define BUTTON_LEFT 0x00000004 | ||
38 | #define BUTTON_RIGHT 0x00000008 | ||
39 | #define BUTTON_UP 0x00000010 | ||
40 | #define BUTTON_DOWN 0x00000020 | ||
41 | |||
42 | #define BUTTON_VOL_UP 0x00000040 | ||
43 | #define BUTTON_VOL_DOWN 0x00000080 | ||
44 | |||
45 | #define BUTTON_SELECT 0x00000100 | ||
46 | #define BUTTON_A 0x00000200 | ||
47 | 35 | ||
48 | /* Remote control buttons */ | 36 | /* Remote control buttons */ |
49 | 37 | ||
50 | #define BUTTON_RC_VOL_UP 0x00000400 | 38 | #define BUTTON_RC_HEART 0x00000002 |
51 | #define BUTTON_RC_VOL_DOWN 0x00000800 | 39 | #define BUTTON_RC_MODE 0x00000004 |
52 | #define BUTTON_RC_FF 0x00001000 | 40 | #define BUTTON_RC_VOL_DOWN 0x00000008 |
53 | #define BUTTON_RC_REW 0x00002000 | 41 | #define BUTTON_RC_VOL_UP 0x00000010 |
54 | |||
55 | #define BUTTON_RC_PLAY 0x00004000 | ||
56 | #define BUTTON_RC_DSP 0x00008000 | ||
57 | |||
58 | /* Toshiba Gigabeat specific remote button ADC values */ | ||
59 | /* The remote control uses ADC 1 to emulate button pushes | ||
60 | Reading (approx) Button HP plugged in? Remote plugged in? | ||
61 | 0 N/A Yes No | ||
62 | 125 Play/Pause Cant tell Yes | ||
63 | 241 Speaker+ Cant tell Yes | ||
64 | 369 Rewind Cant tell Yes | ||
65 | 492 Fast Fwd Cant tell Yes | ||
66 | 616 Vol + Cant tell Yes | ||
67 | 742 Vol - Cant tell Yes | ||
68 | 864 None Cant tell Yes | ||
69 | 1023 N/A No No | ||
70 | */ | ||
71 | 42 | ||
72 | /* | ||
73 | Notes: | ||
74 | 43 | ||
75 | Buttons on the remote are translated into equivalent button presses just | 44 | #define BUTTON_RC_PLAY 0x00000020 |
76 | as if you were pressing them on the Gigabeat itself. | 45 | #define BUTTON_RC_REW 0x00000040 |
77 | 46 | #define BUTTON_RC_FF 0x00000080 | |
78 | We cannot tell if the hold is asserted on the remote. The Hold function on | 47 | #define BUTTON_RC_DOWN 0x00000100 |
79 | the remote is to block the output of the buttons changing. | 48 | #define BUTTON_TOUCH 0x00000200 |
80 | 49 | ||
81 | Only one button can be sensed at a time. If another is pressed, the button | 50 | /* compatibility hacks */ |
82 | with the lowest reading is dominant. So, if Rewind and Vol + are pressed | 51 | #define BUTTON_LEFT BUTTON_RC_REW |
83 | at the same time, Rewind value is the one that is read. | 52 | #define BUTTON_RIGHT BUTTON_RC_FF |
84 | */ | 53 | #define POWEROFF_BUTTON BUTTON_POWER |
85 | 54 | #define POWEROFF_COUNT 40 | |
86 | |||
87 | |||
88 | |||
89 | #define BUTTON_MAIN (BUTTON_POWER|BUTTON_MENU|BUTTON_LEFT|BUTTON_RIGHT\ | ||
90 | |BUTTON_UP|BUTTON_DOWN|BUTTON_VOL_UP|BUTTON_VOL_DOWN\ | ||
91 | |BUTTON_SELECT|BUTTON_A) | ||
92 | 55 | ||
93 | #define BUTTON_REMOTE (BUTTON_RC_VOL_UP|BUTTON_RC_VOL_DOWN|BUTTON_RC_FF\ | 56 | #define BUTTON_MAIN BUTTON_POWER |
94 | |BUTTON_RC_REW|BUTTON_RC_PLAY|BUTTON_RC_DSP) | ||
95 | 57 | ||
96 | #define POWEROFF_BUTTON BUTTON_POWER | 58 | #define BUTTON_REMOTE (BUTTON_RC_HEART|BUTTON_RC_MODE| \ |
97 | #define POWEROFF_COUNT 10 | 59 | BUTTON_RC_VOL_DOWN|BUTTON_RC_VOL_UP| \ |
60 | BUTTON_RC_PLAY|BUTTON_RC_DOWN| \ | ||
61 | BUTTON_RC_REW|BUTTON_RC_FF) | ||
98 | 62 | ||
99 | #endif /* _BUTTON_TARGET_H_ */ | 63 | #endif /* _BUTTON_TARGET_H_ */ |