forked from len0rd/rockbox
mr500: move remote button reading code to buttom-mr500.c
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@31609 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
b612263b1e
commit
56e2eea175
3 changed files with 48 additions and 56 deletions
|
@ -108,6 +108,52 @@ inline bool button_hold(void)
|
||||||
return hold_button;
|
return hold_button;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef HAVE_REMOTE_LCD
|
||||||
|
static bool remote_hold_button;
|
||||||
|
static int remote_read_buttons(void)
|
||||||
|
{
|
||||||
|
static char read_buffer[5];
|
||||||
|
int read_button = BUTTON_NONE;
|
||||||
|
|
||||||
|
static int oldbutton=BUTTON_NONE;
|
||||||
|
|
||||||
|
/* Handle remote buttons */
|
||||||
|
if(uart1_gets_queue(read_buffer, 5)>=0)
|
||||||
|
{
|
||||||
|
int button_location;
|
||||||
|
|
||||||
|
for(button_location=0;button_location<4;button_location++)
|
||||||
|
{
|
||||||
|
if((read_buffer[button_location]&0xF0)==0xF0
|
||||||
|
&& (read_buffer[button_location+1]&0xF0)!=0xF0)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(button_location==4)
|
||||||
|
button_location=0;
|
||||||
|
|
||||||
|
button_location++;
|
||||||
|
|
||||||
|
read_button |= read_buffer[button_location];
|
||||||
|
|
||||||
|
/* Find the hold status location */
|
||||||
|
if(button_location==4)
|
||||||
|
button_location=0;
|
||||||
|
else
|
||||||
|
button_location++;
|
||||||
|
|
||||||
|
remote_hold_button=((read_buffer[button_location]&0x80)?true:false);
|
||||||
|
|
||||||
|
uart1_clear_queue();
|
||||||
|
oldbutton=read_button;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
read_button=oldbutton;
|
||||||
|
|
||||||
|
return read_button;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Since this is a touchscreen, the expectation in higher levels is that the
|
/* Since this is a touchscreen, the expectation in higher levels is that the
|
||||||
* previous touch location is maintained when a release occurs. This is
|
* previous touch location is maintained when a release occurs. This is
|
||||||
* intended to mimic a mouse or other similar pointing device.
|
* intended to mimic a mouse or other similar pointing device.
|
||||||
|
@ -137,8 +183,8 @@ int button_read_device(int *data)
|
||||||
|
|
||||||
#if defined(HAVE_REMOTE_LCD)
|
#if defined(HAVE_REMOTE_LCD)
|
||||||
/* Read data from the remote */
|
/* Read data from the remote */
|
||||||
button_read |= remote_read_device();
|
button_read |= remote_read_buttons();
|
||||||
hold_button=remote_button_hold();
|
hold_button=remote_hold_button;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Take care of hold notifications */
|
/* Take care of hold notifications */
|
||||||
|
|
|
@ -45,8 +45,6 @@ static enum remote_draw_states
|
||||||
DRAW_PAUSE,
|
DRAW_PAUSE,
|
||||||
} remote_state_draw = DRAW_TOP, remote_state_draw_next;
|
} remote_state_draw = DRAW_TOP, remote_state_draw_next;
|
||||||
|
|
||||||
static bool remote_hold_button=false;
|
|
||||||
|
|
||||||
bool remote_initialized=true;
|
bool remote_initialized=true;
|
||||||
|
|
||||||
static unsigned char remote_contrast=DEFAULT_REMOTE_CONTRAST_SETTING;
|
static unsigned char remote_contrast=DEFAULT_REMOTE_CONTRAST_SETTING;
|
||||||
|
@ -292,54 +290,6 @@ void lcd_remote_update_rect(int x, int y, int width, int height)
|
||||||
remote_state_control=REMOTE_CONTROL_DRAW;
|
remote_state_control=REMOTE_CONTROL_DRAW;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool remote_button_hold(void)
|
|
||||||
{
|
|
||||||
return remote_hold_button;
|
|
||||||
}
|
|
||||||
|
|
||||||
int remote_read_device(void)
|
|
||||||
{
|
|
||||||
static char read_buffer[5];
|
|
||||||
int read_button = BUTTON_NONE;
|
|
||||||
|
|
||||||
static int oldbutton=BUTTON_NONE;
|
|
||||||
|
|
||||||
/* Handle remote buttons */
|
|
||||||
if(uart1_gets_queue(read_buffer, 5)>=0)
|
|
||||||
{
|
|
||||||
int button_location;
|
|
||||||
|
|
||||||
for(button_location=0;button_location<4;button_location++)
|
|
||||||
{
|
|
||||||
if((read_buffer[button_location]&0xF0)==0xF0
|
|
||||||
&& (read_buffer[button_location+1]&0xF0)!=0xF0)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(button_location==4)
|
|
||||||
button_location=0;
|
|
||||||
|
|
||||||
button_location++;
|
|
||||||
|
|
||||||
read_button |= read_buffer[button_location];
|
|
||||||
|
|
||||||
/* Find the hold status location */
|
|
||||||
if(button_location==4)
|
|
||||||
button_location=0;
|
|
||||||
else
|
|
||||||
button_location++;
|
|
||||||
|
|
||||||
remote_hold_button=((read_buffer[button_location]&0x80)?true:false);
|
|
||||||
|
|
||||||
uart1_clear_queue();
|
|
||||||
oldbutton=read_button;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
read_button=oldbutton;
|
|
||||||
|
|
||||||
return read_button;
|
|
||||||
}
|
|
||||||
|
|
||||||
void _remote_backlight_on(void)
|
void _remote_backlight_on(void)
|
||||||
{
|
{
|
||||||
remote_power|=0x40;
|
remote_power|=0x40;
|
||||||
|
|
|
@ -22,10 +22,6 @@
|
||||||
#define LCD_REMOTE_TARGET_H
|
#define LCD_REMOTE_TARGET_H
|
||||||
|
|
||||||
void lcd_remote_powersave(bool on);
|
void lcd_remote_powersave(bool on);
|
||||||
|
|
||||||
void lcd_remote_sleep(void);
|
void lcd_remote_sleep(void);
|
||||||
|
|
||||||
int remote_read_device(void);
|
|
||||||
bool remote_button_hold(void);
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue