/kodi-airmouse-0c45-2702

Reads button presses from a "2.4G Wireless Device" air mouse and sends them to Kodi through EventServer.

Primary LanguagePython

Air Mouse for Kodi

I am using this cheap air mouse I got from DX:

sku_382619_2

"2.4GHz Motion Sensing Air Mouse + Remote Control - Black". Vendor ID: 0c45 Product ID: 2702

Anyone with this mouse and Kodi will agree that using it is very annoying, especially if you want to use it as a remote and disable the gyro mouse feature.

This is a script I wrote to fix the annoyances. It reads key presses from this air mouse, and sends them to Kodi through EventServer. It works on a Raspberry Pi with OSMC.

The script reads all the button presses, and sends them to Kodi on the same machine, and it does not care if the mouse is in 'mouse' mode, or in 'mouse disabled' mode.

It only respond to key presses, and ignores all mouse events, so that the device will only work as a remote and not as a mouse.

The script XBMCClient.py is taken from the Kodi repo: https://github.com/xbmc/xbmc/blob/master/tools/EventClients/lib/python/xbmcclient.py

The script reads the input from "/dev/input/" and searches the files that start with "usb-2.4G_2.4G_Wireless_Device-".

Since XBMC uses the EVIOCGRAB operation, it is impossible to read the files after XBMC has launched, so in order to fix that, the script is called from rc.local, and it also uses EVIOCGRAB, to prevent XBMC from accessing the device files.

If you want to use this (instructions are for OSMC on the Raspberry Pi):

  1. Take script.py and XBMCClient.py and put them in a directory (I used /home/osmc/kodi-airmouse-0c45-2702/)

  2. Have the script to run at boot: sudo nano /etc/rc.local

  3. On a line just above exit 0, enter python /home/osmc/kodi-airmouse-0c45-2702/script.py &

  4. chmod +x /home/osmc/kodi-airmouse-0c45-2702/script.py

  5. Put airmouse.xml in /home/osmc/.kodi/userdata/keymaps.

  6. Reboot