[systemd-commits] 3 commits - src/udev
Peter Hutterer
whot at kemper.freedesktop.org
Mon Apr 13 18:27:03 PDT 2015
src/udev/udev-builtin-input_id.c | 129 +++++++++++++++++++++++----------------
1 file changed, 79 insertions(+), 50 deletions(-)
New commits:
commit 37186823f3868612e0cbfdc65b2562ccbda61ada
Author: Hans de Goede <hdegoede at redhat.com>
Date: Mon Apr 13 11:15:01 2015 +0200
input_id: Identify scroll-wheel device on Trust TB7300 tablet as keyboard
The Trust TB7300 (relabelled Waltop?) tablet has a scrollwheel which shows
up as a /dev/input/event# node all by itself. Currently input_id does not
set any ID_INPUT_FOO attr on this causing it it to not be recognized by
Xorg / libinput.
This commit fixes this by marking it with ID_INPUT_KEY.
Reported-by: Sjoerd Timmer <themba at randomdata.nl>
diff --git a/src/udev/udev-builtin-input_id.c b/src/udev/udev-builtin-input_id.c
index 3f3e785..b14190e 100644
--- a/src/udev/udev-builtin-input_id.c
+++ b/src/udev/udev-builtin-input_id.c
@@ -265,6 +265,8 @@ static int builtin_input_id(struct udev_device *dev, int argc, char *argv[], boo
unsigned long bitmask_rel[NBITS(REL_MAX)];
unsigned long bitmask_props[NBITS(INPUT_PROP_MAX)];
const char *sysname, *devnode;
+ bool is_pointer;
+ bool is_key;
/* walk up the parental chain until we find the real input device; the
* argument is very likely a subdevice of this, like eventN */
@@ -281,9 +283,14 @@ static int builtin_input_id(struct udev_device *dev, int argc, char *argv[], boo
get_cap_mask(dev, pdev, "capabilities/rel", bitmask_rel, sizeof(bitmask_rel), test);
get_cap_mask(dev, pdev, "capabilities/key", bitmask_key, sizeof(bitmask_key), test);
get_cap_mask(dev, pdev, "properties", bitmask_props, sizeof(bitmask_props), test);
- test_pointers(dev, bitmask_ev, bitmask_abs, bitmask_key,
- bitmask_rel, bitmask_props, test);
- test_key(dev, bitmask_ev, bitmask_key, test);
+ is_pointer = test_pointers(dev, bitmask_ev, bitmask_abs,
+ bitmask_key, bitmask_rel,
+ bitmask_props, test);
+ is_key = test_key(dev, bitmask_ev, bitmask_key, test);
+ /* Some evdev nodes have only a scrollwheel */
+ if (!is_pointer && !is_key && test_bit(EV_REL, bitmask_ev) &&
+ (test_bit(REL_WHEEL, bitmask_rel) || test_bit(REL_HWHEEL, bitmask_rel)))
+ udev_builtin_add_property(dev, test, "ID_INPUT_KEY", "1");
}
devnode = udev_device_get_devnode(dev);
commit 941a2aca3d92deed5bde85d744eb1d25ceba3ba2
Author: Hans de Goede <hdegoede at redhat.com>
Date: Mon Apr 13 11:15:00 2015 +0200
udev: input_id: Make test_pointer / test_keys return if they've found anything
Make test_pointer / test_keys return a boolean indicating whether or not
they've set any properties on the device.
diff --git a/src/udev/udev-builtin-input_id.c b/src/udev/udev-builtin-input_id.c
index 1e94b09..3f3e785 100644
--- a/src/udev/udev-builtin-input_id.c
+++ b/src/udev/udev-builtin-input_id.c
@@ -126,7 +126,7 @@ static void get_cap_mask(struct udev_device *dev,
}
/* pointer devices */
-static void test_pointers(struct udev_device *dev,
+static bool test_pointers(struct udev_device *dev,
const unsigned long* bitmask_ev,
const unsigned long* bitmask_abs,
const unsigned long* bitmask_key,
@@ -135,77 +135,93 @@ static void test_pointers(struct udev_device *dev,
bool test) {
int is_mouse = 0;
int is_touchpad = 0;
+ bool ret = false;
if (test_bit(INPUT_PROP_ACCELEROMETER, bitmask_props)) {
udev_builtin_add_property(dev, test, "ID_INPUT_ACCELEROMETER", "1");
- return;
+ return true;
}
if (!test_bit(EV_KEY, bitmask_ev)) {
if (test_bit(EV_ABS, bitmask_ev) &&
test_bit(ABS_X, bitmask_abs) &&
test_bit(ABS_Y, bitmask_abs) &&
- test_bit(ABS_Z, bitmask_abs))
+ test_bit(ABS_Z, bitmask_abs)) {
udev_builtin_add_property(dev, test, "ID_INPUT_ACCELEROMETER", "1");
- return;
+ ret = true;
+ }
+ return ret;
}
if (test_bit(EV_ABS, bitmask_ev) &&
test_bit(ABS_X, bitmask_abs) && test_bit(ABS_Y, bitmask_abs)) {
- if (test_bit(BTN_STYLUS, bitmask_key) || test_bit(BTN_TOOL_PEN, bitmask_key))
+ if (test_bit(BTN_STYLUS, bitmask_key) || test_bit(BTN_TOOL_PEN, bitmask_key)) {
udev_builtin_add_property(dev, test, "ID_INPUT_TABLET", "1");
- else if (test_bit(BTN_TOOL_FINGER, bitmask_key) && !test_bit(BTN_TOOL_PEN, bitmask_key))
+ ret = true;
+ } else if (test_bit(BTN_TOOL_FINGER, bitmask_key) && !test_bit(BTN_TOOL_PEN, bitmask_key)) {
is_touchpad = 1;
- else if (test_bit(BTN_MOUSE, bitmask_key))
+ } else if (test_bit(BTN_MOUSE, bitmask_key)) {
/* This path is taken by VMware's USB mouse, which has
* absolute axes, but no touch/pressure button. */
is_mouse = 1;
- else if (test_bit(BTN_TOUCH, bitmask_key))
+ } else if (test_bit(BTN_TOUCH, bitmask_key)) {
udev_builtin_add_property(dev, test, "ID_INPUT_TOUCHSCREEN", "1");
+ ret = true;
/* joysticks don't necessarily have to have buttons; e. g.
* rudders/pedals are joystick-like, but buttonless; they have
* other fancy axes */
- else if (test_bit(BTN_TRIGGER, bitmask_key) ||
- test_bit(BTN_A, bitmask_key) ||
- test_bit(BTN_1, bitmask_key) ||
- test_bit(ABS_RX, bitmask_abs) ||
- test_bit(ABS_RY, bitmask_abs) ||
- test_bit(ABS_RZ, bitmask_abs) ||
- test_bit(ABS_THROTTLE, bitmask_abs) ||
- test_bit(ABS_RUDDER, bitmask_abs) ||
- test_bit(ABS_WHEEL, bitmask_abs) ||
- test_bit(ABS_GAS, bitmask_abs) ||
- test_bit(ABS_BRAKE, bitmask_abs))
+ } else if (test_bit(BTN_TRIGGER, bitmask_key) ||
+ test_bit(BTN_A, bitmask_key) ||
+ test_bit(BTN_1, bitmask_key) ||
+ test_bit(ABS_RX, bitmask_abs) ||
+ test_bit(ABS_RY, bitmask_abs) ||
+ test_bit(ABS_RZ, bitmask_abs) ||
+ test_bit(ABS_THROTTLE, bitmask_abs) ||
+ test_bit(ABS_RUDDER, bitmask_abs) ||
+ test_bit(ABS_WHEEL, bitmask_abs) ||
+ test_bit(ABS_GAS, bitmask_abs) ||
+ test_bit(ABS_BRAKE, bitmask_abs)) {
udev_builtin_add_property(dev, test, "ID_INPUT_JOYSTICK", "1");
+ ret = true;
+ }
}
- if (test_bit(INPUT_PROP_POINTING_STICK, bitmask_props))
+ if (test_bit(INPUT_PROP_POINTING_STICK, bitmask_props)) {
udev_builtin_add_property(dev, test, "ID_INPUT_POINTINGSTICK", "1");
+ ret = true;
+ }
if (test_bit(EV_REL, bitmask_ev) &&
test_bit(REL_X, bitmask_rel) && test_bit(REL_Y, bitmask_rel) &&
test_bit(BTN_MOUSE, bitmask_key))
is_mouse = 1;
- if (is_mouse)
+ if (is_mouse) {
udev_builtin_add_property(dev, test, "ID_INPUT_MOUSE", "1");
- if (is_touchpad)
+ ret = true;
+ }
+ if (is_touchpad) {
udev_builtin_add_property(dev, test, "ID_INPUT_TOUCHPAD", "1");
+ ret = true;
+ }
+
+ return ret;
}
/* key like devices */
-static void test_key(struct udev_device *dev,
+static bool test_key(struct udev_device *dev,
const unsigned long* bitmask_ev,
const unsigned long* bitmask_key,
bool test) {
unsigned i;
unsigned long found;
unsigned long mask;
+ bool ret = false;
/* do we have any KEY_* capability? */
if (!test_bit(EV_KEY, bitmask_ev)) {
log_debug("test_key: no EV_KEY capability");
- return;
+ return false;
}
/* only consider KEY_* here, not BTN_* */
@@ -225,14 +241,20 @@ static void test_key(struct udev_device *dev,
}
}
- if (found > 0)
+ if (found > 0) {
udev_builtin_add_property(dev, test, "ID_INPUT_KEY", "1");
+ ret = true;
+ }
/* the first 32 bits are ESC, numbers, and Q to D; if we have all of
* those, consider it a full keyboard; do not test KEY_RESERVED, though */
mask = 0xFFFFFFFE;
- if ((bitmask_key[0] & mask) == mask)
+ if ((bitmask_key[0] & mask) == mask) {
udev_builtin_add_property(dev, test, "ID_INPUT_KEYBOARD", "1");
+ ret = true;
+ }
+
+ return ret;
}
static int builtin_input_id(struct udev_device *dev, int argc, char *argv[], bool test) {
commit b914418a153098c5112f1e4487e01e5a14cc60dc
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date: Tue Apr 14 09:22:50 2015 +1000
udev: input_id: whitespace fixes
Remove whitespaces before opening parentheses, mostly before test_bit.
diff --git a/src/udev/udev-builtin-input_id.c b/src/udev/udev-builtin-input_id.c
index ecfc447..1e94b09 100644
--- a/src/udev/udev-builtin-input_id.c
+++ b/src/udev/udev-builtin-input_id.c
@@ -126,65 +126,65 @@ static void get_cap_mask(struct udev_device *dev,
}
/* pointer devices */
-static void test_pointers (struct udev_device *dev,
- const unsigned long* bitmask_ev,
- const unsigned long* bitmask_abs,
- const unsigned long* bitmask_key,
- const unsigned long* bitmask_rel,
- const unsigned long* bitmask_props,
- bool test) {
+static void test_pointers(struct udev_device *dev,
+ const unsigned long* bitmask_ev,
+ const unsigned long* bitmask_abs,
+ const unsigned long* bitmask_key,
+ const unsigned long* bitmask_rel,
+ const unsigned long* bitmask_props,
+ bool test) {
int is_mouse = 0;
int is_touchpad = 0;
- if (test_bit (INPUT_PROP_ACCELEROMETER, bitmask_props)) {
+ if (test_bit(INPUT_PROP_ACCELEROMETER, bitmask_props)) {
udev_builtin_add_property(dev, test, "ID_INPUT_ACCELEROMETER", "1");
return;
}
- if (!test_bit (EV_KEY, bitmask_ev)) {
- if (test_bit (EV_ABS, bitmask_ev) &&
- test_bit (ABS_X, bitmask_abs) &&
- test_bit (ABS_Y, bitmask_abs) &&
- test_bit (ABS_Z, bitmask_abs))
+ if (!test_bit(EV_KEY, bitmask_ev)) {
+ if (test_bit(EV_ABS, bitmask_ev) &&
+ test_bit(ABS_X, bitmask_abs) &&
+ test_bit(ABS_Y, bitmask_abs) &&
+ test_bit(ABS_Z, bitmask_abs))
udev_builtin_add_property(dev, test, "ID_INPUT_ACCELEROMETER", "1");
return;
}
- if (test_bit (EV_ABS, bitmask_ev) &&
- test_bit (ABS_X, bitmask_abs) && test_bit (ABS_Y, bitmask_abs)) {
- if (test_bit (BTN_STYLUS, bitmask_key) || test_bit (BTN_TOOL_PEN, bitmask_key))
+ if (test_bit(EV_ABS, bitmask_ev) &&
+ test_bit(ABS_X, bitmask_abs) && test_bit(ABS_Y, bitmask_abs)) {
+ if (test_bit(BTN_STYLUS, bitmask_key) || test_bit(BTN_TOOL_PEN, bitmask_key))
udev_builtin_add_property(dev, test, "ID_INPUT_TABLET", "1");
- else if (test_bit (BTN_TOOL_FINGER, bitmask_key) && !test_bit (BTN_TOOL_PEN, bitmask_key))
+ else if (test_bit(BTN_TOOL_FINGER, bitmask_key) && !test_bit(BTN_TOOL_PEN, bitmask_key))
is_touchpad = 1;
- else if (test_bit (BTN_MOUSE, bitmask_key))
+ else if (test_bit(BTN_MOUSE, bitmask_key))
/* This path is taken by VMware's USB mouse, which has
* absolute axes, but no touch/pressure button. */
is_mouse = 1;
- else if (test_bit (BTN_TOUCH, bitmask_key))
+ else if (test_bit(BTN_TOUCH, bitmask_key))
udev_builtin_add_property(dev, test, "ID_INPUT_TOUCHSCREEN", "1");
/* joysticks don't necessarily have to have buttons; e. g.
* rudders/pedals are joystick-like, but buttonless; they have
* other fancy axes */
- else if (test_bit (BTN_TRIGGER, bitmask_key) ||
- test_bit (BTN_A, bitmask_key) ||
- test_bit (BTN_1, bitmask_key) ||
- test_bit (ABS_RX, bitmask_abs) ||
- test_bit (ABS_RY, bitmask_abs) ||
- test_bit (ABS_RZ, bitmask_abs) ||
- test_bit (ABS_THROTTLE, bitmask_abs) ||
- test_bit (ABS_RUDDER, bitmask_abs) ||
- test_bit (ABS_WHEEL, bitmask_abs) ||
- test_bit (ABS_GAS, bitmask_abs) ||
- test_bit (ABS_BRAKE, bitmask_abs))
+ else if (test_bit(BTN_TRIGGER, bitmask_key) ||
+ test_bit(BTN_A, bitmask_key) ||
+ test_bit(BTN_1, bitmask_key) ||
+ test_bit(ABS_RX, bitmask_abs) ||
+ test_bit(ABS_RY, bitmask_abs) ||
+ test_bit(ABS_RZ, bitmask_abs) ||
+ test_bit(ABS_THROTTLE, bitmask_abs) ||
+ test_bit(ABS_RUDDER, bitmask_abs) ||
+ test_bit(ABS_WHEEL, bitmask_abs) ||
+ test_bit(ABS_GAS, bitmask_abs) ||
+ test_bit(ABS_BRAKE, bitmask_abs))
udev_builtin_add_property(dev, test, "ID_INPUT_JOYSTICK", "1");
}
- if (test_bit (INPUT_PROP_POINTING_STICK, bitmask_props))
+ if (test_bit(INPUT_PROP_POINTING_STICK, bitmask_props))
udev_builtin_add_property(dev, test, "ID_INPUT_POINTINGSTICK", "1");
- if (test_bit (EV_REL, bitmask_ev) &&
- test_bit (REL_X, bitmask_rel) && test_bit (REL_Y, bitmask_rel) &&
- test_bit (BTN_MOUSE, bitmask_key))
+ if (test_bit(EV_REL, bitmask_ev) &&
+ test_bit(REL_X, bitmask_rel) && test_bit(REL_Y, bitmask_rel) &&
+ test_bit(BTN_MOUSE, bitmask_key))
is_mouse = 1;
if (is_mouse)
@@ -194,16 +194,16 @@ static void test_pointers (struct udev_device *dev,
}
/* key like devices */
-static void test_key (struct udev_device *dev,
- const unsigned long* bitmask_ev,
- const unsigned long* bitmask_key,
- bool test) {
+static void test_key(struct udev_device *dev,
+ const unsigned long* bitmask_ev,
+ const unsigned long* bitmask_key,
+ bool test) {
unsigned i;
unsigned long found;
unsigned long mask;
/* do we have any KEY_* capability? */
- if (!test_bit (EV_KEY, bitmask_ev)) {
+ if (!test_bit(EV_KEY, bitmask_ev)) {
log_debug("test_key: no EV_KEY capability");
return;
}
@@ -217,7 +217,7 @@ static void test_key (struct udev_device *dev,
/* If there are no keys in the lower block, check the higher block */
if (!found) {
for (i = KEY_OK; i < BTN_TRIGGER_HAPPY; ++i) {
- if (test_bit (i, bitmask_key)) {
+ if (test_bit(i, bitmask_key)) {
log_debug("test_key: Found key %x in high block", i);
found = 1;
break;
More information about the systemd-commits
mailing list