#ifndef _XINPUT_H_
#define _XINPUT_H_
#include <X11/Xlib.h>
#include <X11/extensions/XI.h>
#define _deviceKeyPress 0
#define _deviceKeyRelease 1
#define _deviceButtonPress 0
#define _deviceButtonRelease 1
#define _deviceMotionNotify 0
#define _deviceFocusIn 0
#define _deviceFocusOut 1
#define _proximityIn 0
#define _proximityOut 1
#define _deviceStateNotify 0
#define _deviceMappingNotify 1
#define _changeDeviceNotify 2
#define FindTypeAndClass(d,type,_class,classid,offset) \
{ int _i; XInputClassInfo *_ip; \
type = 0; _class = 0; \
for (_i=0, _ip= ((XDevice *) d)->classes; \
_i< ((XDevice *) d)->num_classes; \
_i++, _ip++) \
if (_ip->input_class == classid) \
{type = _ip->event_type_base + offset; \
_class = ((XDevice *) d)->device_id << 8 | type;}}
#define DeviceKeyPress(d,type,_class) \
FindTypeAndClass(d, type, _class, KeyClass, _deviceKeyPress)
#define DeviceKeyRelease(d,type,_class) \
FindTypeAndClass(d, type, _class, KeyClass, _deviceKeyRelease)
#define DeviceButtonPress(d,type,_class) \
FindTypeAndClass(d, type, _class, ButtonClass, _deviceButtonPress)
#define DeviceButtonRelease(d,type,_class) \
FindTypeAndClass(d, type, _class, ButtonClass, _deviceButtonRelease)
#define DeviceMotionNotify(d,type,_class) \
FindTypeAndClass(d, type, _class, ValuatorClass, _deviceMotionNotify)
#define DeviceFocusIn(d,type,_class) \
FindTypeAndClass(d, type, _class, FocusClass, _deviceFocusIn)
#define DeviceFocusOut(d,type,_class) \
FindTypeAndClass(d, type, _class, FocusClass, _deviceFocusOut)
#define ProximityIn(d,type,_class) \
FindTypeAndClass(d, type, _class, ProximityClass, _proximityIn)
#define ProximityOut(d,type,_class) \
FindTypeAndClass(d, type, _class, ProximityClass, _proximityOut)
#define DeviceStateNotify(d,type,_class) \
FindTypeAndClass(d, type, _class, OtherClass, _deviceStateNotify)
#define DeviceMappingNotify(d,type,_class) \
FindTypeAndClass(d, type, _class, OtherClass, _deviceMappingNotify)
#define ChangeDeviceNotify(d,type,_class) \
FindTypeAndClass(d, type, _class, OtherClass, _changeDeviceNotify)
#define DevicePointerMotionHint(d,type,_class) \
{ _class = ((XDevice *) d)->device_id << 8 | _devicePointerMotionHint;}
#define DeviceButton1Motion(d,type,_class) \
{ _class = ((XDevice *) d)->device_id << 8 | _deviceButton1Motion;}
#define DeviceButton2Motion(d,type,_class) \
{ _class = ((XDevice *) d)->device_id << 8 | _deviceButton2Motion;}
#define DeviceButton3Motion(d,type,_class) \
{ _class = ((XDevice *) d)->device_id << 8 | _deviceButton3Motion;}
#define DeviceButton4Motion(d,type, _class) \
{ _class = ((XDevice *) d)->device_id << 8 | _deviceButton4Motion;}
#define DeviceButton5Motion(d,type,_class) \
{ _class = ((XDevice *) d)->device_id << 8 | _deviceButton5Motion;}
#define DeviceButtonMotion(d,type, _class) \
{ _class = ((XDevice *) d)->device_id << 8 | _deviceButtonMotion;}
#define DeviceOwnerGrabButton(d,type,_class) \
{ _class = ((XDevice *) d)->device_id << 8 | _deviceOwnerGrabButton;}
#define DeviceButtonPressGrab(d,type,_class) \
{ _class = ((XDevice *) d)->device_id << 8 | _deviceButtonGrab;}
#define NoExtensionEvent(d,type,_class) \
{ _class = ((XDevice *) d)->device_id << 8 | _noExtensionEvent;}
#define BadDevice(dpy,error) _xibaddevice(dpy, &error)
#define BadClass(dpy,error) _xibadclass(dpy, &error)
#define BadEvent(dpy,error) _xibadevent(dpy, &error)
#define BadMode(dpy,error) _xibadmode(dpy, &error)
#define DeviceBusy(dpy,error) _xidevicebusy(dpy, &error)
typedef struct
{
int type;
unsigned long serial;
Bool send_event;
Display *display;
Window window;
XID deviceid;
Window root;
Window subwindow;
Time time;
int x, y;
int x_root;
int y_root;
unsigned int state;
unsigned int keycode;
Bool same_screen;
unsigned int device_state;
unsigned char axes_count;
unsigned char first_axis;
int axis_data[6];
} XDeviceKeyEvent;
typedef XDeviceKeyEvent XDeviceKeyPressedEvent;
typedef XDeviceKeyEvent XDeviceKeyReleasedEvent;
typedef struct {
int type;
unsigned long serial;
Bool send_event;
Display *display;
Window window;
XID deviceid;
Window root;
Window subwindow;
Time time;
int x, y;
int x_root;
int y_root;
unsigned int state;
unsigned int button;
Bool same_screen;
unsigned int device_state;
unsigned char axes_count;
unsigned char first_axis;
int axis_data[6];
} XDeviceButtonEvent;
typedef XDeviceButtonEvent XDeviceButtonPressedEvent;
typedef XDeviceButtonEvent XDeviceButtonReleasedEvent;
typedef struct
{
int type;
unsigned long serial;
Bool send_event;
Display *display;
Window window;
XID deviceid;
Window root;
Window subwindow;
Time time;
int x, y;
int x_root;
int y_root;
unsigned int state;
char is_hint;
Bool same_screen;
unsigned int device_state;
unsigned char axes_count;
unsigned char first_axis;
int axis_data[6];
} XDeviceMotionEvent;
typedef struct
{
int type;
unsigned long serial;
Bool send_event;
Display *display;
Window window;
XID deviceid;
int mode;
int detail;
Time time;
} XDeviceFocusChangeEvent;
typedef XDeviceFocusChangeEvent XDeviceFocusInEvent;
typedef XDeviceFocusChangeEvent XDeviceFocusOutEvent;
typedef struct
{
int type;
unsigned long serial;
Bool send_event;
Display *display;
Window window;
XID deviceid;
Window root;
Window subwindow;
Time time;
int x, y;
int x_root, y_root;
unsigned int state;
Bool same_screen;
unsigned int device_state;
unsigned char axes_count;
unsigned char first_axis;
int axis_data[6];
} XProximityNotifyEvent;
typedef XProximityNotifyEvent XProximityInEvent;
typedef XProximityNotifyEvent XProximityOutEvent;
typedef struct
{
#if defined(__cplusplus) || defined(c_plusplus)
unsigned char c_class;
#else
unsigned char class;
#endif
unsigned char length;
} XInputClass;
typedef struct {
int type;
unsigned long serial;
Bool send_event;
Display *display;
Window window;
XID deviceid;
Time time;
int num_classes;
char data[64];
} XDeviceStateNotifyEvent;
typedef struct {
#if defined(__cplusplus) || defined(c_plusplus)
unsigned char c_class;
#else
unsigned char class;
#endif
unsigned char length;
unsigned char num_valuators;
unsigned char mode;
int valuators[6];
} XValuatorStatus;
typedef struct {
#if defined(__cplusplus) || defined(c_plusplus)
unsigned char c_class;
#else
unsigned char class;
#endif
unsigned char length;
short num_keys;
char keys[32];
} XKeyStatus;
typedef struct {
#if defined(__cplusplus) || defined(c_plusplus)
unsigned char c_class;
#else
unsigned char class;
#endif
unsigned char length;
short num_buttons;
char buttons[32];
} XButtonStatus;
typedef struct {
int type;
unsigned long serial;
Bool send_event;
Display *display;
Window window;
XID deviceid;
Time time;
int request;
int first_keycode;
int count;
} XDeviceMappingEvent;
typedef struct {
int type;
unsigned long serial;
Bool send_event;
Display *display;
Window window;
XID deviceid;
Time time;
int request;
} XChangeDeviceNotifyEvent;
typedef struct {
#if defined(__cplusplus) || defined(c_plusplus)
XID c_class;
#else
XID class;
#endif
int length;
XID id;
} XFeedbackState;
typedef struct {
#if defined(__cplusplus) || defined(c_plusplus)
XID c_class;
#else
XID class;
#endif
int length;
XID id;
int click;
int percent;
int pitch;
int duration;
int led_mask;
int global_auto_repeat;
char auto_repeats[32];
} XKbdFeedbackState;
typedef struct {
#if defined(__cplusplus) || defined(c_plusplus)
XID c_class;
#else
XID class;
#endif
int length;
XID id;
int accelNum;
int accelDenom;
int threshold;
} XPtrFeedbackState;
typedef struct {
#if defined(__cplusplus) || defined(c_plusplus)
XID c_class;
#else
XID class;
#endif
int length;
XID id;
int resolution;
int minVal;
int maxVal;
} XIntegerFeedbackState;
typedef struct {
#if defined(__cplusplus) || defined(c_plusplus)
XID c_class;
#else
XID class;
#endif
int length;
XID id;
int max_symbols;
int num_syms_supported;
KeySym *syms_supported;
} XStringFeedbackState;
typedef struct {
#if defined(__cplusplus) || defined(c_plusplus)
XID c_class;
#else
XID class;
#endif
int length;
XID id;
int percent;
int pitch;
int duration;
} XBellFeedbackState;
typedef struct {
#if defined(__cplusplus) || defined(c_plusplus)
XID c_class;
#else
XID class;
#endif
int length;
XID id;
int led_values;
int led_mask;
} XLedFeedbackState;
typedef struct {
#if defined(__cplusplus) || defined(c_plusplus)
XID c_class;
#else
XID class;
#endif
int length;
XID id;
} XFeedbackControl;
typedef struct {
#if defined(__cplusplus) || defined(c_plusplus)
XID c_class;
#else
XID class;
#endif
int length;
XID id;
int accelNum;
int accelDenom;
int threshold;
} XPtrFeedbackControl;
typedef struct {
#if defined(__cplusplus) || defined(c_plusplus)
XID c_class;
#else
XID class;
#endif
int length;
XID id;
int click;
int percent;
int pitch;
int duration;
int led_mask;
int led_value;
int key;
int auto_repeat_mode;
} XKbdFeedbackControl;
typedef struct {
#if defined(__cplusplus) || defined(c_plusplus)
XID c_class;
#else
XID class;
#endif
int length;
XID id;
int num_keysyms;
KeySym *syms_to_display;
} XStringFeedbackControl;
typedef struct {
#if defined(__cplusplus) || defined(c_plusplus)
XID c_class;
#else
XID class;
#endif
int length;
XID id;
int int_to_display;
} XIntegerFeedbackControl;
typedef struct {
#if defined(__cplusplus) || defined(c_plusplus)
XID c_class;
#else
XID class;
#endif
int length;
XID id;
int percent;
int pitch;
int duration;
} XBellFeedbackControl;
typedef struct {
#if defined(__cplusplus) || defined(c_plusplus)
XID c_class;
#else
XID class;
#endif
int length;
XID id;
int led_mask;
int led_values;
} XLedFeedbackControl;
typedef struct {
XID control;
int length;
} XDeviceControl;
typedef struct {
XID control;
int length;
int first_valuator;
int num_valuators;
int *resolutions;
} XDeviceResolutionControl;
typedef struct {
XID control;
int length;
int num_valuators;
int *resolutions;
int *min_resolutions;
int *max_resolutions;
} XDeviceResolutionState;
typedef struct _XAnyClassinfo *XAnyClassPtr;
typedef struct _XAnyClassinfo {
#if defined(__cplusplus) || defined(c_plusplus)
XID c_class;
#else
XID class;
#endif
int length;
} XAnyClassInfo;
typedef struct _XDeviceInfo *XDeviceInfoPtr;
typedef struct _XDeviceInfo
{
XID id;
Atom type;
char *name;
int num_classes;
int use;
XAnyClassPtr inputclassinfo;
} XDeviceInfo;
typedef struct _XKeyInfo *XKeyInfoPtr;
typedef struct _XKeyInfo
{
#if defined(__cplusplus) || defined(c_plusplus)
XID c_class;
#else
XID class;
#endif
int length;
unsigned short min_keycode;
unsigned short max_keycode;
unsigned short num_keys;
} XKeyInfo;
typedef struct _XButtonInfo *XButtonInfoPtr;
typedef struct _XButtonInfo {
#if defined(__cplusplus) || defined(c_plusplus)
XID c_class;
#else
XID class;
#endif
int length;
short num_buttons;
} XButtonInfo;
typedef struct _XAxisInfo *XAxisInfoPtr;
typedef struct _XAxisInfo {
int resolution;
int min_value;
int max_value;
} XAxisInfo;
typedef struct _XValuatorInfo *XValuatorInfoPtr;
typedef struct _XValuatorInfo
{
#if defined(__cplusplus) || defined(c_plusplus)
XID c_class;
#else
XID class;
#endif
int length;
unsigned char num_axes;
unsigned char mode;
unsigned long motion_buffer;
XAxisInfoPtr axes;
} XValuatorInfo;
typedef struct {
unsigned char input_class;
unsigned char event_type_base;
} XInputClassInfo;
typedef struct {
XID device_id;
int num_classes;
XInputClassInfo *classes;
} XDevice;
typedef struct {
XEventClass event_type;
XID device;
} XEventList;
typedef struct {
Time time;
int *data;
} XDeviceTimeCoord;
typedef struct {
XID device_id;
int num_classes;
XInputClass *data;
} XDeviceState;
typedef struct {
#if defined(__cplusplus) || defined(c_plusplus)
unsigned char c_class;
#else
unsigned char class;
#endif
unsigned char length;
unsigned char num_valuators;
unsigned char mode;
int *valuators;
} XValuatorState;
typedef struct {
#if defined(__cplusplus) || defined(c_plusplus)
unsigned char c_class;
#else
unsigned char class;
#endif
unsigned char length;
short num_keys;
char keys[32];
} XKeyState;
typedef struct {
#if defined(__cplusplus) || defined(c_plusplus)
unsigned char c_class;
#else
unsigned char class;
#endif
unsigned char length;
short num_buttons;
char buttons[32];
} XButtonState;
_XFUNCPROTOBEGIN
extern int XChangeKeyboardDevice(
Display* ,
XDevice*
);
extern int XChangePointerDevice(
Display* ,
XDevice* ,
int ,
int
);
extern int XGrabDevice(
Display* ,
XDevice* ,
Window ,
Bool ,
int ,
XEventClass* ,
int ,
int ,
Time
);
extern int XUngrabDevice(
Display* ,
XDevice* ,
Time
);
extern int XGrabDeviceKey(
Display* ,
XDevice* ,
unsigned int ,
unsigned int ,
XDevice* ,
Window ,
Bool ,
unsigned int ,
XEventClass* ,
int ,
int
);
extern int XUngrabDeviceKey(
Display* ,
XDevice* ,
unsigned int ,
unsigned int ,
XDevice* ,
Window
);
extern int XGrabDeviceButton(
Display* ,
XDevice* ,
unsigned int ,
unsigned int ,
XDevice* ,
Window ,
Bool ,
unsigned int ,
XEventClass* ,
int ,
int
);
extern int XUngrabDeviceButton(
Display* ,
XDevice* ,
unsigned int ,
unsigned int ,
XDevice* ,
Window
);
extern int XAllowDeviceEvents(
Display* ,
XDevice* ,
int ,
Time
);
extern int XGetDeviceFocus(
Display* ,
XDevice* ,
Window* ,
int* ,
Time*
);
extern int XSetDeviceFocus(
Display* ,
XDevice* ,
Window ,
int ,
Time
);
extern XFeedbackState *XGetFeedbackControl(
Display* ,
XDevice* ,
int*
);
extern void XFreeFeedbackList(
XFeedbackState*
);
extern int XChangeFeedbackControl(
Display* ,
XDevice* ,
unsigned long ,
XFeedbackControl*
);
extern int XDeviceBell(
Display* ,
XDevice* ,
XID ,
XID ,
int
);
extern KeySym *XGetDeviceKeyMapping(
Display* ,
XDevice* ,
#if NeedWidePrototypes
unsigned int ,
#else
KeyCode ,
#endif
int ,
int*
);
extern int XChangeDeviceKeyMapping(
Display* ,
XDevice* ,
int ,
int ,
KeySym* ,
int
);
extern XModifierKeymap *XGetDeviceModifierMapping(
Display* ,
XDevice*
);
extern int XSetDeviceModifierMapping(
Display* ,
XDevice* ,
XModifierKeymap*
);
extern int XSetDeviceButtonMapping(
Display* ,
XDevice* ,
unsigned char* ,
int
);
extern int XGetDeviceButtonMapping(
Display* ,
XDevice* ,
unsigned char* ,
unsigned int
);
extern XDeviceState *XQueryDeviceState(
Display* ,
XDevice*
);
extern void XFreeDeviceState(
XDeviceState*
);
extern XExtensionVersion *XGetExtensionVersion(
Display* ,
_Xconst char*
);
extern XDeviceInfo *XListInputDevices(
Display* ,
int*
);
extern void XFreeDeviceList(
XDeviceInfo*
);
extern XDevice *XOpenDevice(
Display* ,
XID
);
extern int XCloseDevice(
Display* ,
XDevice*
);
extern int XSetDeviceMode(
Display* ,
XDevice* ,
int
);
extern int XSetDeviceValuators(
Display* ,
XDevice* ,
int* ,
int ,
int
);
extern XDeviceControl *XGetDeviceControl(
Display* ,
XDevice* ,
int
);
extern int XChangeDeviceControl(
Display* ,
XDevice* ,
int ,
XDeviceControl*
);
extern int XSelectExtensionEvent(
Display* ,
Window ,
XEventClass* ,
int
);
extern int XGetSelectedExtensionEvents(
Display* ,
Window ,
int* ,
XEventClass** ,
int* ,
XEventClass**
);
extern int XChangeDeviceDontPropagateList(
Display* ,
Window ,
int ,
XEventClass* ,
int
);
extern XEventClass *XGetDeviceDontPropagateList(
Display* ,
Window ,
int*
);
extern Status XSendExtensionEvent(
Display* ,
XDevice* ,
Window ,
Bool ,
int ,
XEventClass* ,
XEvent*
);
extern XDeviceTimeCoord *XGetDeviceMotionEvents(
Display* ,
XDevice* ,
Time ,
Time ,
int* ,
int* ,
int*
);
extern void XFreeDeviceMotionEvents(
XDeviceTimeCoord*
);
extern void XFreeDeviceControl(
XDeviceControl*
);
_XFUNCPROTOEND
#endif