diff --git a/xf86-input-mfndev/src/labels.h b/xf86-input-mfndev/src/labels.h new file mode 100644 index 00000000..e31d473c --- /dev/null +++ b/xf86-input-mfndev/src/labels.h @@ -0,0 +1,56 @@ +#ifndef INPUT_LABELS +#define INPUT_LABELS + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include + +/* Aligned with linux/input.h. + Note that there are holes in the ABS_ range, these are simply replaced with + MISC here */ +const char* abs_labels[] = { + AXIS_LABEL_PROP_ABS_X, /* 0x00 */ + AXIS_LABEL_PROP_ABS_Y, /* 0x01 */ + AXIS_LABEL_PROP_ABS_Z, /* 0x02 */ + AXIS_LABEL_PROP_ABS_RX, /* 0x03 */ + AXIS_LABEL_PROP_ABS_RY, /* 0x04 */ + AXIS_LABEL_PROP_ABS_RZ, /* 0x05 */ + AXIS_LABEL_PROP_ABS_THROTTLE, /* 0x06 */ + AXIS_LABEL_PROP_ABS_RUDDER, /* 0x07 */ + AXIS_LABEL_PROP_ABS_WHEEL, /* 0x08 */ + AXIS_LABEL_PROP_ABS_GAS, /* 0x09 */ + AXIS_LABEL_PROP_ABS_BRAKE, /* 0x0a */ +}; + +const char* rel_labels[] = { + AXIS_LABEL_PROP_REL_X, + AXIS_LABEL_PROP_REL_Y, + AXIS_LABEL_PROP_REL_Z, + AXIS_LABEL_PROP_REL_RX, + AXIS_LABEL_PROP_REL_RY, + AXIS_LABEL_PROP_REL_RZ, + AXIS_LABEL_PROP_REL_HWHEEL, + AXIS_LABEL_PROP_REL_DIAL, + AXIS_LABEL_PROP_REL_WHEEL, + AXIS_LABEL_PROP_REL_MISC +}; + +const char* btn_labels[] = { + BTN_LABEL_PROP_BTN_LEFT, + BTN_LABEL_PROP_BTN_MIDDLE, + BTN_LABEL_PROP_BTN_RIGHT, + BTN_LABEL_PROP_BTN_WHEEL_UP, + BTN_LABEL_PROP_BTN_WHEEL_DOWN, + BTN_LABEL_PROP_BTN_HWHEEL_LEFT, + BTN_LABEL_PROP_BTN_HWHEEL_RIGHT, + BTN_LABEL_PROP_BTN_SIDE, + BTN_LABEL_PROP_BTN_EXTRA, + BTN_LABEL_PROP_BTN_FORWARD, + BTN_LABEL_PROP_BTN_BACK, +}; + + + +#endif diff --git a/xf86-input-mfndev/src/qubes.c b/xf86-input-mfndev/src/qubes.c index 495c69a1..04b7beff 100644 --- a/xf86-input-mfndev/src/qubes.c +++ b/xf86-input-mfndev/src/qubes.c @@ -51,6 +51,7 @@ #include #include +#include #include @@ -63,16 +64,6 @@ #include -#ifdef HAVE_PROPERTIES -#include -/* 1.6 has properties, but no labels */ -#ifdef AXIS_LABEL_PROP -#define HAVE_LABELS -#else -#undef HAVE_LABELS -#endif - -#endif #if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 23 #define HAVE_THREADED_INPUT 1 @@ -100,6 +91,7 @@ #include #include "xdriver-shm-cmd.h" #include "qubes.h" +#include "labels.h" #include "../../xf86-qubes-common/include/xf86-qubes-common.h" @@ -125,7 +117,7 @@ static void QubesBlockHandler(void *arg, void *timeout); static void QubesWakeupHandler(void *arg, int result); #endif - +#define ArrayLength(x) (sizeof(x)/sizeof((x)[0])) _X_EXPORT InputDriverRec QUBES = { 1, @@ -275,6 +267,29 @@ static int _qubes_init_kbd(DeviceIntPtr device) return Success; } +static void QubesInitButtonLabels(QubesDevicePtr pQubes, int natoms, + Atom * atoms) +{ + Atom atom; + int btn; + const char **labels; + int labels_len = 0; + + labels = btn_labels; + labels_len = ArrayLength(btn_labels); + + memset(atoms, 0, natoms * sizeof(Atom)); + + /* Now fill the ones we know */ + for (btn = 0; btn < labels_len && btn < natoms; btn++) { + atom = XIGetKnownProperty(labels[btn]); + if (!atom) /* Should not happen */ + continue; + + atoms[btn] = atom; + } +} + static int _qubes_init_buttons(DeviceIntPtr device) { InputInfoPtr pInfo = device->public.devicePrivate; @@ -293,6 +308,7 @@ static int _qubes_init_buttons(DeviceIntPtr device) pQubes->labels = calloc(num_buttons, sizeof(Atom)); + QubesInitButtonLabels(pQubes, num_buttons, pQubes->labels); if (!InitButtonClassDeviceStruct(device, num_buttons, pQubes->labels, map)) { xf86Msg(X_ERROR, "%s: Failed to register buttons.\n", @@ -307,31 +323,24 @@ static int _qubes_init_buttons(DeviceIntPtr device) static void QubesInitAxesLabels(QubesDevicePtr pQubes, int natoms, Atom * atoms) { -#ifdef HAVE_LABELS Atom atom; int axis; - char **labels; + const char **labels; int labels_len = 0; - char *misc_label; labels = rel_labels; labels_len = ArrayLength(rel_labels); - misc_label = AXIS_LABEL_PROP_REL_MISC; memset(atoms, 0, natoms * sizeof(Atom)); /* Now fill the ones we know */ - for (axis = 0; axis < labels_len; axis++) { - if (pQubes->axis_map[axis] == -1) - continue; - + for (axis = 0; axis < labels_len && axis < natoms; axis++) { atom = XIGetKnownProperty(labels[axis]); if (!atom) /* Should not happen */ continue; - atoms[pQubes->axis_map[axis]] = atom; + atoms[axis] = atom; } -#endif }