diff options
author | Zephaniah E. Hull <warp@agamemnon.b5> | 2007-06-05 23:12:58 -0400 |
---|---|---|
committer | Zephaniah E. Hull <warp@agamemnon.b5> | 2007-06-05 23:12:58 -0400 |
commit | 294355842ba9fb3cb3bbd7bfd60c9ca3ce704475 (patch) | |
tree | 243c982bb7f88578246e8c50715220a30199ab8b /src/evdev.h | |
parent | Disable and remove the device when a read error occurs. (diff) | |
download | xf86-input-evdev-294355842ba9fb3cb3bbd7bfd60c9ca3ce704475.tar.gz xf86-input-evdev-294355842ba9fb3cb3bbd7bfd60c9ca3ce704475.tar.bz2 xf86-input-evdev-294355842ba9fb3cb3bbd7bfd60c9ca3ce704475.zip |
Alright, this is a really big commit that breaks stuff.
evdev.h:
Switch to flags in the abs and rel structs.
Add the axes struct, and defines.
Rework the abs and rel structs, moving stuff to the axes struct and moving
everything to the new mapping handling.
Add the structs and function declarations for the new tokenization stuff,
parsing stuff, and mapping stuff.
evdev.c: Add EvdevTokenize, and the evdev_map_parsers list.
evdev_axes.c:
Basicly a full rewrite, big, messy.
We now use a completely different mapping setup for axes, and mapping to
buttons is currently missing.
However we now handle ABS_CALIB and ABS_AREA, including rotation in both
rel and abs modes.
evdev_btn.c:
Disable lots of code and break things horribly, we compile but we don't
work very well.
Fixing this is next on my todo list.
Diffstat (limited to 'src/evdev.h')
-rw-r--r-- | src/evdev.h | 113 |
1 files changed, 99 insertions, 14 deletions
diff --git a/src/evdev.h b/src/evdev.h index 06d8aeb..517840d 100644 --- a/src/evdev.h +++ b/src/evdev.h @@ -94,9 +94,26 @@ #include <X11/extensions/XKB.h> #include <X11/extensions/XKBstr.h> +/* + * At the moment, ABS_MAX is larger then REL_MAX. + * As they are the only two providors of axes, ABS_MAX is it. + */ +#define AXES_MAX ABS_MAX + #define EVDEV_MAXBUTTONS 96 +struct _evdevDevice; + +/* + * FIXME: The mode option here is a kludge. + * It can be 0 (rel mode), 1 (abs mode), or -1 (input side has no clue). + * + * Worse, it arguably shouldn't even be the sender that decides here. + * And only the Axes targets and sources care at all right now. + */ +typedef void (*evdev_map_func_f)(InputInfoPtr pInfo, int value, int mode, void *map_data); + typedef struct { unsigned long ev[NBITS(EV_MAX)]; unsigned long key[NBITS(KEY_MAX)]; @@ -111,6 +128,7 @@ typedef struct { #define EV_BTN_IGNORE_X 1 #define EV_BTN_IGNORE_EVDEV 2 #define EV_BTN_IGNORE_MAP (EV_BTN_IGNORE_X | EV_BTN_IGNORE_EVDEV) + typedef struct { int real_buttons; int buttons; @@ -119,31 +137,60 @@ typedef struct { void (*callback[EVDEV_MAXBUTTONS])(InputInfoPtr pInfo, int button, int value); } evdevBtnRec, *evdevBtnPtr; +#define EV_ABS_V_PRESENT (1<<0) +#define EV_ABS_V_M_AUTO (1<<1) +#define EV_ABS_V_M_REL (1<<2) +#define EV_ABS_V_INVERT (1<<3) +#define EV_ABS_V_RESET (1<<4) +#define EV_ABS_V_USE_TOUCH (1<<5) + +#define EV_ABS_USE_TOUCH (1<<0) +#define EV_ABS_TOUCH (1<<1) +#define EV_ABS_UPDATED (1<<2) + typedef struct { + int flags; int axes; int v[ABS_MAX]; - int old_x, old_y; - int count; - int min[ABS_MAX]; - int max[ABS_MAX]; - int map[ABS_MAX]; - int screen; /* Screen number for this device. */ - Bool use_touch; - Bool touch; - Bool reset_x, reset_y; + int v_flags[ABS_MAX]; + int v_min[ABS_MAX]; + int v_max[ABS_MAX]; + void *v_map_data[ABS_MAX]; + evdev_map_func_f v_map[ABS_MAX]; } evdevAbsRec, *evdevAbsPtr; +#define EV_REL_V_PRESENT (1<<0) +#define EV_REL_V_INVERT (1<<1) +#define EV_REL_UPDATED (1<<0) + typedef struct { - int axes; + int flags; + int v_flags[REL_MAX]; int v[REL_MAX]; - int count; - int map[REL_MAX]; - int btnMap[REL_MAX][2]; + int axes; + void *v_map_data[REL_MAX]; + evdev_map_func_f v_map[REL_MAX]; } evdevRelRec, *evdevRelPtr; +#define EV_AXES_V_M_ABS (1<<0) +#define EV_AXES_V_M_REL (1<<1) +#define EV_AXES_V_PRESENT (1<<2) +#define EV_AXES_V_UPDATED (1<<3) + +#define EV_AXES_V_M_MASK (EV_AXES_V_M_ABS | EV_AXES_V_M_REL) + +#define EV_AXES_UPDATED (1<<0) + typedef struct { int axes; - int v[ABS_MAX]; + int flags; + int v_flags[AXES_MAX]; + int v_min[AXES_MAX]; + int v_max[AXES_MAX]; + int v[AXES_MAX]; + int rotation; + float rot_sin, rot_cos; + int x, y; } evdevAxesRec, *evdevAxesPtr; typedef struct { @@ -201,4 +248,42 @@ int EvdevKeyOn (DeviceIntPtr device); int EvdevKeyOff (DeviceIntPtr device); void EvdevKeyProcess (InputInfoPtr pInfo, struct input_event *ev); + +/* + * Option handling stuff. + */ + +typedef struct evdev_option_token_s { + int is_chain; + union { + const char *str; + struct evdev_option_token_s *chain; + } u; + struct evdev_option_token_s *next; +} evdev_option_token_t; + +typedef Bool (*evdev_parse_opt_func_f)(InputInfoPtr pInfo, const char *name, evdev_option_token_t *token, int *flags); +typedef Bool (*evdev_parse_map_func_f)(InputInfoPtr pInfo, + const char *name, + evdev_option_token_t *option, + void **map_data, evdev_map_func_f *map_func); + +evdev_option_token_t *EvdevTokenize (const char *option, const char *tokens, const char *first); +void EvdevFreeTokens (evdev_option_token_t *token); +Bool EvdevParseMapToRelAxis (InputInfoPtr pInfo, + const char *name, + evdev_option_token_t *option, + void **map_data, evdev_map_func_f *map_func); +Bool EvdevParseMapToAbsAxis (InputInfoPtr pInfo, + const char *name, + evdev_option_token_t *option, + void **map_data, evdev_map_func_f *map_func); + +typedef struct { + char *name; + evdev_parse_map_func_f func; +} evdev_map_parsers_t; + +extern evdev_map_parsers_t evdev_map_parsers[]; + #endif /* LNX_EVDEV_H_ */ |