Sign in to PrePAN


User's Modules

Linux::Input::Capabilities Read /sys to determine the event types attached input devices can emit

This is a module for parsing /sys/class/input/input*/capabilities/* which is a Linux-specific interface. Linux exports all the events that the device can report, separated into several categories (some stretching belief in calling them input devices, like the PC speaker — but that's what Linux does). Linux unfortunately exports these as bit strings, encoded in hex, split in to words without leading zeros. And yes, word length does vary by architecture.

The modules already include POD. And some tests, too.

The …::Constants module is auto-generated from the Linux C headers by Which isn't a NIH re-implementation of h2xs, I'm pretty sure.

Modules in the neighborhood I'm aware of:

  • Linux::Input, which I believe is mainly for getting the events from the devices and looks like it requires permission to actually open the devices. (I don't think I'm stepping on its namespace, as there are already multiple modules under Linux::Input:: by different authors).
  • Linux::Input::Info — reads the easy files, does not do capabilities. Possibly my module could be merged into this, but last update of 2008 doesn't give me much hope. Also, this appears to be opening the device in /dev, not using /sys.

The synopsis, tested on a VM, spits out:

Input devices found (numbers): 0, 4, 2, 3, 5
Input device found: input0, AT Translated Set 2 keyboard
Input device found: input4, Power Button
Input device found: input2, ImExPS/2 Generic Explorer Mouse
Input device found: input3, QEMU QEMU USB Tablet
Input device found: input5, PC Speaker
Device AT Translated Set 2 keyboard answers questions

BTW: This is currently part of an application I'm writing, App::ABAN, and currently it lives in the same repository. I'm thinking I'll move it to its own, or at least build it separately, once its ready for CPAN. (My PAUSE ID hasn't be processed yet, so I've been working on other things).

derobert@github 1 comment