[plug] USB Keypad Shennanigans

Onno Benschop onno at itmaze.com.au
Fri Aug 2 07:32:57 UTC 2013


Thank you all for your suggestions. On Wednesday night I tested an
implementation using xbindkeys. I made two keyboard shortcuts to start and
stop xbindkeys and when it starts, it also launches Firefox to show what
the shortcuts are and what file they're playing.

Worked well.

I'll use it in anger on Sunday when we broadcast the national and local
amateur radio news live from Hamfest. If you're an Amateur, it will be on
VK6RAP, if you're not, it will be on CB Channel 1 and 4. Also available for
download after the fact from vk6.net/news

Thanks again for your comments and suggestions.

O


On 26 July 2013 08:46, Jeremy Kerr <jk at ozlabs.org> wrote:

> Hi Onno,
>
> > I've learnt that there is much voodoo in this, lots of contradictory
> > information and a basic assumption that you'd just want to use some or
> > other layout.
> >
> > I've been unable to locate any information on how to create a layout
> > that actually generates a range of bogus keys from pressing a key on the
> > keypad.
>
> There are three "layers" involved here: the hardware scancode, the
> kernel input event and the X input event. There are mappings for
> (scancode -> kernel event) and (kernel event -> X event).
>
> If you aren't seeing the necessary events appearing, I'd suggest
> updating the scancode -> kernel event mapping; this way, you're not
> reliant on X, and you can set a per-device mapping (IIRC, X events are
> for the multiplexed input queue, so mappings apply to all devices).
>
> Here's how you'd update the scancode map:
>
> Quick rundown:
>
> 1) See which input device number your keypad is using.
>
>     sudo lsinput
>
>    - if your keypad is listed under /dev/input/event6, then your
>      device number if 6
>
> 2) See which scancodes are being generated from the keypad, and which
>    EV_KEY events are being generated:
>
>     sudo input-events $device-number
>
>    - then press some keys on your keypad.
>
>    Each keypress will generate the following:
>
>    08:21:49.636874: EV_MSC MSC_SCAN 458978
>    08:21:49.636879: EV_KEY KEY_LEFTMETA (0x7d) pressed
>
>    This shows that the hardware scancode 458978 (0x700E2) was emitted
>    by my keyboard, which the kernel translated to a left-meta keypress
>
>    If you find that the kernel events aren't suitable for you, you can
>    remap them. This is what I have done to switch the left meta and
>    left alt keys on my keyboard:
>
>    $ cat /lib/udev/keymaps/apple-keyboard
>    0x700e2      leftmeta
>    0x700e3      leftalt
>
>    - this is the scancode -> kernel event mapping that I would like.
>    Take a look in /usr/include/linux/input.h for possible event names
>    (listed as KEY_*).
>
>    you can manually load this keymap with:
>
>      /lib/udev/keymap input/event6 /lib/udev/keymaps/apple-keyboard
>
>    however, you probably want to do it in a udev rule:
>
>    $ cat /etc/udev/rules.d/96-apple-keymap.rules
>    ACTION=="add", SUBSYSTEMS=="usb", ENV{ID_VENDOR_ID}=="05ac",
>      ENV{ID_MODEL_ID}=="024f", RUN+="keymap $name apple-keyboard"
>
>    - this tells udev to load the above "apple-keyboard" keymap when
>      this particular device is detected
>
>
> If you need to check out which X events are being generated, I'd suggest
> using xev. However, if you're using X, you'll probably have some nifty
> tool to detect key events and allow you to map them to run your suitable
> audio-output command.
>
> Hope this helps,
>
>
> Jeremy
>



-- 
Onno Benschop

()/)/)()        ..ASCII for Onno..
|>>?            ..EBCDIC for Onno..
--- -. -. ---   ..Morse for Onno..

ITmaze   -   ABN: 56 178 057 063   -  ph: 04 1219 8888   -
onno at itmaze.com.au
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.plug.org.au/pipermail/plug/attachments/20130802/bb9be908/attachment.html>


More information about the plug mailing list