mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-12-09 05:05:20 -05:00
Add generic touchscreen driver which allows calibration (apps/ layer will follow later).
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@20055 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
1cb3ff0ab0
commit
44eba07516
5 changed files with 230 additions and 92 deletions
|
|
@ -25,31 +25,13 @@
|
|||
#include "adc.h"
|
||||
#include "pcf50606.h"
|
||||
#include "backlight.h"
|
||||
#include "touchscreen.h"
|
||||
|
||||
#define TOUCH_MARGIN 8
|
||||
|
||||
static enum touchscreen_mode current_mode = TOUCHSCREEN_POINT;
|
||||
|
||||
static short last_x, last_y;
|
||||
static bool touch_available = false;
|
||||
|
||||
static int touchscreen_buttons[3][3] =
|
||||
{
|
||||
{BUTTON_TOPLEFT, BUTTON_TOPMIDDLE, BUTTON_TOPRIGHT},
|
||||
{BUTTON_MIDLEFT, BUTTON_CENTER, BUTTON_MIDRIGHT},
|
||||
{BUTTON_BOTTOMLEFT, BUTTON_BOTTOMMIDDLE, BUTTON_BOTTOMRIGHT},
|
||||
};
|
||||
|
||||
void touchscreen_set_mode(enum touchscreen_mode mode)
|
||||
{
|
||||
current_mode = mode;
|
||||
}
|
||||
|
||||
enum touchscreen_mode touchscreen_get_mode(void)
|
||||
{
|
||||
return current_mode;
|
||||
}
|
||||
|
||||
void button_set_touch_available(void)
|
||||
{
|
||||
touch_available = true;
|
||||
|
|
@ -186,20 +168,9 @@ int button_read_device(int *data)
|
|||
last_x = x;
|
||||
last_y = y;
|
||||
*data = touch_to_pixels(x, y);
|
||||
switch (current_mode)
|
||||
{
|
||||
case TOUCHSCREEN_POINT:
|
||||
btn |= BUTTON_TOUCHSCREEN;
|
||||
break;
|
||||
case TOUCHSCREEN_BUTTON:
|
||||
{
|
||||
int px_x = (*data&0xffff0000)>>16;
|
||||
int px_y = (*data&0x0000ffff);
|
||||
btn |= touchscreen_buttons[px_y/(LCD_HEIGHT/3)]
|
||||
[px_x/(LCD_WIDTH/3)];
|
||||
break;
|
||||
}
|
||||
}
|
||||
btn |= touchscreen_to_pixels((*data&0xffff0000)>>16,
|
||||
(*data&0x0000ffff),
|
||||
data);
|
||||
}
|
||||
last_touch = current_tick;
|
||||
touch_available = false;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue