forked from len0rd/rockbox
Added key-release event masking
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@1460 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
c16a86677f
commit
406edc298d
2 changed files with 45 additions and 10 deletions
|
|
@ -36,6 +36,8 @@ struct event_queue button_queue;
|
|||
#define REPEAT_INTERVAL 4
|
||||
|
||||
static int repeat_mask = DEFAULT_REPEAT_MASK;
|
||||
static int release_mask = DEFAULT_RELEASE_MASK;
|
||||
static int locked_mask = DEFAULT_LOCKED_MASK;
|
||||
|
||||
static int button_read(void);
|
||||
|
||||
|
|
@ -45,13 +47,23 @@ static void button_tick(void)
|
|||
static int count=0;
|
||||
static int lastbtn=0;
|
||||
static bool repeat=false;
|
||||
int diff;
|
||||
|
||||
/* only poll every X ticks */
|
||||
if ( ++tick >= POLL_FREQUENCY ) {
|
||||
bool post = false;
|
||||
int btn = button_read();
|
||||
|
||||
if ( btn ) {
|
||||
if ( btn )
|
||||
{
|
||||
/* Find out if a key has been released */
|
||||
diff = btn ^ lastbtn;
|
||||
if((btn & diff) == 0)
|
||||
{
|
||||
if(diff & release_mask)
|
||||
queue_post(&button_queue, BUTTON_REL | diff, NULL);
|
||||
}
|
||||
|
||||
/* normal keypress */
|
||||
if ( btn != lastbtn ) {
|
||||
post = true;
|
||||
|
|
@ -96,7 +108,8 @@ static void button_tick(void)
|
|||
/* Report that the key has been released */
|
||||
if(lastbtn != btn)
|
||||
{
|
||||
queue_post(&button_queue, BUTTON_REL | lastbtn, NULL);
|
||||
if(lastbtn & release_mask)
|
||||
queue_post(&button_queue, BUTTON_REL | lastbtn, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -118,6 +131,27 @@ int button_get(bool block)
|
|||
return BUTTON_NONE;
|
||||
}
|
||||
|
||||
int button_set_repeat(int newmask)
|
||||
{
|
||||
int oldmask = repeat_mask;
|
||||
repeat_mask = newmask;
|
||||
return oldmask;
|
||||
}
|
||||
|
||||
int button_set_release(int newmask)
|
||||
{
|
||||
int oldmask = release_mask;
|
||||
release_mask = newmask;
|
||||
return oldmask;
|
||||
}
|
||||
|
||||
int button_set_locked(int newmask)
|
||||
{
|
||||
int oldmask = locked_mask;
|
||||
locked_mask = newmask;
|
||||
return oldmask;
|
||||
}
|
||||
|
||||
#ifdef HAVE_RECORDER_KEYPAD
|
||||
|
||||
/* AJBR buttons are connected to the CPU as follows:
|
||||
|
|
@ -151,13 +185,6 @@ void button_init()
|
|||
tick_add_task(button_tick);
|
||||
}
|
||||
|
||||
int button_set_repeat(int newmask)
|
||||
{
|
||||
int oldmask = repeat_mask;
|
||||
repeat_mask = newmask;
|
||||
return oldmask;
|
||||
}
|
||||
|
||||
/*
|
||||
* Get button pressed from hardware
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -27,6 +27,8 @@ extern struct event_queue button_queue;
|
|||
void button_init (void);
|
||||
int button_get (bool block);
|
||||
int button_set_repeat(int newmask);
|
||||
int button_set_release(int newmask);
|
||||
int button_set_locked(int newmask);
|
||||
|
||||
/* Shared button codes */
|
||||
#define BUTTON_NONE 0x0000
|
||||
|
|
@ -40,6 +42,9 @@ int button_set_repeat(int newmask);
|
|||
#define BUTTON_HELD 0x4000
|
||||
#define BUTTON_REL 0x8000
|
||||
|
||||
/* Special message */
|
||||
#define BUTTON_LOCKED 0x2000
|
||||
|
||||
#ifdef HAVE_RECORDER_KEYPAD
|
||||
|
||||
/* Recorder specific button codes */
|
||||
|
|
@ -61,6 +66,9 @@ int button_set_repeat(int newmask);
|
|||
|
||||
#define DEFAULT_REPEAT_MASK (BUTTON_LEFT | BUTTON_RIGHT)
|
||||
|
||||
#endif
|
||||
#endif /* HAVE_PLAYER_KEYPAD */
|
||||
|
||||
#define DEFAULT_RELEASE_MASK 0
|
||||
#define DEFAULT_LOCKED_MASK 0
|
||||
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue