1
0
Fork 0
forked from len0rd/rockbox

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
This commit is contained in:
Szymon Dziok 2010-07-04 12:27:39 +00:00
parent 63c795a349
commit b43c43c591
2 changed files with 80 additions and 26 deletions

View file

@ -22,12 +22,17 @@
#include "system.h" #include "system.h"
#include "button.h" #include "button.h"
#include "backlight.h" #include "backlight.h"
#include "powermgmt.h"
#include "synaptics-mep.h" #include "synaptics-mep.h"
/*#define LOGF_ENABLE*/ /*#define LOGF_ENABLE*/
#include "logf.h" #include "logf.h"
static int int_btn = BUTTON_NONE; 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) * Generate a click sound from the player (not in headphones yet)
@ -59,27 +64,61 @@ void button_int(void)
int_btn = BUTTON_NONE; int_btn = BUTTON_NONE;
val = touchpad_read_device(data, 4); val = touchpad_read_device(data, 4);
if (val == MEP_BUTTON_HEADER) if (data[0] == MEP_BUTTON_HEADER)
{ {
/* Buttons packet */ /* Buttons packet */
if (data[1] & 0x1) if (data[1] & 0x1)
int_btn |= BUTTON_LEFT; int_btn |= BUTTON_LEFT;
if (data[1] & 0x2) if (data[1] & 0x2)
int_btn |= BUTTON_MENU;
if (data[1] & 0x4)
int_btn |= BUTTON_RIGHT; 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. if (data[1] & MEP_FINGER)
Position ranges from 1-4095, with 1 at the bottom. */ {
val = ((data[1] >> 4) << 8) | data[2]; /* position */ /* 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 */
if ((val > 0) && (val <= 1365)) /* The HDD63x0 actually has 2 scrollbars. One vertical and one horizontal
int_btn |= BUTTON_DOWN; (where the prev, play, and next buttons are). Because of that, we need to know
else if ((val > 1365) && (val <= 2730)) which sensor is reporting data. */
int_btn |= BUTTON_SELECT; if ((data[3] >> 6) == 1) /* index = 1 */
else if ((val > 2730) && (val <= 4095)) {
int_btn |= BUTTON_UP; 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 #else
@ -104,13 +143,23 @@ int button_read_device(void)
return BUTTON_NONE; return BUTTON_NONE;
/* Device buttons */ /* Device buttons */
if (!(GPIOA_INPUT_VAL & 0x01)) btn |= BUTTON_MENU;
if (!(GPIOA_INPUT_VAL & 0x02)) btn |= BUTTON_VOL_UP; if (!(GPIOA_INPUT_VAL & 0x02)) btn |= BUTTON_VOL_UP;
if (!(GPIOA_INPUT_VAL & 0x04)) btn |= BUTTON_VOL_DOWN; 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; 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)) if ((btn != btn_old) && (btn != BUTTON_NONE))
button_click(); button_click();

View file

@ -28,6 +28,7 @@
#define MEP_BUTTON_HEADER 0x19 #define MEP_BUTTON_HEADER 0x19
#define MEP_BUTTON_ID 0x9 #define MEP_BUTTON_ID 0x9
#define MEP_ABSOLUTE_HEADER 0x0b #define MEP_ABSOLUTE_HEADER 0x0b
#define MEP_FINGER 0x01
#define HAS_BUTTON_HOLD #define HAS_BUTTON_HOLD
@ -41,18 +42,22 @@ void button_int(void);
/* Main unit's buttons */ /* Main unit's buttons */
#define BUTTON_POWER 0x00000001 #define BUTTON_POWER 0x00000001
#define BUTTON_PLAYLIST 0x00000002 #define BUTTON_MENU 0x00000002
#define BUTTON_MENU 0x00000004 #define BUTTON_VIEW 0x00000004
#define BUTTON_VIEW 0x00000008 #define BUTTON_VOL_UP 0x00000008
#define BUTTON_VOL_UP 0x00000010 #define BUTTON_VOL_DOWN 0x00000010
#define BUTTON_VOL_DOWN 0x00000020 #define BUTTON_LEFT 0x00000020
#define BUTTON_SELECT 0x00000040 #define BUTTON_RIGHT 0x00000040
#define BUTTON_LEFT 0x00000080 #define BUTTON_UP 0x00000080
#define BUTTON_RIGHT 0x00000100 #define BUTTON_DOWN 0x00000100
#define BUTTON_UP 0x00000200 #define BUTTON_NEXT 0x00000200
#define BUTTON_DOWN 0x00000400 #define BUTTON_PREV 0x00000400
#define BUTTON_PLAY 0x00000800
#define BUTTON_MAIN 0x00000fff #define BUTTON_SELECT 0x00001000
#define BUTTON_PLAYLIST 0x00002000
#define BUTTON_MAIN 0x00003fff
/* No Remote control */ /* No Remote control */
#define BUTTON_REMOTE 0 #define BUTTON_REMOTE 0