#ifndef EVDEV_H
#define EVDEV_H
#include <linux/input.h>
#include <xf86Xinput.h>
#include <xf86_OSproc.h>
#ifdef XKB
#include <xkbstr.h>
#endif
#define EVDEV_MAXBUTTONS 32
#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 3
#define HAVE_PROPERTIES 1
#endif
#define LONG_BITS (sizeof(long) * 8)
#define NBITS(x) (((x) + LONG_BITS - 1) / LONG_BITS)
typedef struct {
int up_button;
int down_button;
int traveled_distance;
} WheelAxis, *WheelAxisPtr;
typedef struct {
const char *device;
int grabDevice;
int screen;
int min_x, min_y, max_x, max_y;
int abs_x, abs_y, old_x, old_y;
int flags;
int tool;
int buttons;
BOOL invert_x;
BOOL invert_y;
int noXkb;
#ifdef XKB
char *xkb_rules;
char *xkb_model;
char *xkb_layout;
char *xkb_variant;
char *xkb_options;
XkbComponentNamesRec xkbnames;
#endif
struct {
BOOL enabled;
BOOL pending;
int buttonstate;
int state;
Time expires;
Time timeout;
} emulateMB;
struct {
int meta;
BOOL meta_state;
unsigned int lock_pair[EVDEV_MAXBUTTONS];
BOOL lock_state[EVDEV_MAXBUTTONS];
} dragLock;
struct {
BOOL enabled;
int button;
int button_state;
int inertia;
WheelAxis X;
WheelAxis Y;
Time expires;
Time timeout;
} emulateWheel;
unsigned char btnmap[32];
int reopen_attempts;
int reopen_left;
OsTimerPtr reopen_timer;
char name[1024];
long bitmask[NBITS(EV_MAX)];
long key_bitmask[NBITS(KEY_MAX)];
long rel_bitmask[NBITS(REL_MAX)];
long abs_bitmask[NBITS(ABS_MAX)];
long led_bitmask[NBITS(LED_MAX)];
struct input_absinfo absinfo[ABS_MAX];
} EvdevRec, *EvdevPtr;
unsigned int EvdevUtilButtonEventToButtonNumber(int code);
int EvdevMBEmuTimer(InputInfoPtr);
BOOL EvdevMBEmuFilterEvent(InputInfoPtr, int, BOOL);
void EvdevMBEmuWakeupHandler(pointer, int, pointer);
void EvdevMBEmuBlockHandler(pointer, struct timeval**, pointer);
void EvdevMBEmuPreInit(InputInfoPtr);
void EvdevMBEmuOn(InputInfoPtr);
void EvdevMBEmuFinalize(InputInfoPtr);
void EvdevMBEmuEnable(InputInfoPtr, BOOL);
void EvdevWheelEmuPreInit(InputInfoPtr pInfo);
BOOL EvdevWheelEmuFilterButton(InputInfoPtr pInfo, unsigned int button, int value);
BOOL EvdevWheelEmuFilterMotion(InputInfoPtr pInfo, struct input_event *pEv);
void EvdevDragLockPreInit(InputInfoPtr pInfo);
BOOL EvdevDragLockFilterEvent(InputInfoPtr pInfo, unsigned int button, int value);
#ifdef HAVE_PROPERTIES
void EvdevMBEmuInitProperty(DeviceIntPtr);
void EvdevWheelEmuInitProperty(DeviceIntPtr);
void EvdevDragLockInitProperty(DeviceIntPtr);
#endif
#endif