Re: Sysfs properties with libudev (for example capabilities/key)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

You can check the code out more in-depth in the following with the
produced output. This is the compilation command I used for testing:
gcc -Wall -o test -ggdb -ludev  main.c.

I just would like to get the real input devices.. so VID/PID: (null)
(null) and related device node entries are undesired. In essence I get
more outputs that I would expect because I expect the real entries
where I can use sysattr later and so on. I have just checked
get_parent method, but that did not help me too much.

Thank you in advance!

Best Regards,
Laszlo Papp

[code]

#include <libudev.h>
#include <stdio.h>

int main()
{
    struct udev *udev;
    struct udev_enumerate *enumerate;
    struct udev_list_entry *devices;
    struct udev_list_entry *dev_list_entry;
    struct udev_device *dev;

    udev = udev_new();
    if (!udev) {
        printf("Cannot create udev\n");
        return -1;
    }

    enumerate = udev_enumerate_new(udev);
    udev_enumerate_add_match_subsystem(enumerate, "input");
    udev_enumerate_scan_devices(enumerate);
    devices = udev_enumerate_get_list_entry(enumerate);

    udev_list_entry_foreach(dev_list_entry, devices) {
        const char *path;
        path = udev_list_entry_get_name(dev_list_entry);
        dev = udev_device_new_from_syspath(udev, path);
        printf("Device Node Path: %s, Name: %s\r\n", path,
                udev_device_get_sysattr_value(dev, "name"));
        printf("VID/PID: %s %s\r\n",
                udev_device_get_sysattr_value(dev,"id/vendor"),
                udev_device_get_sysattr_value(dev, "id/product"));
        udev_device_unref(dev);
    }

    udev_enumerate_unref(enumerate);
    udev_unref(udev);

    return 0;
}

[/code]

Device Node Path: /sys/devices/LNXSYSTM:00/LNXPWRBN:00/input/input3,
Name: Power Button
VID/PID: 0000 0001
Device Node Path:
/sys/devices/LNXSYSTM:00/LNXPWRBN:00/input/input3/event3, Name: (null)
VID/PID: (null) (null)
Device Node Path:
/sys/devices/LNXSYSTM:00/LNXSYBUS:00/PNP0C0C:00/input/input2, Name:
Power Button
VID/PID: 0000 0001
Device Node Path:
/sys/devices/LNXSYSTM:00/LNXSYBUS:00/PNP0C0C:00/input/input2/event2,
Name: (null)
VID/PID: (null) (null)
Device Node Path:
/sys/devices/pci0000:00/0000:00:04.0/usb2/2-10/2-10:1.0/input/input5,
Name: Logitech USB Optical Mouse
VID/PID: 046d c00c
Device Node Path:
/sys/devices/pci0000:00/0000:00:04.0/usb2/2-10/2-10:1.0/input/input5/event5,
Name: (null)
VID/PID: (null) (null)
Device Node Path:
/sys/devices/pci0000:00/0000:00:04.0/usb2/2-10/2-10:1.0/input/input5/mouse1,
Name: (null)
VID/PID: (null) (null)
Device Node Path: /sys/devices/pci0000:00/0000:00:09.0/input/input6,
Name: HDA Digital PCBeep
VID/PID: 10ec 0662
Device Node Path:
/sys/devices/pci0000:00/0000:00:09.0/input/input6/event6, Name: (null)
VID/PID: (null) (null)
Device Node Path: /sys/devices/platform/i8042/serio0/input/input1,
Name: AT Translated Set 2 keyboard
VID/PID: 0001 0001
Device Node Path:
/sys/devices/platform/i8042/serio0/input/input1/event1, Name: (null)
VID/PID: (null) (null)
Device Node Path: /sys/devices/platform/pcspkr/input/input4, Name: PC Speaker
VID/PID: 001f 0001
Device Node Path: /sys/devices/platform/pcspkr/input/input4/event4, Name: (null)
VID/PID: (null) (null)
Device Node Path: /sys/devices/virtual/input/input0, Name: Macintosh
mouse button emulation
VID/PID: 0001 0001
Device Node Path: /sys/devices/virtual/input/input0/event0, Name: (null)
VID/PID: (null) (null)
Device Node Path: /sys/devices/virtual/input/input0/mouse0, Name: (null)
VID/PID: (null) (null)
Device Node Path: /sys/devices/virtual/input/mice, Name: (null)
VID/PID: (null) (null)



On Sat, Oct 30, 2010 at 6:39 PM, Greg KH <greg@xxxxxxxxx> wrote:
> On Sat, Oct 30, 2010 at 02:17:20PM -0700, Laszlo Papp wrote:
>> Hi,
>>
>> I would like to get the capabilities/key entry from sysfs for my
>> keyboard for example with libudev library.
>
> Have you tried it?  It works here for me using libudev, do you have a
> pointer to your code that does not work properly?
>
> thanks,
>
> greg k-h
>
--
To unsubscribe from this list: send the line "unsubscribe linux-hotplug" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel]     [Linux DVB]     [Asterisk Internet PBX]     [DCCP]     [Netdev]     [X.org]     [Util Linux NG]     [Fedora Women]     [ALSA Devel]     [Linux USB]

  Powered by Linux