Hi,
It appears that there is a bug touch screen handling in SDL2 in piCore.
For reference I'm using piCorePlayer 11.0-rc2.
The touch location reported in SDL events does not change after touching the screen, and no finger motion events are reported.
My test program yields this output even though I have moved my finger far away from the position i put my finger down before raising my finger off the screen
FDN: 0703, 0585 -> FDN: 0703, 0585
FUP: 0703, 0585 -> FUP: hit: 0675, 0525 0737, 0525
FUP: 0703, 0585
This indicates that the co-ordinates for the SDL_FINGERUP, event always match that of the preceding SDL_FINGERDOWN event.
And no events appear to be generated for SDL_FINGERMOTION.
This is the section of code producing that output, in a SDL_PollEvent loop.
case SDL_FINGERMOTION:
{
SDL_Point pt = {
.x = (int)(event.tfinger.x*screen_width),
.y = (int)(event.tfinger.y*screen_height)
};
translate_point(&pt);
input_printf("FMO: %04d, %04d\n", (int)(event.tfinger.x*screen_width), (int)(event.tfinger.y*screen_height));
bool selected = false;
for(widget* widget=view.list->tail.prev; widget != NULL; widget=widget->prev) {
if (widget->hidden) { continue;}
if (!selected) {
widget->focussed = SDL_PointInRect(&pt, &widget->input_rect) && (!widget->focus_disabled);
widget->highlight = widget->focussed;
selected = widget->highlight;
} else {
widget->focussed = false;
widget->highlight = false;
}
}
} break;
case SDL_FINGERDOWN:
{
input_printf("FDN: %04d, %04d -> ", (int)(event.tfinger.x*screen_width), (int)(event.tfinger.y*screen_height));
SDL_Point pt = {
.x = (int)(event.tfinger.x*screen_width),
.y = (int)(event.tfinger.y*screen_height)
};
translate_point(&pt);
bool selected = false;
for(widget* widget=view.list->tail.prev; widget != NULL; widget=widget->prev) {
if (widget->hidden) { continue;}
if (!selected) {
widget->focussed = SDL_PointInRect(&pt, &widget->input_rect) && (!widget->focus_disabled);
widget->highlight = widget->focussed;
widget->pressed = widget->focussed;
selected = widget->highlight;
} else {
widget->focussed = false;
widget->highlight = false;
widget->pressed = false;
}
}
input_printf("FDN: %04d, %04d\n", pt.x, pt.y);
} break;
case SDL_FINGERUP:
{
input_printf("FUP: %04d, %04d -> ", (int)(event.tfinger.x*screen_width), (int)(event.tfinger.y*screen_height));
SDL_Point pt = {
.x = (int)(event.tfinger.x*screen_width),
.y = (int)(event.tfinger.y*screen_height)
};
translate_point(&pt);
for(widget* widget=view.list->tail.prev; widget != NULL; widget=widget->prev) {
if (widget->hidden) { continue;}
widget->pressed = false;
if (SDL_PointInRect(&pt, &widget->input_rect) && widget->focussed) {
input_printf("FUP: hit: %04d, %04d %04d, %04d\n",
widget->input_rect.x, widget->input_rect.y,
widget->input_rect.x + widget->input_rect.w,
widget->input_rect.y, widget->input_rect.h
);
widget->focussed = false;
widget->highlight = widget->focussed;
widget_dispatch_action(widget);
} else {
widget->focussed = false;
widget->highlight = false;
}
}
input_printf("FUP: %04d, %04d\n", pt.x, pt.y);
} break;