Device Events in Setsu

This commit is contained in:
Florian Märkl 2020-07-01 18:44:54 +02:00
commit 4a1ad05b5d
No known key found for this signature in database
GPG key ID: 125BC8A5A6A1E857
3 changed files with 155 additions and 38 deletions

View file

@ -25,16 +25,43 @@ typedef struct setsu_device_t SetsuDevice;
typedef int SetsuTrackingId;
typedef enum {
/* New device available to connect.
* Event will have path set to the new device. */
SETSU_EVENT_DEVICE_ADDED,
/* Previously available device removed.
* Event will have path set to the new device.
* Any SetsuDevice connected to this path will automatically
* be disconnected and their pointers will be invalid immediately
* after the callback for this event returns. */
SETSU_EVENT_DEVICE_REMOVED,
/* Touch down.
* Event will have dev and tracking_id set. */
SETSU_EVENT_DOWN,
/* Touch down.
* Event will have dev and tracking_id set. */
SETSU_EVENT_UP,
/* Touch position update.
* Event will have dev, tracking_id, x and y set. */
SETSU_EVENT_POSITION
} SetsuEventType;
typedef struct setsu_event_t {
SetsuDevice *dev;
SetsuTrackingId tracking_id;
typedef struct setsu_event_t
{
SetsuEventType type;
uint32_t x, y;
union
{
const char *path;
struct
{
SetsuDevice *dev;
SetsuTrackingId tracking_id;
uint32_t x, y;
};
};
} SetsuEvent;
typedef void (*SetsuEventCb)(SetsuEvent *event, void *user);
@ -42,5 +69,7 @@ typedef void (*SetsuEventCb)(SetsuEvent *event, void *user);
Setsu *setsu_new();
void setsu_free(Setsu *setsu);
void setsu_poll(Setsu *setsu, SetsuEventCb cb, void *user);
SetsuDevice *setsu_connect(Setsu *setsu, const char *path);
void setsu_disconnect(Setsu *setsu, SetsuDevice *dev);
#endif