mirror of
https://git.sr.ht/~thestr4ng3r/chiaki
synced 2025-08-19 04:59:19 -07:00
Add Motion Stub to Setsu
This commit is contained in:
parent
0e324a41a0
commit
abc9a27208
5 changed files with 196 additions and 130 deletions
|
@ -409,7 +409,7 @@ void StreamSession::HandleSetsuEvent(SetsuEvent *event)
|
||||||
switch(event->type)
|
switch(event->type)
|
||||||
{
|
{
|
||||||
case SETSU_EVENT_DEVICE_ADDED:
|
case SETSU_EVENT_DEVICE_ADDED:
|
||||||
setsu_connect(setsu, event->path);
|
setsu_connect(setsu, event->path, event->dev_type);
|
||||||
break;
|
break;
|
||||||
case SETSU_EVENT_DEVICE_REMOVED:
|
case SETSU_EVENT_DEVICE_REMOVED:
|
||||||
for(auto it=setsu_ids.begin(); it!=setsu_ids.end();)
|
for(auto it=setsu_ids.begin(); it!=setsu_ids.end();)
|
||||||
|
|
|
@ -3,7 +3,7 @@ cmake_minimum_required(VERSION 3.2)
|
||||||
|
|
||||||
project(libsetsu)
|
project(libsetsu)
|
||||||
|
|
||||||
option(SETSU_BUILD_DEMO "Build testing executable for libsetsu" OFF)
|
option(SETSU_BUILD_DEMOS "Build testing executables for libsetsu" OFF)
|
||||||
|
|
||||||
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
|
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
|
||||||
|
|
||||||
|
@ -17,9 +17,8 @@ find_package(Udev REQUIRED)
|
||||||
find_package(Evdev REQUIRED)
|
find_package(Evdev REQUIRED)
|
||||||
target_link_libraries(setsu Udev::libudev Evdev::libevdev)
|
target_link_libraries(setsu Udev::libudev Evdev::libevdev)
|
||||||
|
|
||||||
if(SETSU_BUILD_DEMO)
|
if(SETSU_BUILD_DEMOS)
|
||||||
add_executable(setsu-demo
|
add_executable(setsu-demo-touchpad demo/touchpad.c)
|
||||||
demo/main.c)
|
target_link_libraries(setsu-demo-touchpad setsu)
|
||||||
target_link_libraries(setsu-demo setsu)
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|
|
@ -68,11 +68,15 @@ void event(SetsuEvent *event, void *user)
|
||||||
switch(event->type)
|
switch(event->type)
|
||||||
{
|
{
|
||||||
case SETSU_EVENT_DEVICE_ADDED: {
|
case SETSU_EVENT_DEVICE_ADDED: {
|
||||||
SetsuDevice *dev = setsu_connect(setsu, event->path);
|
if(event->dev_type != SETSU_DEVICE_TYPE_TOUCHPAD)
|
||||||
|
break;
|
||||||
|
SetsuDevice *dev = setsu_connect(setsu, event->path, SETSU_DEVICE_TYPE_TOUCHPAD);
|
||||||
LOG("Device added: %s, connect %s\n", event->path, dev ? "succeeded" : "FAILED!");
|
LOG("Device added: %s, connect %s\n", event->path, dev ? "succeeded" : "FAILED!");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case SETSU_EVENT_DEVICE_REMOVED:
|
case SETSU_EVENT_DEVICE_REMOVED:
|
||||||
|
if(event->dev_type != SETSU_DEVICE_TYPE_TOUCHPAD)
|
||||||
|
break;
|
||||||
LOG("Device removed: %s\n", event->path);
|
LOG("Device removed: %s\n", event->path);
|
||||||
break;
|
break;
|
||||||
case SETSU_EVENT_TOUCH_DOWN:
|
case SETSU_EVENT_TOUCH_DOWN:
|
|
@ -13,13 +13,18 @@ typedef struct setsu_t Setsu;
|
||||||
typedef struct setsu_device_t SetsuDevice;
|
typedef struct setsu_device_t SetsuDevice;
|
||||||
typedef int SetsuTrackingId;
|
typedef int SetsuTrackingId;
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
SETSU_DEVICE_TYPE_TOUCHPAD,
|
||||||
|
SETSU_DEVICE_TYPE_MOTION
|
||||||
|
} SetsuDeviceType;
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
/* New device available to connect.
|
/* New device available to connect.
|
||||||
* Event will have path set to the new device. */
|
* Event will have path and type set to the new device. */
|
||||||
SETSU_EVENT_DEVICE_ADDED,
|
SETSU_EVENT_DEVICE_ADDED,
|
||||||
|
|
||||||
/* Previously available device removed.
|
/* Previously available device removed.
|
||||||
* Event will have path set to the new device.
|
* Event will have path and type set to the removed device.
|
||||||
* Any SetsuDevice connected to this path will automatically
|
* Any SetsuDevice connected to this path will automatically
|
||||||
* be disconnected and their pointers will be invalid immediately
|
* be disconnected and their pointers will be invalid immediately
|
||||||
* after the callback for this event returns. */
|
* after the callback for this event returns. */
|
||||||
|
@ -52,8 +57,12 @@ typedef struct setsu_event_t
|
||||||
{
|
{
|
||||||
SetsuEventType type;
|
SetsuEventType type;
|
||||||
union
|
union
|
||||||
|
{
|
||||||
|
struct
|
||||||
{
|
{
|
||||||
const char *path;
|
const char *path;
|
||||||
|
SetsuDeviceType dev_type;
|
||||||
|
};
|
||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
SetsuDevice *dev;
|
SetsuDevice *dev;
|
||||||
|
@ -75,11 +84,11 @@ typedef void (*SetsuEventCb)(SetsuEvent *event, void *user);
|
||||||
Setsu *setsu_new();
|
Setsu *setsu_new();
|
||||||
void setsu_free(Setsu *setsu);
|
void setsu_free(Setsu *setsu);
|
||||||
void setsu_poll(Setsu *setsu, SetsuEventCb cb, void *user);
|
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, SetsuDeviceType type);
|
||||||
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_touchpad_get_width(SetsuDevice *dev);
|
||||||
uint32_t setsu_device_get_height(SetsuDevice *dev);
|
uint32_t setsu_device_touchpad_get_height(SetsuDevice *dev);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,6 +25,7 @@
|
||||||
typedef struct setsu_avail_device_t
|
typedef struct setsu_avail_device_t
|
||||||
{
|
{
|
||||||
struct setsu_avail_device_t *next;
|
struct setsu_avail_device_t *next;
|
||||||
|
SetsuDeviceType type;
|
||||||
char *path;
|
char *path;
|
||||||
bool connect_dirty; // whether the connect has not been sent as an event yet
|
bool connect_dirty; // whether the connect has not been sent as an event yet
|
||||||
bool disconnect_dirty; // whether the disconnect has not been sent as an event yet
|
bool disconnect_dirty; // whether the disconnect has not been sent as an event yet
|
||||||
|
@ -36,11 +37,18 @@ typedef struct setsu_device_t
|
||||||
{
|
{
|
||||||
struct setsu_device_t *next;
|
struct setsu_device_t *next;
|
||||||
char *path;
|
char *path;
|
||||||
|
SetsuDeviceType type;
|
||||||
int fd;
|
int fd;
|
||||||
struct libevdev *evdev;
|
struct libevdev *evdev;
|
||||||
|
|
||||||
|
union
|
||||||
|
{
|
||||||
|
struct
|
||||||
|
{
|
||||||
int min_x, min_y, max_x, max_y;
|
int min_x, min_y, max_x, max_y;
|
||||||
|
|
||||||
struct {
|
struct
|
||||||
|
{
|
||||||
/* Saves the old tracking id that was just up-ed.
|
/* Saves the old tracking id that was just up-ed.
|
||||||
* also for handling "atomic" up->down
|
* also for handling "atomic" up->down
|
||||||
* i.e. when there is an up, then down with a different tracking id
|
* i.e. when there is an up, then down with a different tracking id
|
||||||
|
@ -54,9 +62,13 @@ typedef struct setsu_device_t
|
||||||
bool pos_dirty;
|
bool pos_dirty;
|
||||||
} slots[SLOTS_COUNT];
|
} slots[SLOTS_COUNT];
|
||||||
unsigned int slot_cur;
|
unsigned int slot_cur;
|
||||||
|
|
||||||
uint64_t buttons_prev;
|
uint64_t buttons_prev;
|
||||||
uint64_t buttons_cur;
|
uint64_t buttons_cur;
|
||||||
|
} touchpad;
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
} motion;
|
||||||
|
};
|
||||||
} SetsuDevice;
|
} SetsuDevice;
|
||||||
|
|
||||||
struct setsu_t
|
struct setsu_t
|
||||||
|
@ -131,8 +143,8 @@ static void scan_udev(Setsu *setsu)
|
||||||
if(udev_enumerate_add_match_subsystem(udev_enum, "input") < 0)
|
if(udev_enumerate_add_match_subsystem(udev_enum, "input") < 0)
|
||||||
goto beach;
|
goto beach;
|
||||||
|
|
||||||
if(udev_enumerate_add_match_property(udev_enum, "ID_INPUT_TOUCHPAD", "1") < 0)
|
//if(udev_enumerate_add_match_property(udev_enum, "ID_INPUT_TOUCHPAD", "1") < 0)
|
||||||
goto beach;
|
// goto beach;
|
||||||
|
|
||||||
if(udev_enumerate_scan_devices(udev_enum) < 0)
|
if(udev_enumerate_scan_devices(udev_enum) < 0)
|
||||||
goto beach;
|
goto beach;
|
||||||
|
@ -153,7 +165,7 @@ beach:
|
||||||
udev_enumerate_unref(udev_enum);
|
udev_enumerate_unref(udev_enum);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool is_device_interesting(struct udev_device *dev)
|
static bool is_device_interesting(struct udev_device *dev, SetsuDeviceType *type)
|
||||||
{
|
{
|
||||||
static const uint32_t device_ids[] = {
|
static const uint32_t device_ids[] = {
|
||||||
// vendor id, model id
|
// vendor id, model id
|
||||||
|
@ -162,9 +174,19 @@ static bool is_device_interesting(struct udev_device *dev)
|
||||||
0x54c, 0x0ce6 // DualSense
|
0x54c, 0x0ce6 // DualSense
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const char *touchpad_str = udev_device_get_property_value(dev, "ID_INPUT_TOUCHPAD");
|
||||||
|
const char *accel_str = udev_device_get_property_value(dev, "ID_INPUT_ACCELEROMETER");
|
||||||
|
if(touchpad_str && !strcmp(touchpad_str, "1"))
|
||||||
|
{
|
||||||
// Filter mouse-device (/dev/input/mouse*) away and only keep the evdev (/dev/input/event*) one:
|
// Filter mouse-device (/dev/input/mouse*) away and only keep the evdev (/dev/input/event*) one:
|
||||||
if(!udev_device_get_property_value(dev, "ID_INPUT_TOUCHPAD_INTEGRATION"))
|
if(!udev_device_get_property_value(dev, "ID_INPUT_TOUCHPAD_INTEGRATION"))
|
||||||
return false;
|
return false;
|
||||||
|
*type = SETSU_DEVICE_TYPE_TOUCHPAD;
|
||||||
|
}
|
||||||
|
else if(touchpad_str && !strcmp(touchpad_str, "1"))
|
||||||
|
*type = SETSU_DEVICE_TYPE_MOTION;
|
||||||
|
else
|
||||||
|
return false;
|
||||||
|
|
||||||
uint32_t vendor;
|
uint32_t vendor;
|
||||||
uint32_t model;
|
uint32_t model;
|
||||||
|
@ -221,12 +243,14 @@ static void update_udev_device(Setsu *setsu, struct udev_device *dev)
|
||||||
}
|
}
|
||||||
|
|
||||||
// not yet added
|
// not yet added
|
||||||
if(!is_device_interesting(dev))
|
SetsuDeviceType type;
|
||||||
|
if(!is_device_interesting(dev, &type))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
SetsuAvailDevice *adev = calloc(1, sizeof(SetsuAvailDevice));
|
SetsuAvailDevice *adev = calloc(1, sizeof(SetsuAvailDevice));
|
||||||
if(!adev)
|
if(!adev)
|
||||||
return;
|
return;
|
||||||
|
adev->type = type;
|
||||||
adev->path = strdup(path);
|
adev->path = strdup(path);
|
||||||
if(!adev->path)
|
if(!adev->path)
|
||||||
{
|
{
|
||||||
|
@ -272,7 +296,7 @@ bool get_dev_ids(const char *path, uint32_t *vendor_id, uint32_t *model_id)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
SetsuDevice *setsu_connect(Setsu *setsu, const char *path)
|
SetsuDevice *setsu_connect(Setsu *setsu, const char *path, SetsuDeviceType type)
|
||||||
{
|
{
|
||||||
SetsuDevice *dev = calloc(1, sizeof(SetsuDevice));
|
SetsuDevice *dev = calloc(1, sizeof(SetsuDevice));
|
||||||
if(!dev)
|
if(!dev)
|
||||||
|
@ -281,6 +305,7 @@ SetsuDevice *setsu_connect(Setsu *setsu, const char *path)
|
||||||
dev->path = strdup(path);
|
dev->path = strdup(path);
|
||||||
if(!dev->path)
|
if(!dev->path)
|
||||||
goto error;
|
goto error;
|
||||||
|
dev->type = type;
|
||||||
|
|
||||||
dev->fd = open(dev->path, O_RDONLY | O_NONBLOCK);
|
dev->fd = open(dev->path, O_RDONLY | O_NONBLOCK);
|
||||||
if(dev->fd == -1)
|
if(dev->fd == -1)
|
||||||
|
@ -292,15 +317,23 @@ SetsuDevice *setsu_connect(Setsu *setsu, const char *path)
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
dev->min_x = libevdev_get_abs_minimum(dev->evdev, ABS_X);
|
switch(type)
|
||||||
dev->min_y = libevdev_get_abs_minimum(dev->evdev, ABS_Y);
|
{
|
||||||
dev->max_x = libevdev_get_abs_maximum(dev->evdev, ABS_X);
|
case SETSU_DEVICE_TYPE_TOUCHPAD:
|
||||||
dev->max_y = libevdev_get_abs_maximum(dev->evdev, ABS_Y);
|
dev->touchpad.min_x = libevdev_get_abs_minimum(dev->evdev, ABS_X);
|
||||||
|
dev->touchpad.min_y = libevdev_get_abs_minimum(dev->evdev, ABS_Y);
|
||||||
|
dev->touchpad.max_x = libevdev_get_abs_maximum(dev->evdev, ABS_X);
|
||||||
|
dev->touchpad.max_y = libevdev_get_abs_maximum(dev->evdev, ABS_Y);
|
||||||
|
|
||||||
for(size_t i=0; i<SLOTS_COUNT; i++)
|
for(size_t i=0; i<SLOTS_COUNT; i++)
|
||||||
{
|
{
|
||||||
dev->slots[i].tracking_id_prev = -1;
|
dev->touchpad.slots[i].tracking_id_prev = -1;
|
||||||
dev->slots[i].tracking_id = -1;
|
dev->touchpad.slots[i].tracking_id = -1;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case SETSU_DEVICE_TYPE_MOTION:
|
||||||
|
// TODO: init to defaults
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
dev->next = setsu->dev;
|
dev->next = setsu->dev;
|
||||||
|
@ -342,14 +375,18 @@ const char *setsu_device_get_path(SetsuDevice *dev)
|
||||||
return dev->path;
|
return dev->path;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t setsu_device_get_width(SetsuDevice *dev)
|
uint32_t setsu_device_touchpad_get_width(SetsuDevice *dev)
|
||||||
{
|
{
|
||||||
return dev->max_x - dev->min_x;
|
if(dev->type != SETSU_DEVICE_TYPE_TOUCHPAD)
|
||||||
|
return 0;
|
||||||
|
return dev->touchpad.max_x - dev->touchpad.min_x;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t setsu_device_get_height(SetsuDevice *dev)
|
uint32_t setsu_device_touchpad_get_height(SetsuDevice *dev)
|
||||||
{
|
{
|
||||||
return dev->max_y - dev->min_y;
|
if(dev->type != SETSU_DEVICE_TYPE_TOUCHPAD)
|
||||||
|
return 0;
|
||||||
|
return dev->touchpad.max_y - dev->touchpad.min_y;
|
||||||
}
|
}
|
||||||
|
|
||||||
void kill_avail_device(Setsu *setsu, SetsuAvailDevice *adev)
|
void kill_avail_device(Setsu *setsu, SetsuAvailDevice *adev)
|
||||||
|
@ -466,10 +503,18 @@ static void device_event(Setsu *setsu, SetsuDevice *dev, struct input_event *ev,
|
||||||
libevdev_event_code_get_name(ev->type, ev->code),
|
libevdev_event_code_get_name(ev->type, ev->code),
|
||||||
ev->value);
|
ev->value);
|
||||||
#endif
|
#endif
|
||||||
#define S dev->slots[dev->slot_cur]
|
if(ev->type == EV_SYN && ev->code == SYN_REPORT)
|
||||||
|
{
|
||||||
|
device_drain(setsu, dev, cb, user);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
switch(dev->type)
|
||||||
|
{
|
||||||
|
case SETSU_DEVICE_TYPE_TOUCHPAD:
|
||||||
switch(ev->type)
|
switch(ev->type)
|
||||||
{
|
{
|
||||||
case EV_ABS:
|
case EV_ABS:
|
||||||
|
#define S dev->touchpad.slots[dev->touchpad.slot_cur]
|
||||||
switch(ev->code)
|
switch(ev->code)
|
||||||
{
|
{
|
||||||
case ABS_MT_SLOT:
|
case ABS_MT_SLOT:
|
||||||
|
@ -478,7 +523,7 @@ static void device_event(Setsu *setsu, SetsuDevice *dev, struct input_event *ev,
|
||||||
SETSU_LOG("slot too high\n");
|
SETSU_LOG("slot too high\n");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
dev->slot_cur = ev->value;
|
dev->touchpad.slot_cur = ev->value;
|
||||||
break;
|
break;
|
||||||
case ABS_MT_TRACKING_ID:
|
case ABS_MT_TRACKING_ID:
|
||||||
if(S.tracking_id != -1 && S.tracking_id_prev == -1)
|
if(S.tracking_id != -1 && S.tracking_id_prev == -1)
|
||||||
|
@ -503,22 +548,23 @@ static void device_event(Setsu *setsu, SetsuDevice *dev, struct input_event *ev,
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
#undef S
|
||||||
case EV_KEY: {
|
case EV_KEY: {
|
||||||
uint64_t button = button_from_evdev(ev->code);
|
uint64_t button = button_from_evdev(ev->code);
|
||||||
if(!button)
|
if(!button)
|
||||||
break;
|
break;
|
||||||
if(ev->value)
|
if(ev->value)
|
||||||
dev->buttons_cur |= button;
|
dev->touchpad.buttons_cur |= button;
|
||||||
else
|
else
|
||||||
dev->buttons_cur &= ~button;
|
dev->touchpad.buttons_cur &= ~button;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case EV_SYN:
|
}
|
||||||
if(ev->code == SYN_REPORT)
|
break;
|
||||||
device_drain(setsu, dev, cb, user);
|
case SETSU_DEVICE_TYPE_MOTION:
|
||||||
|
// TODO: handle the events
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
#undef S
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void device_drain(Setsu *setsu, SetsuDevice *dev, SetsuEventCb cb, void *user)
|
static void device_drain(Setsu *setsu, SetsuDevice *dev, SetsuEventCb cb, void *user)
|
||||||
|
@ -526,40 +572,43 @@ static void device_drain(Setsu *setsu, SetsuDevice *dev, SetsuEventCb cb, void *
|
||||||
SetsuEvent event;
|
SetsuEvent event;
|
||||||
#define BEGIN_EVENT(tp) do { memset(&event, 0, sizeof(event)); event.dev = dev; event.type = tp; } while(0)
|
#define BEGIN_EVENT(tp) do { memset(&event, 0, sizeof(event)); event.dev = dev; event.type = tp; } while(0)
|
||||||
#define SEND_EVENT() do { cb(&event, user); } while (0)
|
#define SEND_EVENT() do { cb(&event, user); } while (0)
|
||||||
|
switch(dev->type)
|
||||||
|
{
|
||||||
|
case SETSU_DEVICE_TYPE_TOUCHPAD:
|
||||||
for(size_t i=0; i<SLOTS_COUNT; i++)
|
for(size_t i=0; i<SLOTS_COUNT; i++)
|
||||||
{
|
{
|
||||||
if(dev->slots[i].tracking_id_prev != -1)
|
if(dev->touchpad.slots[i].tracking_id_prev != -1)
|
||||||
{
|
{
|
||||||
BEGIN_EVENT(SETSU_EVENT_TOUCH_UP);
|
BEGIN_EVENT(SETSU_EVENT_TOUCH_UP);
|
||||||
event.tracking_id = dev->slots[i].tracking_id_prev;
|
event.tracking_id = dev->touchpad.slots[i].tracking_id_prev;
|
||||||
SEND_EVENT();
|
SEND_EVENT();
|
||||||
dev->slots[i].tracking_id_prev = -1;
|
dev->touchpad.slots[i].tracking_id_prev = -1;
|
||||||
}
|
}
|
||||||
if(dev->slots[i].downed)
|
if(dev->touchpad.slots[i].downed)
|
||||||
{
|
{
|
||||||
BEGIN_EVENT(SETSU_EVENT_TOUCH_DOWN);
|
BEGIN_EVENT(SETSU_EVENT_TOUCH_DOWN);
|
||||||
event.tracking_id = dev->slots[i].tracking_id;
|
event.tracking_id = dev->touchpad.slots[i].tracking_id;
|
||||||
SEND_EVENT();
|
SEND_EVENT();
|
||||||
dev->slots[i].downed = false;
|
dev->touchpad.slots[i].downed = false;
|
||||||
}
|
}
|
||||||
if(dev->slots[i].pos_dirty)
|
if(dev->touchpad.slots[i].pos_dirty)
|
||||||
{
|
{
|
||||||
BEGIN_EVENT(SETSU_EVENT_TOUCH_POSITION);
|
BEGIN_EVENT(SETSU_EVENT_TOUCH_POSITION);
|
||||||
event.tracking_id = dev->slots[i].tracking_id;
|
event.tracking_id = dev->touchpad.slots[i].tracking_id;
|
||||||
event.x = (uint32_t)(dev->slots[i].x - dev->min_x);
|
event.x = (uint32_t)(dev->touchpad.slots[i].x - dev->touchpad.min_x);
|
||||||
event.y = (uint32_t)(dev->slots[i].y - dev->min_y);
|
event.y = (uint32_t)(dev->touchpad.slots[i].y - dev->touchpad.min_y);
|
||||||
SEND_EVENT();
|
SEND_EVENT();
|
||||||
dev->slots[i].pos_dirty = false;
|
dev->touchpad.slots[i].pos_dirty = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t buttons_diff = dev->buttons_prev ^ dev->buttons_cur;
|
uint64_t buttons_diff = dev->touchpad.buttons_prev ^ dev->touchpad.buttons_cur;
|
||||||
for(uint64_t i=0; i<64; i++)
|
for(uint64_t i=0; i<64; i++)
|
||||||
{
|
{
|
||||||
if(buttons_diff & 1)
|
if(buttons_diff & 1)
|
||||||
{
|
{
|
||||||
uint64_t button = 1 << i;
|
uint64_t button = 1 << i;
|
||||||
BEGIN_EVENT((dev->buttons_cur & button) ? SETSU_EVENT_BUTTON_DOWN : SETSU_EVENT_BUTTON_UP);
|
BEGIN_EVENT((dev->touchpad.buttons_cur & button) ? SETSU_EVENT_BUTTON_DOWN : SETSU_EVENT_BUTTON_UP);
|
||||||
event.button = button;
|
event.button = button;
|
||||||
SEND_EVENT();
|
SEND_EVENT();
|
||||||
}
|
}
|
||||||
|
@ -567,7 +616,12 @@ static void device_drain(Setsu *setsu, SetsuDevice *dev, SetsuEventCb cb, void *
|
||||||
if(!buttons_diff)
|
if(!buttons_diff)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
dev->buttons_prev = dev->buttons_cur;
|
dev->touchpad.buttons_prev = dev->touchpad.buttons_cur;
|
||||||
|
break;
|
||||||
|
case SETSU_DEVICE_TYPE_MOTION:
|
||||||
|
// TODO
|
||||||
|
break;
|
||||||
|
}
|
||||||
#undef BEGIN_EVENT
|
#undef BEGIN_EVENT
|
||||||
#undef SEND_EVENT
|
#undef SEND_EVENT
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue