Skip to content. | Skip to navigation

Personal tools
Log in
Sections
You are here: Home Projects Python-uinput

Python-uinput

Python API to the Linux uinput-system.

Uinput allows attaching user-space device drivers into the Linux kernel. Python-uinput provides a simple and easy to use API to the Linux uinput-system.

Usage example

Create and use a new uinput device with key-capabilities:

import uinput

capabilities = {
    uinput.EV_KEY: (uinput.KEY_E, uinput.KEY_H, uinput.KEY_L, uinput.KEY_O),
    }

device = uinput.Device(name="python-uinput-keyboard",
                       capabilities=capabilities)

device.emit(uinput.EV_KEY, uinput.KEY_H, 1) # Press.
device.emit(uinput.EV_KEY, uinput.KEY_H, 0) # Release.
device.emit(uinput.EV_KEY, uinput.KEY_E, 1)
device.emit(uinput.EV_KEY, uinput.KEY_E, 0)
device.emit(uinput.EV_KEY, uinput.KEY_L, 1)
device.emit(uinput.EV_KEY, uinput.KEY_L, 0)
device.emit(uinput.EV_KEY, uinput.KEY_L, 1)
device.emit(uinput.EV_KEY, uinput.KEY_L, 0)
device.emit(uinput.EV_KEY, uinput.KEY_O, 1)
device.emit(uinput.EV_KEY, uinput.KEY_O, 0)

More examples can be found here.

Download & Install

There are couple of ways to obtain and install Python-uinput, depending on your needs. The following sections describe these ways, from the easiest to the geekiest.

Ubuntu 10.04 Lucid Lynx and later

Install from Codegrove's PPA:

sudo add-apt-repository ppa:tuos/codegrove
sudo apt-get update
sudo apt-get install python-uinput

Other systems

Grab the latest source release from PyPI and install it manually. Please refer to README and/or INSTALL files in the root of the source package for installation requirements and procedure.

Facts
Author: Tuomas Räsänen
License: GPLv3+
Programming languages: Python, C
Source control: Bazaar
Bug control: Launchpad
Support: Launchpad