#ifndef LIBINPUTEVENTGATHER_H
#define LIBINPUTEVENTGATHER_H

#include "inputeventgather.h"

class LibinputEventGather : public InputEventGather
{
    Q_OBJECT
public:
    LibinputEventGather(InputEventGather* parent = nullptr);
    ~LibinputEventGather();

    void run() override;

private:
    void init();
    void handleEvent(struct libinput_event *event);
    /*!
     *  \brief 事件转换
     */
    void handleSwipeEvent(struct libinput_event *e, Event &event);
    void handlePinchEvent(struct libinput_event *e, Event &event);
//    void handleTapEvent(struct libinput_event *e, Event &event);
    void handleSwitchEvent(struct libinput_event *e, Event &event);

    /**
     * udev context.
     */
    struct udev *udevContext = nullptr;

    /**
     * libinput context.
     */
    struct libinput *libinputContext = nullptr;
    /**
     * libinput structure with pointers to the open/close callbacks.
     */
    struct libinput_interface libinputInterface {
            LibinputEventGather::openRestricted,
            LibinputEventGather::closeRestricted
    };
    static int openRestricted(const char *path, int flags, void *userData);
    static void closeRestricted(int fd, void *userData);
};

#endif // LIBINPUTEVENTGATHER_H
