sonynwz: fix various drivers, notably touchscreen related

Change-Id: If43087ec9ad405ee6eeae8bedba8d221f8fb142f
This commit is contained in:
Amaury Pouly 2017-09-06 23:30:15 +02:00
parent 0291db372e
commit f22ccabac3
3 changed files with 44 additions and 36 deletions

View file

@ -35,6 +35,7 @@
#include <fcntl.h>
#include <string.h>
#include <stdlib.h>
#include <system.h>
/* device types */
#define DEV_KEY 0 /* icx_keys driver */
@ -70,64 +71,64 @@ static bool touch_detect;
/* get touchscreen information and init state */
int ts_init_state(int fd)
{
memset(state, 0, sizeof(struct nwz_ts_state_t));
memset(&ts_state, 0, sizeof(ts_state));
struct input_absinfo info;
if(ioctl(fd, EVIOCGABS(ABS_X), &info) < 0)
return -1;
state->max_x = info.maximum;
ts_state.max_x = info.maximum;
if(ioctl(fd, EVIOCGABS(ABS_Y), &info) < 0)
return -1;
state->max_y = info.maximum;
ts_state.max_y = info.maximum;
if(ioctl(fd, EVIOCGABS(ABS_PRESSURE), &info) < 0)
return -1;
state->max_pressure = info.maximum;
ts_state.max_pressure = info.maximum;
if(ioctl(fd, EVIOCGABS(ABS_TOOL_WIDTH), &info) < 0)
return -1;
state->max_tool_width = info.maximum;
ts_state.max_tool_width = info.maximum;
touch_detect = false;
return 0;
}
void handle_touch(struct input_event *evt)
void handle_touch(struct input_event evt)
{
switch(evt->type)
switch(evt.type)
{
case EV_SYN:
/* on SYN, we copy the state to the rockbox state */
touch_x = ts_state->x;
touch_y = ts_state->y;
touch_x = ts_state.x;
touch_y = ts_state.y;
/* map coordinate to screen */
x = x * LCD_WIDTH / ts_state->max_x;
y = y * LCD_HEIGHT / ts_state->max_y;
touch_x = touch_x * LCD_WIDTH / ts_state.max_x;
touch_y = touch_y * LCD_HEIGHT / ts_state.max_y;
/* don't trust driver reported ranges */
x = MAX(0, MIN(x, LCD_WIDTH - 1));
y = MAX(0, MIN(y, LCD_HEIGHT - 1));
touch_detect = ts_state->touch;
touch_x = MAX(0, MIN(touch_x, LCD_WIDTH - 1));
touch_y = MAX(0, MIN(touch_y, LCD_HEIGHT - 1));
touch_detect = ts_state.touch;
/* reset flick */
state->flick = false;
ts_state.flick = false;
break;
case EV_REL:
if(evt->code == REL_RX)
state->flick_x = evt->value;
else if(evt->code == REL_RY)
state->flick_y = evt->value;
if(evt.code == REL_RX)
ts_state.flick_x = evt.value;
else if(evt.code == REL_RY)
ts_state.flick_y = evt.value;
else
break;
state->flick = true;
ts_state.flick = true;
break;
case EV_ABS:
if(evt->code == ABS_X)
state->x = evt->value;
else if(evt->code == ABS_Y)
state->y = evt->value;
else if(evt->code == ABS_PRESSURE)
state->pressure = evt->value;
else if(evt->code == ABS_TOOL_WIDTH)
state->tool_width = evt->value;
if(evt.code == ABS_X)
ts_state.x = evt.value;
else if(evt.code == ABS_Y)
ts_state.y = evt.value;
else if(evt.code == ABS_PRESSURE)
ts_state.pressure = evt.value;
else if(evt.code == ABS_TOOL_WIDTH)
ts_state.tool_width = evt.value;
break;
case EV_KEY:
if(evt->code == BTN_TOUCH)
state->touch = evt->value;
if(evt.code == BTN_TOUCH)
ts_state.touch = evt.value;
break;
default:
break;
@ -296,7 +297,8 @@ int button_read_device(
}
}
#ifdef HAVE_TOUCHSCREEN
button_bitmap |= touchscreen_to_pixels(touch_x, touch_y, data);
if(touch_detect)
button_bitmap |= touchscreen_to_pixels(touch_x, touch_y, data);
#endif
return hold_status ? 0 : button_bitmap;
}

View file

@ -47,7 +47,7 @@ void identify_fb(const char *id)
nwz_fb_type = FB_EMXX;
else
nwz_fb_type = FB_OTHER;
printf("lcd: fb id = '%s -> type = %d\n", id, nwz_fb_type);
printf("lcd: fb id = '%s' -> type = %d\n", id, nwz_fb_type);
}
/* select which page (0 or 1) to display, disable DSP, transparency and rotation */

View file

@ -167,15 +167,21 @@ void system_reboot(void)
power_off();
}
#ifdef HAVE_BUTTON_DATA
#define IF_DATA(data) data
#else
#define IF_DATA(data)
#endif
void system_exception_wait(void)
{
backlight_hw_on();
backlight_hw_brightness(DEFAULT_BRIGHTNESS_SETTING);
/* wait until button press and release */
while(button_read_device() != 0) {}
while(button_read_device() == 0) {}
while(button_read_device() != 0) {}
while(button_read_device() == 0) {}
IF_DATA(int data);
while(button_read_device(IF_DATA(&data)) != 0) {}
while(button_read_device(IF_DATA(&data)) == 0) {}
while(button_read_device(IF_DATA(&data)) != 0) {}
while(button_read_device(IF_DATA(&data)) == 0) {}
}
int hostfs_init(void)