Add width/height to Setsu

This commit is contained in:
Florian Märkl 2020-07-01 20:55:26 +02:00
commit 000a125a8d
No known key found for this signature in database
GPG key ID: 125BC8A5A6A1E857
3 changed files with 15 additions and 12 deletions

View file

@ -72,5 +72,7 @@ void setsu_poll(Setsu *setsu, SetsuEventCb cb, void *user);
SetsuDevice *setsu_connect(Setsu *setsu, const char *path);
void setsu_disconnect(Setsu *setsu, SetsuDevice *dev);
const char *setsu_device_get_path(SetsuDevice *dev);
uint32_t setsu_device_get_width(SetsuDevice *dev);
uint32_t setsu_device_get_height(SetsuDevice *dev);
#endif

View file

@ -308,6 +308,16 @@ const char *setsu_device_get_path(SetsuDevice *dev)
return dev->path;
}
uint32_t setsu_device_get_width(SetsuDevice *dev)
{
return dev->max_x - dev->min_x;
}
uint32_t setsu_device_get_height(SetsuDevice *dev)
{
return dev->max_y - dev->min_y;
}
void kill_avail_device(Setsu *setsu, SetsuAvailDevice *adev)
{
for(SetsuDevice *dev = setsu->dev; dev;)
@ -477,8 +487,8 @@ static void device_drain(Setsu *setsu, SetsuDevice *dev, SetsuEventCb cb, void *
{
BEGIN_EVENT(SETSU_EVENT_POSITION);
event.tracking_id = dev->slots[i].tracking_id;
event.x = dev->slots[i].x;
event.y = dev->slots[i].y;
event.x = (uint32_t)(dev->slots[i].x - dev->min_x);
event.y = (uint32_t)(dev->slots[i].y - dev->min_y);
SEND_EVENT();
dev->slots[i].pos_dirty = false;
}

View file

@ -28,6 +28,7 @@ Setsu *setsu;
#define WIDTH 1920
#define HEIGHT 942
#define TOUCHES_MAX 8
#define SCALE 16
struct {
bool down;
@ -47,15 +48,6 @@ void quit()
void print_state()
{
for(size_t i=0; i<TOUCHES_MAX; i++)
{
if(touches[i].down)
{
// printf("%8u, %8u\n", touches[i].x, touches[i].y);
}
}
#define SCALE 16
char buf[(1 + WIDTH/SCALE)*(HEIGHT/SCALE) + 1];
size_t i = 0;
for(size_t y=0; y<HEIGHT/SCALE; y++)
@ -77,7 +69,6 @@ beach:
buf[i++] = '\n';
}
buf[i++] = '\0';
// printf("%zu, %zu\n", i, sizeof(buf));
assert(i == sizeof(buf));
printf("\033[2J%s", buf);