Linux Input/HID development
 help / color / mirror / Atom feed
From: Antonio Ospite <ospite@studenti.unina.it>
To: linux-hotplug@vger.kernel.org
Cc: linux-input@vger.kernel.org, Alan Ott <alan@signal11.us>
Subject: libudev, a question about the enumerate API.
Date: Wed, 23 Feb 2011 23:50:53 +0100	[thread overview]
Message-ID: <20110223235053.ae9d6b0a.ospite@studenti.unina.it> (raw)

[-- Attachment #1: Type: text/plain, Size: 2291 bytes --]

Hi,

in my attempts to handle leds setting and usb pairing for the Sixaxis
controller I had to fight with libudev a little bit, eventually I
succeeded in what I wanted to achieve but I still have some questions
about the libudev API, so here I am.

This is basically the layout for the device:

4-1:1.0/
|-- 0003:054C:0268.000C  (hid device)
|   |-- hidraw
|   |   `-- hidraw1
|   `-- uevent  (which tells me HID_PHYS)
|
`-- input
    `-- input17
        |-- js0
        `-- phys

I needed to get the hidraw device node, and the js device number, the
two sibling devices (from hid and input subsystem) can be matched using
the 'phys' property.

This is what I do now:
 0. Monitor with a filter matching the "hidraw" subsystem.
 1. When a matching device is connected we get the "hidraw" device.
 2. Go up to its "hid" parent device and check it is actually a
    Sixaxis (using HID_NAME), if not GOTO 1.
 3. Store the hidraw device node for later use
 4. Store the HID_PHYS value in order to look for the matching joystick.
 5. Enumerate the joystick devices with the sysname filter "js*"
 6. For each joystick:
    a. Go up to its input parent device
    b. Check that the phys attribute matches HID_PHYS,
       if so, store the joystick device number.
 7. Set leds
 8. If the Sixaxis is connected via USB do the cable pairing.

My doubt is about 5. and 6a.: I have go deep in the hierarchy down to
the js0 leaf device and then I have to go up one level to get the
input device, naively I would have done the contrary:
 5'. Enumerate the input devices such that phys == HID_PHYS
 6'. Enumerate the devices _below_ the input device from 5'. looking
     for the jsX device.

But this is not possible because the enumerate API is designed to start
always from the root of /sys.

Finally the question: why the enumerate API in libudev does not allow
enumerating only from a _subtree_? Has that been designed this way to
keep the API simple, or because it is not considered useful?

Thanks,
   Antonio

-- 
Antonio Ospite
http://ao2.it

PGP public key ID: 0x4553B001

A: Because it messes up the order in which people normally read text.
   See http://en.wikipedia.org/wiki/Posting_style
Q: Why is top-posting such a bad thing?

[-- Attachment #2: Type: application/pgp-signature, Size: 198 bytes --]

             reply	other threads:[~2011-02-23 22:51 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-02-23 22:50 Antonio Ospite [this message]
2011-03-07 15:27 ` libudev, a question about the enumerate API Kay Sievers
2011-03-07 16:01   ` Alan Ott
2011-03-07 16:11     ` Kay Sievers

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20110223235053.ae9d6b0a.ospite@studenti.unina.it \
    --to=ospite@studenti.unina.it \
    --cc=alan@signal11.us \
    --cc=linux-hotplug@vger.kernel.org \
    --cc=linux-input@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox