mirror of
https://git.sr.ht/~thestr4ng3r/chiaki
synced 2025-08-19 21:13:12 -07:00
Add width/height to Setsu
This commit is contained in:
parent
38123ea38f
commit
000a125a8d
3 changed files with 15 additions and 12 deletions
|
@ -72,5 +72,7 @@ void setsu_poll(Setsu *setsu, SetsuEventCb cb, void *user);
|
||||||
SetsuDevice *setsu_connect(Setsu *setsu, const char *path);
|
SetsuDevice *setsu_connect(Setsu *setsu, const char *path);
|
||||||
void setsu_disconnect(Setsu *setsu, SetsuDevice *dev);
|
void setsu_disconnect(Setsu *setsu, SetsuDevice *dev);
|
||||||
const char *setsu_device_get_path(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
|
#endif
|
||||||
|
|
|
@ -308,6 +308,16 @@ const char *setsu_device_get_path(SetsuDevice *dev)
|
||||||
return dev->path;
|
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)
|
void kill_avail_device(Setsu *setsu, SetsuAvailDevice *adev)
|
||||||
{
|
{
|
||||||
for(SetsuDevice *dev = setsu->dev; dev;)
|
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);
|
BEGIN_EVENT(SETSU_EVENT_POSITION);
|
||||||
event.tracking_id = dev->slots[i].tracking_id;
|
event.tracking_id = dev->slots[i].tracking_id;
|
||||||
event.x = dev->slots[i].x;
|
event.x = (uint32_t)(dev->slots[i].x - dev->min_x);
|
||||||
event.y = dev->slots[i].y;
|
event.y = (uint32_t)(dev->slots[i].y - dev->min_y);
|
||||||
SEND_EVENT();
|
SEND_EVENT();
|
||||||
dev->slots[i].pos_dirty = false;
|
dev->slots[i].pos_dirty = false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,6 +28,7 @@ Setsu *setsu;
|
||||||
#define WIDTH 1920
|
#define WIDTH 1920
|
||||||
#define HEIGHT 942
|
#define HEIGHT 942
|
||||||
#define TOUCHES_MAX 8
|
#define TOUCHES_MAX 8
|
||||||
|
#define SCALE 16
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
bool down;
|
bool down;
|
||||||
|
@ -47,15 +48,6 @@ void quit()
|
||||||
|
|
||||||
void print_state()
|
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];
|
char buf[(1 + WIDTH/SCALE)*(HEIGHT/SCALE) + 1];
|
||||||
size_t i = 0;
|
size_t i = 0;
|
||||||
for(size_t y=0; y<HEIGHT/SCALE; y++)
|
for(size_t y=0; y<HEIGHT/SCALE; y++)
|
||||||
|
@ -77,7 +69,6 @@ beach:
|
||||||
buf[i++] = '\n';
|
buf[i++] = '\n';
|
||||||
}
|
}
|
||||||
buf[i++] = '\0';
|
buf[i++] = '\0';
|
||||||
// printf("%zu, %zu\n", i, sizeof(buf));
|
|
||||||
assert(i == sizeof(buf));
|
assert(i == sizeof(buf));
|
||||||
printf("\033[2J%s", buf);
|
printf("\033[2J%s", buf);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue