#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#ifndef EVDEV_H
#define EVDEV_H
#include <linux/input.h>
#include <linux/types.h>
#include <xorg-server.h>
#include <xf86Xinput.h>
#include <xf86_OSproc.h>
#include <xkbstr.h>
#ifdef MULTITOUCH
#include <mtdev.h>
#endif
#ifndef EV_CNT
#define EV_CNT (EV_MAX+1)
#endif
#ifndef KEY_CNT
#define KEY_CNT (KEY_MAX+1)
#endif
#ifndef REL_CNT
#define REL_CNT (REL_MAX+1)
#endif
#ifndef ABS_CNT
#define ABS_CNT (ABS_MAX+1)
#endif
#ifndef LED_CNT
#define LED_CNT (LED_MAX+1)
#endif
#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 14
#define HAVE_SMOOTH_SCROLLING 1
#endif
#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) < 18
#define LogMessageVerbSigSafe xf86MsgVerb
#endif
#define EVDEV_MAXBUTTONS 32
#define EVDEV_MAXQUEUE 32
#define EVDEV_KEYBOARD_EVENTS (1 << 0)
#define EVDEV_BUTTON_EVENTS (1 << 1)
#define EVDEV_RELATIVE_EVENTS (1 << 2)
#define EVDEV_ABSOLUTE_EVENTS (1 << 3)
#define EVDEV_TOUCHPAD (1 << 4)
#define EVDEV_INITIALIZED (1 << 5)
#define EVDEV_TOUCHSCREEN (1 << 6)
#define EVDEV_CALIBRATED (1 << 7)
#define EVDEV_TABLET (1 << 8)
#define EVDEV_UNIGNORE_ABSOLUTE (1 << 9)
#define EVDEV_UNIGNORE_RELATIVE (1 << 10)
#define EVDEV_RELATIVE_MODE (1 << 11)
#ifndef MAX_VALUATORS
#define MAX_VALUATORS 36
#endif
#ifndef XI_PROP_DEVICE_NODE
#define XI_PROP_DEVICE_NODE "Device Node"
#endif
#define LONG_BITS (sizeof(long) * 8)
#define NLONGS(x) (((x) + LONG_BITS - 1) / LONG_BITS)
enum fkeymode {
FKEYMODE_UNKNOWN = 0,
FKEYMODE_FKEYS,
FKEYMODE_MMKEYS,
};
enum SlotState {
SLOTSTATE_OPEN = 8,
SLOTSTATE_CLOSE,
SLOTSTATE_UPDATE,
SLOTSTATE_EMPTY,
};
enum ButtonAction {
BUTTON_RELEASE = 0,
BUTTON_PRESS = 1
};
typedef struct {
int up_button;
int down_button;
int traveled_distance;
} WheelAxis, *WheelAxisPtr;
typedef struct {
enum {
EV_QUEUE_KEY,
EV_QUEUE_BTN,
EV_QUEUE_PROXIMITY,
#ifdef MULTITOUCH
EV_QUEUE_TOUCH,
#endif
} type;
union {
int key;
#ifdef MULTITOUCH
unsigned int touch;
#endif
} detail;
int val;
#ifdef MULTITOUCH
ValuatorMask *touchMask;
#endif
} EventQueueRec, *EventQueuePtr;
typedef struct {
unsigned short id_vendor;
unsigned short id_product;
char *device;
int grabDevice;
int num_vals;
int num_mt_vals;
int axis_map[max(ABS_CNT, REL_CNT)];
ValuatorMask *vals;
ValuatorMask *old_vals;
ValuatorMask *prox;
ValuatorMask *mt_mask;
ValuatorMask **last_mt_vals;
int cur_slot;
enum SlotState slot_state;
#ifdef MULTITOUCH
struct mtdev *mtdev;
#endif
int flags;
int in_proximity;
int use_proximity;
int num_buttons;
BOOL swap_axes;
BOOL invert_x;
BOOL invert_y;
int delta[REL_CNT];
unsigned int abs_queued, rel_queued, prox_queued;
XkbRMLVOSet rmlvo;
struct {
BOOL enabled;
BOOL pending;
int buttonstate;
int state;
Time expires;
Time timeout;
} emulateMB;
struct emulate3B {
BOOL enabled;
BOOL state;
Time timeout;
int buttonstate;
int button;
int threshold;
OsTimerPtr timer;
int delta[2];
int startpos[2];
int flags;
} emulate3B;
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;
struct {
int min_x;
int max_x;
int min_y;
int max_y;
} calibration;
unsigned char btnmap[32];
int reopen_attempts;
int reopen_left;
OsTimerPtr reopen_timer;
char name[1024];
unsigned long bitmask[NLONGS(EV_CNT)];
unsigned long key_bitmask[NLONGS(KEY_CNT)];
unsigned long rel_bitmask[NLONGS(REL_CNT)];
unsigned long abs_bitmask[NLONGS(ABS_CNT)];
unsigned long led_bitmask[NLONGS(LED_CNT)];
struct input_absinfo absinfo[ABS_CNT];
dev_t min_maj;
int num_queue;
EventQueueRec queue[EVDEV_MAXQUEUE];
enum fkeymode fkeymode;
} EvdevRec, *EvdevPtr;
void EvdevQueueKbdEvent(InputInfoPtr pInfo, struct input_event *ev, int value);
void EvdevQueueButtonEvent(InputInfoPtr pInfo, int button, int value);
void EvdevQueueProximityEvent(InputInfoPtr pInfo, int value);
#ifdef MULTITOUCH
void EvdevQueueTouchEvent(InputInfoPtr pInfo, unsigned int touch,
ValuatorMask *mask, uint16_t type);
#endif
void EvdevPostButtonEvent(InputInfoPtr pInfo, int button, enum ButtonAction act);
void EvdevQueueButtonClicks(InputInfoPtr pInfo, int button, int count);
void EvdevPostRelativeMotionEvents(InputInfoPtr pInfo, int num_v, int first_v,
int v[MAX_VALUATORS]);
void EvdevPostAbsoluteMotionEvents(InputInfoPtr pInfo, int num_v, int first_v,
int v[MAX_VALUATORS]);
unsigned int EvdevUtilButtonEventToButtonNumber(EvdevPtr pEvdev, 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);
CARD32 Evdev3BEmuTimer(OsTimerPtr timer, CARD32 time, pointer arg);
BOOL Evdev3BEmuFilterEvent(InputInfoPtr, int, BOOL);
void Evdev3BEmuPreInit(InputInfoPtr pInfo);
void Evdev3BEmuOn(InputInfoPtr);
void Evdev3BEmuFinalize(InputInfoPtr);
void Evdev3BEmuProcessRelMotion(InputInfoPtr pInfo, int dx, int dy);
void Evdev3BEmuProcessAbsMotion(InputInfoPtr pInfo, ValuatorMask *vals);
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);
void EvdevMBEmuInitProperty(DeviceIntPtr);
void Evdev3BEmuInitProperty(DeviceIntPtr);
void EvdevWheelEmuInitProperty(DeviceIntPtr);
void EvdevDragLockInitProperty(DeviceIntPtr);
void EvdevAppleInitProperty(DeviceIntPtr);
#endif