Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F135995682
D18694.id52435.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
3 KB
Referenced Files
None
Subscribers
None
D18694.id52435.diff
View Options
Index: sys/dev/evdev/evdev.c
===================================================================
--- sys/dev/evdev/evdev.c
+++ sys/dev/evdev/evdev.c
@@ -39,6 +39,8 @@
#include <sys/proc.h>
#include <sys/sysctl.h>
#include <sys/systm.h>
+#include <sys/bus.h>
+#include <sys/sbuf.h>
#include <dev/evdev/evdev.h>
#include <dev/evdev/evdev_private.h>
@@ -196,6 +198,102 @@
return (size);
}
+static bool
+bit_find(bitstr_t *bitstr, int start, int stop)
+{
+ int i;
+
+ for (i = start; i < stop; i++)
+ if (bit_test(bitstr, i))
+ return (true);
+
+ return (false);
+}
+
+static void
+evdev_notify_addq(const char *type, struct evdev_dev *evdev)
+{
+ struct sbuf *sb;
+ char *input_type = "NONE";
+ bool has_keys, has_buttons, has_lmr;
+ bool has_rel_axes, has_abs_axes, has_mt;
+
+ /* Derived from EvdevProbe() function of xf86-input-evdev driver */
+ has_keys = bit_find(evdev->ev_key_flags, 0, BTN_MISC);
+ has_buttons = bit_find(evdev->ev_key_flags, BTN_MISC, BTN_JOYSTICK);
+ has_lmr = bit_find(evdev->ev_key_flags, BTN_LEFT, BTN_MIDDLE + 1);
+ has_rel_axes = bit_find(evdev->ev_rel_flags, 0, REL_CNT);
+ has_abs_axes = bit_find(evdev->ev_abs_flags, 0, ABS_CNT);
+ has_mt = bit_find(evdev->ev_abs_flags, ABS_MT_SLOT, ABS_CNT);
+
+ if (has_abs_axes) {
+ if (has_mt && !has_buttons) {
+ if (bit_test(evdev->ev_key_flags, BTN_JOYSTICK)) {
+ input_type = "JOYSTICK";
+ goto detected;
+ } else {
+ has_buttons = true;
+ }
+ }
+
+ if (bit_test(evdev->ev_abs_flags, ABS_X) &&
+ bit_test(evdev->ev_abs_flags, ABS_Y)) {
+ if (bit_test(evdev->ev_key_flags, BTN_TOOL_PEN) ||
+ bit_test(evdev->ev_key_flags, BTN_STYLUS) ||
+ bit_test(evdev->ev_key_flags, BTN_STYLUS2)) {
+ input_type = "TABLET";
+ goto detected;
+ } else if (bit_test(evdev->ev_abs_flags, ABS_PRESSURE) ||
+ bit_test(evdev->ev_key_flags, BTN_TOUCH)) {
+ if (has_lmr ||
+ bit_test(evdev->ev_key_flags, BTN_TOOL_FINGER)) {
+ input_type = "TOUCHPAD";
+ } else {
+ input_type = "TOUCHSCREEN";
+ }
+ goto detected;
+ } else if (!(bit_test(evdev->ev_rel_flags, REL_X) &&
+ bit_test(evdev->ev_rel_flags, REL_Y)) &&
+ has_lmr) {
+ /* some touchscreens use BTN_LEFT rather than BTN_TOUCH */
+ input_type = "TOUCHSCREEN";
+ goto detected;
+ }
+ }
+ }
+
+ if (has_keys)
+ input_type = "KEYBOARD";
+ else if (has_rel_axes || has_abs_axes || has_buttons)
+ input_type = "MOUSE";
+
+detected:
+ sb = sbuf_new_auto();
+ sbuf_printf(sb,
+ "cdev=%s "
+ "unit=%d "
+ "name=\"%s\" "
+ "shortname=%s "
+ "bustype=0x%04x "
+ "vendor=0x%04x "
+ "product=0x%04x "
+ "version=0x%04x "
+ "inputtype=%s",
+ evdev->ev_cdev->si_name,
+ evdev->ev_unit,
+ evdev->ev_name,
+ evdev->ev_shortname,
+ evdev->ev_id.bustype,
+ evdev->ev_id.vendor,
+ evdev->ev_id.product,
+ evdev->ev_id.version,
+ input_type
+ );
+ sbuf_finish(sb);
+ devctl_notify("EVDEV", "DEVICE", type, sbuf_data(sb));
+ sbuf_delete(sb);
+}
+
static int
evdev_register_common(struct evdev_dev *evdev)
{
@@ -235,6 +333,7 @@
/* Create char device node */
ret = evdev_cdev_create(evdev);
+ evdev_notify_addq("ATTACH", evdev);
bail_out:
return (ret);
}
@@ -269,6 +368,7 @@
{
struct evdev_client *client;
int ret;
+ evdev_notify_addq("DETACH", evdev);
debugf(evdev, "%s: unregistered evdev provider: %s\n",
evdev->ev_shortname, evdev->ev_name);
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Nov 15, 10:29 PM (9 h, 40 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
25342205
Default Alt Text
D18694.id52435.diff (3 KB)
Attached To
Mode
D18694: evdev: add sysctls with device info
Attached
Detach File
Event Timeline
Log In to Comment