diff options
author | Mark Arigo <markarigo@gmail.com> | 2009-06-19 03:23:38 +0000 |
---|---|---|
committer | Mark Arigo <markarigo@gmail.com> | 2009-06-19 03:23:38 +0000 |
commit | a61196fd3ae5ebd71134da8eb10e3189403c116f (patch) | |
tree | 7ce78201cb299ebfd6ac92f490776072c47a9e03 /firmware/target/arm/philips/sa9200/button-sa9200.c | |
parent | 6a0d931f383259b4b82fcfd1cc87700f53bbcb02 (diff) | |
download | rockbox-a61196fd3ae5ebd71134da8eb10e3189403c116f.tar.gz rockbox-a61196fd3ae5ebd71134da8eb10e3189403c116f.zip |
Philips SA9200: Working touchpad and button lights! Also, improvements to the keymap (still needs work).
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@21346 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/target/arm/philips/sa9200/button-sa9200.c')
-rwxr-xr-x | firmware/target/arm/philips/sa9200/button-sa9200.c | 79 |
1 files changed, 54 insertions, 25 deletions
diff --git a/firmware/target/arm/philips/sa9200/button-sa9200.c b/firmware/target/arm/philips/sa9200/button-sa9200.c index d965966075..be37111ecb 100755 --- a/firmware/target/arm/philips/sa9200/button-sa9200.c +++ b/firmware/target/arm/philips/sa9200/button-sa9200.c | |||
@@ -22,11 +22,58 @@ | |||
22 | #include "system.h" | 22 | #include "system.h" |
23 | #include "button.h" | 23 | #include "button.h" |
24 | #include "backlight.h" | 24 | #include "backlight.h" |
25 | #include "synaptics-mep.h" | ||
25 | 26 | ||
27 | #define LOGF_ENABLE | ||
28 | #include "logf.h" | ||
29 | |||
30 | static int int_btn = BUTTON_NONE; | ||
31 | |||
32 | #ifndef BOOTLOADER | ||
26 | void button_init_device(void) | 33 | void button_init_device(void) |
27 | { | 34 | { |
28 | /* TODO...for now, hardware initialisation is done by the c200 bootloader */ | 35 | /* The touchpad is powered on and initialized in power-sa9200.c |
36 | since it needs to be ready for both buttons and button lights. */ | ||
37 | } | ||
38 | |||
39 | /* | ||
40 | * Button interrupt handler | ||
41 | */ | ||
42 | void button_int(void) | ||
43 | { | ||
44 | char data[4]; | ||
45 | int val; | ||
46 | |||
47 | int_btn = BUTTON_NONE; | ||
48 | |||
49 | val = touchpad_read_device(data, 4); | ||
50 | |||
51 | if (val == MEP_BUTTON_HEADER) | ||
52 | { | ||
53 | /* Buttons packet */ | ||
54 | if (data[1] & 0x1) int_btn |= BUTTON_FFWD; | ||
55 | if (data[1] & 0x2) int_btn |= BUTTON_RIGHT; | ||
56 | if (data[1] & 0x4) int_btn |= BUTTON_LEFT; | ||
57 | if (data[1] & 0x8) int_btn |= BUTTON_REW; | ||
58 | if (data[2] & 0x1) int_btn |= BUTTON_MENU; | ||
59 | } | ||
60 | else if (val == MEP_ABSOLUTE_HEADER) | ||
61 | { | ||
62 | /* Absolute packet - the finger is on the vertical strip. | ||
63 | Position ranges from 1-4095, with 1 at the bottom. */ | ||
64 | val = ((data[1] >> 4) << 8) | data[2]; /* position */ | ||
65 | |||
66 | if ((val > 0) && (val <= 1365)) | ||
67 | int_btn |= BUTTON_DOWN; | ||
68 | else if ((val > 1365) && (val <= 2730)) | ||
69 | int_btn |= BUTTON_PLAY; | ||
70 | else if ((val > 2730) && (val <= 4095)) | ||
71 | int_btn |= BUTTON_UP; | ||
72 | } | ||
29 | } | 73 | } |
74 | #else | ||
75 | void button_init_device(void){} | ||
76 | #endif /* bootloader */ | ||
30 | 77 | ||
31 | bool button_hold(void) | 78 | bool button_hold(void) |
32 | { | 79 | { |
@@ -38,32 +85,14 @@ bool button_hold(void) | |||
38 | */ | 85 | */ |
39 | int button_read_device(void) | 86 | int button_read_device(void) |
40 | { | 87 | { |
41 | int btn = BUTTON_NONE; | 88 | int btn = int_btn; |
42 | static bool hold_button = false; | ||
43 | bool hold_button_old; | ||
44 | |||
45 | /* Hold */ | ||
46 | hold_button_old = hold_button; | ||
47 | hold_button = button_hold(); | ||
48 | 89 | ||
49 | #ifndef BOOTLOADER | 90 | if (button_hold()) |
50 | if (hold_button != hold_button_old) | 91 | return BUTTON_NONE; |
51 | backlight_hold_changed(hold_button); | ||
52 | #endif | ||
53 | 92 | ||
54 | /* device buttons */ | 93 | if (!(GPIOB_INPUT_VAL & 0x20)) btn |= BUTTON_POWER; |
55 | if (!hold_button) | 94 | if (!(GPIOF_INPUT_VAL & 0x10)) btn |= BUTTON_VOL_UP; |
56 | { | 95 | if (!(GPIOF_INPUT_VAL & 0x04)) btn |= BUTTON_VOL_DOWN; |
57 | #if 0 | ||
58 | if (!(GPIOB_INPUT_VAL & 0x20)) btn |= BUTTON_POWER; | ||
59 | if (!(GPIOF_INPUT_VAL & 0x10)) btn |= BUTTON_VOL_UP; | ||
60 | if (!(GPIOF_INPUT_VAL & 0x04)) btn |= BUTTON_VOL_DOWN; | ||
61 | #endif | ||
62 | /* A hack until the touchpad works */ | ||
63 | if (!(GPIOB_INPUT_VAL & 0x20)) btn |= BUTTON_SELECT; | ||
64 | if (!(GPIOF_INPUT_VAL & 0x10)) btn |= BUTTON_UP; | ||
65 | if (!(GPIOF_INPUT_VAL & 0x04)) btn |= BUTTON_DOWN; | ||
66 | } | ||
67 | 96 | ||
68 | return btn; | 97 | return btn; |
69 | } | 98 | } |