diff options
author | Szymon Dziok <b0hoon@o2.pl> | 2010-07-04 12:27:39 +0000 |
---|---|---|
committer | Szymon Dziok <b0hoon@o2.pl> | 2010-07-04 12:27:39 +0000 |
commit | b43c43c591de2490d7b87a40c8c2cf4246361e0d (patch) | |
tree | 672187daadbfc91be51b58d4a542a9eab6ce1a67 /firmware/target/arm | |
parent | 63c795a3496bc322a9e6118a3b08d0a7029b0b7d (diff) | |
download | rockbox-b43c43c591de2490d7b87a40c8c2cf4246361e0d.tar.gz rockbox-b43c43c591de2490d7b87a40c8c2cf4246361e0d.zip |
hdd6330: enable full touchpad support - code cleanup, all buttons should work now correctly, scrollstrip should work like in the OF.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@27274 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/target/arm')
-rw-r--r-- | firmware/target/arm/philips/hdd6330/button-hdd6330.c | 81 | ||||
-rw-r--r-- | firmware/target/arm/philips/hdd6330/button-target.h | 29 |
2 files changed, 82 insertions, 28 deletions
diff --git a/firmware/target/arm/philips/hdd6330/button-hdd6330.c b/firmware/target/arm/philips/hdd6330/button-hdd6330.c index ab06c0cf1a..1d15b11a1e 100644 --- a/firmware/target/arm/philips/hdd6330/button-hdd6330.c +++ b/firmware/target/arm/philips/hdd6330/button-hdd6330.c @@ -22,12 +22,17 @@ #include "system.h" #include "button.h" #include "backlight.h" +#include "powermgmt.h" #include "synaptics-mep.h" /*#define LOGF_ENABLE*/ #include "logf.h" static int int_btn = BUTTON_NONE; +static int old_pos = -1; + +static int scroll_repeat = BUTTON_NONE; +static int repeat = 0; /* * Generate a click sound from the player (not in headphones yet) @@ -59,27 +64,61 @@ void button_int(void) int_btn = BUTTON_NONE; val = touchpad_read_device(data, 4); - - if (val == MEP_BUTTON_HEADER) + + if (data[0] == MEP_BUTTON_HEADER) { /* Buttons packet */ if (data[1] & 0x1) int_btn |= BUTTON_LEFT; if (data[1] & 0x2) + int_btn |= BUTTON_MENU; + if (data[1] & 0x4) int_btn |= BUTTON_RIGHT; + if (data[1] & 0x8) + int_btn |= BUTTON_VIEW; } - else if (val == MEP_ABSOLUTE_HEADER) + else if ((data[0] == MEP_ABSOLUTE_HEADER)) { - /* Absolute packet - the finger is on the vertical strip. - Position ranges from 1-4095, with 1 at the bottom. */ - val = ((data[1] >> 4) << 8) | data[2]; /* position */ - - if ((val > 0) && (val <= 1365)) - int_btn |= BUTTON_DOWN; - else if ((val > 1365) && (val <= 2730)) - int_btn |= BUTTON_SELECT; - else if ((val > 2730) && (val <= 4095)) - int_btn |= BUTTON_UP; + if (data[1] & MEP_FINGER) + { + /* Absolute packet - the finger is on the horizontal strip. + Position ranges from 1-4095, with 1 at the bottom. */ + val = ((data[1] >> 4) << 8) | data[2]; /* position */ + + /* The HDD63x0 actually has 2 scrollbars. One vertical and one horizontal + (where the prev, play, and next buttons are). Because of that, we need to know + which sensor is reporting data. */ + if ((data[3] >> 6) == 1) /* index = 1 */ + { + if ((val > 0) && (val <= 1365)) + int_btn |= BUTTON_PREV; + else if ((val > 1365) && (val <= 2730)) + int_btn |= BUTTON_PLAY; + else if ((val > 2730) && (val <= 4095)) + int_btn |= BUTTON_NEXT; + } else + { + int scr_pos = val >> 8; /* split the scrollstrip into 16 regions */ + if ((old_pos<scr_pos)&&(old_pos!=-1)) int_btn = BUTTON_UP; + if ((old_pos>scr_pos)&&(old_pos!=-1)) int_btn = BUTTON_DOWN; + + old_pos = scr_pos; + + /* repeat button */ + repeat = 0; + if (int_btn != BUTTON_NONE) + { + if (int_btn != scroll_repeat) + scroll_repeat = int_btn; + else repeat = BUTTON_REPEAT; + } + } + } + else + { + old_pos = -1; + scroll_repeat = BUTTON_NONE; + } } } #else @@ -104,13 +143,23 @@ int button_read_device(void) return BUTTON_NONE; /* Device buttons */ - if (!(GPIOA_INPUT_VAL & 0x01)) btn |= BUTTON_MENU; if (!(GPIOA_INPUT_VAL & 0x02)) btn |= BUTTON_VOL_UP; if (!(GPIOA_INPUT_VAL & 0x04)) btn |= BUTTON_VOL_DOWN; - if (!(GPIOA_INPUT_VAL & 0x08)) btn |= BUTTON_VIEW; - if (!(GPIOD_INPUT_VAL & 0x20)) btn |= BUTTON_PLAYLIST; if (!(GPIOD_INPUT_VAL & 0x40)) btn |= BUTTON_POWER; + /* Scrollstrip direct button post - much better response */ + if ((btn == BUTTON_UP) || (btn == BUTTON_DOWN)) + { + queue_post(&button_queue,btn|repeat,0); + backlight_on(); + buttonlight_on(); + reset_poweroff_timer(); + + int_btn = BUTTON_NONE; + repeat = BUTTON_NONE; + btn = BUTTON_NONE; + } + if ((btn != btn_old) && (btn != BUTTON_NONE)) button_click(); diff --git a/firmware/target/arm/philips/hdd6330/button-target.h b/firmware/target/arm/philips/hdd6330/button-target.h index b7fc21aca2..07d8d9b0de 100644 --- a/firmware/target/arm/philips/hdd6330/button-target.h +++ b/firmware/target/arm/philips/hdd6330/button-target.h @@ -28,6 +28,7 @@ #define MEP_BUTTON_HEADER 0x19 #define MEP_BUTTON_ID 0x9 #define MEP_ABSOLUTE_HEADER 0x0b +#define MEP_FINGER 0x01 #define HAS_BUTTON_HOLD @@ -41,18 +42,22 @@ void button_int(void); /* Main unit's buttons */ #define BUTTON_POWER 0x00000001 -#define BUTTON_PLAYLIST 0x00000002 -#define BUTTON_MENU 0x00000004 -#define BUTTON_VIEW 0x00000008 -#define BUTTON_VOL_UP 0x00000010 -#define BUTTON_VOL_DOWN 0x00000020 -#define BUTTON_SELECT 0x00000040 -#define BUTTON_LEFT 0x00000080 -#define BUTTON_RIGHT 0x00000100 -#define BUTTON_UP 0x00000200 -#define BUTTON_DOWN 0x00000400 - -#define BUTTON_MAIN 0x00000fff +#define BUTTON_MENU 0x00000002 +#define BUTTON_VIEW 0x00000004 +#define BUTTON_VOL_UP 0x00000008 +#define BUTTON_VOL_DOWN 0x00000010 +#define BUTTON_LEFT 0x00000020 +#define BUTTON_RIGHT 0x00000040 +#define BUTTON_UP 0x00000080 +#define BUTTON_DOWN 0x00000100 +#define BUTTON_NEXT 0x00000200 +#define BUTTON_PREV 0x00000400 +#define BUTTON_PLAY 0x00000800 + +#define BUTTON_SELECT 0x00001000 +#define BUTTON_PLAYLIST 0x00002000 + +#define BUTTON_MAIN 0x00003fff /* No Remote control */ #define BUTTON_REMOTE 0 |