Logitech MediaPlay Cordless Mouse USB Linux driver

Introdution

The main purpose of this page is to share my experiences with Logitech MediaPlay Cordless Mouse. Here you will find all the necessary information to put your MediaPlay mouse fully operational.
When i bought this mouse, the first thing that crossed my mind was the incompatibility between all this multimedia buttons and Linux. After googling about it, I noticed there was no useful information regarding this mouse, so I decided to put myself at work. Did my reseach, and after a few hours browsing kernel source files, reading some usb documentation, code changes, I was able to make the bit map for MediaPlay multimedia keys. The next step was to change usbmouse.c by Vojtech Pavlik allowing it to get and export mouse extra keys as keyboard entries using kernel input core support. The result was lmpcm_usb driver which is currently available for Linux 2.4 and 2.6 kernels.

Internals

This is the MediaPlay USB bit map:

Download

Version 0.5.8 of lmpcm_usb is available here.

Before installation

This is what you need to install lmpcm_usb:

Installation

Kernel

First, confirm required support on your kernel source configuration file.
Open /lib/modules/your-kernel-version/build/.config and check for this lines:

Kernel 2.6

CONFIG_INPUT=y
CONFIG_INPUT_MOUSEDEV=y
CONFIG_INPUT_EVDEV=m

CONFIG_USB=m
CONFIG_USB_UHCI_HCD=m

Kernel 2.4

CONFIG_INPUT=m
CONFIG_INPUT_KEYBDEV=m
CONFIG_INPUT_MOUSEDEV=m
CONFIG_INPUT_EVDEV=m

CONFIG_USB=m
CONFIG_USB_UHCI=m


If this lines are not present, add them.
Now, make sure CONFIG_USB_MOUSE and CONFIG_USB_HID ARE NOT kernel builtin (=y).

If you made any kind of change to the kernel configuration file, you should recompile (Kernel-HOWTO).
When all the required support is compiled, you can proceed.

Compilation

Get lmpcm_usb source tarball and uncompress it: # tar zxf lmpcm_usb-0.5.8.tar.gz
Now, change to the created directory, compile and install the driver: # cd lmpcm_usb-0.5.8
# make
# make install

Installation script installed lmpcm_usb.ko (lmpcm_usb.o for kernel 2.4) into /lib/modules/your-kernel-version/misc/ and added an entry to modules.dep file, using depmod.

Loading modules

Edit /lib/modules/your-kernel-version/misc/modules.dep and remove usbmouse and hid entries. This is required because these modules "steal" any kind of mouse, so we have to load lmpcm_usb first. If usbmouse and/or hid are required for any other device, just load them after lmpcm_usb. But don't forget, lmpcm_usb SHOULD LOAD FIRST that any generic mouse driver.
Loading support:

Kernel 2.6

# modprobe usbcore
# modprobe uhci-hcd

# modprobe evdev

Kernel 2.4

# modprobe usbcore
# modprobe usb-uhci

# modprobe input
# modprobe mousedev
# modprobe keybdev
# modprobe evdev


Ensure usbmouse and hid are not loaded:

Kernel 2.6

# rmmod usbmouse
# rmmod usbhid

Kernel 2.4

# rmmod usbmouse
# rmmod hid

Load lmpcm_usb module: # modprobe lmpcm_usb
At this time, your mouse should work.

Testing

To check if your mouse was successfully detected, perform these commands:
# dmesg | grep '^lmpcm.* usb'

You should get something like this: lmpcm_usb.c: Logitech MediaPlay Mouse on usb1:4.0 [Logitech USB Receiver]: input0
If you got nothing, that's because your mouse was not detected by lmpcm_usb kernel module. Maybe you have no USB support or HID is loaded and "stealing" mouse device.

Check your multimedia buttons by running:
# hexdump < /dev/input/eventX
   (where X is the mouse event device number)

Press and release play/pause button, the result should be similar to: 0000000 d0c8 4287 1e3b 000e 0001 00a4 0001 0000
0000010 d0c9 4287 6c1a 0001 0001 00a4 0000 0000


Configuring X server

Edit the X server configuration file (/etc/X11/XF86Config for XFree86 or /etc/X11/xorg.conf for X.org) and change it to match this configuration: ...
Section "InputDevice"
  ...
  Option "XkbModel" "pc105"
EndSection

Section "InputDevice"
  Identifier "LMPCM"
  Driver "mouse"
  Option "Protocol" "ExplorerPS/2"
  Option "Device" "/dev/input/mice"
  Option "ZAxisMapping" "6 7"
  Option "Buttons" "7"

EndSection

Section "ServerLayout"
  ...
  InputDevice "LMPCM" "CorePointer"
EndSection


Download Xmodmap-2.6 (or Xmodmap-2.4 for kernel 2.4), move to your home directory, set LMPCM as main pointer device (if you have more than one) and load it:

Kernel 2.6

$ mv Xmodmap-2.6 $HOME/.Xmodmap
$ xsetpointer LMPCM
$ xmodmap $HOME/.Xmodmap

Kernel 2.4

$ mv Xmodmap-2.4 $HOME/.Xmodmap
$ xsetpointer LMPCM
$ xmodmap $HOME/.Xmodmap


Configuring applications

Gnome

Gnome have a simple and quick interface to configure shortcut keys, but unfortunately it just supports a few number of operations.

Assuming you have Gnome-2.10, on your higher panel, click on "Desktop" menu, choose "Preferences" and "Keyboard Shortcuts".


Choose an event from event list and press the button you preffer.


Done :)

Kde

I think KDE have an almost perfect shortcut management system. It's very simple to configure shortcut keys on any application and operation. Anyway, the only thing I couldn't get working here was the Left blue Back/Forward browser buttons.

Assuming you have Kde-3.4, on your bottom menu, click on Konqueror web browser icon.


Type "settings:/Accessibility/" on the location bar.


Click on "Keyboard Shortcuts" icon, this will show you a very complete shortcut management interface. Choose an action, click on the button-like image, press the button you want to assign and click "Ok".


Done :)

Bugs

Bug reports and questions should be sent <d (dot) oliveira (at) prozone (dot) org>. Don't forget to mention your lmpcm_usb and kernel version.

Thanks

Thanks to Vojtech Pavlik who saved me a lot of time writing code, giving me the opportunity of focusing on Logitech Mediaplay and helped me with kernel level programming.
Thanks to all the people I annoyed to give me suggestions for my projects.


David Oliveira <d (dot) oliveira (at) prozone (dot) org> / v1.0.11